Compare commits
1768
Commits
1.6
..
commandbook-3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
494d9bec4e | ||
|
|
b835ee39d5 | ||
|
|
4a7552e6be | ||
|
|
c6c0fc9d74 | ||
|
|
f43a4eaad8 | ||
|
|
abfa5cb6a5 | ||
|
|
05f7d68705 | ||
|
|
9adac4f239 | ||
|
|
c5355adb4b | ||
|
|
fb37342b3c | ||
|
|
1fd94a3655 | ||
|
|
c413cf4123 | ||
|
|
87162acf11 | ||
|
|
2c14acc28c | ||
|
|
26477406f1 | ||
|
|
121b34ecb9 | ||
|
|
3ebaaf9c8b | ||
|
|
4c9812db04 | ||
|
|
e792dd6f98 | ||
|
|
d410e1f84e | ||
|
|
d07f95952d | ||
|
|
cb9ab3a7b2 | ||
|
|
1c3cf02ebd | ||
|
|
fc0f7acab5 | ||
|
|
20db92541b | ||
|
|
5fca3b3c3d | ||
|
|
c633a2d070 | ||
|
|
effbd62e68 | ||
|
|
056eaa6587 | ||
|
|
cb2c0870ec | ||
|
|
179c324c80 | ||
|
|
96d15d6dbf | ||
|
|
120d2e223d | ||
|
|
70ea6bad6e | ||
|
|
e59d61e1cf | ||
|
|
bbed280f62 | ||
|
|
f165ae3d95 | ||
|
|
124898ec91 | ||
|
|
ba32d24363 | ||
|
|
0bba822295 | ||
|
|
7538af2686 | ||
|
|
48922118b1 | ||
|
|
14fe2d0e79 | ||
|
|
11a1ac6742 | ||
|
|
c5bfdcb0e6 | ||
|
|
93dae282b2 | ||
|
|
3468e3d47e | ||
|
|
b7ad0257b7 | ||
|
|
070f6e005f | ||
|
|
cc3f4d4d44 | ||
|
|
21e65be110 | ||
|
|
61494fd76e | ||
|
|
556b638d04 | ||
|
|
825b3a3f36 | ||
|
|
afe042ef4d | ||
|
|
4044e2b122 | ||
|
|
aa4137822f | ||
|
|
f37acd3de6 | ||
|
|
b0e4cf148b | ||
|
|
248ffd0ba8 | ||
|
|
3272759f25 | ||
|
|
456a16591b | ||
|
|
79f6635b8a | ||
|
|
1f362bef59 | ||
|
|
63209d1174 | ||
|
|
f546700189 | ||
|
|
35e0db36d3 | ||
|
|
ab7751e046 | ||
|
|
a9cd23c6ef | ||
|
|
8ca01b37a4 | ||
|
|
aa8997aeca | ||
|
|
b757fcc88b | ||
|
|
7593e1a01c | ||
|
|
af3eb85962 | ||
|
|
aabb0b2345 | ||
|
|
6d25513739 | ||
|
|
96b61743b9 | ||
|
|
ff7209a58b | ||
|
|
fe4f0cfc49 | ||
|
|
9cf1e02506 | ||
|
|
b0f8852198 | ||
|
|
cce9c39e01 | ||
|
|
11c95861f9 | ||
|
|
75bb0adbe6 | ||
|
|
32ec74aed7 | ||
|
|
b152cdc4ec | ||
|
|
d019e43a81 | ||
|
|
8c778ed861 | ||
|
|
1b842204e9 | ||
|
|
8aa4c25186 | ||
|
|
026361ae0b | ||
|
|
426a709e43 | ||
|
|
903a831248 | ||
|
|
1792bcb18a | ||
|
|
23ab79c999 | ||
|
|
a29afe8cc1 | ||
|
|
029f867a41 | ||
|
|
ce35798f67 | ||
|
|
0f989fc1b4 | ||
|
|
4871752f49 | ||
|
|
c4b31cf085 | ||
|
|
6e30f98322 | ||
|
|
4b320ab733 | ||
|
|
f516999087 | ||
|
|
2b854f0d72 | ||
|
|
36d25c08c6 | ||
|
|
3e899a70c4 | ||
|
|
d6c2504bbf | ||
|
|
f2d2f47394 | ||
|
|
aefebf32c2 | ||
|
|
7102f6204c | ||
|
|
d542ba78ff | ||
|
|
e7ef6af012 | ||
|
|
1ffa4b48b8 | ||
|
|
d4c49a7539 | ||
|
|
2e2be7092d | ||
|
|
ec4c53da77 | ||
|
|
024a51549d | ||
|
|
8c345cb64b | ||
|
|
461f3e1faf | ||
|
|
6fd7190ff2 | ||
|
|
5180673878 | ||
|
|
c57dd20f24 | ||
|
|
71df9c0011 | ||
|
|
b27f18788c | ||
|
|
18365bbe42 | ||
|
|
82451595cb | ||
|
|
c516eb2174 | ||
|
|
7199b8e70f | ||
|
|
fc4c67ff29 | ||
|
|
d9bb321f83 | ||
|
|
7692e30721 | ||
|
|
5f88bef5ac | ||
|
|
5b0bfd50d3 | ||
|
|
5c0be800ae | ||
|
|
ac505f0064 | ||
|
|
2aee42cbf2 | ||
|
|
5c8b6d3f95 | ||
|
|
eab7b5c47f | ||
|
|
36eba9c9dd | ||
|
|
3b8b67da84 | ||
|
|
d9b09ab7f1 | ||
|
|
50e62bd0e7 | ||
|
|
abfe3a2eb9 | ||
|
|
e94af1d77e | ||
|
|
1dbd25d15e | ||
|
|
c3675a10a2 | ||
|
|
ef2783f30a | ||
|
|
2c2b475513 | ||
|
|
0ebb4e0ffa | ||
|
|
47fb9bd30d | ||
|
|
5ffade9787 | ||
|
|
ca92464cca | ||
|
|
453740b56a | ||
|
|
397a71a602 | ||
|
|
44c4e5816f | ||
|
|
41268ca443 | ||
|
|
c7ed49388c | ||
|
|
874e429779 | ||
|
|
9c5eee90da | ||
|
|
4f088e5bf0 | ||
|
|
c2f96c9587 | ||
|
|
c181a86fd1 | ||
|
|
e2ffab5ee8 | ||
|
|
8a3f066023 | ||
|
|
c53ed56b3a | ||
|
|
6144ca82ac | ||
|
|
d091cb578f | ||
|
|
b2fe4c9c71 | ||
|
|
ea47e93323 | ||
|
|
10100bd194 | ||
|
|
91687dc204 | ||
|
|
e091a59063 | ||
|
|
ee7dc27283 | ||
|
|
54c3cdad77 | ||
|
|
ff37cc7935 | ||
|
|
b6e2bca5bc | ||
|
|
1f85a53117 | ||
|
|
bd4726f887 | ||
|
|
9ea2312751 | ||
|
|
cc988c0b5a | ||
|
|
af93530dbe | ||
|
|
43d8cf8cba | ||
|
|
090a00d6d8 | ||
|
|
a233be1df8 | ||
|
|
f9339e144e | ||
|
|
1f1e6eedf6 | ||
|
|
96e7c43f56 | ||
|
|
f8e129f33e | ||
|
|
144c31645c | ||
|
|
d24157e693 | ||
|
|
d5dddba8bc | ||
|
|
72a392aca2 | ||
|
|
c6442e6669 | ||
|
|
0102dbb9bc | ||
|
|
3f7a9f9bc8 | ||
|
|
ae51d74afb | ||
|
|
e51a22032e | ||
|
|
84017bffc4 | ||
|
|
60731f9836 | ||
|
|
3ea7c9fc08 | ||
|
|
9804c69044 | ||
|
|
cd39387e7f | ||
|
|
b48e145508 | ||
|
|
405b210fb5 | ||
|
|
d4d7601125 | ||
|
|
fdd9064170 | ||
|
|
803c2055c3 | ||
|
|
344c6cf814 | ||
|
|
863f6cc13b | ||
|
|
3dd35dabec | ||
|
|
80aec378d8 | ||
|
|
6dbd731c92 | ||
|
|
aea129889c | ||
|
|
2757a001c0 | ||
|
|
693314c7f7 | ||
|
|
db35c908ba | ||
|
|
14ce7d1be2 | ||
|
|
015f192193 | ||
|
|
83b375b6e1 | ||
|
|
91696533cf | ||
|
|
0dc5781326 | ||
|
|
5ad21521be | ||
|
|
e0b91e9529 | ||
|
|
7e0ff24c57 | ||
|
|
be426e92df | ||
|
|
a6261b9071 | ||
|
|
f235e870a7 | ||
|
|
a26eb87603 | ||
|
|
7fb7d59856 | ||
|
|
01dfebe531 | ||
|
|
87e5770405 | ||
|
|
d3c4681c49 | ||
|
|
e43daa726a | ||
|
|
8e819f7a82 | ||
|
|
ee4259b88d | ||
|
|
8771173146 | ||
|
|
d28a31f255 | ||
|
|
b4bda6bfaf | ||
|
|
44e3f720de | ||
|
|
7f47e31686 | ||
|
|
b2e64498a8 | ||
|
|
e31fa306ab | ||
|
|
1123270a07 | ||
|
|
b850b5caf8 | ||
|
|
ba61919168 | ||
|
|
34efb6e40e | ||
|
|
3203a81710 | ||
|
|
d8dba47c0f | ||
|
|
a6cfe7d0c9 | ||
|
|
f19d2ee73d | ||
|
|
bd89bd9d2f | ||
|
|
66eb8fa553 | ||
|
|
dcdd0497d8 | ||
|
|
8ac5f8f6f2 | ||
|
|
45a4e59965 | ||
|
|
43ed630034 | ||
|
|
3189b1ac13 | ||
|
|
e94083045f | ||
|
|
acce59edd4 | ||
|
|
bb29883fe0 | ||
|
|
e7ff99ae96 | ||
|
|
b10cf6adbc | ||
|
|
2e8d14c995 | ||
|
|
89db0d9fee | ||
|
|
6c5319f355 | ||
|
|
8eeab682db | ||
|
|
2ae6f39a09 | ||
|
|
d2c52f7c1b | ||
|
|
3a332fd87d | ||
|
|
0f72811bfc | ||
|
|
95b88ea64b | ||
|
|
f76259df82 | ||
|
|
3a8e3e84b8 | ||
|
|
84bc322de7 | ||
|
|
129bbd8ea1 | ||
|
|
4dc6e27660 | ||
|
|
4cb29796c1 | ||
|
|
85693b91b3 | ||
|
|
1c29e85f19 | ||
|
|
e019890f1d | ||
|
|
fb90b1446f | ||
|
|
22ef224a81 | ||
|
|
c0f3171a33 | ||
|
|
67ece5c5d7 | ||
|
|
46cca2b950 | ||
|
|
6e56763a7f | ||
|
|
f147402d30 | ||
|
|
8e35db0f35 | ||
|
|
9b2eff0a71 | ||
|
|
104cdc023d | ||
|
|
deb283c44b | ||
|
|
324e90c68a | ||
|
|
c60502ffd8 | ||
|
|
26e59955ed | ||
|
|
4746e95249 | ||
|
|
9cafb07e4d | ||
|
|
b2b0fe65c6 | ||
|
|
06e6ce589b | ||
|
|
12fc1438c2 | ||
|
|
e5e1f71a2a | ||
|
|
2aaa14261b | ||
|
|
f006a9584c | ||
|
|
03cf9a668b | ||
|
|
db70e6f346 | ||
|
|
e0df194ff2 | ||
|
|
ab55137f59 | ||
|
|
bbb79526b2 | ||
|
|
cde9a403f7 | ||
|
|
43a9228304 | ||
|
|
c1b8d12d05 | ||
|
|
a25674e9a5 | ||
|
|
778ec404ff | ||
|
|
4ab38e5b89 | ||
|
|
8b842e3a0d | ||
|
|
e38d98da00 | ||
|
|
5c9ba2e22e | ||
|
|
e9ecb6d2a8 | ||
|
|
f5a554f4a4 | ||
|
|
53aadca45b | ||
|
|
6c3dd4234d | ||
|
|
5bd2125963 | ||
|
|
8765bbb192 | ||
|
|
53e8b780bc | ||
|
|
0e252e41b2 | ||
|
|
15a9c50ea4 | ||
|
|
d3acbdf382 | ||
|
|
4239bdc96d | ||
|
|
43a5bf1638 | ||
|
|
a8591e536a | ||
|
|
38dcdff0b6 | ||
|
|
65e48d17d4 | ||
|
|
c9b8e9f6a2 | ||
|
|
93d454c675 | ||
|
|
ca4bb7a53d | ||
|
|
c2054615db | ||
|
|
6db2df4e29 | ||
|
|
536132a250 | ||
|
|
7c3b1ad20f | ||
|
|
729f66afdf | ||
|
|
a7c2026414 | ||
|
|
9222b3d364 | ||
|
|
adcc41413d | ||
|
|
ec08d7d73a | ||
|
|
3d5ee7b571 | ||
|
|
32341393fe | ||
|
|
0fcd42fdd5 | ||
|
|
e28b236a52 | ||
|
|
96e0ffd293 | ||
|
|
0ddc011a3c | ||
|
|
d320356045 | ||
|
|
95bf6bc9b2 | ||
|
|
1c4c213ed7 | ||
|
|
c9eaec0ae8 | ||
|
|
fc0be7db09 | ||
|
|
dbbc31a4f4 | ||
|
|
0f3e893aaf | ||
|
|
aa668916e4 | ||
|
|
a426d2a42c | ||
|
|
5ff8b37ae8 | ||
|
|
2d28e8db6d | ||
|
|
463a356020 | ||
|
|
21d13cc72c | ||
|
|
9cf85caf3c | ||
|
|
2f1343f408 | ||
|
|
3cb6c4e46f | ||
|
|
7f9b850288 | ||
|
|
e8d4f2fd84 | ||
|
|
f3891aaaf9 | ||
|
|
ea75549a29 | ||
|
|
fbd8206038 | ||
|
|
522ac459db | ||
|
|
255dd2d41a | ||
|
|
cf1716ff37 | ||
|
|
a277e69e9c | ||
|
|
ec5bb32510 | ||
|
|
8ddb7d4b99 | ||
|
|
3258bff2d1 | ||
|
|
8d7d32a2d2 | ||
|
|
a907eb2348 | ||
|
|
32132b5b0a | ||
|
|
c0c7c3215e | ||
|
|
ddf0f41061 | ||
|
|
d3ecbcb18a | ||
|
|
b7f4262978 | ||
|
|
60e6f92c64 | ||
|
|
98af7966cd | ||
|
|
99d042d260 | ||
|
|
c9d6166fcb | ||
|
|
752ccec150 | ||
|
|
91ccb95672 | ||
|
|
4caff457d3 | ||
|
|
a1a6ee7107 | ||
|
|
af157b88bd | ||
|
|
ea4f4c088b | ||
|
|
6559ed5c1a | ||
|
|
deddcf8dd2 | ||
|
|
dfe536a2d2 | ||
|
|
5bfb348354 | ||
|
|
afcf93b7b1 | ||
|
|
e1843624bb | ||
|
|
0f4e7b5061 | ||
|
|
869ead63bc | ||
|
|
6a6de7802b | ||
|
|
b50302d9d0 | ||
|
|
c841d74aaf | ||
|
|
09cce39aff | ||
|
|
e5b76a571b | ||
|
|
7c58fa4be6 | ||
|
|
f150a41d72 | ||
|
|
bca1c2bdb3 | ||
|
|
47a8bcc442 | ||
|
|
83cad75916 | ||
|
|
6b5a12105e | ||
|
|
451b679323 | ||
|
|
66a8bfd5b1 | ||
|
|
2a2b2f6f64 | ||
|
|
73dea11de2 | ||
|
|
9998a6c930 | ||
|
|
5111d40aaf | ||
|
|
972ccaed7e | ||
|
|
f7d36bc1f3 | ||
|
|
8073945af0 | ||
|
|
91353d6b01 | ||
|
|
bfbcc8dcf8 | ||
|
|
8f65798141 | ||
|
|
fdddb17d2f | ||
|
|
520f9e3fcf | ||
|
|
a3d2a1b127 | ||
|
|
7ecf73165b | ||
|
|
e90a7ed075 | ||
|
|
aae521b727 | ||
|
|
643345b459 | ||
|
|
a62d9f5617 | ||
|
|
2f3f76c8cf | ||
|
|
a03aaa45b1 | ||
|
|
372155b5c3 | ||
|
|
159de771bf | ||
|
|
41d922cb27 | ||
|
|
6a4fac63e8 | ||
|
|
3daf8db113 | ||
|
|
9c62a35e07 | ||
|
|
931f438b14 | ||
|
|
3109612c1b | ||
|
|
e4d63ffbcc | ||
|
|
866a554d30 | ||
|
|
ab2811ed2d | ||
|
|
8cc7bcc849 | ||
|
|
547e89b85d | ||
|
|
477f1188df | ||
|
|
d9e4b27cd2 | ||
|
|
37f39eaf66 | ||
|
|
223d22e79f | ||
|
|
04214a96eb | ||
|
|
f40cb69f38 | ||
|
|
6c1489d434 | ||
|
|
6fe63838f5 | ||
|
|
d883c22d64 | ||
|
|
3bd1c869f1 | ||
|
|
e7273aaf6f | ||
|
|
6e02f80f6c | ||
|
|
01276dfc62 | ||
|
|
f516fd5e54 | ||
|
|
79612915a7 | ||
|
|
f04f9093bc | ||
|
|
9dac950faf | ||
|
|
f2a8ff3f64 | ||
|
|
b78317dd42 | ||
|
|
048dd25099 | ||
|
|
0900289437 | ||
|
|
d8dd86dfe8 | ||
|
|
9a569d7ed8 | ||
|
|
53132ce83a | ||
|
|
c3bdc33215 | ||
|
|
c6bf8ceb5c | ||
|
|
792d041078 | ||
|
|
cb965c9bf9 | ||
|
|
f33889b88f | ||
|
|
e747e3a3fa | ||
|
|
fd460337f4 | ||
|
|
38c9479385 | ||
|
|
da032cb04e | ||
|
|
37a80338f5 | ||
|
|
8a5f233e84 | ||
|
|
e3a9131929 | ||
|
|
bab98d5463 | ||
|
|
4333b39377 | ||
|
|
8bd427a6ab | ||
|
|
d3493a3361 | ||
|
|
51982cda28 | ||
|
|
a2e14bc76a | ||
|
|
c050d274f5 | ||
|
|
bdff22cbac | ||
|
|
7da10198e3 | ||
|
|
b11e2b3d11 | ||
|
|
c95b619974 | ||
|
|
e61b2e18c1 | ||
|
|
e9d64dbf03 | ||
|
|
3c8121d088 | ||
|
|
93ced5ca7a | ||
|
|
7580583fbf | ||
|
|
41c68664d7 | ||
|
|
c8393cdcec | ||
|
|
42d12e4fa8 | ||
|
|
bed9bd77a6 | ||
|
|
f3c2390fbb | ||
|
|
83a7ed58a5 | ||
|
|
ddc1f77825 | ||
|
|
88169236cb | ||
|
|
0cb36b3b8b | ||
|
|
ce169461a3 | ||
|
|
18ec3db1bb | ||
|
|
53fdff1d9b | ||
|
|
9a91336958 | ||
|
|
7bd69bebf4 | ||
|
|
57b6f04b79 | ||
|
|
c7442c2a9e | ||
|
|
df985013eb | ||
|
|
41f520845a | ||
|
|
dac09c64c8 | ||
|
|
a2defe5971 | ||
|
|
ba4e5d6ea9 | ||
|
|
25f12e9733 | ||
|
|
ca37dc0fc6 | ||
|
|
7d41835794 | ||
|
|
b37014463f | ||
|
|
2b94883e70 | ||
|
|
5c7468ffb5 | ||
|
|
343632cbf2 | ||
|
|
2a3ccec429 | ||
|
|
d6f12804ea | ||
|
|
f858c175f9 | ||
|
|
cdab004505 | ||
|
|
59bd11e742 | ||
|
|
2e6faff8c1 | ||
|
|
722cc2e38c | ||
|
|
669c0e9651 | ||
|
|
d2252c6142 | ||
|
|
eab4101d1c | ||
|
|
db31c35d8e | ||
|
|
125595e6b9 | ||
|
|
6d5d9934cc | ||
|
|
bd2a8daad3 | ||
|
|
c4b3c1d033 | ||
|
|
eb051bc194 | ||
|
|
1a12faf5ab | ||
|
|
73fe9cd62f | ||
|
|
7ab4a283fe | ||
|
|
46138c9abe | ||
|
|
841cc8e033 | ||
|
|
cb0844c64d | ||
|
|
6e8e59aee5 | ||
|
|
358eebf96b | ||
|
|
01892b609f | ||
|
|
096981bd27 | ||
|
|
0852fc0d65 | ||
|
|
40ceb3d0b8 | ||
|
|
b52a6bd6d6 | ||
|
|
992e53856d | ||
|
|
f776d15e03 | ||
|
|
438bc59fbc | ||
|
|
453f253e77 | ||
|
|
550df20f18 | ||
|
|
e8ee0a8c5b | ||
|
|
5fcd7ddf7a | ||
|
|
b11d416035 | ||
|
|
f7e216ba84 | ||
|
|
f6406b668c | ||
|
|
7cd4a1d411 | ||
|
|
bd558bb527 | ||
|
|
8d29f6971a | ||
|
|
300f69597f | ||
|
|
8e320b6dbe | ||
|
|
fa422bef32 | ||
|
|
e8cd1cc253 | ||
|
|
5e9ffe9e29 | ||
|
|
edebb0efc9 | ||
|
|
913d5d64ae | ||
|
|
6da8fabb1f | ||
|
|
ee022d7cd7 | ||
|
|
c126a0ac38 | ||
|
|
4a3dac0aa4 | ||
|
|
f4700ded12 | ||
|
|
8570921049 | ||
|
|
612b953b63 | ||
|
|
02777c370d | ||
|
|
7a8ab1df99 | ||
|
|
182c5f6a17 | ||
|
|
7c7673af20 | ||
|
|
9282fc25de | ||
|
|
f66e47c01f | ||
|
|
f00d73d60e | ||
|
|
c5b08781f7 | ||
|
|
4b80c4e4e6 | ||
|
|
7da3cc224b | ||
|
|
0659a5263a | ||
|
|
0f8614519f | ||
|
|
541f828db4 | ||
|
|
70aedb4a84 | ||
|
|
4f24f2631e | ||
|
|
ddb910e2ea | ||
|
|
b5c4eb3587 | ||
|
|
a0553bfa34 | ||
|
|
241f053b8a | ||
|
|
6174c9e486 | ||
|
|
d7629acb61 | ||
|
|
8169b6f650 | ||
|
|
7b174683ba | ||
|
|
88e7327af6 | ||
|
|
b7d8562ece | ||
|
|
439826ddc6 | ||
|
|
b94641f1b5 | ||
|
|
0ddf56f7f6 | ||
|
|
74e64d0641 | ||
|
|
858b0b2c1c | ||
|
|
54237c0038 | ||
|
|
0edb948a40 | ||
|
|
f85aeecde7 | ||
|
|
69a0f26a52 | ||
|
|
8bb28b5ef1 | ||
|
|
a6118c3aa4 | ||
|
|
59494233e3 | ||
|
|
d0ff1815aa | ||
|
|
9b7970475a | ||
|
|
88c0bdfffb | ||
|
|
b43bc4a57a | ||
|
|
bd8e1a35f6 | ||
|
|
722dabcf1a | ||
|
|
09207367c0 | ||
|
|
3336b73536 | ||
|
|
0d7e3ad2de | ||
|
|
95d1bd8ee0 | ||
|
|
6c97e04c7c | ||
|
|
24f72cb07f | ||
|
|
ef56a32f00 | ||
|
|
d8da89703b | ||
|
|
e47c563ced | ||
|
|
bd0917d34b | ||
|
|
8098211d01 | ||
|
|
83c95bbb8c | ||
|
|
4d4e1c6c26 | ||
|
|
3045dc0293 | ||
|
|
e649973318 | ||
|
|
2d147bb7e1 | ||
|
|
f57afb2944 | ||
|
|
95052546a5 | ||
|
|
768532cb8b | ||
|
|
6b7e1286f2 | ||
|
|
577cfd0954 | ||
|
|
06df4585c2 | ||
|
|
416006dbde | ||
|
|
5ff9f5c175 | ||
|
|
fa14184eb4 | ||
|
|
d29f66563b | ||
|
|
53957e7b26 | ||
|
|
2c81cb2f84 | ||
|
|
711fe7ad2f | ||
|
|
f6f94571ea | ||
|
|
985629c196 | ||
|
|
bb64079d17 | ||
|
|
c3363f0d70 | ||
|
|
937a5758f7 | ||
|
|
bb1826bdb1 | ||
|
|
1a781fc5b0 | ||
|
|
039d174477 | ||
|
|
929f9e99cd | ||
|
|
ae8bf63c86 | ||
|
|
3eb5c65a3d | ||
|
|
095f2aa67e | ||
|
|
0f10e89f7c | ||
|
|
3a2b453e3f | ||
|
|
c43a24d78f | ||
|
|
d43eb3bc34 | ||
|
|
3ca147e405 | ||
|
|
41fb8a0722 | ||
|
|
ff3fa759d1 | ||
|
|
cab42af53b | ||
|
|
d9d665ab14 | ||
|
|
fac6ebef40 | ||
|
|
a4fd29c30c | ||
|
|
59c7197229 | ||
|
|
e7c9703ced | ||
|
|
5a63115fb2 | ||
|
|
4597849466 | ||
|
|
a35aaf9659 | ||
|
|
bfb3f9e840 | ||
|
|
91e34601ec | ||
|
|
7481acba8c | ||
|
|
4d43ef5305 | ||
|
|
b1fb143fd4 | ||
|
|
d07e81288a | ||
|
|
c0d4ba5c6c | ||
|
|
8a11752253 | ||
|
|
1d24be8c34 | ||
|
|
d3f3489c7e | ||
|
|
3f16fef57e | ||
|
|
608d782321 | ||
|
|
5d6dad4c6d | ||
|
|
28c538e981 | ||
|
|
a35cb9277e | ||
|
|
e43ce420a3 | ||
|
|
501a7aa77a | ||
|
|
76f7ac8d8e | ||
|
|
518d5958c9 | ||
|
|
7e25de38da | ||
|
|
bf8ef39871 | ||
|
|
cd62af698b | ||
|
|
709ce9eb08 | ||
|
|
e24d7ccb10 | ||
|
|
98bbd900cb | ||
|
|
19b87b628a | ||
|
|
dc2652f87b | ||
|
|
99660920d7 | ||
|
|
ad1c10a3e9 | ||
|
|
5b685e71d3 | ||
|
|
5ddc4b9251 | ||
|
|
38587a1c61 | ||
|
|
eb23e28c16 | ||
|
|
4379c7e989 | ||
|
|
989ce82c5d | ||
|
|
f92e55e061 | ||
|
|
0fc3d21b90 | ||
|
|
26d3645f86 | ||
|
|
110aa2e56b | ||
|
|
05369b69b6 | ||
|
|
4a501a49db | ||
|
|
2a69d1c7c9 | ||
|
|
573204caad | ||
|
|
7a01168781 | ||
|
|
b5dfed9e01 | ||
|
|
29f804b9f0 | ||
|
|
504fceceeb | ||
|
|
9a852f4cbe | ||
|
|
fafd3aba6a | ||
|
|
d87a335e85 | ||
|
|
471b4496c9 | ||
|
|
32e39f5c7c | ||
|
|
bf48361b10 | ||
|
|
387431c9c7 | ||
|
|
9b69c07663 | ||
|
|
a1d59373ac | ||
|
|
81a727fe7f | ||
|
|
189fd15498 | ||
|
|
1a602f2f8a | ||
|
|
7986238936 | ||
|
|
a2fc9c94fd | ||
|
|
51f98c9eb7 | ||
|
|
418b8ff6a7 | ||
|
|
9cab51dac8 | ||
|
|
26ac987024 | ||
|
|
e44875532d | ||
|
|
956d1b4248 | ||
|
|
3aa8bbe947 | ||
|
|
f46b1cb138 | ||
|
|
5b5022b0b8 | ||
|
|
d93c7fa09d | ||
|
|
2c1d1ef0a3 | ||
|
|
bf97e41697 | ||
|
|
c0852d63fe | ||
|
|
acc39e11b1 | ||
|
|
b4880ae982 | ||
|
|
1a1acae588 | ||
|
|
1581390092 | ||
|
|
cd221ea19c | ||
|
|
abeab91be4 | ||
|
|
227f54d315 | ||
|
|
ac88367f6c | ||
|
|
f788f0e0d9 | ||
|
|
9a4bc70cdd | ||
|
|
ab46fd6244 | ||
|
|
6deafa660d | ||
|
|
0d2adc5707 | ||
|
|
b0ed119585 | ||
|
|
ff2462b084 | ||
|
|
894a42ea13 | ||
|
|
d827e01760 | ||
|
|
5e6de8b76d | ||
|
|
b298bedea0 | ||
|
|
fb5ae838d9 | ||
|
|
3bfcd69fd9 | ||
|
|
c66adf0119 | ||
|
|
2119b274fd | ||
|
|
22f45c45ee | ||
|
|
0dd9729b35 | ||
|
|
ff46c2cf54 | ||
|
|
1537fc879e | ||
|
|
f00352cde0 | ||
|
|
fdc74b1c0d | ||
|
|
83a3c61b66 | ||
|
|
4422d536b7 | ||
|
|
1f40908c04 | ||
|
|
b707289284 | ||
|
|
43486bda63 | ||
|
|
7086a1d0d2 | ||
|
|
4dd13bd925 | ||
|
|
4ce97bca0e | ||
|
|
ec9712f30e | ||
|
|
0162910964 | ||
|
|
c252a79c1a | ||
|
|
89739d4efe | ||
|
|
9c7fb6a1d3 | ||
|
|
2df3290d38 | ||
|
|
4805df2f03 | ||
|
|
5bc670db8b | ||
|
|
ffda88f193 | ||
|
|
96a69aa2ef | ||
|
|
2d90fddbee | ||
|
|
bbd1a0ef10 | ||
|
|
6b16ed79b3 | ||
|
|
73b9a7fb0d | ||
|
|
4a0ae833f0 | ||
|
|
5f32ebe2de | ||
|
|
723928d239 | ||
|
|
d024ed7b81 | ||
|
|
ec4143d3dc | ||
|
|
071fdaabd3 | ||
|
|
23766f20dd | ||
|
|
31739c647b | ||
|
|
faa016180a | ||
|
|
e26238e814 | ||
|
|
f8ed1a3e3e | ||
|
|
d47c255168 | ||
|
|
d1e7796f81 | ||
|
|
1095064c5e | ||
|
|
a15c9d289b | ||
|
|
c0f95bebf0 | ||
|
|
0a54779fc4 | ||
|
|
ac525958c5 | ||
|
|
458cf64501 | ||
|
|
4acef77623 | ||
|
|
d38d7fc492 | ||
|
|
2510c3eeb5 | ||
|
|
326d53fd09 | ||
|
|
75b3082b12 | ||
|
|
1f214aadee | ||
|
|
174b3fad15 | ||
|
|
07531f67d4 | ||
|
|
291c45064a | ||
|
|
6f56cb29a5 | ||
|
|
977c7d2f29 | ||
|
|
ecb87efe8d | ||
|
|
a57c162cd8 | ||
|
|
60c3ed4f6b | ||
|
|
714e75eb95 | ||
|
|
636819c801 | ||
|
|
9a6c2e0685 | ||
|
|
736eecc13b | ||
|
|
4718c5dab0 | ||
|
|
7e9bd49da2 | ||
|
|
a0d0ff0b92 | ||
|
|
b41be0c319 | ||
|
|
17a466059e | ||
|
|
2d9e95a63e | ||
|
|
532a45f9e7 | ||
|
|
d61e32ebb5 | ||
|
|
b7d38e94c8 | ||
|
|
ae158742f6 | ||
|
|
c35686f8d1 | ||
|
|
a5b6651582 | ||
|
|
54973fdf82 | ||
|
|
0bee631385 | ||
|
|
6283382837 | ||
|
|
39bb522051 | ||
|
|
bf80d57abe | ||
|
|
865b94006a | ||
|
|
874248f8b5 | ||
|
|
cef7d5bb12 | ||
|
|
2a8131780f | ||
|
|
7094f70f4a | ||
|
|
df5af6129c | ||
|
|
a6888c3767 | ||
|
|
1bd367ddde | ||
|
|
0cf87ae561 | ||
|
|
fa80f5f67f | ||
|
|
7f080f920d | ||
|
|
13658323b4 | ||
|
|
2d440ab5ba | ||
|
|
dc55673691 | ||
|
|
92bb3948a6 | ||
|
|
f67ad6478c | ||
|
|
1d984198ce | ||
|
|
f2ca980771 | ||
|
|
b826697aea | ||
|
|
89430c13ec | ||
|
|
f07acea3e1 | ||
|
|
e9402c55e6 | ||
|
|
2eb6c76da8 | ||
|
|
a34e48a145 | ||
|
|
2d50659b48 | ||
|
|
327ae2b807 | ||
|
|
e831b7facc | ||
|
|
dfb6114584 | ||
|
|
5085841d9d | ||
|
|
7a98944469 | ||
|
|
3d2b455cda | ||
|
|
460d5d0691 | ||
|
|
b5f80351ec | ||
|
|
72a9472a57 | ||
|
|
7eb820c688 | ||
|
|
886b279da6 | ||
|
|
f2d7135fc5 | ||
|
|
d214a859c3 | ||
|
|
d1e221c2b7 | ||
|
|
e0e4207a4d | ||
|
|
4398c781c5 | ||
|
|
3e06000fd9 | ||
|
|
833795ebe1 | ||
|
|
6e270d5ec3 | ||
|
|
09a9bea3a7 | ||
|
|
035ccee2a6 | ||
|
|
17aa2a4153 | ||
|
|
f5bc5c0b47 | ||
|
|
e7a4afde7d | ||
|
|
8758c9b940 | ||
|
|
a569d20779 | ||
|
|
88e01fa083 | ||
|
|
7b435f9283 | ||
|
|
a240e5d128 | ||
|
|
0d0ba31d3a | ||
|
|
e79bb3533d | ||
|
|
f94c4ec831 | ||
|
|
d5afb76105 | ||
|
|
dd7e9ba05e | ||
|
|
ee54698fdb | ||
|
|
955b0e991c | ||
|
|
c1b98b9e40 | ||
|
|
d6939b7916 | ||
|
|
5f0ca37879 | ||
|
|
548bdb7eb5 | ||
|
|
5c85f39228 | ||
|
|
85b2cbc03a | ||
|
|
cc78011da6 | ||
|
|
d016da1895 | ||
|
|
8593f1c80a | ||
|
|
0b3c40dc3e | ||
|
|
2e7ecc59c0 | ||
|
|
942ce95dbf | ||
|
|
03f77d5ab7 | ||
|
|
8dec32fa6a | ||
|
|
8f409d47d9 | ||
|
|
93f062d4e3 | ||
|
|
b8f9ceafbb | ||
|
|
75d07b6dad | ||
|
|
6060a0a430 | ||
|
|
647ba1572c | ||
|
|
051e0cb811 | ||
|
|
b8c9e78910 | ||
|
|
2d7d9c6093 | ||
|
|
0f32f56208 | ||
|
|
5addfd8975 | ||
|
|
7f108ce8f0 | ||
|
|
8c883e1ca8 | ||
|
|
d18fe6ffa0 | ||
|
|
80a8ac9e98 | ||
|
|
671fd58568 | ||
|
|
c4ea3b59f0 | ||
|
|
5d5def206d | ||
|
|
b2ebbb9b55 | ||
|
|
3734c071bf | ||
|
|
b1a419f2a2 | ||
|
|
bf5e292160 | ||
|
|
df57d91270 | ||
|
|
4da1741578 | ||
|
|
7a3774e730 | ||
|
|
e6e21caeea | ||
|
|
200d47ab09 | ||
|
|
ab274151d4 | ||
|
|
aec1e3a529 | ||
|
|
916caa1eb2 | ||
|
|
50b29f8ad6 | ||
|
|
88d662cf27 | ||
|
|
5316130ae8 | ||
|
|
4f36dbc636 | ||
|
|
230a8697bf | ||
|
|
121449b230 | ||
|
|
fede549b51 | ||
|
|
1bdd7f9a6b | ||
|
|
b3f9da67b7 | ||
|
|
1ba7d623b4 | ||
|
|
47902e1177 | ||
|
|
a035bcc671 | ||
|
|
9bcc6b9605 | ||
|
|
282c3a864e | ||
|
|
eb083a8934 | ||
|
|
0fc71ff79e | ||
|
|
68a7455496 | ||
|
|
fcfc3acbb8 | ||
|
|
aa53c0aa6a | ||
|
|
f098905a92 | ||
|
|
eec78092b5 | ||
|
|
34fa5eceb8 | ||
|
|
c32d2dd6f8 | ||
|
|
da80d3536a | ||
|
|
e9361022d2 | ||
|
|
dd0c1a5ab5 | ||
|
|
bb9dff7b8c | ||
|
|
7e419c116e | ||
|
|
2cbc2f5226 | ||
|
|
68b5e3e0a8 | ||
|
|
1502ec12a9 | ||
|
|
6d09b18479 | ||
|
|
08ce207636 | ||
|
|
f199b977eb | ||
|
|
5715e2c835 | ||
|
|
b8642b7ca3 | ||
|
|
2c4d4708d8 | ||
|
|
0edb6e6157 | ||
|
|
4f394b5668 | ||
|
|
9834c30e3a | ||
|
|
f3f1b0870f | ||
|
|
915d314c18 | ||
|
|
02b3ae6aa5 | ||
|
|
f725e73653 | ||
|
|
c5858ef202 | ||
|
|
ba2fd2ca2e | ||
|
|
1075d36748 | ||
|
|
3ee3799e55 | ||
|
|
6654b0a67a | ||
|
|
9577c93edb | ||
|
|
7cd67281bc | ||
|
|
d21c226183 | ||
|
|
4322236b9e | ||
|
|
05e408ee65 | ||
|
|
3d1012ba94 | ||
|
|
94937e41ef | ||
|
|
3957aa83fc | ||
|
|
8aa79d1c4c | ||
|
|
578eeff0e1 | ||
|
|
5f2f1c67f5 | ||
|
|
c92b9c3d97 | ||
|
|
0951d00da3 | ||
|
|
6df9c3660b | ||
|
|
19be2bf96e | ||
|
|
e10ed6ac7a | ||
|
|
479ebf4d89 | ||
|
|
1f1e36e9f7 | ||
|
|
27e634ae03 | ||
|
|
e60b20b37b | ||
|
|
684214ff6a | ||
|
|
ba5be6071f | ||
|
|
6c8d13690e | ||
|
|
3e0b2ef3e4 | ||
|
|
c5304d2775 | ||
|
|
ca95ae04a5 | ||
|
|
1ab9f85ca6 | ||
|
|
01ff1b2f8f | ||
|
|
9b17fe68e7 | ||
|
|
0fed35a80f | ||
|
|
25280c9fa9 | ||
|
|
a98ebfdb21 | ||
|
|
acb1d18654 | ||
|
|
18b5a4e106 | ||
|
|
bab420a359 | ||
|
|
4f14f1f736 | ||
|
|
166831447c | ||
|
|
f2bd5961d0 | ||
|
|
2cc990a530 | ||
|
|
f0e6008563 | ||
|
|
93f19cca0a | ||
|
|
1cbe508f82 | ||
|
|
0c178c3155 | ||
|
|
e67304389d | ||
|
|
ad5b1cdcba | ||
|
|
fe1e09289f | ||
|
|
583ea76e4b | ||
|
|
a7d198893e | ||
|
|
fe62c8d0c5 | ||
|
|
16ce56c1ad | ||
|
|
15f0bfb9db | ||
|
|
22db589742 | ||
|
|
69119e6db7 | ||
|
|
690da2332b | ||
|
|
f2fead1444 | ||
|
|
c4f6267921 | ||
|
|
0dc65d083f | ||
|
|
40c1d93f02 | ||
|
|
2024a93126 | ||
|
|
88d79a42e6 | ||
|
|
b01b2cce9b | ||
|
|
c5b1089c96 | ||
|
|
679e43758b | ||
|
|
90e6e5a96c | ||
|
|
4fb003c4df | ||
|
|
9d5f349a04 | ||
|
|
f4f4a47a7f | ||
|
|
6a3e987668 | ||
|
|
83f943965f | ||
|
|
c9fdff169f | ||
|
|
5454832918 | ||
|
|
3d6d774b17 | ||
|
|
1463547af4 | ||
|
|
0bcf4b3597 | ||
|
|
824e8dcb4b | ||
|
|
4b2f0c8020 | ||
|
|
7fd424cf65 | ||
|
|
5ff2855eb0 | ||
|
|
8c8c162a54 | ||
|
|
37d52f3688 | ||
|
|
f361cbfa71 | ||
|
|
ddefbfe2cf | ||
|
|
10296cb736 | ||
|
|
49dc0599c9 | ||
|
|
14348e170b | ||
|
|
59d1f0d817 | ||
|
|
e024f134a4 | ||
|
|
cf5a5b5b47 | ||
|
|
e957f92496 | ||
|
|
9484bb9941 | ||
|
|
d781f9822f | ||
|
|
7845ef2de4 | ||
|
|
a9d4ecf33d | ||
|
|
6f4a62c7a3 | ||
|
|
6b4f872742 | ||
|
|
ef4f00f8f5 | ||
|
|
a27deb3936 | ||
|
|
18814c7373 | ||
|
|
1d9908e1f6 | ||
|
|
29529e4a06 | ||
|
|
74b1003c4c | ||
|
|
27ffdec323 | ||
|
|
d9e5fc2b60 | ||
|
|
646b3e3064 | ||
|
|
d3475208ef | ||
|
|
7246da472d | ||
|
|
e1f917894a | ||
|
|
c14d25f860 | ||
|
|
57ed91cd28 | ||
|
|
47c84beb43 | ||
|
|
1e3032bdce | ||
|
|
ed69684843 | ||
|
|
2eea5c7bf7 | ||
|
|
16da53ae4e | ||
|
|
f45464b0d9 | ||
|
|
2351ade6fe | ||
|
|
c19ccf9278 | ||
|
|
5c92762ba9 | ||
|
|
e665f966e6 | ||
|
|
7dcca7e505 | ||
|
|
e25049b1d6 | ||
|
|
da9bc4a138 | ||
|
|
1224d3b443 | ||
|
|
d33be37694 | ||
|
|
551ff26a65 | ||
|
|
74082f9c68 | ||
|
|
b93331e184 | ||
|
|
d5d26168b3 | ||
|
|
9d848e222b | ||
|
|
46a2510e85 | ||
|
|
0789a453a2 | ||
|
|
b30f7fe9c7 | ||
|
|
525bd199b2 | ||
|
|
dffd8b59f5 | ||
|
|
df206724bd | ||
|
|
41f31250a9 | ||
|
|
b29007275f | ||
|
|
35f268319e | ||
|
|
6e8a185b63 | ||
|
|
120fff1fc4 | ||
|
|
f879bd5e3a | ||
|
|
01f9fd561d | ||
|
|
6802a7d747 | ||
|
|
b918b29014 | ||
|
|
4895a3313b | ||
|
|
59673c9e66 | ||
|
|
b126255be7 | ||
|
|
606c9f3fd8 | ||
|
|
aa306a8df7 | ||
|
|
b1256eedcf | ||
|
|
4454df341f | ||
|
|
5bcac17f1c | ||
|
|
875b9f326c | ||
|
|
a0d27c6f86 | ||
|
|
1d47d12189 | ||
|
|
67f78ae8b5 | ||
|
|
5948855da7 | ||
|
|
f6ec46cdf6 | ||
|
|
ebd2755eb2 | ||
|
|
78f5827d3d | ||
|
|
0829070c67 | ||
|
|
8b4332e842 | ||
|
|
f904c91443 | ||
|
|
944539453e | ||
|
|
5856b002df | ||
|
|
12f68bc227 | ||
|
|
de6e20d60a | ||
|
|
35e6ef5cd8 | ||
|
|
27251dda2e | ||
|
|
4bb967ab4a | ||
|
|
7c1f878610 | ||
|
|
e8c4c9b218 | ||
|
|
bc37d365ab | ||
|
|
d9ae1bbd9f | ||
|
|
e492b30178 | ||
|
|
920860c298 | ||
|
|
5f8a6e3423 | ||
|
|
3e7a5056d5 | ||
|
|
2ec6f04763 | ||
|
|
ecef9c9792 | ||
|
|
810501a508 | ||
|
|
6285a66d76 | ||
|
|
72e4922e8e | ||
|
|
c1f1885633 | ||
|
|
56e514a500 | ||
|
|
5ede100d56 | ||
|
|
f1456b8101 | ||
|
|
ef8eb76b16 | ||
|
|
b4f2188f72 | ||
|
|
38c30f5ecd | ||
|
|
94c794de6f | ||
|
|
fb535e620c | ||
|
|
5a42980d78 | ||
|
|
299d2a1f01 | ||
|
|
164ff5ea9a | ||
|
|
6c89ef908a | ||
|
|
3441ae11f2 | ||
|
|
c028331ef9 | ||
|
|
9343c300cd | ||
|
|
63693cc529 | ||
|
|
e6de06aae8 | ||
|
|
89ce7312d1 | ||
|
|
b884787377 | ||
|
|
a1427e7743 | ||
|
|
0c02190e19 | ||
|
|
1f7cce9535 | ||
|
|
9fea677b60 | ||
|
|
6b9a3aff58 | ||
|
|
b938271b4d | ||
|
|
297e06ba71 | ||
|
|
a521ab76a5 | ||
|
|
b1c8fc82c4 | ||
|
|
d4ba90c21d | ||
|
|
14dc868d45 | ||
|
|
61a60ecdd6 | ||
|
|
2b56247e21 | ||
|
|
e0066e6173 | ||
|
|
b5b92f91dc | ||
|
|
7b12510182 | ||
|
|
e2fc6a3ff0 | ||
|
|
5acd3a7f6c | ||
|
|
ce49ca0998 | ||
|
|
eacce487ed | ||
|
|
602b1d8a27 | ||
|
|
dec469caef | ||
|
|
4194b2ca86 | ||
|
|
17741822c1 | ||
|
|
3757056e46 | ||
|
|
0eb68ef864 | ||
|
|
3f77a9b721 | ||
|
|
321b3acf0a | ||
|
|
dfbbeeb473 | ||
|
|
31d3f2e7c6 | ||
|
|
40a66b9be4 | ||
|
|
049a1fb2ed | ||
|
|
3fc68af05f | ||
|
|
c3f0c8a7a1 | ||
|
|
cba1a95838 | ||
|
|
345f4a2e0e | ||
|
|
162d53b66e | ||
|
|
bed6782a00 | ||
|
|
d90b960597 | ||
|
|
3325feb1cb | ||
|
|
62d181eb81 | ||
|
|
1e24e9c128 | ||
|
|
cfffba25cf | ||
|
|
671b4fe2db | ||
|
|
5b300bc5d1 | ||
|
|
a5332c2166 | ||
|
|
141d5ccd25 | ||
|
|
c75b9c2328 | ||
|
|
0863db8cf0 | ||
|
|
53d6a272e6 | ||
|
|
71467a7ae7 | ||
|
|
56fa3458ab | ||
|
|
82e04ac4e5 | ||
|
|
564d4442fc | ||
|
|
df8fdd086b | ||
|
|
a31476251e | ||
|
|
360a655627 | ||
|
|
3b871b9c00 | ||
|
|
65834a2087 | ||
|
|
e9d85da691 | ||
|
|
cfa78af654 | ||
|
|
45d9119150 | ||
|
|
ea487eb6a4 | ||
|
|
4e295ea1eb | ||
|
|
32265414bd | ||
|
|
80e706e962 | ||
|
|
110838715b | ||
|
|
b90334c8a8 | ||
|
|
3ce0530d5f | ||
|
|
7eaa84d5b1 | ||
|
|
ad325dfedb | ||
|
|
5bb7eb6f01 | ||
|
|
342cfc0801 | ||
|
|
f5c6a9f507 | ||
|
|
e843ff372e | ||
|
|
ed27ffed65 | ||
|
|
7995ecd867 | ||
|
|
fcef6679c4 | ||
|
|
742b6a2e27 | ||
|
|
258fbc8870 | ||
|
|
0fa43ee287 | ||
|
|
fb39261dc7 | ||
|
|
7fce4bf53e | ||
|
|
13840cf61b | ||
|
|
e26f6b5e8d | ||
|
|
767c49f9fa | ||
|
|
c9178da608 | ||
|
|
855bc59a53 | ||
|
|
798c22e94b | ||
|
|
ea3be11294 | ||
|
|
335073b3b0 | ||
|
|
2b6ee344b7 | ||
|
|
8f55b82e2f | ||
|
|
ba9cd1f3e2 | ||
|
|
e0e7ae98e7 | ||
|
|
b05e439da9 | ||
|
|
fb5dbbdf58 | ||
|
|
9cb9dd0a58 | ||
|
|
276d42561e | ||
|
|
44b98165ba | ||
|
|
b5088340fd | ||
|
|
b7dd63ebd9 | ||
|
|
ba376a6326 | ||
|
|
87a43e8e8f | ||
|
|
b62ada53c3 | ||
|
|
4f3198b1bd | ||
|
|
c9f99e0903 | ||
|
|
3b4c58b721 | ||
|
|
6496bbd87f | ||
|
|
4ad8d362f7 | ||
|
|
d9aeb6afaa | ||
|
|
d971389746 | ||
|
|
233a2bdbe7 | ||
|
|
2277183330 | ||
|
|
b2cd3d31fd | ||
|
|
02f6b3be42 | ||
|
|
22e84321fc | ||
|
|
c472dc89ad | ||
|
|
b89d9d44b0 | ||
|
|
a2c21f8ceb | ||
|
|
e35596b0fa | ||
|
|
b95a7f063b | ||
|
|
e4bbd36d47 | ||
|
|
9790ab29a2 | ||
|
|
24cc2d3b36 | ||
|
|
12779699e3 | ||
|
|
2188690d20 | ||
|
|
7059fdfd9e | ||
|
|
9e1bde4b00 | ||
|
|
45790b60b0 | ||
|
|
c5f3a27d6b | ||
|
|
d9136aa407 | ||
|
|
183f48a998 | ||
|
|
3c5bc507a5 | ||
|
|
548dd0365c | ||
|
|
4591fc603f | ||
|
|
26946feecc | ||
|
|
dd14f3c469 | ||
|
|
69af41f1e5 | ||
|
|
474562455d | ||
|
|
c75d612541 | ||
|
|
8de6ce9868 | ||
|
|
97bde50708 | ||
|
|
b23e35cf26 | ||
|
|
b58e04707d | ||
|
|
846cf63268 | ||
|
|
4850bdefdf | ||
|
|
424b580eb9 | ||
|
|
7f8ad468ca | ||
|
|
e07e2bd7d1 | ||
|
|
7074963fb1 | ||
|
|
88acbe655d | ||
|
|
903ebc68a4 | ||
|
|
49bdccf020 | ||
|
|
ba3818884d | ||
|
|
64ce904ec1 | ||
|
|
8c5f7ef020 | ||
|
|
98426f6dcc | ||
|
|
f3ec873ac2 | ||
|
|
30961483e1 | ||
|
|
33e0750959 | ||
|
|
e59a07e232 | ||
|
|
3b05b9be11 | ||
|
|
943bbd9889 | ||
|
|
763cf8dbda | ||
|
|
5117518d8f | ||
|
|
936996da17 | ||
|
|
019a7e59b7 | ||
|
|
428a47f889 | ||
|
|
2be2cb19b2 | ||
|
|
66ee09d050 | ||
|
|
906dab28c1 | ||
|
|
6db8e1d842 | ||
|
|
a665e86096 | ||
|
|
b7481dbd2e | ||
|
|
b1e509c6f8 | ||
|
|
1f69622a34 | ||
|
|
215b2b5f75 | ||
|
|
1e8c91e92f | ||
|
|
19d447d67d | ||
|
|
925fa2ee1b | ||
|
|
1cedf0e9a0 | ||
|
|
ca8bb7f5f0 | ||
|
|
9e15a4a557 | ||
|
|
af5d0c4b0e | ||
|
|
08ab359534 | ||
|
|
28c44e0b2f | ||
|
|
7038f49a1a | ||
|
|
af25c15286 | ||
|
|
ffc5281d59 | ||
|
|
ad659cd32e | ||
|
|
afd3cbd311 | ||
|
|
a5a5f7e24a | ||
|
|
1e203b58c3 | ||
|
|
104b7c2cf2 | ||
|
|
355c89ecab | ||
|
|
1241e18f9c | ||
|
|
6566acf7eb | ||
|
|
4332ed92f2 | ||
|
|
2e7f96aab0 | ||
|
|
3cb9b90ef0 | ||
|
|
21a04cc8c8 | ||
|
|
dcc1b59627 | ||
|
|
e8fb3e6d24 | ||
|
|
93d084d5ba | ||
|
|
e45ecf9c86 | ||
|
|
beb10e22f2 | ||
|
|
64b12f8497 | ||
|
|
0821a08df2 | ||
|
|
50870a9b32 | ||
|
|
b823446e28 | ||
|
|
48b00874e5 | ||
|
|
deba6c79f3 | ||
|
|
c0be10ad94 | ||
|
|
5010d35ff3 | ||
|
|
42d26a1f4f | ||
|
|
92c25d2df4 | ||
|
|
5b5349fc34 | ||
|
|
cc6ac93b7a | ||
|
|
1b843b3586 | ||
|
|
3b9a426547 | ||
|
|
989ba0103d | ||
|
|
b584b996a3 | ||
|
|
896c7fc467 | ||
|
|
bd2393342f | ||
|
|
762b10cb17 | ||
|
|
9322eedb4e | ||
|
|
4e2a902b75 | ||
|
|
d3b8bd6f39 | ||
|
|
0fa64dad7f | ||
|
|
792e8663e6 | ||
|
|
4dc999b0d9 | ||
|
|
7c15c2de41 | ||
|
|
43137c3e53 | ||
|
|
521ecd438e | ||
|
|
949c6599b3 | ||
|
|
ea79efe693 | ||
|
|
b4a89462f8 | ||
|
|
70bd3d0e9a | ||
|
|
c33474e0f9 | ||
|
|
3d0ebe5c91 | ||
|
|
a9ab0702e0 | ||
|
|
9272741a3c | ||
|
|
2b72a99608 | ||
|
|
4c38e10fe1 | ||
|
|
7806b48d34 | ||
|
|
9803d6b731 | ||
|
|
649db3aca2 | ||
|
|
b75ab68e7a | ||
|
|
8ffc42d349 | ||
|
|
145c9750cd | ||
|
|
12647c3a6c | ||
|
|
056f8a57c7 | ||
|
|
94f0acf9f3 | ||
|
|
40bf65d56a | ||
|
|
726e3a5c20 | ||
|
|
d1cab0da7f | ||
|
|
ede4873c6a | ||
|
|
fd8c827bf1 | ||
|
|
20afbdf264 | ||
|
|
0dd92e5189 | ||
|
|
4b1ba5acb0 | ||
|
|
edc94594eb | ||
|
|
837efb75d1 | ||
|
|
252208a479 | ||
|
|
2641cb7d4f | ||
|
|
9c91f06c5d | ||
|
|
7fab4144ae | ||
|
|
81eb2cad1a | ||
|
|
eda7db7aca | ||
|
|
45a7653dcd | ||
|
|
36fef995e4 | ||
|
|
af2e862ca2 | ||
|
|
7f48ce06be | ||
|
|
1c5ae9ef67 | ||
|
|
3bf18c41bb | ||
|
|
7ab49f1909 | ||
|
|
44b5e5548d | ||
|
|
50ca9d129b | ||
|
|
7b725d655c | ||
|
|
3e9c7aa74b | ||
|
|
916ed2652e | ||
|
|
59a1726e8c | ||
|
|
20f91b5258 | ||
|
|
353ce7e825 | ||
|
|
94be4ab18e | ||
|
|
df7409607f | ||
|
|
79b937e8d2 | ||
|
|
83c6c9c743 | ||
|
|
6a2affc0f9 | ||
|
|
8ad713c183 | ||
|
|
f8fb746f64 | ||
|
|
c6b3507bf4 | ||
|
|
2dc95da6e0 | ||
|
|
8f9bfcf474 | ||
|
|
a8b54757e9 | ||
|
|
19cfd9edc6 | ||
|
|
03d0f962e5 | ||
|
|
0ff24627ca | ||
|
|
4d8cd430b7 | ||
|
|
30b0e5d0b1 | ||
|
|
cdf067bba8 | ||
|
|
e4d05e14ac | ||
|
|
82dc78523f | ||
|
|
676e744c02 | ||
|
|
0d80265ff2 | ||
|
|
442521a73c | ||
|
|
dcef083e30 | ||
|
|
162cd20f80 | ||
|
|
c74433422a | ||
|
|
f338650b24 | ||
|
|
65c0d77d3e | ||
|
|
09a150b6e9 | ||
|
|
06173a446a | ||
|
|
d6adea447e | ||
|
|
d042b785ed | ||
|
|
881846d301 | ||
|
|
2092cc43b3 | ||
|
|
dc637d0f2b | ||
|
|
987a20b33c | ||
|
|
dbf65f798f | ||
|
|
97aa259b2d | ||
|
|
770a108bad | ||
|
|
71aaa574b2 | ||
|
|
a02fe633e2 | ||
|
|
0669bab563 | ||
|
|
a258400443 | ||
|
|
d02c5057c6 | ||
|
|
a473f47235 | ||
|
|
7bedf6bb15 | ||
|
|
9d813290c6 | ||
|
|
05239bccb0 | ||
|
|
1d5c28f37f | ||
|
|
16fb6b4f9d | ||
|
|
97b09aab34 | ||
|
|
55210caceb | ||
|
|
8127e56603 | ||
|
|
e61b496ca4 | ||
|
|
3ed8eb76c2 | ||
|
|
a5c3b8a245 | ||
|
|
3f5d52f901 | ||
|
|
46e0607a26 | ||
|
|
23fa7a89ad | ||
|
|
dcd379bce7 | ||
|
|
40238a9d25 | ||
|
|
44db374e09 | ||
|
|
d960d543ff | ||
|
|
0a45292587 | ||
|
|
9b4a7c705b | ||
|
|
71a6d8ab44 | ||
|
|
91f9acb633 | ||
|
|
0e45dc5a3f | ||
|
|
3341574e02 | ||
|
|
881dc38a18 | ||
|
|
e54b201aa5 | ||
|
|
2d06a40127 | ||
|
|
f7e68798fa | ||
|
|
b9fe5d2afc | ||
|
|
5f12d99e73 | ||
|
|
933987ac0a | ||
|
|
3a10a0969a | ||
|
|
ba4907e67b | ||
|
|
99b37147d3 | ||
|
|
92a03ab7d6 | ||
|
|
68a0c67769 | ||
|
|
17e9105b9c | ||
|
|
5411a294e7 | ||
|
|
f821e277de | ||
|
|
18c2164049 | ||
|
|
c9688a9c58 | ||
|
|
cd599849b2 | ||
|
|
423f0199d0 | ||
|
|
40299eeea4 | ||
|
|
38077275bc | ||
|
|
23aa6dc743 | ||
|
|
b90fb6a2b0 | ||
|
|
17c8ed9ebc | ||
|
|
a091a32c26 | ||
|
|
23970a4e36 | ||
|
|
f61a9ab5cc | ||
|
|
4505bb6f4e | ||
|
|
bb836aea57 | ||
|
|
d584fba31c | ||
|
|
feacf3af7b | ||
|
|
8c428bb399 | ||
|
|
8edb6976fb | ||
|
|
edd2f460a0 | ||
|
|
8810647bb8 | ||
|
|
2204bd67a7 | ||
|
|
c9c747693d | ||
|
|
135d92303d | ||
|
|
c707434155 | ||
|
|
4b72805a69 | ||
|
|
d5a9b0c65f | ||
|
|
2015604fe2 | ||
|
|
96a290b153 | ||
|
|
912fcfe88a | ||
|
|
4dcf7489fa | ||
|
|
7f1552dff8 | ||
|
|
d2ca8bffc4 | ||
|
|
e15b01bac5 | ||
|
|
dcd3cb80b8 | ||
|
|
d0ddc7c271 | ||
|
|
2b55f3407c | ||
|
|
e84afb4808 | ||
|
|
10c47eff7e | ||
|
|
aee81f918e | ||
|
|
95b2d9419f | ||
|
|
feb9ce6633 | ||
|
|
43489ca087 | ||
|
|
ce1a15e6ea | ||
|
|
cc72d370ea | ||
|
|
d042185660 | ||
|
|
e78b639018 | ||
|
|
e8ea562b09 | ||
|
|
3b5a729ef3 | ||
|
|
ef7d487ec5 | ||
|
|
b379b8f022 | ||
|
|
a31378c2c8 | ||
|
|
0d2c2121bb | ||
|
|
21040b306a | ||
|
|
541b1dbc44 | ||
|
|
005ac41820 | ||
|
|
dd93772233 | ||
|
|
428fc7e5f6 | ||
|
|
5cf38cc885 | ||
|
|
2f6b51e811 | ||
|
|
2f12da6bc6 | ||
|
|
3985e157d9 | ||
|
|
3034eb5c12 | ||
|
|
f666f1baa9 | ||
|
|
3bbffa7b55 | ||
|
|
bc774e2596 | ||
|
|
65a0e5c188 | ||
|
|
772d2cb580 | ||
|
|
edc6825f83 | ||
|
|
7b2f9e0c86 | ||
|
|
0fa4fa1862 | ||
|
|
5be31ebb5c | ||
|
|
962394b2ba | ||
|
|
7cf7c5f44c | ||
|
|
5b494a09ec | ||
|
|
5cfac5da4a | ||
|
|
203004951b | ||
|
|
765d7402fa | ||
|
|
151b5fc561 | ||
|
|
b489da7fe4 | ||
|
|
786a0f6f2b | ||
|
|
e2a940e01b | ||
|
|
518c3be478 | ||
|
|
6f3eaac008 | ||
|
|
31633e9466 | ||
|
|
02913780ec | ||
|
|
f03a2263d8 | ||
|
|
a8cd832c28 | ||
|
|
abbced0530 | ||
|
|
200e07023f | ||
|
|
5fdd26b53f | ||
|
|
61896ea760 | ||
|
|
b43881c299 | ||
|
|
6046f4defc | ||
|
|
69ccb9f12b | ||
|
|
430f2f57e9 | ||
|
|
c3f0bbb41c | ||
|
|
7e481e6a9a | ||
|
|
627de1aebd | ||
|
|
194108336b | ||
|
|
eade612981 | ||
|
|
733163cc4c | ||
|
|
86a917ddd1 | ||
|
|
e8503aa0b9 | ||
|
|
01bf9e8406 | ||
|
|
0bdadf63b3 | ||
|
|
5b1c35bf06 | ||
|
|
c467acdfac | ||
|
|
22167a0a07 | ||
|
|
251647c7a2 | ||
|
|
80e9799579 | ||
|
|
95f49f34d0 | ||
|
|
b01b67f64c | ||
|
|
603fb5d2b8 | ||
|
|
22f7c347ab | ||
|
|
08229ed4f9 | ||
|
|
a942fd08f5 | ||
|
|
c96d534c26 | ||
|
|
789a9a9bb4 | ||
|
|
d2435a8026 | ||
|
|
36db436fa3 | ||
|
|
30d9978412 | ||
|
|
5db7f124ac | ||
|
|
c82ee055e7 | ||
|
|
cb1c1efc35 | ||
|
|
0037a4e83f | ||
|
|
c369b3c62a | ||
|
|
0934a12205 | ||
|
|
d19db5f86f | ||
|
|
5657ee6c90 | ||
|
|
41a71d6185 | ||
|
|
11592cd742 | ||
|
|
43d83d8855 | ||
|
|
d1cb628473 | ||
|
|
44fc802e8b | ||
|
|
bfa1734d23 | ||
|
|
66139dacac | ||
|
|
714c24445d | ||
|
|
79f55a02cb | ||
|
|
484fe22e9e | ||
|
|
119d8b1a81 | ||
|
|
953d1f0aed | ||
|
|
2e225a9452 | ||
|
|
960dc2cd48 | ||
|
|
345ac35649 | ||
|
|
802114c605 | ||
|
|
16bbd30209 | ||
|
|
0021e789bc | ||
|
|
41daebb629 | ||
|
|
b496e88557 | ||
|
|
7c0e10d058 | ||
|
|
1d72447096 | ||
|
|
01e93a642e | ||
|
|
696ae7c967 | ||
|
|
b28202f1cb | ||
|
|
601e15db5a | ||
|
|
f30b413b46 | ||
|
|
a9c4a81abe | ||
|
|
d619ed5798 | ||
|
|
e94a9bf68f | ||
|
|
257c12e727 | ||
|
|
8b3eaa70fb | ||
|
|
c96bb890b4 | ||
|
|
8192a1962a | ||
|
|
80df9c6aa4 | ||
|
|
8073089da4 | ||
|
|
23e7d4a8bb | ||
|
|
0e1e92df13 | ||
|
|
d13f0b9191 | ||
|
|
aa2bffbd00 | ||
|
|
a456d67528 | ||
|
|
95f074342c | ||
|
|
74016bf93e | ||
|
|
3f8bac582c | ||
|
|
6b57e58d63 | ||
|
|
19aa20537d | ||
|
|
cf31df35ec | ||
|
|
6d39ce7240 | ||
|
|
0f3c1b94d7 | ||
|
|
13cc6736e2 |
No files matched your search
@@ -0,0 +1,2 @@
|
||||
*.java diff=java
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
.classpath
|
||||
.project
|
||||
.settings/
|
||||
target/
|
||||
|
||||
.DS_Store
|
||||
|
||||
**/*.iml
|
||||
**/.idea
|
||||
|
||||
bin/
|
||||
dependency-reduced-pom.xml
|
||||
*-private.sh
|
||||
|
||||
.gradle/
|
||||
**/build/
|
||||
out/
|
||||
@@ -0,0 +1,8 @@
|
||||
language: java
|
||||
dist: trusty
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
notifications:
|
||||
email: false
|
||||
before_install: chmod +x gradlew
|
||||
script: ./gradlew build -S
|
||||
+915
@@ -0,0 +1,915 @@
|
||||
# Changelog
|
||||
|
||||
## 7.0.1
|
||||
* Add `/rg toggle-bypass` command which temporarily turns off region bypassing until used again.
|
||||
* More improvements to `/rg flag` and `/rg flags` commands.
|
||||
* Fix some checks for adding owners to unclaimed regions.
|
||||
* Fix an issue with time-/weather-lock flags when logging in to a region with the flag set.
|
||||
* Fix cause tracking in vehicles (incl. breaking lilypads in a boat)
|
||||
* Use async teleports on Paper.
|
||||
* Include hopper minecarts in the ignore hoppers config setting.
|
||||
* Add sugar cane and cacti to the crop-growth flag. Bamboo is also included pending Spigot throwing an event for it.
|
||||
* Specifically track when players ignite creepers with flint and steel.
|
||||
* Fix fuzziness when using bonemeal near a protected region.
|
||||
* Fix color codes not applying in greeting, etc flags when placed after a newline (\n).
|
||||
* Add applicable region information to `/wg report`.
|
||||
* Fix pistons flag not applying to sticky pistons pulling blocks.
|
||||
* Add some custom metrics for bStats.
|
||||
* Everything in the RC/beta changelog below.
|
||||
|
||||
## 7.0.1 RC 2 (inc. beta 1)
|
||||
* Due to breaking changes in important Bukkit API, this is not compatible with MC 1.13!
|
||||
* Update to MC 1.14. Adds protection for new blocks, etc.
|
||||
* To allow players to read from lecterns, but not take the book, flag interact allow, and then flag chest-access -g nonmembers deny.
|
||||
* Add ravager-grief flag.
|
||||
* Fix overprotection of unsaddled pigs with the ride flag.
|
||||
* Fix lava fire defaulting to off (won't change existing configs).
|
||||
* Fix damaged/chipped anvils not respecting use flag like regular anvils.
|
||||
* Add on-equip blacklist event. Note that it is overprotective due to deficiencies in Bukkit API.
|
||||
* Update WorldEdit CUI when using /rg select.
|
||||
* Add config option to disable villagers getting zapped into witches. ("weather.disable-villager-witchification")
|
||||
* Add entity support to interact-whitelist config option (use the Material of the corresponding item).
|
||||
* Fix vehicle-place protecting the rails at the very top of region boundaries incorrectly.
|
||||
* Fix for emptying buckets on waterloggable blocks.
|
||||
* Whitelist all player -> player interactions (previously was spammy in pvp).
|
||||
* Fix sleep flag not protecting against explosions in nether/end.
|
||||
* Add config for the teleport-on-void to reset fall distance.
|
||||
* Fix config options taking material lists requiring "minecraft:" namespace.
|
||||
* Fix disallowed-lightning-blocks situationally not working.
|
||||
* Fix errors that occurred when plugins used falling block entities with non-item materials.
|
||||
* Add special support for Paper servers (papermc.io): Paper's API allows us to track who launched fireworks.
|
||||
* Fireworks are now protected by default. On Paper servers, members can use them by default (to deal damage),
|
||||
on non-Paper servers, flag firework-damage allow to revert to old behavior (everyone can deal damage with fireworks by default).
|
||||
* Misc performance enhancements for Paper servers.
|
||||
* Add 'regions.use-paper-entity-origin' as an experimental setting (default off) for Paper servers. Enabling it will make non-player entities be treated as members of the place they spawned, instead of their current location when flags are checked.
|
||||
|
||||
## 7.0.0
|
||||
* Added support for MC 1.13, dropped support for previous versions.
|
||||
* Added lots of interactive text in e.g. `/rg info` command.
|
||||
* Added `/rg flags` command which allows viewing and interactively setting all flags on a region.
|
||||
* Large behind-the-scenes changes to WorldGuard's API (developers, see https://worldguard.enginehub.org/en/latest/developer/)
|
||||
* Places that used numeric block ids (e.g. blacklist) should now use Minecraft's new string IDs.
|
||||
* Fix various interactions with NPCs and region protection.
|
||||
* Sponge-simulation now destroys kelp and seagrass, and de-waterlogs blocks.
|
||||
* Added an option to block conduit effects.
|
||||
* Fix using newlines in string flags such as greeting and farewell.
|
||||
* Add item-frame-rotation flag.
|
||||
* Ender chests no longer require chest-access (since they don't have inventories).
|
||||
* Add kelp to vine-growth flag/config.
|
||||
* Add block-trampling flag (for turtle eggs and farmland).
|
||||
* Add snowman-trails flag.
|
||||
* Track potion area-of-effect cloud causes for pvp etc. protection.
|
||||
* Add confirmation to /stoplag command.
|
||||
* Forcefully eject players from vehicles trying to force their way into entry deny regions (and out of exit deny).
|
||||
* Fix removing child regions when removing a region with children.
|
||||
* Fix some over-protectiveness of pistons.
|
||||
* Chat and command flags (send-/receive- and allowed-/blocked-) now respect deny-message flag.
|
||||
* Misc fixes.
|
||||
|
||||
## 6.2.2
|
||||
* Added support for MC 1.12.
|
||||
* Changed flower pots to fall under the build flag.
|
||||
* Fix heal flag not functioning.
|
||||
* Add option to allow Forge clients with host-keys setting.
|
||||
* Add mobs.block-armor-stand-destroy config.
|
||||
* Add firework-damage flag.
|
||||
* Add config option to ignore hopper checks.
|
||||
* Misc fixes.
|
||||
|
||||
## 6.2
|
||||
* Added support for MC 1.11.
|
||||
* Add a custom flag and session API (for developers, see https://worldguard.enginehub.org/en/latest/developer/)
|
||||
* Add a config option to ensure location flags (teleport, spawn) are inside their region.
|
||||
* Misc fixes.
|
||||
|
||||
## 6.1.2
|
||||
* Added support for new blocks in 1.8, 1.9, and 1.10.
|
||||
* Added protection from nether portals being created in protected region (enable via config `nether-portal-protection`).
|
||||
* Added protection from slime block piston contraptions pushing into or pulling from regions.
|
||||
* Added `chorus-fruit-teleport` flag, works similar to `enderpearl` to prevent teleportation.
|
||||
* Added protection from pulling armor stands, items, and entities from protected regions.
|
||||
* Changed order of greeting and farewell flags on adjacent regions. When leaving a region with a farewell flag and entering one with a greeting flag, the farewell message will be shown first now.
|
||||
* Changed /heal command to also fill food/saturation meters.
|
||||
* Changed fall damage prevention to also prevent flying into walls with elytra being fatal.
|
||||
* Fixed fire-spread flag only preventing destruction, now prevents spreading too as per its name.
|
||||
* Fixed creepers targeting players being able to blow things up in certain cases.
|
||||
* Fixed armor stands being removed by /stoplag.
|
||||
* Fixed some issues with fireballs being able to explode when ghast-fireball was set to deny.
|
||||
* Fixed a lot of other minor issues.
|
||||
|
||||
## 6.1
|
||||
|
||||
* Added `exit-via-teleport` flag (default allow) to control exiting an exit=deny region via teleportation.
|
||||
* Added a `fall-damage` flag to control player damage caused by falling.
|
||||
* Added a `time-lock` flag to lock players' time of day. Valid values are from 0 to 24000 for absolute time, or +- any number for relative time.
|
||||
* Added a `weather-lock` flag to lock players' weather. Valid values are "clear" or "downfall". Unset to restore to normal world weather.
|
||||
* Added `-s` to the event debugging commands to show a stack trace rather than attempt to detect the causing plugin.
|
||||
* Added support for using the `-e` argument (sets an empty value for the flag) in the flag set command when the type of flag is of the 'set' type.
|
||||
* Added NPCs from the Citizens plugin to a whitelist so they are not protected.
|
||||
* Added support for Spigot's BlockExplodeEvent.
|
||||
* Changed tripwire to fall under the `use` flag.
|
||||
* Changed enderchests to fall under the `use` flag.
|
||||
* Changed vehicles and animals so they are not included in the `interact` flag.
|
||||
* Changed the display of custom blacklist messages to no longer include a period at the end.
|
||||
* Changed protection logic to consider connected chests.
|
||||
* Changed the heal and feed flags to increase values for players who are invincible (or in creative mode) but not decrease them.
|
||||
* Changed PvP protection to consider both attacker and defender locations.
|
||||
* Fixed missing protection data for some 1.8-added blocks.
|
||||
* Fixed compatibility issues with MC 1.7.
|
||||
* Fixed inverted daylight detectors not being protected.
|
||||
* Fixed spawn eggs not being included in protection.
|
||||
* Fixed piston blocking not working due to a bug in Spigot.
|
||||
* Fixed the blocking of certain invalid entity damage events.
|
||||
* Fixed creeper explosions not being blocked in certain situations with explosion related flags set.
|
||||
* Fixed "stickiness" with some position-related flags, sometimes resulting in rubber banding in the exit flags.
|
||||
* Fixed armor stands so that they are treated more like item frames than mobs.
|
||||
* Fixed blocks (e.g. sugar canes) adjacent to physics blocks (e.g. sand) not updating.
|
||||
* Fixed a NullPointerException that occurred sometimes when generating the scheduler section of the report function (`/wg report`).
|
||||
* Fixed the "no XP drops" configuration not functioning following a previous release.
|
||||
* Fixed changes to region ownership sometimes not triggering a region database save.
|
||||
* Fixed bucket protection displaying the "deny effect" even if bucket use was not prevented.
|
||||
* Fixed CommandFilter matching emoticons and other unwanted characters.
|
||||
* Fixed an exception occurring sometimes during game mode changes.
|
||||
* Fixed primed TNT being checked twice for TNT flags.
|
||||
|
||||
## 6.0 beta 5
|
||||
|
||||
MC 1.7.9, 1.7.10 and 1.8 (Spigot only) are supported.
|
||||
|
||||
* Added a feature to detect when another plugin (incorrectly) includes WorldGuard's files, causing errors.
|
||||
* Added a new `exit-override` flag that can be used on an entry=allow region that players can walk into from an entry=deny region.
|
||||
* Added a new `entry-deny-message` to change the "entry denied" message.
|
||||
* Added a new `exit-deny-message` to change the "exit denied" message.
|
||||
* Changed entry/exit blocking to disembark players from their vehicles.
|
||||
* Changed the PvP flag to no longer apply to self-attack.
|
||||
* Fixed [#3220](http://youtrack.sk89q.com/issue/WORLDGUARD-3220): Polygon regions sharing points
|
||||
* Fixed [#3216](http://youtrack.sk89q.com/issue/WORLDGUARD-3216): Polygon regions 'disappearing' or not working correctly
|
||||
* Fixed [#3315](http://youtrack.sk89q.com/issue/WORLDGUARD-3315): Invincibility flag and mode not blocking knockback from snowballs, etc.
|
||||
* Fixed [#3314](http://youtrack.sk89q.com/issue/WORLDGUARD-3314): Protection bypassable by getting a skeleton or creeper to target a player
|
||||
* Fixed [#3326](http://youtrack.sk89q.com/issue/WORLDGUARD-3326): Enderchests cannot be protected with the use flag
|
||||
* Fixed [#3327](http://youtrack.sk89q.com/issue/WORLDGUARD-3327): Fake players from some Forge mods are not being detected properly
|
||||
* Fixed [#3328](http://youtrack.sk89q.com/issue/WORLDGUARD-3328): TypeToken error with CraftBukkit 1.7 in `/wg report`
|
||||
* Fixed [#3086](http://youtrack.sk89q.com/issue/WORLDGUARD-3086): Region entry / exit messages overlap between seprate worlds
|
||||
* Fixed [#2542](http://youtrack.sk89q.com/issue/WORLDGUARD-2542): Exit deny regions don't handle respawn / logout consistently
|
||||
* Fixed [#2731](http://youtrack.sk89q.com/issue/WORLDGUARD-2731): Greeting / farewell messages don't understand region inheritance
|
||||
* Fixed [#3308](http://youtrack.sk89q.com/issue/WORLDGUARD-3308): Enderchest interaction block not functioning with blacklist.txt
|
||||
* Fixed [#3312](http://youtrack.sk89q.com/issue/WORLDGUARD-3312): PVP flag blocking enderpearl teleport fall damage
|
||||
* Fixed [#3309](http://youtrack.sk89q.com/issue/WORLDGUARD-3309): Inventory view commands being blocked in protected regions
|
||||
* Fixed [#3310](http://youtrack.sk89q.com/issue/WORLDGUARD-3310): USE flag is not allowing workbench usage
|
||||
* Fixed [#3330](http://youtrack.sk89q.com/issue/WORLDGUARD-3330): Build permissions preventing block placement
|
||||
* API: Added `BukkitUtil.toRegion(Chunk)`
|
||||
|
||||
## 6.0 beta 4
|
||||
|
||||
MC 1.7.9, 1.7.10 and 1.8 (Spigot only) are supported.
|
||||
|
||||
* Added better support for MC 1.8 blocks (regarding the use flag, etc.).
|
||||
* Added an an experimental "lite" version of WarmRoast to CPU profile your server (try it: `/wg profile -p`)
|
||||
* Added permissions for individual flag values (i.e. `worldguard.region.flag.flags.use.allow`).
|
||||
* Added support for slightly older versions of Bukkit 1.7.9.
|
||||
* Improved `/wg report`'s output (try it: `/wg report -p`)
|
||||
* Fixed armor stands not being protected properly.
|
||||
* Fixed lack of wood plate support with the `USE` flag.
|
||||
* Fixed left click also being blocked when only right click needed to be blocked.
|
||||
* Fixed items and paintings/item frames not decaying under some versions of Spigot.
|
||||
* Fixed parent-child inheritance so the child will always inherit the parent.
|
||||
* Fixed inheritance issues with a flag is set with a region group on a parent region.
|
||||
* Fixed high CPU usage when Citizens is also installed.
|
||||
* Fixed `on-acquire` in the blacklist so it also handles item transfers between inventories.
|
||||
* Fixed the blacklist not supporting color codes.
|
||||
* Changed the PvP flag so it applies to self-attack like in WG 5 (this change *may* be reverted).
|
||||
|
||||
## 6.0 beta 3
|
||||
|
||||
MC 1.7.10 and 1.8 (Spigot only) are supported.
|
||||
|
||||
* Support both MC 1.7.10 and 1.8.
|
||||
* Don't apply the region override permission to PvP.
|
||||
* Fix incorrect detection of hostile and ambient creatures when protecting against PvE.
|
||||
* Fix the splash potion flag not working with the other flags.
|
||||
* Fix potion blocking.
|
||||
* Fix inability to blacklist the enchantment table and the workbench.
|
||||
* Make PASSTHROUGH=DENY useful on ``__global__``.
|
||||
* Fix issues (pistons broken, etc.) caused by adding members to ``__global__``.
|
||||
* Make the EXP_DROPS flag a build-compat flag and set its deny message.
|
||||
* Give the player back his/her XP bottle if it was blocked.
|
||||
* Expand the interaction whitelist configuration to "physical" events.
|
||||
* Catch command prefixes in the command flags.
|
||||
* Add a RIDE flag for vehicles.
|
||||
* Check for names in addition to UUIDs with /rg list.
|
||||
* Whitelist hoppers and let them cross regions regardless of region protection.
|
||||
* Revert USE flag's functionality to 5.x, add new INTERACT flag.
|
||||
* Fix spawn egg blocking.
|
||||
* Fix failed detection of incorrect blacklist block and item names.
|
||||
* Fix command prefix bypass with the op command blocking configuration.
|
||||
* Rewrite and update report generation (wg report).
|
||||
* Add event cancellation debug commands.
|
||||
* Fix location flags causing NullPointerExceptions.
|
||||
* Show more details in error log which world the error belongs to.
|
||||
* Add missing color codes when parsing input.
|
||||
* Let players use NPCs always.
|
||||
* Fix [WorldGuard] in log messages stacking on reloads.
|
||||
* Better handle empty group / player names due to bad region data.
|
||||
* Fix players being invincible with BUILD=deny.
|
||||
* Fix certain entities not being damaged in protected regions.
|
||||
* Improve entity detection in Entities utility class, add Entities.isNonPlayerCreature().
|
||||
* Add missing SQL table prefix in statement selecting world names.
|
||||
|
||||
## 6.0 beta 2
|
||||
|
||||
* Added an `-e` parameter to `/rg flag` that sets the flag to an empty value. You can use this to, for example, make it so the `deny-message` flag is empty, meaning that players won't get a message at all.
|
||||
* Added a visual smoke effect when an action on a block has been denied.
|
||||
* Added `event-handling.interaction-whitelist`, a list of items or blocks that should never be protected. For example, adding `wooden_door` to the list would make it so that doors could be used by anyone regardless if they have permission or not. You may still protect the blocks via other means.
|
||||
* Added `event-handling.emit-block-use-at-feet`, a list of items that, when used, will also be considered as the player using that item on the block at the player's feet. The purpose of this setting is, for example, to allow you to (sort of) prevent the use of a mod-added item that does not emit events.
|
||||
* Added `-s` to silently turn toggle `/stoplag` and `-i` to show the current state of the setting. (Thanks, [stuntguy3000](https://github.com/stuntguy3000)).
|
||||
* Added support for Bukkit [Material](http://jd.bukkit.org/rb/apidocs/org/bukkit/Material.html) names in the blacklist.
|
||||
* Fixed [#3167](http://youtrack.sk89q.com/issue/WORLDGUARD-3167): Saplings can be used without permission although it won't place blocks inside the region
|
||||
* Fixed [#3168](http://youtrack.sk89q.com/issue/WORLDGUARD-3168): Grown saplings that are partially prevented from placing all of its leaves may not remove the sapling
|
||||
* Fixed [#3169](http://youtrack.sk89q.com/issue/WORLDGUARD-3169): Bonemeal usage falls under the USE flag when it should really fall under building
|
||||
* Fixed [#3174](http://youtrack.sk89q.com/issue/WORLDGUARD-3174): Boat placement is not properly prevented in a protected region
|
||||
* Fixed [#3130](http://youtrack.sk89q.com/issue/WORLDGUARD-3130): Polygonal selections allow unlimited claim volumes with /rg claim
|
||||
* Fixed [#3137](http://youtrack.sk89q.com/issue/WORLDGUARD-3137): Claiming infinite regions is possible due to integer overflow
|
||||
* Fixed [#3171](http://youtrack.sk89q.com/issue/WORLDGUARD-3171): Can't pickup XP in protected regions without permission
|
||||
* Fixed [#3170](http://youtrack.sk89q.com/issue/WORLDGUARD-3170): Boats without a driver can be used to break lily pads
|
||||
* Fixed [#3172](http://youtrack.sk89q.com/issue/WORLDGUARD-3172): Players cannot be damaged by mobs in protected regions unless they have permission
|
||||
* Fixed [#3152](http://youtrack.sk89q.com/issue/WORLDGUARD-3152): BUILD overrides all other flags, unlike in WG 5
|
||||
* Fixed [#3154](http://youtrack.sk89q.com/issue/WORLDGUARD-3154): notify-enterflag doesn't work with horses and other vehicles
|
||||
* Fixed [#3166](http://youtrack.sk89q.com/issue/WORLDGUARD-3166): Trees do not grow naturally within protected regions
|
||||
|
||||
## 6.0 beta 1
|
||||
|
||||
### UUID support
|
||||
|
||||
Regions now fully support the use of UUIDs rather than names for storing the owners and members of a region. Commands still accept names, but they are translated into UUIDs in the background. For users who already have existing region data, names will be automatically converted to UUIDs on the first run of WorldGuard.
|
||||
|
||||
It is still possible to specify names rather than a UUID by using the `-n` flag with the region membership commands.
|
||||
|
||||
### 'Deny by default'
|
||||
|
||||
Previously, a pre-determined list of blocks and entities was used to determine whether an action by the player should be blocked. However, this has been reversed so that every action on a block or entity is denied (in a protected region) unless it has been deemed safe (such as, for example, right clicking with steak). Mods are now supported as a result.
|
||||
|
||||
The `USE` flag has been repurposed as a general "interaction" flag and covers every left click or right click of a block or entity. It also covers interaction that falls outside clicking.
|
||||
|
||||
### Exhaustive protection
|
||||
|
||||
More events are now handled in the protection code. For example,
|
||||
|
||||
* It is no longer possible to drop sand or gravel into a protected region from outside.
|
||||
* It is no longer possible to grief a region by growing a tree into it.
|
||||
* The entry and exit flags now handle players sitting on vehicles properly.
|
||||
* Piston-moved blocks cannot be pushed into a different protected region.
|
||||
* Owners of tamable animals are now considered in protection code.
|
||||
|
||||
Even water and lava flow can also be checked, although this requires that it be explicitly enabled in the configuration (flow events are very frequent, so they incur extra CPU cost).
|
||||
|
||||
The goal is to provide extremely exhaustive protection.
|
||||
|
||||
### Large performance boost for spatial queries
|
||||
|
||||
The performance of spatial queries for regions has been substantially increased at least an order of magnitude. Spatial queries are a necessity for the region code to query the list of regions that apply to a location in the world. There should be a negligible difference between 4, 40, and 4000 regions as long as too many regions are not overlapping.
|
||||
|
||||
### Background region operations
|
||||
|
||||
Region commands are now executed in the background. Notably, saves and loads will not lock up your server while they complete. Additionally, changes to regions are now saved periodically rather than immediately after every change.
|
||||
|
||||
### Updated MySQL region support
|
||||
|
||||
MySQL support has been completely overhauled. It should now be faster, no longer crash on foreign key index errors, use transactions, and support automatic creation and migration of tables (including support for table prefixes).
|
||||
|
||||
### Partial region data saving
|
||||
|
||||
For users of MySQL, WorldGuard now only saves changed and deleted regions when saving region data. No longer does WorldGuard have to rewrite the entire region database on each save.
|
||||
|
||||
### Improved handling of related flags
|
||||
|
||||
Multiple flags that apply to an event are now evaluated together if they are similar. For example, if a player right clicks a bed to sleep in it, both the `USE` and `SLEEP` flag are checked since they are both interaction-related. If one of them is `DENY`, then sleeping is denied (remember, `DENY` overrides `ALLOW`). If one of them is `ALLOW` and the other is not `DENY`, then sleeping is permitted.
|
||||
|
||||
Only one "category" of flags needs to evaluate to true to permit an action. `DENY` will not cross categories. For example, if `BUILD` is deny, it will not override `SLEEP`, so if `SLEEP` is set to `ALLOW`, sleeping will be permitted. This is fairly similar to how it worked on WorldGuard 5.
|
||||
|
||||
### Flag groups now work properly
|
||||
|
||||
While you could always set a group to a flag's value, the functionality was incomplete and did not work most of the time.
|
||||
|
||||
Now that groups are supported, you can change a flag so it only applies to a certain group of players. For example, `/rg flag example sleep deny -g members` would deny sleeping for only members of the `example` region.
|
||||
|
||||
### Inheritance now works as expected
|
||||
|
||||
Previously, a region only inherited flags and other details from its parents if the parent and the child overlapped at the location queried. This is no longer the case and inheritance is now always applied.
|
||||
|
||||
In addition, a new `-g` flag for `/rg define` lets you create a region with no physical area so that you can assign flags and use this region as a "template region."
|
||||
|
||||
### Settable deny message
|
||||
|
||||
It is now possible to change the message that users get when they are prevented from interacting with blocks or entities. This message is defined as a region flag, so you can set it on the `__global__` region or override it in a specific region. In addition, the tone and color of the default message has been softened, but you are free to change it entirely.
|
||||
|
||||
### Blacklist support for data values (and later, variants)
|
||||
|
||||
The blacklist was rewritten to support more than just block and item IDs. The immediate result is that you can now use data values, but as those are in the process of being deprecated by Mojang, it also allows support for Minecraft's new block variants in the future.
|
||||
|
||||
### Debounced events
|
||||
|
||||
Events that tend to reoccur very frequently (such as the ones that occur when you stand on a pressure plate continuously) have been "debounced" to reduce the number of checks that WorldGuard has to perform, reducing the amount of wasted CPU. In addition, the "you don't have permission" message is rate limited so players are not flooded with the message.
|
||||
|
||||
### New block place and break flags
|
||||
|
||||
A long requested feature was the availability of block place and break flags. These newly added flags work in tandem with the `BUILD` flag but can override `BUILD`. At the moment, it is not possible to allow explicit types of blocks to be placed or broken yet.
|
||||
|
||||
### Build permission nodes
|
||||
|
||||
A new optional (disabled by default in the configuration) feature is the checking of build permission nodes. For every block, entity, and item, the following permission nodes are checked:
|
||||
|
||||
* Block place: `worldguard.build.block.place.<material>`
|
||||
* Block break: `worldguard.build.block.remove.<material>`
|
||||
* Block interact: `worldguard.build.block.interact.<material>`
|
||||
* Entity spawn: `worldguard.build.entity.place.<type>`
|
||||
* Entity destroy: `worldguard.build.entity.remove.<type>`
|
||||
* Entity interact: `worldguard.build.entity.interact.<type>`
|
||||
* Entity damage: `worldguard.build.entity.damage.<type>`
|
||||
* Item use: `worldguard.build.item.use.<material>`
|
||||
|
||||
In addition, the permissions are also checked in the style of `worldguard.build.block.<material>.<action>`, so `worldguard.build.block.<material>.place` would work too.
|
||||
|
||||
The list of usable material names comes from the [Material enumeration in Bukkit](http://jd.bukkit.org/rb/apidocs/org/bukkit/Material.html). For example, the permission for placing the bed block would be `worldguard.build.build.place.bed_block`. Be aware that _Material_ contains both item and block names.
|
||||
|
||||
For entity names, see [EntityType](http://jd.bukkit.org/rb/apidocs/org/bukkit/entity/EntityType.html).
|
||||
|
||||
### Other changes
|
||||
|
||||
* Added a setting to permit "fake players" to bypass protection. Fake players are used by some servers and some mods to allow events to be thrown for mod blocks. WorldGuard considers a player to be a fake player if the name starts with `[` and ends with `]`.
|
||||
* Added a check so players can no longer disembark in a region from their tamed animal if they don't have permission to get back on.
|
||||
* Added an item pickup flag to go along with the item drop flag.
|
||||
* Added a new `//running` command was added to show currently running background tasks.
|
||||
* Added a blacklist `on-dispense` event.
|
||||
* Added more detailed error messages when parsing the YAML regions file.
|
||||
* Added the `-Dworldguard.debug.listener=true` option that can be set on your server's command line to see how WorldGuard processes events, although this will result in a lot of log messages.
|
||||
* Added log messages that occur on player join when a player had auto-god mode or auto-amphibious mode.
|
||||
* Fixed the heal command so that it now sets a player's health to the maximum rather than 20.
|
||||
* Fixed `ProtectedCuboidRegion.getPoints()` returning points in wrong order.
|
||||
* Fixed the obsidian generator disable option to also apply to tripwire.
|
||||
* Fixed an error with the blocked commands flag.
|
||||
* Fixed a connection leak with the MySQL region code.
|
||||
* Fixed `/wg reload` sometimes not applying new changes right away.
|
||||
* Changed the region removal command so that child regions are no longer removed without warning when removing the parent region.
|
||||
* Changed the YAML region data save code to first write the data to a temporary file before replacing the final file.
|
||||
* Changed how region data is handled when region support is disabled: it is no longer loaded.
|
||||
* Changed sponges to now be disabled by default. However, if you had previously installed WorldGuard, sponges will still be enabled. Sponges are being added in Minecraft and they work differently than in Minecraft Classic (which WorldGuard emulates). In addition, enabling sponge support in WorldGuard incurs extra CPU cost even if no sponges exist in the world.
|
||||
* Changed how region data is loaded and saved so failures are now more graceful. If the region data fails to load for a world, then the entire world will be protected by default. In addition, periodic attempts will be made to load the region data in the background.
|
||||
* Changed the `FEED` flag to maximize the player's saturation level if the hunger level is raised.
|
||||
* Changed the `wg-invincible` and `wg-amphibious` groups feature so that it now must be enabled in the configuration.
|
||||
* Removed the ability for WorldGuard to upgrade from a version for Minecraft Alpha.
|
||||
|
||||
### API changes
|
||||
|
||||
* You can use a new `WorldGuardPlugin.createProtectionQuery()` method to easily check build permissions.
|
||||
* The listener classes were moved. Consider them internal -- if you want to make use of the listener somehow, please put in a ticket in our issue tracker.
|
||||
* Much of the protection-related handling was previously scattered throughout the code. Now WorldGuard funnels events into an internal event system and then processes protection queries in a more consistent matter. These events are for internal use so it is strongly recommended that you do not use them (they may change without notice drastically). A lot of the protection-related flag handling was moved there.
|
||||
* A significant portion of classes under the package of `com.sk89q.worldguard.protection` were changed or removed. However, the basic calls (testing the value of a flag, etc.) should still work, but they may be deprecated. Some of the utility `Domain`-related classes were removed.
|
||||
* The old region database (load/save) API was removed and replaced with a new one. The new one no longer needs to pointless store a collection of regions on itself -- it has `collection = load()` and `save(collection)` methods.
|
||||
* Previously, there were subclasses of `RegionManager` that implemented different spatial indices. However, now `RegionManager` is a final class and the spatial indices are separate (see the `RegionIndex` interface).
|
||||
* A hash table was implemented that caches a list of regions within each loaded chunk. This increases performance of spatial queries substantially.
|
||||
* A cache of recent spatial queries now exists (a cache of `ApplicableRegionSets`), but you need to make use of `RegionQuery` to make use of this cache. However, if you need to do a spatial query to modify region data, then the old method is better (get a `RegionManager`, etc.).
|
||||
* `ApplicableRegionSet` was converted into an interface. In addition, there are now "virtual" `ApplicableRegionSet` instances that are returned by `RegionQuery` for certain special cases (such as, for example, region support being disabled by the user or region data being unavailable for a world due to an error). A new `isVirtual()` method is available. This is not an issue if you are getting `ApplicableRegionSet` instances from a `RegionManager`.
|
||||
* `ApplicableRegionSet` now can accept a pre-sorted collection and its use of a `TreeSet` was removed for performance reasons.
|
||||
* `FileNotFoundException` is now properly handled in the YAML region file class. It creates the new file and continues on.
|
||||
* Player names are deprecated by Mojang and so they need to be converted into UUIDs. As this will take some time, you should do this conversion in a background task. To check whether a region contains a player, it recommended that `contains(LocalPlayer)` be used because it's possible that the user may be still using names. A new `WorldGuardPlugin.wrapOfflinePlayer()` method was added for this specific purposes.
|
||||
* All flags now use `RegionGroup.ALL` as the default region group.
|
||||
* `StateFlag.getDefault()` now returns a `State` rather than a `boolean`.
|
||||
* The priority R-tree index now uses the R-tree for region intersection queries. Previously, it was only used for single point containment queries.
|
||||
* Regions now keep a "dirty" flag and changes it whenever data within the region is changed. When WorldGuard decides to periodically save region data, it may only save changed regions. Calling `save()` on the `RegionManager` is no longer needed as periodical saves happen automatically.
|
||||
* The old region data migration API was removed in favor of region store drivers. There is no longer a need to have an implementation for every possible conversion (i.e. YAML -> MySQL, MySQL -> YAML, etc.).
|
||||
* `ProtectedRegion.copyFrom()` was added to copy region settings from another region.
|
||||
* `@Nullable` annotations were added throughout the code. If you use IntelliJ IDEA, you may notice that it now warns you when a return value may be `null`.
|
||||
|
||||
## 5.9
|
||||
|
||||
* Added a config option to allow explosion flags to only prevent block damage
|
||||
* Added allow-tamed-spawns setting, on by default. This will stop WorldGuard from culling tamed animals.
|
||||
* Added config option and flag to prevent soil from drying naturally.
|
||||
* Added formatting codes, &k/l/m/n/o and &x (reset).
|
||||
* Added snow-fall-blocks option to config to restrict snow fall to certain blocks
|
||||
* Allow players to add newlines (\n) via command, not just manually in yml.
|
||||
* Allow the console to load/save all region managers with one command.
|
||||
* Changed entity report format slightly.
|
||||
* Check bypass perms for item-drop flag.
|
||||
* Check for entities and projectiles removing items from frames too.
|
||||
* Fix being able to use bonemeal to turn tall grass into double plants.
|
||||
* Fix number of arguments for migratedb command.
|
||||
* Fixed addowner/addmember commands adding command artifacts. Specifically, "-w <world>" will no longer be added when using it.
|
||||
* Fixed milking cows in protected areas due to changes in Bukkit.
|
||||
* Fixed ProtectedCuboidRegion::getPoints() returning points in wrong order.
|
||||
* Fixed snowman trails being treated as snow fall.
|
||||
* Make /rg list default to own regions if the player doesn't have permission otherwise.
|
||||
* Protected items in item frames in protected regions.
|
||||
* Resolved an issue where explosions of type OTHER_EXPLOSION were ignoring the world configuration settings.
|
||||
* Send item-use blacklist event when right-clicking entities.
|
||||
* Transformed the BlockFadeEvent handler into a switch.
|
||||
|
||||
## 5.8
|
||||
|
||||
* BREAKING CHANGE: This version has been built for versions of Bukkit for MC 1.6.1 and newer. Do not try to use this version of WG on an older Bukkit version.
|
||||
* Added support for Minecraft 1.6+. Actual support of new 1.6 additions is dependant on Bukkit. Please use a newer build of Bukkit if, for example, you seem to be unable to add "Horses" to your lists of entities.
|
||||
* Added mobs.disable-snowman-trails to disable the trails left by walking snowmen.
|
||||
* Added -a flag to /region removeowner and /region removemember to remove all objects.
|
||||
* Teleporting is now handled by entry/exit flags. If this is causing people to get entirely stuck inside entry/exit deny regions, set the new setting 'use-player-teleports' to 'false' in your configuration.
|
||||
* Updated formatting for region commands, especially /region info.
|
||||
* Changed permissions checking for /region commands to be more consistent, checking for region IDs as a sub-node. This means that if some permissions for some region commands no longer work, add '.*' to the end of permission lines for WG in your permission plugin.
|
||||
|
||||
## 5.7.5
|
||||
|
||||
* Refixed a few issues from 5.7.4.
|
||||
|
||||
## 5.7.4
|
||||
|
||||
* BREAKING CHANGE: Removed the cyan "**" in front of greeting and farewell messages to allow more customizability. You can re-add them by adding "&c**" to the flag.
|
||||
* Fixed an issue enderpearling inside exit/entry deny regions.
|
||||
* Added checks to players teleporting in and out of exit/entry regions.
|
||||
* Fix bad matching in blocked and allowed command flags.
|
||||
* Fixed heal flag bugs when player max health was increased.
|
||||
* Add fishing to xp blocker.
|
||||
* Applied other-explosion flag to entity damage as well.
|
||||
* Fixed an issue with interaction that should allow blacklisting item use actions with no block involved (eg fishing rods, potions)
|
||||
* Fix witherskull/fireball settings not being differentiated in one case
|
||||
* Allow cow milking in no-build areas
|
||||
* Fix infinite durability breaking items instantly.
|
||||
|
||||
## 5.7.3
|
||||
|
||||
* Fixed the error caused by Bukkit's change of the TNT minecart API.
|
||||
|
||||
## 5.7.2
|
||||
|
||||
* Updated to MineCraft 1.5.
|
||||
* Added TNT Minecart support. They are handled with the same flags/settings as TNT.
|
||||
* Added mining and smelting xp handling to the xp drops flag and setting.
|
||||
* Fixed a few edge cases for placing items on region borders.
|
||||
* Legacy: Fixed issue with //stack not respecting item metadata.
|
||||
|
||||
## 5.7.1
|
||||
|
||||
* Added a vine growth config option and flag.
|
||||
* Added support for many commands to be used from console. Usage is with -w flag and a world name e.g. /rg addmem <id> <player> -w <worldname> /rg flag <id> <flag> -w <worldname> <flagvalue>
|
||||
* Fixed bug that blocks placing plants in flower pots.
|
||||
* Fixed permissions check for /rg tp
|
||||
* Fixed enderchests not being accessible (they are now part of the USE flag)
|
||||
* Fixed an issue with slabs being placable in protected regions. This was also fixed in CraftBukkit but has been left in for users running other versions.
|
||||
* Fixed wither skulls being handled with other fireballs, despite having their own settings.
|
||||
* Fixed item frames being placable on region borders.
|
||||
* Fixed a bug that made explosions more ineffective than they should have been.
|
||||
* Fixed bonemeal usage in protected regions.
|
||||
* Fixed special minecarts being placable in protected regions.
|
||||
* Fixed bugs being placable on region borders.
|
||||
* Fixed wolves bypassing pvp flags.
|
||||
|
||||
## 5.7
|
||||
|
||||
* Fixed thread sync issue with FlagStateManager.
|
||||
* Fixed dragon egg region protection not working in certain cases.
|
||||
* Added beacon and anvil usage protection in regions.
|
||||
* Add mobs.block-enderdragon-portal-creation to stop enderdragons from making portals on death.
|
||||
* Fix TNT being lethal in some case when damage was disabled.
|
||||
* Fix snowballs and enderpearls being able to knock players back in pvp deny regions.
|
||||
* Add subcommand support for allowed and blocked command flags.
|
||||
* Add max-players-allowed and max-players-reject-message flags to limit the numbers of players in a region.
|
||||
* Fix players being able to plant cocoa beans in protected areas.
|
||||
* Add an enderpearl flag to prevent players from teleporting to and from regions.
|
||||
* Added mobs.block-other-explosions config setting and other-explosion flag to block explosions caused by uncovered things, such as other plugins. (It doesn't actually have to be a mob)
|
||||
* Fix mob damage setting and flag not blocking the DoT wither effect.
|
||||
* Ghast fireball flag will not block blaze fireballs from lighting things on fire.
|
||||
* Fixed players without region permissions being able to trigger tripwires, use enderchests, use wooden buttons, and put plants in flower pots.
|
||||
* Added mobs.block-zombie-door-destruction setting to stop zombies from breaking down doors while difficulty is set to hard.
|
||||
|
||||
Thank you to thvortex, Dilandau, tophathacker, and Dark_arc for their contributions this release.
|
||||
|
||||
## 5.6.5
|
||||
|
||||
* Fixed a regression that caused paintings and item frames to no longer be properly protected.
|
||||
|
||||
## 5.6.4
|
||||
|
||||
* Added mobs.block-above-ground-slimes to block slimes spawning naturally above ground.
|
||||
* Added security.deop-everyone-on-join to de-op all players when they join.
|
||||
* Added security.block-in-game-op-command to prevent usage of /op from in-game.
|
||||
* Fixed a NullPointerException in PlayerInteract involving water potions and potion blocking.
|
||||
* Fixed an issue with snowballs being blocked in regions.
|
||||
* Changed dragon eggs to be checked like it is a broken block in regions.
|
||||
* Moved developer's WGBukkit class to package com.sk89q.worldguard.bukkit.
|
||||
|
||||
## 5.6.3
|
||||
|
||||
* Added helper WGBukkit class to get references to WorldGuard from other plugins.
|
||||
* Added physics.vine-like-rope-ladders to make ladders work like vines. As long as the top ladder block is present, ladder blocks will hold even if they have no block behind them, like a rope ladder.
|
||||
* Fixed NullPointerException in PlayerInteractEvent caused by potion blocking.
|
||||
* Fixed mobs.block-{item-frame,painting}-destroy not working.
|
||||
|
||||
Thank you to def for testing the above fixes and features.
|
||||
|
||||
## 5.6.2
|
||||
|
||||
* Fixed potion blocking not working well for splash potions.
|
||||
|
||||
## 5.6.1
|
||||
|
||||
* Added a mycelium-spread region flag.
|
||||
* Added a dynamics.disable-mycelium-spread configuration setting.
|
||||
* Added new gameplay.block-potions option. For example: gameplay: block-potions: [invisibility, speed]
|
||||
* Fixed a bug in the entity explosion event handler that caused a NullPointerException.
|
||||
|
||||
Thank you for gabizou for his contribution in this release.
|
||||
|
||||
## 5.6
|
||||
|
||||
* Added official support for Minecraft 1.4. Support for 1.3.2 (and below) is still provided in this release.
|
||||
* Added support for new and existing explosion types.
|
||||
* Added support for blocking withers with the following settings: mobs: block-wither-explosions: false block-wither-block-damage: false block-wither-skull-explosions: false block-wither-skull-block-damage: true
|
||||
* Added support for blocking item frames (and their use) in protected regions.
|
||||
* Added item frame destruction region flags (if you wish to disable item frame destruction completely).
|
||||
* (Re-)added support for priority R-tree region indexes. This means quicker region lookup, and better support for servers with thousands of regions.
|
||||
* Improved /region info output for -g group flags.
|
||||
* Allowed removing of -g group flags with /region flag.
|
||||
* Allowed /region flag to set group and value at once.
|
||||
* Deleting a region flag now also deletes group flag.
|
||||
* Fixed detection of attack by projectiles to be more accurate.
|
||||
* Fixed support for saving non-string flags in the MySQL region support.
|
||||
* Fixed spurious comma in "Flags:" /region info output.
|
||||
* Fixed players who are not in god mode not receiving damage in PVP areas from enderpearls.
|
||||
* Players will now be told that they are in a no-PvP area if they are in one and attempting to attack someone, or that the player they are attacking is in a no-PvP area, if that is the case instead.
|
||||
* Fixed an issue where region.getId() was lowercase'd each pass of a for loop in MySQLDatabase.updatePoly2dPoints().
|
||||
* Fixed mob damage from projectiles not being properly blocked in regions where applicable.
|
||||
* Changed default region wand to leather (#334).
|
||||
|
||||
Thank you to the following individuals for their contribution:
|
||||
thvortex, Rutr, Glitchfinder, and DarthAndroid.
|
||||
|
||||
## 5.5.4
|
||||
|
||||
* Minecraft 1.3 support.
|
||||
* Fixed /stack dupe bugs.
|
||||
* Added regions.use-creature-spawn-event.
|
||||
* Update for Async chat issue.
|
||||
* Add use flag to cakes.
|
||||
* Report number of plugins loaded in report writer.
|
||||
* Updated fireblal item blocking.
|
||||
* Fixed permissions for /region reload.
|
||||
|
||||
## 5.5.3
|
||||
|
||||
* Added game mode flag.
|
||||
* Added item drop pickup flag to regions.
|
||||
* Added support for fireball item blocking (385).
|
||||
* Added configuration option to allow creature spawns from plugins.
|
||||
* Added host key check.
|
||||
* Added a new line split feature to region greetings.
|
||||
* Prevented commands in the allow commands list from being blocked and vice versa.
|
||||
|
||||
## 5.5.2
|
||||
|
||||
* Added potion-splash flag to block splash potions
|
||||
* Add entity-painting-destroy which can be used to prevent entities from destroying paintings (skeletons firing arrows)
|
||||
* Added send-chat and receive-chat flags
|
||||
* Fixed having regions in multiple worlds with the same name not working with MySQL
|
||||
* A cancellable event is now fired if WorldGuard disallows PvP. (for developers!)
|
||||
* Made /region setparent check worldguard.region.setparent.own/member.<parent> instead of worldguard.region.setparent.own/member.<child>.
|
||||
* Allowed passing #<index> in place of a region ID, where <index> is the index as displayed by /region list.
|
||||
* Fixed an error that occured when clearing a non-existant region's parent.
|
||||
* Added a -s flag to /region teleport, which sends you to the spawn point instead of the teleport point of a region.
|
||||
* Added region/role-based permissions to /region teleport.
|
||||
* BREAKING CHANGE: Added a LocationFlag class and made the teleport and spawn flags use it.
|
||||
* /region info -s now selects the region being queried.
|
||||
* Added /region teleport <id>.
|
||||
* Vector flags can now be set to the current location with the value "here" and to a specific position with x,y,z.
|
||||
* Made /region info show the region you're in if you don't specify an id explicitly.
|
||||
* Prevent block ignition from lightning strikes if lightning is blocked in region. Fixes #1175
|
||||
* Correctly check both WEPIF and superperms in WorldGurdPlugin.broadcastNotification()
|
||||
* Destroy fire blocks when fire-spread is disallowed
|
||||
* Added a construct flag that can be used to restrict block placing/destroying in zones to certain roles.
|
||||
* Added FallingSand to list of intensive entities to be removed with /halt-activiy.
|
||||
* Replaced all usage of CreatureType by EntityType.
|
||||
* Updated to support Bukkit 1.2-R0.3 and newer
|
||||
* Made auto-god-mode disabled by default again.
|
||||
* Added sign protection check disable.
|
||||
* Cleaned up javadoc, deprecated duplicate methods, other cleanup
|
||||
* Added a RegionGroupFlag to evey region flag Using the /region flag command with -g, the region group that the region flag applies to can be set.
|
||||
|
||||
## 5.5.1
|
||||
|
||||
* Fixed attacking with arrows from non-PVP to PVP areas
|
||||
* Compatibility with Bukkit 1.1-R5
|
||||
* Removed broken suppress-tick-sync-warnings config option. See bukkit.yml's setings.warn-on-overload option instead.
|
||||
* Add region and 'can build' information to CommandBook's /whois
|
||||
|
||||
Contributions thanks to: NolanSyKinsley
|
||||
|
||||
## 5.5
|
||||
|
||||
* Removed WorldEdit.jar from the classpath to stop conflicts with Bukkit's plugin loader
|
||||
* Now using Bukkit's tagged logging
|
||||
* Updated to new event system
|
||||
* Flush player flag state cache on world change
|
||||
* Improved compatibility with versions of CommandBook without GodComponent and updated pom dep for 2.0
|
||||
* Added MySQL region storage method.
|
||||
* Made explosions display their animations even when the event was blocked.
|
||||
* Added fallback support for those who don't have a version of CommandBook with GodComponent
|
||||
* Added LIGHTNING flag to DefaultFlag's flagsList Fixes #1026
|
||||
* Removed /god, /heal, /locate, and /stack from WorldGuard to CommandBook. CommandBook is now checked to see whether a player is godded.
|
||||
* Removed remaining usages of org.bukkit.util.config.Configuration
|
||||
* Removed some unused configuration options
|
||||
* Added permission worldguard.region.wand to the region wand
|
||||
* Fixed ProtectedRegion.compareTo.
|
||||
* Fixed FlatRegionManager.getApplicableRegions to return parent regions as well.
|
||||
* Added exp-drops flag to disable experience drops per-region.
|
||||
* Fixed some warnings.
|
||||
* Updated dependency version for WorldGuard from 5.0 to 5.1-SNAPSHOT.
|
||||
* Added support for fireballs shot by players being blocked by the PVP flag.
|
||||
* Now using dynamic command registration
|
||||
* Split off ender dragon block damage from creeper block damage.
|
||||
|
||||
Contributions thanks to: narthollis, DarkArc, Wolvereness, and skeight
|
||||
|
||||
## 5.4
|
||||
|
||||
* Fixed configuration generation on Windows
|
||||
* Fixed intersection calculation for regions
|
||||
* Fixed timer and feeding delay for food flags
|
||||
* Fixed region managers not being created properly (This caused errors related to CREATURE_SPAWN)
|
||||
* Added support for Minecraft 1.0.1 blocks
|
||||
* Added support for enchantments and tool damage (worldguard.stack.damaged is the node) with /stack
|
||||
* Made being in the wg-invincible group respect the configuration's auto-invincible setting
|
||||
* Added per-group region claim limit maximum
|
||||
* Added worldguard.region.addowner.unclaimed.* permission for non-economy region 'buying'
|
||||
* Checking allowed/blocked commands now occurs earlier to override more plugins
|
||||
* Made PVP flag check whether either player is in a pvp deny region for blocking
|
||||
|
||||
Contributions thanks to: epuidokas, wizjany, Turtle9598, and DerFlash
|
||||
|
||||
## 5.3
|
||||
|
||||
* Added new config options and flags to better handle explosions of all types
|
||||
* Added config options and flags for snow, ice, mushroom spread, grass spread, and leaf decay
|
||||
* Added min and max health flags to clamp the values for the existing healing flags
|
||||
* Added hunger flags similar to the existing healing flags
|
||||
* Added an option to disable the use of the move event. This can boost performance on large servers but will disable the greeting/farewell and entry/exit flags
|
||||
* Added flag to prevent pistons (including those that are outside the region, but would affect blocks inside the region)
|
||||
* Added a /wg flushstates [player] command to free players stuck in a region that was exit-deny but no longer exists or the flag was removed
|
||||
* Added a config option to disable xp orb dropping
|
||||
* Added config option to disable redstone wire obsidian generators
|
||||
* Added a vehicle-destroy flag
|
||||
* Added enderman protection config and flag
|
||||
* Allowed and blocked command flags will now fall back to the global region
|
||||
* The worldguard.region.flag.own/member permissions are now worldguard.region.flag.regions.own/member! Please change your permissions accordingly.
|
||||
* Made //stack respect max stack sizes unless the player has the worldguard.stack.illegitimate permission
|
||||
* Setting invincibility flag to deny will override god mode unless the player has worldguard.god.override-regions
|
||||
* The sleep flag will now prevent beds in the nether from exploding if set to deny
|
||||
* Existing regions can no longer be accidentally overwritten. Use /region redefine to move an existing region.
|
||||
* The info command will now sort players alphabetically
|
||||
* Priming TNT by punching it with flint and steal should throw a blacklist event (consistent with old Minecraft versions)
|
||||
* The /stoplag command will now remove xp orbs
|
||||
* Permissions system will use per-world permissions if the provider supports it
|
||||
* Players in vehicles are now subject to entry/exit and greeting/farewell flags
|
||||
* Fixed interact blacklist event not logging correctly
|
||||
* Fixed heal flag taking effect half a block northeast of the region
|
||||
* Fixed a infinite sign dropping bug
|
||||
* Fixed players being able to douse fire by punching it in regions they couldn't build it
|
||||
* Fixed players being able to eat protected cake
|
||||
* Fence gate usage can be blocked with the use flag
|
||||
* Fixed chests being unprotected when they should be in 1.8
|
||||
* Fixed weather config settings not applying when a world was loaded
|
||||
* Fixed explosion handling in certain cases
|
||||
* Fixed arrows working in non-pvp zones
|
||||
* Fixed buckets working on the border of protected regions in certain cases
|
||||
Contributions thanks to:
|
||||
wizjany, zml2008, imjake9, Droolio, epuidokas,
|
||||
EduardBaer, TomyLobo, and halvors
|
||||
|
||||
## 5.2.2
|
||||
|
||||
* Changed configuration saving so empty lists will be added to the configuration files.
|
||||
|
||||
## 5.2.1
|
||||
|
||||
* Add region bounds to /region info
|
||||
* Added the ability to add owners/members to the global region for handling guest groups. Now if there's owners or members on the global region, then those that are not on the list cannot build.
|
||||
* Fixed some flag algorithm issues.
|
||||
* API: Fixed DefaultDomain.size() not counting players.
|
||||
* API: Undeprecated ApplicableRegionSet.allows(StateFlag).
|
||||
|
||||
## 5.2
|
||||
|
||||
* Gave the ability to use color colors and macros in greeting and farewell messages.
|
||||
* Added disable-ice-melting, disable-snow-formation, disable-mushroom-spread, disable-snow-melting, disable-ice-formation.
|
||||
* Added paintings to blacklist support.
|
||||
* Added default.disable-health-regain.
|
||||
* Added auto-invincible-permission setting, which lets you use the permission 'worldguard.auto-invincible' to become invincible on join automatically.
|
||||
* Flames won't appear if you are /god'ed now.
|
||||
* Added blocked-cmds region flag to block commands.
|
||||
* Added allowed-cmds region flag to whitelist commands.
|
||||
* Added entry region flag to block entry. Use entry-group to determine who this affects.
|
||||
* Added exit region flag to block exit. Use exit-group to determine who this affects.
|
||||
* Made negative healing possible via the healing flag.
|
||||
* Changed the configuration header messages to be more helpful to new users.
|
||||
* Added a warning about modifying region files by hand.
|
||||
* Improved the API for plugin developers.
|
||||
|
||||
## 5.1
|
||||
|
||||
* A lot of changes.
|
||||
|
||||
## 4.0-alpha1
|
||||
|
||||
* This release is only to fix WorldGuard for Bukkit. Ignore the 4.0 label. Just move along. Nothing to see.
|
||||
|
||||
## 3.2.2
|
||||
|
||||
* Changed disable-water-damage to disable-drowning-damage.
|
||||
* Fixed suffocation disable option.
|
||||
* Fixed fire spread blocking.
|
||||
* stopfire and allowfire now work in server console, just like in hMod.
|
||||
|
||||
## 3.2.1
|
||||
|
||||
* Updated for recent Bukkit ItemStack change.
|
||||
|
||||
## 3.2
|
||||
|
||||
* Added regions.default.pvp to control default PvP setting.
|
||||
* Updated WorldGuard for the newer builds of Bukkit.
|
||||
* Fixed creeper explosion blocking.
|
||||
* Added redstone support to sponges, removed classic water.
|
||||
* Fixed item durability disable for hoes.
|
||||
|
||||
|
||||
## 3.1.2
|
||||
|
||||
* Increased the priority of WorldGuard's event handling.
|
||||
|
||||
## 3.1.1
|
||||
|
||||
* Fixed creeper and chest flag conflicting.
|
||||
|
||||
## 3.1
|
||||
|
||||
* Added ability to disable chest protection. New configuration setting (regions.build.chest-access) and new chest flag.
|
||||
* Possibly fixed projectile blocking in no-PvP zones.
|
||||
* Added /regionmembership permission that lets people only change the owners and members of regions they own.
|
||||
|
||||
## 3.0b2
|
||||
|
||||
* Fixed issue where built-in permissions were not (re)loaded.
|
||||
* Fixed /god not working for others.
|
||||
|
||||
## 3.0b1
|
||||
|
||||
* Added parent-child relationships to regions.
|
||||
* Added global build flag.
|
||||
* Improved flag support.
|
||||
* Fixed no-PvP zone messages being sent to the wrong person.
|
||||
* Fixed commands so that they work in a recent version of Bukkit.
|
||||
* Fixed NullPointerException in explode hook.
|
||||
|
||||
## 2.3.1
|
||||
|
||||
* Fixed various cast exceptions with the blacklist loggers.
|
||||
* Added checks for unchecked exceptions when resolving permissions.
|
||||
* Fixed the item durability disable setting changing the damage value on an empty hand.
|
||||
|
||||
## 2.3
|
||||
|
||||
* /god now works very well.
|
||||
* Item (TNT, flint and steel, etc.) blocking should now work.
|
||||
* The TNT blocking configuration variable should now work.
|
||||
* Re-added /heal (not sure where that went), added /slay.
|
||||
* Implemented contact damage disable toggle.
|
||||
* Made all player damage disabling configuration parameters work.
|
||||
* Fixed teleport-on-suffocation setting.
|
||||
* Added /locate <name>, /locate <x> <y> <z>, and /locate that lets you program/change your compass bearing to point to a player's position (not yet live), a position, or back to spawn.
|
||||
* Fixed CSVDatabase spitting an error if the owners list was empty.
|
||||
|
||||
## 2.2
|
||||
|
||||
* Now supports GroupUsers.
|
||||
* Added support for blocking creeper explosions.
|
||||
* Fixed a bug where a player's groups were not being loaded correctly, causing the blacklist group ignore option to not work.
|
||||
|
||||
## 2.1.1
|
||||
|
||||
* Fixed fire spread disable preventing flint and steel too.
|
||||
* Fixed NullPointerException related to the player item event.
|
||||
* Made setup simpler.
|
||||
|
||||
## 2.1
|
||||
|
||||
* Improved Bukkit support.
|
||||
|
||||
## 2.0beta3
|
||||
|
||||
* Fixed NullPointerException inside the ignite hook.
|
||||
|
||||
## 2.0beta2
|
||||
|
||||
* Fixed a NullPointerException in the damage hook.
|
||||
|
||||
## 2.0beta1
|
||||
|
||||
* Added area protection. Use /region or /rg to define regions.
|
||||
|
||||
## 1.8.1
|
||||
|
||||
* Fixed NullPointerException.
|
||||
|
||||
## 1.8
|
||||
|
||||
* Updated for Minecraft beta.
|
||||
* Blacklist hooks have CHANGED. The new hooks are work better. on-create has been replaced with on-place (for block placement) and on-use (for item usage, light buckets and lighters). The old on-use is now on-right-click although it currently does nothing.
|
||||
* Added coordinates to blacklist file logger.
|
||||
* Added suffocation damage prevention.
|
||||
|
||||
## 1.7.1
|
||||
|
||||
* Updated for v0.2.8.
|
||||
|
||||
## 1.7
|
||||
|
||||
* Updated for v0.2.6_02 and hMod b129.
|
||||
* Added option to prevent water from damaging particular blocks (Redstone wire, Minecart tracks, etc.). See disable-water-damage-blocks.
|
||||
* /reload WorldGuard should now reload WorldGuard's configuration.
|
||||
* Added wg-invincible and wg-amphibious groups that let you give certain players invincibility or underwater breathing.
|
||||
* Added the ability to disable fall, water, lava, and/or fire damage.
|
||||
* Water/lava bucket blocking should now be more reliable.
|
||||
* Added /stack (alias /;) commands to stack items in your inventory into piles up to 64 items in size. Even unstackable items like signs can be stacked.
|
||||
* /god mode should now let you gain health.
|
||||
* /god mode should now work more reliably.
|
||||
* Caught an error message for when the configuration file does not exist.
|
||||
|
||||
## 1.6
|
||||
|
||||
* Added spawn protection that prevents damage when a player spawns.
|
||||
* Added login protection that prevents damage when a player joins.
|
||||
* Added /god. /god can be used on others, provided that the /godother permission is set for the command's user.
|
||||
|
||||
## 1.5.1
|
||||
|
||||
* Removed the 'java.lang.NoSuchMethodError: Item.setDamage(I)V' error generated.
|
||||
|
||||
## 1.5
|
||||
|
||||
* Removed the block lag fix.
|
||||
* WorldGuard now conditionally loads features so you can use any up-to-date build of hMod and the unsupported features won't break the entire plugin. When WG loads, check the server console for a report of features that are not supported by your version of hMod.
|
||||
* Changed some configuration defaults: disable-lava-fire=true simulate-sponge=true item-durability=false
|
||||
|
||||
## 1.4.1
|
||||
|
||||
* Fixed issue with the block lag fix dropping item stacks of 0 quantity.
|
||||
|
||||
## 1.4
|
||||
|
||||
* New on-acquire hook. This does both a total inventory check on inventory change and item pick up denial. The item pick up denial is largely thanks to Dinnerbone for fulfilling my request to add a particular hook.
|
||||
* Item durability can now be toggled with item-durability. Thanks to Dinnerbone for figuring this out while filfilling my request. The default setting is to fix item durability.
|
||||
* New no-physics-gravel and no-physics-sand options allow you to prevent gravel and sand from falling.
|
||||
* New allow-portal-anywhere option allows you to create portal blocks anywhere.
|
||||
|
||||
## 1.3
|
||||
|
||||
* UPGRADE WARNING: If you are using database logging, you must add a NULL 'comment' VARCHAR field to the table. The line of SQL that you can run for MySQL can be found in blacklist_table.sql.
|
||||
* Improved plugin compatibility with the block lag fix. For maximum compatibility, you must now list WorldGuard as the first plugin in server.properties and you cannot reload or enable the plugin while the server is up. This is for bad plugins that unnecessarily use the "critical" priority for its hooks like the LWC. Most plugins don't do that though, so this won't apply for most people.
|
||||
* Fixed signs being blank if they were denied via the blacklist.
|
||||
* Added on-break event to the blacklist.
|
||||
* Added comments and messages. Comments are only for your own use and they are printed with the log and notify actions of the blacklist. The message replaces the message that is shown the user and it is optional.
|
||||
* The blacklist notification messages are now more compact and are light grey instead of light purple.
|
||||
* The notify, log, and tell actions will now trigger every time for the on-break, on-create, on-drop events rather than wait 3 seconds between events for the same item or block for a player.
|
||||
|
||||
## 1.2
|
||||
|
||||
* /stopfire and /allowfire disable and enable fire spreading globally.
|
||||
* Block lag fix slightly improved in accuracy for item drops.
|
||||
* Sponge updated to remove water when the sponge block is set. Sponge radius can now be controlled using the 'sponge-radius' parameter and the default is now set to simulate Classic.
|
||||
* Updated for a newer build of "b126," meaning that lava spread control now works well!
|
||||
* A new summary of the status of some core protections is now printed on start. Disable this with 'summary-on-start'.
|
||||
* Blacklist system has been overhauled. Check README.txt for changed configuration settings!
|
||||
* The blacklist's method of preventing notification repeats is now better, instead waiting 3 seconds before notifying again (before it didn't notify again at all unless the user started using another blocked action).
|
||||
* To give users the ability to receive notifications, the command to give permission to has been changed to /worldguardnotify, although the old one (that was never mentioned anywhere) still works.
|
||||
* Water and lava buckets are now psuedo-blocked using an unreliable method that risks the stability of your server (no other plugin does it better though). Use it as your own risk.
|
||||
* Added on item drop and on item use (i.e. chest) events.
|
||||
* Chests, signs, and furnaces can now be blocked better with the blacklist system.
|
||||
* The event names in the blacklist configuration have changed but the old event names should still work. The new names should make "more sense."
|
||||
* A new "ban" action has been added to the blacklist.
|
||||
* Action messages have been improved, now longer saying "destroyed" for everything.
|
||||
* Logging to file has been completely changed, allowing you to use the date and time and the player's username in the log filename. It no longer rotates log files based on size, however.
|
||||
* Logging to database is now supported.
|
||||
* Tools can now be destroyed on drop to alleviate the durability cheat. You can do this with either with the blacklist or with the 'item-drop-blacklist' configuration option. The configuration option prints more friendly messages than the 'tell' action of blacklists.
|
||||
|
||||
## 1.1.2
|
||||
|
||||
* Block lag fix: Snow and glass should no longer drop items.
|
||||
* Block lag fix: Block object now reset after hook call.
|
||||
|
||||
## 1.1.1
|
||||
|
||||
* Fixed redstone wire dropping wood blocks with the block lag fix.
|
||||
* The block lag fix now consults other plugins so that ALL protection mechanisms and plugins should work.
|
||||
|
||||
## 1.1
|
||||
|
||||
* Added block lag fix.
|
||||
|
||||
## 1.0
|
||||
|
||||
* Initial release.
|
||||
-110
@@ -1,110 +0,0 @@
|
||||
1.6
|
||||
- Added spawn protection that prevents damage when a player spawns.
|
||||
- Added login protection that prevents damage when a player joins.
|
||||
- Added /god. /god can be used on others, provided that the /godother
|
||||
permission is set for the command's user.
|
||||
|
||||
1.5.1
|
||||
- Removed the 'java.lang.NoSuchMethodError: Item.setDamage(I)V' error
|
||||
generated.
|
||||
|
||||
1.5
|
||||
- Removed the block lag fix.
|
||||
- WorldGuard now conditionally loads features so you can use any up-to-date
|
||||
build of hMod and the unsupported features won't break the entire
|
||||
plugin. When WG loads, check the server console for a report of
|
||||
features that are not supported by your version of hMod.
|
||||
- Changed some configuration defaults:
|
||||
disable-lava-fire=true
|
||||
simulate-sponge=true
|
||||
item-durability=false
|
||||
|
||||
1.4.1
|
||||
- Fixed issue with the block lag fix dropping item stacks of 0 quantity.
|
||||
|
||||
1.4
|
||||
- New on-acquire hook. This does both a total inventory check on inventory
|
||||
change and item pick up denial. The item pick up denial is largely
|
||||
thanks to Dinnerbone for fulfilling my request to add a particular hook.
|
||||
- Item durability can now be toggled with item-durability. Thanks to
|
||||
Dinnerbone for figuring this out while filfilling my request. The
|
||||
default setting is to fix item durability.
|
||||
- New no-physics-gravel and no-physics-sand options allow you to
|
||||
prevent gravel and sand from falling.
|
||||
- New allow-portal-anywhere option allows you to create portal blocks
|
||||
anywhere.
|
||||
|
||||
1.3
|
||||
- UPGRADE WARNING: If you are using database logging, you must add a
|
||||
NULL 'comment' VARCHAR field to the table. The line of SQL that you
|
||||
can run for MySQL can be found in blacklist_table.sql.
|
||||
- Improved plugin compatibility with the block lag fix. For maximum
|
||||
compatibility, you must now list WorldGuard as the first plugin in
|
||||
server.properties and you cannot reload or enable the plugin
|
||||
while the server is up. This is for bad plugins that unnecessarily
|
||||
use the "critical" priority for its hooks like the LWC. Most plugins
|
||||
don't do that though, so this won't apply for most people.
|
||||
- Fixed signs being blank if they were denied via the blacklist.
|
||||
- Added on-break event to the blacklist.
|
||||
- Added comments and messages. Comments are only for your own use and they
|
||||
are printed with the log and notify actions of the blacklist. The
|
||||
message replaces the message that is shown the user and it is optional.
|
||||
- The blacklist notification messages are now more compact and are
|
||||
light grey instead of light purple.
|
||||
- The notify, log, and tell actions will now trigger every time for the
|
||||
on-break, on-create, on-drop events rather than wait 3 seconds between
|
||||
events for the same item or block for a player.
|
||||
|
||||
1.2
|
||||
- /stopfire and /allowfire disable and enable fire spreading globally.
|
||||
- Block lag fix slightly improved in accuracy for item drops.
|
||||
- Sponge updated to remove water when the sponge block is set. Sponge radius
|
||||
can now be controlled using the 'sponge-radius' parameter and the
|
||||
default is now set to simulate Classic.
|
||||
- Updated for a newer build of "b126," meaning that lava spread control
|
||||
now works well!
|
||||
- A new summary of the status of some core protections is now printed
|
||||
on start. Disable this with 'summary-on-start'.
|
||||
- Blacklist system has been overhauled. Check README.txt for changed
|
||||
configuration settings!
|
||||
- The blacklist's method of preventing notification repeats is now better,
|
||||
instead waiting 3 seconds before notifying again (before it didn't
|
||||
notify again at all unless the user started using another blocked
|
||||
action).
|
||||
- To give users the ability to receive notifications, the command to give
|
||||
permission to has been changed to /worldguardnotify, although the
|
||||
old one (that was never mentioned anywhere) still works.
|
||||
- Water and lava buckets are now psuedo-blocked using an unreliable
|
||||
method that risks the stability of your server (no other plugin
|
||||
does it better though). Use it as your own risk.
|
||||
- Added on item drop and on item use (i.e. chest) events.
|
||||
- Chests, signs, and furnaces can now be blocked better with the
|
||||
blacklist system.
|
||||
- The event names in the blacklist configuration have changed but the old
|
||||
event names should still work. The new names should make "more sense."
|
||||
- A new "ban" action has been added to the blacklist.
|
||||
- Action messages have been improved, now longer saying "destroyed"
|
||||
for everything.
|
||||
- Logging to file has been completely changed, allowing you to use
|
||||
the date and time and the player's username in the log filename. It
|
||||
no longer rotates log files based on size, however.
|
||||
- Logging to database is now supported.
|
||||
- Tools can now be destroyed on drop to alleviate the durability cheat.
|
||||
You can do this with either with the blacklist or with the
|
||||
'item-drop-blacklist' configuration option. The configuration option
|
||||
prints more friendly messages than the 'tell' action of blacklists.
|
||||
|
||||
1.1.2
|
||||
- Block lag fix: Snow and glass should no longer drop items.
|
||||
- Block lag fix: Block object now reset after hook call.
|
||||
|
||||
1.1.1
|
||||
- Fixed redstone wire dropping wood blocks with the block lag fix.
|
||||
- The block lag fix now consults other plugins so that ALL protection
|
||||
mechanisms and plugins should work.
|
||||
|
||||
1.1
|
||||
- Added block lag fix.
|
||||
|
||||
1.0
|
||||
- Initial release.
|
||||
@@ -0,0 +1,68 @@
|
||||
# Contributing
|
||||
|
||||
Thank you for your interest in contributing to WorldGuard! We appreciate your
|
||||
effort, but to make sure that the inclusion of your patch is a smooth process, we
|
||||
ask that you make note of the following guidelines.
|
||||
|
||||
* **Follow the [Oracle coding conventions](https://www.oracle.com/technetwork/java/javase/documentation/codeconvtoc-136057.html).**
|
||||
We can't stress this enough; if your code has notable issues, it may delay
|
||||
the process significantly.
|
||||
* **Target Java 6 for source and compilation.** Make sure to mark methods with
|
||||
` @Override` that override methods of parent classes, or that implement
|
||||
methods of interfaces (Java 6+).
|
||||
* **Use only spaces for indentation.** Our indents are 4-spaces long, and tabs
|
||||
are unacceptable.
|
||||
* **Wrap code to a 89 column limit.** We do this to make side by side diffs
|
||||
and other such tasks easier. Ignore this guideline if it makes the code
|
||||
too unreadable.
|
||||
* **Write complete Javadocs.** Do so only for public methods, and make sure
|
||||
that your `@param` and `@return` fields are not just blank.
|
||||
* **Don't tag classes with @author.** Some legacy classes may have this tag,
|
||||
but we are phasing it out.
|
||||
* **Make sure the code is efficient.** One way you can achieve this is to spend
|
||||
around ten minutes to think about what the code is doing and whether it
|
||||
seems awfully roundabout. If you had to copy the same large piece of
|
||||
code in several places, that's bad.
|
||||
* **Keep commit summaries under 70 characters.** For more details, place two
|
||||
new lines after the summary line and write away!
|
||||
* **Test your code.** We're not interested in broken code, for the obvious reasons.
|
||||
* **Write unit tests.** While this is strictly optional, we recommend it for
|
||||
complicated algorithms.
|
||||
|
||||
|
||||
Checklist
|
||||
---------
|
||||
|
||||
Ready to submit? Perform the checklist below:
|
||||
|
||||
1. Have all tabs been replaced into four spaces? Are indentations 4-space wide?
|
||||
2. Have I written proper Javadocs for my public methods? Are the @param and
|
||||
@return fields actually filled out?
|
||||
3. Have I `git rebase`d my pull request to the latest commit of the target
|
||||
branch?
|
||||
4. Have I combined my commits into a reasonably small number (if not one)
|
||||
commit using `git rebase`?
|
||||
5. Have I made my pull request too large? Pull requests should introduce
|
||||
small sets of changes at a time. Major changes should be discussed with
|
||||
the team prior to starting work.
|
||||
6. Are my commit messages descriptive?
|
||||
|
||||
You should be aware of [`git rebase`](http://learn.github.com/p/rebasing.html).
|
||||
It allows you to modify existing commit messages, and combine, break apart, or
|
||||
adjust past changes.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
This is **GOOD:**
|
||||
|
||||
if (var.func(param1, param2)) {
|
||||
// do things
|
||||
}
|
||||
|
||||
This is **EXTREMELY BAD:**
|
||||
|
||||
if(var.func( param1, param2 ))
|
||||
{
|
||||
// do things
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
WorldGuard, a suite of tools for Minecraft
|
||||
Copyright (C) sk89q <http://www.sk89q.com>
|
||||
Copyright (C) WorldGuard team and contributors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
Installation
|
||||
------------
|
||||
|
||||
This plugin requires Hey0's server modification.
|
||||
|
||||
1. Create a "plugins" folder inside your "bin" folder.
|
||||
|
||||
2. Copy WorldGuard.jar into "plugins".
|
||||
|
||||
3. Add "WorldGuard" to the "plugins" line of your server.properties file.
|
||||
If it's not already there, add the line. The line should look like this:
|
||||
|
||||
plugins=WorldGuard
|
||||
|
||||
If you have multiple plugins, separate plugin names with commas.
|
||||
+201
-165
@@ -1,165 +1,201 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
This work includes Robert Olofsson's Priority R-Tree implementation, for which
|
||||
its license is reproduced below.
|
||||
|
||||
Copyright (c) 2008-2010 Robert Olofsson.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the authors nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS 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 AUTHORS 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.
|
||||
@@ -0,0 +1,46 @@
|
||||
# 
|
||||
|
||||
WorldGuard lets you and players guard areas of land against griefers and undesirables, as well as tweak and disable various gameplay features of Minecraft.
|
||||
|
||||
* Block creeper and wither block damage, falling damage, etc.;
|
||||
* Disable fire spread, lava fire spread, ice formation, Endermen picking up blocks, etc.;
|
||||
* Blacklist certain items and blocks so they can't be used;
|
||||
* Warn moderators when certain items and blocks are used;
|
||||
* Protect areas of your world so only certain people can build in them;
|
||||
* Set areas where PVP, TNT, mob damage, and other features are disabled;
|
||||
* Protect your server from various 'exploits' like magical obsidian creation machines;
|
||||
* Disable, or enable, various Minecraft features, like sponges from classic;
|
||||
* Add useful commands like an immediate "STOP ALL FIRE SPREAD" command.
|
||||
* Enable only features you want! Everything is off by default.
|
||||
|
||||
WorldGuard is open source and is available under the GNU Lesser
|
||||
General Public License v3.
|
||||
|
||||
Currently, Bukkit is required to use WorldGuard. You can get a release copy of WorldGuard from the [BukkitDev site](http://dev.bukkit.org/bukkit-plugins/worldguard/).
|
||||
|
||||
Compiling
|
||||
---------
|
||||
|
||||
The project is written for Java 8 and our build process makes use of
|
||||
[Gradle](http://gradle.org).
|
||||
|
||||
Dependencies are automatically handled by Gradle.
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
We happily accept contributions, especially through pull requests on GitHub.
|
||||
|
||||
Please read CONTRIBUTING.md for important guidelines to follow.
|
||||
|
||||
Submissions must be licensed under the GNU Lesser General Public License v3.
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
* [Homepage](http://enginehub.org/worldguard)
|
||||
* [Discord](https://discord.gg/enginehub)
|
||||
* [IRC channel](https://webchat.esper.net/?join=sk89q) (#sk89q on irc.esper.net)
|
||||
* [Issue tracker](https://dev.enginehub.org/issues/WORLDGUARD)
|
||||
* [Continuous integration](http://builds.enginehub.org) [](http://ci.enginehub.org/viewType.html?buildTypeId=bt11&guest=1)
|
||||
* [End-user documentation](https://worldguard.enginehub.org/en/latest/)
|
||||
-230
@@ -1,230 +0,0 @@
|
||||
WorldGuard
|
||||
Copyright (c) 2010 sk89q <http://www.sk89q.com>
|
||||
Licensed under the GNU Lesser General Public License v3
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
WorldGuard has a number of features, any of which you can choose to
|
||||
use or not:
|
||||
|
||||
- Enforce only one session for a player on a server (can't login twice).
|
||||
- Block creeper explosions.
|
||||
- Block TNT explosions.
|
||||
- Block lighters from setting fires.
|
||||
- Block all fires.
|
||||
- Allow fire but prevent it from burning certain blocks.
|
||||
- Prevent lava from starting fires.
|
||||
- Restrict lava spreading to only some block types.
|
||||
- Simulate classic-esque water by letting water infinitely expand in
|
||||
area (only if there is a block underneath).
|
||||
- Simulate the function of the sponge from Minecraft Classic.
|
||||
- Notify admins, block, log, kick or ban for the use of certain block types
|
||||
or items.
|
||||
- Temporarily stop fire globally with some commands.
|
||||
- Destroy tools on drop to alleviate the durability cheat.
|
||||
- OR just fix the durability bug. *Requires special version of hMod
|
||||
- Prevent gravel and sand from falling. *Requires special version of hMod
|
||||
- Allow portal blocks to be placed anywhere.
|
||||
*Requires special version of hMod
|
||||
|
||||
hMod is required as WorldGuard is a plugin for hMod.
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
A "worldguard.properties" will be created the first the time that you load
|
||||
WorldGuard on your server. You can either restart your server or use
|
||||
/reloadplugin WorldGuard to reload the configuraton file after editing it.
|
||||
|
||||
NOTE: Some features may require a custom version of hMod. When the server
|
||||
is loaded with the plugin, WorldGuard will tell you the features
|
||||
unsupported by your version of hMod.
|
||||
|
||||
- summary-on-start (def. true)
|
||||
Print a summary of WorldGuard's protection settings at-a-glance when
|
||||
the plugin is loaded.
|
||||
|
||||
- item-durability (def. false)
|
||||
**Requires special version of hMod
|
||||
Enables item durability.
|
||||
|
||||
- classic-water (def. false)
|
||||
Toggle use of classic water. Be foreward that your world may be
|
||||
flooded if you are not careful. If you have WorldEdit, you can use
|
||||
//drain in such an event, although that will drain the entire pool
|
||||
as well. This classic-esque water will only spread infinitely over
|
||||
ground, but if there are air blocks underneath, the water will not
|
||||
spread (preventing waterfalls from becoming tsunamis).
|
||||
|
||||
- simulate-sponge (def. true)
|
||||
Toggle simulation of the sponge from Classic. It blocks water from
|
||||
flowing near the sponge.
|
||||
|
||||
- sponge-radius (def. 3)
|
||||
The radius of the sponge's effect. The default is that of Classic,
|
||||
creating a 5x5x5 cuboid free of water. Increasing the number will
|
||||
increase server load exponentially, although 3-5 has fairly low impact.
|
||||
|
||||
- no-physics-gravel (def. false)
|
||||
**Requires special version of hMod
|
||||
Prevents gravel from falling due to gravity.
|
||||
|
||||
- no-physics-sand (def. false)
|
||||
**Requires special version of hMod
|
||||
Prevents sand from falling due to gravity.
|
||||
|
||||
- allow-portal-anywhere (def. false)
|
||||
**Requires special version of hMod
|
||||
Allows you to place portal blocks anywhere.
|
||||
|
||||
- enforce-single-session (def. true)
|
||||
Enforce single sessions. If the player is already found to be on
|
||||
the server when s/he logs in, the other player will be kicked with
|
||||
an informative message. The inventory will have been saved before
|
||||
the new session starts.
|
||||
|
||||
- block-tnt (def. false)
|
||||
Block TNT explosions. TNT will still explode client-side but the blocks
|
||||
will be "restored" in a few seconds afterwards.
|
||||
|
||||
- block-lighter (def. false)
|
||||
Block flint and steel fires. Those with access to the commands
|
||||
/uselighter or /lighter can bypass this. /uselighter is not a real
|
||||
command; it is only used for permissions.
|
||||
|
||||
- block-creepers (def. false)
|
||||
Block creeper explosions from destroying terrain (and possibly from
|
||||
causing damage).
|
||||
|
||||
- disable-lava-fire (def. true)
|
||||
Prevent lava from starting fires.
|
||||
|
||||
- allowed-lava-spread-blocks (no default)
|
||||
List of block names/IDs to allow lava to spread to. Leave blank
|
||||
to disable this feature.
|
||||
|
||||
- disable-all-fire-spread (def. false)
|
||||
Disable all fire from spreading.
|
||||
|
||||
- disallowed-fire-spread-blocks (no default)
|
||||
List of block names/IDs to prevent fire from spreading to. Leave blank
|
||||
to disable this feature. Enabling disable-all-fire-spread will
|
||||
override this function.
|
||||
|
||||
- item-drop-blacklist (no default)
|
||||
List of block names/IDs to destroy on drop. This can alleviate the
|
||||
durability cheat that allows you to drop your tools to fix their
|
||||
durability. You can also enforce this with the blacklist but
|
||||
this is an easier way to do it (this way also prints a more
|
||||
friendly message than if you used the 'tell' action of the blacklist).
|
||||
|
||||
- login-protection (def. 3)
|
||||
Number of seconds to keep a player invincible when the player joins.
|
||||
|
||||
- spawn-protection (def. 0)
|
||||
Number of seconds to keep a player invincible when the player spawns.
|
||||
This does not apply to players joining the server.
|
||||
|
||||
- kick-on-death (def. false)
|
||||
Kick players when they die (and respawn). This is to work around the
|
||||
issues of invisible players when players die.
|
||||
|
||||
- log-console (def. true)
|
||||
For blacklist log actions, print to console.
|
||||
|
||||
- log-file (def. false)
|
||||
For blacklist log actions, log to file.
|
||||
|
||||
- log-file-path (def. "worldguard/logs/%Y-%m-%d.log")
|
||||
Log blacklist events to file. You can use these patterns in the path:
|
||||
%Y the year (YYYY)
|
||||
%m the month (MM)
|
||||
%d the day (DD)
|
||||
%W the week of the year (00-52)
|
||||
%H 24-hour time (HH)
|
||||
%h 12-hour time (HH)
|
||||
%i the minute (mm)
|
||||
%s the second (ss)
|
||||
%u the user's name
|
||||
%% translates to a single percent sign "%"
|
||||
The files are not automatically rotated if they get large so you should
|
||||
perhaps put a week in the filename at least.
|
||||
|
||||
Escape backslashes with another backslash, like so:
|
||||
C:\path\to\log.txt -> C:\\path\\to\\log.txt
|
||||
|
||||
- log-file-open-files (def. 10)
|
||||
The number of log files to keep open at once. Unless you use dynamic
|
||||
patterns in the path, the value of this variable won't matter. However,
|
||||
if, for example, you use a player's username in the filename and you
|
||||
have many users who cause logged events to occur, files would have
|
||||
to be opened for each user and this parameter would matter.
|
||||
|
||||
- log-database (def. false)
|
||||
Log blacklist events to database.
|
||||
|
||||
- log-database-dsn (def. "jdbc:mysql://localhost:3306/minecraft")
|
||||
Connection string. A string to use for MySQL would be:
|
||||
jdbc:mysql://localhost:3306/minecraft
|
||||
The "minecraft" part at the end is the database name.
|
||||
|
||||
Escape colons with a backslash, like so:
|
||||
jdbc:mysql://localhost:3306/minecraft
|
||||
->
|
||||
jdbc\:mysql\://localhost\:3306/minecraft
|
||||
|
||||
- log-database-user (def. "root")
|
||||
Database username.
|
||||
|
||||
- log-database-pass (def. "")
|
||||
Database password.
|
||||
|
||||
- log-database-table (def. "blacklist_events")
|
||||
Database table to use.
|
||||
|
||||
Commands
|
||||
--------
|
||||
|
||||
- /stopfire and /allowfire
|
||||
Disables and enables fire spread globally. Both commands require the
|
||||
permission to use only "/stopfire. Re-enabling fire spread with this
|
||||
command will not override other fire spread control features of
|
||||
WorldGuard. Note that disabling fire does not disable fire damage
|
||||
but fire at least won't spread.
|
||||
|
||||
- /god
|
||||
Toggles your invincibility. Players must have permission to use "/god"
|
||||
to be able to use this command. You can also use this command to
|
||||
toggle the invincibility of others although you must have the
|
||||
"/godother" permission.
|
||||
|
||||
Server Commands
|
||||
---------------
|
||||
|
||||
- fire-stop and fire-allow
|
||||
Disables and enables fire spread globally. Re-enabling fire spread
|
||||
with this command will not override other fire spread control features
|
||||
of WorldGuard. Note that disabling fire does not disable fire damage
|
||||
but fire at least won't spread.
|
||||
|
||||
Blacklists
|
||||
----------
|
||||
|
||||
Blacklists let you control the use of blocks and items. You can have
|
||||
certain rules apply to only some groups.
|
||||
|
||||
Edit the included worldguard-blacklist.txt file and follow the
|
||||
instructions inside. The file comes with the download for WorldGuard.
|
||||
|
||||
Thanks
|
||||
------
|
||||
|
||||
While I would like to thank everyone for their support, I would like to
|
||||
say thanks to the following individuals for their direct
|
||||
contributions to WorldGuard:
|
||||
|
||||
- Sturmeh, for contributing the original durability workaround
|
||||
- Meaglin, for changing the on flow hook at my request
|
||||
- Dinnerbone, for implementing the on item pick up hook at my request,
|
||||
and also for figuring out the durability bug in the process
|
||||
@@ -0,0 +1,26 @@
|
||||
import org.ajoberstar.grgit.Grgit
|
||||
|
||||
logger.lifecycle("""
|
||||
*******************************************
|
||||
You are building WorldGuard!
|
||||
If you encounter trouble:
|
||||
1) Try running 'build' in a separate Gradle run
|
||||
2) Use gradlew and not gradle
|
||||
3) If you still need help, ask on Discord! https://discord.gg/enginehub
|
||||
|
||||
Output files will be in [subproject]/build/libs
|
||||
*******************************************
|
||||
""")
|
||||
|
||||
applyRootArtifactoryConfig()
|
||||
|
||||
if (!project.hasProperty("gitCommitHash")) {
|
||||
apply(plugin = "org.ajoberstar.grgit")
|
||||
ext["gitCommitHash"] = try {
|
||||
(ext["grgit"] as Grgit?)?.head()?.abbreviatedId
|
||||
} catch (e: Exception) {
|
||||
logger.warn("Error getting commit hash", e)
|
||||
|
||||
"no_git_id"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
kotlin("jvm") version embeddedKotlinVersion
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(gradleApi())
|
||||
implementation("gradle.plugin.net.minecrell:licenser:0.4.1")
|
||||
implementation("org.ajoberstar.grgit:grgit-gradle:3.1.1")
|
||||
implementation("com.github.jengelman.gradle.plugins:shadow:5.1.0")
|
||||
implementation("net.ltgt.apt-eclipse:net.ltgt.apt-eclipse.gradle.plugin:0.21")
|
||||
implementation("net.ltgt.apt-idea:net.ltgt.apt-idea.gradle.plugin:0.21")
|
||||
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.9.7")
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.named
|
||||
import org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention
|
||||
import org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask
|
||||
|
||||
private const val ARTIFACTORY_CONTEXT_URL = "artifactory_contextUrl"
|
||||
private const val ARTIFACTORY_USER = "artifactory_user"
|
||||
private const val ARTIFACTORY_PASSWORD = "artifactory_password"
|
||||
|
||||
fun Project.applyRootArtifactoryConfig() {
|
||||
if (!project.hasProperty(ARTIFACTORY_CONTEXT_URL)) ext[ARTIFACTORY_CONTEXT_URL] = "http://localhost"
|
||||
if (!project.hasProperty(ARTIFACTORY_USER)) ext[ARTIFACTORY_USER] = "guest"
|
||||
if (!project.hasProperty(ARTIFACTORY_PASSWORD)) ext[ARTIFACTORY_PASSWORD] = ""
|
||||
|
||||
apply(plugin = "com.jfrog.artifactory")
|
||||
configure<ArtifactoryPluginConvention> {
|
||||
setContextUrl("${project.property(ARTIFACTORY_CONTEXT_URL)}")
|
||||
clientConfig.publisher.run {
|
||||
repoKey = when {
|
||||
"${project.version}".contains("SNAPSHOT") -> "libs-snapshot-local"
|
||||
else -> "libs-release-local"
|
||||
}
|
||||
username = "${project.property(ARTIFACTORY_USER)}"
|
||||
password = "${project.property(ARTIFACTORY_PASSWORD)}"
|
||||
isMaven = true
|
||||
isIvy = false
|
||||
}
|
||||
}
|
||||
tasks.named<ArtifactoryTask>("artifactoryPublish") {
|
||||
isSkip = true
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.applyCommonArtifactoryConfig() {
|
||||
val named = tasks.named<ArtifactoryTask>("artifactoryPublish") {
|
||||
publishConfigs("archives")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.repositories
|
||||
|
||||
fun Project.applyCommonConfiguration() {
|
||||
group = rootProject.group
|
||||
version = rootProject.version
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url = uri("https://maven.sk89q.com/repo/") }
|
||||
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") }
|
||||
}
|
||||
configurations.all {
|
||||
resolutionStrategy {
|
||||
cacheChangingModulesFor(5, "minutes")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.ExtraPropertiesExtension
|
||||
import org.gradle.api.plugins.JavaPluginConvention
|
||||
import org.gradle.api.tasks.SourceSetContainer
|
||||
import org.gradle.kotlin.dsl.getByType
|
||||
import org.gradle.kotlin.dsl.the
|
||||
|
||||
val Project.ext: ExtraPropertiesExtension
|
||||
get() = extensions.getByType()
|
||||
|
||||
val Project.sourceSets: SourceSetContainer
|
||||
get() = the<JavaPluginConvention>().sourceSets
|
||||
@@ -0,0 +1,96 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.ModuleDependency
|
||||
import org.gradle.api.internal.HasConvention
|
||||
import org.gradle.api.plugins.MavenRepositoryHandlerConvention
|
||||
import org.gradle.api.tasks.Upload
|
||||
import org.gradle.api.tasks.bundling.Jar
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.get
|
||||
import org.gradle.kotlin.dsl.getPlugin
|
||||
import org.gradle.kotlin.dsl.invoke
|
||||
import org.gradle.kotlin.dsl.register
|
||||
|
||||
fun Project.applyLibrariesConfiguration() {
|
||||
applyCommonConfiguration()
|
||||
apply(plugin = "java-base")
|
||||
apply(plugin = "maven")
|
||||
apply(plugin = "com.github.johnrengelman.shadow")
|
||||
apply(plugin = "com.jfrog.artifactory")
|
||||
|
||||
configurations {
|
||||
create("shade")
|
||||
getByName("archives").extendsFrom(getByName("default"))
|
||||
}
|
||||
|
||||
group = "${rootProject.group}.worldguard-libs"
|
||||
|
||||
tasks.register<ShadowJar>("jar") {
|
||||
configurations = listOf(project.configurations["shade"])
|
||||
archiveClassifier.set("")
|
||||
|
||||
dependencies {
|
||||
exclude(dependency("com.google.code.findbugs:jsr305:1.3.9"))
|
||||
}
|
||||
|
||||
relocate("com.sk89q.squirrelid", "com.sk89q.worldguard.util.profile")
|
||||
}
|
||||
val altConfigFiles = { artifactType: String ->
|
||||
val deps = configurations["shade"].incoming.dependencies
|
||||
.filterIsInstance<ModuleDependency>()
|
||||
.map { it.copy() }
|
||||
.map { dependency ->
|
||||
dependency.artifact {
|
||||
name = dependency.name
|
||||
type = artifactType
|
||||
extension = "jar"
|
||||
classifier = artifactType
|
||||
}
|
||||
dependency
|
||||
}
|
||||
|
||||
files(configurations.detachedConfiguration(*deps.toTypedArray())
|
||||
.resolvedConfiguration.lenientConfiguration.artifacts
|
||||
.filter { it.classifier == artifactType }
|
||||
.map { zipTree(it.file) })
|
||||
}
|
||||
tasks.register<Jar>("sourcesJar") {
|
||||
from({
|
||||
altConfigFiles("sources")
|
||||
})
|
||||
val filePattern = Regex("(.*)com/sk89q/squirrelid((?:/|$).*)")
|
||||
val textPattern = Regex("com\\.sk89q\\.squirrelid")
|
||||
eachFile {
|
||||
filter {
|
||||
it.replaceFirst(textPattern, "com.sk89q.worldguard.util.profile")
|
||||
}
|
||||
path = path.replaceFirst(filePattern, "$1com/sk89q/worldguard/util/profile$2")
|
||||
}
|
||||
archiveClassifier.set("sources")
|
||||
}
|
||||
|
||||
tasks.named("assemble").configure {
|
||||
dependsOn("jar", "sourcesJar")
|
||||
}
|
||||
|
||||
artifacts {
|
||||
val jar = tasks.named("jar")
|
||||
add("default", jar) {
|
||||
builtBy(jar)
|
||||
}
|
||||
val sourcesJar = tasks.named("sourcesJar")
|
||||
add("archives", sourcesJar) {
|
||||
builtBy(sourcesJar)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register<Upload>("install") {
|
||||
configuration = configurations["archives"]
|
||||
(repositories as HasConvention).convention.getPlugin<MavenRepositoryHandlerConvention>().mavenInstaller {
|
||||
pom.version = project.version.toString()
|
||||
pom.artifactId = project.name
|
||||
}
|
||||
}
|
||||
|
||||
applyCommonArtifactoryConfig()
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import net.minecrell.gradle.licenser.LicenseExtension
|
||||
import org.gradle.api.JavaVersion
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.JavaPluginConvention
|
||||
import org.gradle.api.plugins.quality.CheckstyleExtension
|
||||
import org.gradle.api.tasks.bundling.Jar
|
||||
import org.gradle.api.tasks.javadoc.Javadoc
|
||||
import org.gradle.api.tasks.testing.Test
|
||||
import org.gradle.external.javadoc.CoreJavadocOptions
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.dependencies
|
||||
import org.gradle.kotlin.dsl.get
|
||||
import org.gradle.kotlin.dsl.getByName
|
||||
import org.gradle.kotlin.dsl.named
|
||||
import org.gradle.kotlin.dsl.register
|
||||
import org.gradle.kotlin.dsl.withType
|
||||
|
||||
fun Project.applyPlatformAndCoreConfiguration() {
|
||||
applyCommonConfiguration()
|
||||
apply(plugin = "java")
|
||||
apply(plugin = "eclipse")
|
||||
apply(plugin = "idea")
|
||||
apply(plugin = "maven")
|
||||
apply(plugin = "checkstyle")
|
||||
apply(plugin = "com.github.johnrengelman.shadow")
|
||||
apply(plugin = "com.jfrog.artifactory")
|
||||
apply(plugin = "net.minecrell.licenser")
|
||||
|
||||
ext["internalVersion"] = "$version;${rootProject.ext["gitCommitHash"]}"
|
||||
|
||||
configure<JavaPluginConvention> {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
configure<CheckstyleExtension> {
|
||||
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
|
||||
toolVersion = "7.6.1"
|
||||
}
|
||||
|
||||
tasks.withType<Test>().configureEach {
|
||||
useJUnit()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
"testCompile"("junit:junit:${Versions.JUNIT}")
|
||||
// TODO switch to jupiter - doesn't support abstract test classes so tests need rewriting
|
||||
//"testImplementation"("org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT}")
|
||||
//"testRuntime"("org.junit.jupiter:junit-jupiter-engine:${Versions.JUNIT}")
|
||||
}
|
||||
|
||||
// Java 8 turns on doclint which we fail
|
||||
tasks.withType<Javadoc>().configureEach {
|
||||
(options as CoreJavadocOptions).addStringOption("Xdoclint:none", "-quiet")
|
||||
}
|
||||
|
||||
tasks.register<Jar>("javadocJar") {
|
||||
dependsOn("javadoc")
|
||||
archiveClassifier.set("javadoc")
|
||||
from(tasks.getByName<Javadoc>("javadoc").destinationDir)
|
||||
}
|
||||
|
||||
tasks.named("assemble").configure {
|
||||
dependsOn("javadocJar")
|
||||
}
|
||||
|
||||
artifacts {
|
||||
add("archives", tasks.named("jar"))
|
||||
add("archives", tasks.named("javadocJar"))
|
||||
}
|
||||
|
||||
if (name == "worldguard-core" || name == "worldguard-bukkit") {
|
||||
tasks.register<Jar>("sourcesJar") {
|
||||
dependsOn("classes")
|
||||
archiveClassifier.set("sources")
|
||||
from(sourceSets["main"].allSource)
|
||||
}
|
||||
|
||||
artifacts {
|
||||
add("archives", tasks.named("sourcesJar"))
|
||||
}
|
||||
tasks.named("assemble").configure {
|
||||
dependsOn("sourcesJar")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named("check").configure {
|
||||
dependsOn("checkstyleMain", "checkstyleTest")
|
||||
}
|
||||
|
||||
applyCommonArtifactoryConfig()
|
||||
|
||||
configure<LicenseExtension> {
|
||||
header = rootProject.file("HEADER.txt")
|
||||
include("**/*.java")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun Project.applyShadowConfiguration() {
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
archiveClassifier.set("dist")
|
||||
dependencies {
|
||||
include(project(":worldguard-libs:core"))
|
||||
//include(project(":worldguard-libs:${project.name.replace("worldguard-", "")}"))
|
||||
include(project(":worldguard-core"))
|
||||
|
||||
relocate("org.flywaydb", "com.sk89q.worldguard.internal.flywaydb") {
|
||||
include(dependency("org.flywaydb:flyway-core:3.0"))
|
||||
}
|
||||
relocate("com.sk89q.squirrelid", "com.sk89q.worldguard.util.profile")
|
||||
}
|
||||
exclude("GradleStart**")
|
||||
exclude(".cache")
|
||||
exclude("LICENSE*")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
object Versions {
|
||||
// const val PISTON = "0.4.3"
|
||||
// const val AUTO_VALUE = "1.6.5"
|
||||
const val WORLDEDIT = "7.1.0-SNAPSHOT"
|
||||
const val JUNIT = "4.11"
|
||||
const val SQUIRRELID = "0.2.0"
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||
<module name="Checker">
|
||||
<!-- Tabs are strictly banned -->
|
||||
<module name="FileTabCharacter"/>
|
||||
|
||||
<module name="SuppressionFilter">
|
||||
<property name="file" value="${config_loc}/suppressions.xml"/>
|
||||
</module>
|
||||
|
||||
|
||||
|
||||
<module name="TreeWalker">
|
||||
<!-- Important basics -->
|
||||
<!-- <module name="PackageDeclaration"/> Unlikely that we would miss this in a PR -->
|
||||
<module name="OuterTypeFilename"/> <!-- TypeName -> TypeName.java -->
|
||||
|
||||
<!--
|
||||
Control package usage, so people don't insert Bukkit into WG where it shouldn't belong, etc.
|
||||
It is a bit draconian, so update as necessary!
|
||||
-->
|
||||
<module name="ImportControl">
|
||||
<property name="file" value="${config_loc}/import-control.xml"/>
|
||||
</module>
|
||||
|
||||
<!-- Code -->
|
||||
<module name="HideUtilityClassConstructor"/> <!-- Utility classes should not have a constructor -->
|
||||
<module name="CovariantEquals"/>
|
||||
<module name="EqualsHashCode"/> <!-- equals() and hashCode() go together -->
|
||||
<module name="NestedTryDepth"> <!-- SHOULD not need to adjust this -->
|
||||
<property name="max" value="2"/>
|
||||
</module>
|
||||
<module name="SuperFinalize"/> <!-- We don't actually use this -->
|
||||
|
||||
<!-- Style -->
|
||||
<module name="LeftCurly"> <!-- Left brace never goes on another line -->
|
||||
<property name="option" value="eol"/>
|
||||
</module> <!-- We don't check right brace -->
|
||||
<module name="DefaultComesLast"/> <!-- default case in switch should be last -->
|
||||
<module name="GenericWhitespace"/>
|
||||
|
||||
<!-- Naming -->
|
||||
<module name="ClassTypeParameterName">
|
||||
<property name="format" value="^[A-Z][a-zA-Z0-9]*$"/>
|
||||
</module>
|
||||
<module name="LocalFinalVariableName"/>
|
||||
<module name="LocalVariableName">
|
||||
<property name="format" value="^[a-z_][a-zA-Z0-9]*$"/>
|
||||
</module>
|
||||
<module name="MemberName">
|
||||
<property name="format" value="^[a-z_][a-zA-Z0-9]*$"/>
|
||||
</module>
|
||||
<module name="MethodName">
|
||||
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
|
||||
</module>
|
||||
<!-- <module name="PackageName"/> Unlikely that we would miss this in a PR -->
|
||||
<module name="ParameterName"/>
|
||||
<!-- <module name="TypeName"/> Unlikely that we would miss this in a PR -->
|
||||
</module>
|
||||
|
||||
</module>
|
||||
@@ -0,0 +1,36 @@
|
||||
<!DOCTYPE import-control PUBLIC
|
||||
"-//Puppy Crawl//DTD Import Control 1.1//EN"
|
||||
"http://www.puppycrawl.com/dtds/import_control_1_1.dtd">
|
||||
|
||||
<import-control pkg="com.sk89q">
|
||||
<allow pkg="java"/>
|
||||
<allow pkg="javax"/>
|
||||
<allow pkg="org.junit"/>
|
||||
<allow pkg="org.hamcrest"/>
|
||||
<allow pkg="org.mockito"/>
|
||||
<allow pkg="junit.framework"/>
|
||||
<allow pkg="com.sk89q"/>
|
||||
<allow pkg="com.google.common"/>
|
||||
|
||||
<subpackage name="worldguard">
|
||||
<allow pkg="org.khelekore"/>
|
||||
<allow pkg="org.flywaydb"/>
|
||||
<allow pkg="org.yaml"/>
|
||||
<allow pkg="org.enginehub.piston"/>
|
||||
|
||||
<subpackage name="util.profile.resolver">
|
||||
<allow pkg="org.bukkit"/>
|
||||
<allow pkg="io.papermc.lib"/>
|
||||
<allow pkg="com.destroystokyo.paper"/>
|
||||
</subpackage>
|
||||
|
||||
<subpackage name="bukkit">
|
||||
<allow pkg="org.bukkit"/>
|
||||
<allow pkg="org.bstats.bukkit"/>
|
||||
<allow pkg="io.papermc.lib"/>
|
||||
<allow pkg="com.destroystokyo.paper"/>
|
||||
</subpackage>
|
||||
|
||||
</subpackage>
|
||||
|
||||
</import-control>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE suppressions PUBLIC
|
||||
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
|
||||
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
|
||||
<suppressions>
|
||||
<suppress files="ProtectedRegion.java" checks="EqualsHashCode"/>
|
||||
</suppressions>
|
||||
@@ -0,0 +1,2 @@
|
||||
group=com.sk89q.worldguard
|
||||
version=7.0.2-SNAPSHOT
|
||||
Vendored
BIN
Binary file not shown.
+5
@@ -0,0 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -0,0 +1,172 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
Vendored
+84
@@ -0,0 +1,84 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -1,2 +0,0 @@
|
||||
Manifest-Version: 1.0
|
||||
WorldGuard-Version: 1.6
|
||||
@@ -0,0 +1,7 @@
|
||||
rootProject.name = "worldguard"
|
||||
|
||||
include("worldguard-libs")
|
||||
include("worldguard-libs:core")
|
||||
include("worldguard-core")
|
||||
//include("worldguard-libs:bukkit")
|
||||
include("worldguard-bukkit")
|
||||
@@ -1,397 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class Blacklist {
|
||||
/**
|
||||
* Logger.
|
||||
*/
|
||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
|
||||
|
||||
/**
|
||||
* List of entries by block ID.
|
||||
*/
|
||||
private Map<Integer,List<BlacklistEntry>> blacklist
|
||||
= new HashMap<Integer,List<BlacklistEntry>>();
|
||||
/**
|
||||
* Logger.
|
||||
*/
|
||||
private BlacklistLogger blacklistLogger = new BlacklistLogger();
|
||||
|
||||
/**
|
||||
* Blacklist contains on-acquire events.
|
||||
*/
|
||||
private boolean hasOnAcquire;
|
||||
|
||||
/**
|
||||
* Returns whether the list is empty.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return blacklist.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entries for an item or list.
|
||||
*/
|
||||
public List<BlacklistEntry> getEntries(int id) {
|
||||
return blacklist.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the logger.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public BlacklistLogger getLogger() {
|
||||
return blacklistLogger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on block destruction. Returns true to let the action pass
|
||||
* through.
|
||||
*
|
||||
* @param block
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onDestroy(final Block block, final Player player) {
|
||||
List<BlacklistEntry> entries = getEntries(block.getType());
|
||||
if (entries == null) {
|
||||
return true;
|
||||
}
|
||||
boolean ret = true;
|
||||
for (BlacklistEntry entry : entries) {
|
||||
if (!entry.onDestroy(block, player)) {
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on block break. Returns true to let the action pass
|
||||
* through.
|
||||
*
|
||||
* @param block
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onBreak(final Block block, final Player player) {
|
||||
List<BlacklistEntry> entries = getEntries(block.getType());
|
||||
if (entries == null) {
|
||||
return true;
|
||||
}
|
||||
boolean ret = true;
|
||||
for (BlacklistEntry entry : entries) {
|
||||
if (!entry.onBreak(block, player)) {
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on left click. Returns true to let the action pass through.
|
||||
*
|
||||
* @param item
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onDestroyWith(int item, Player player) {
|
||||
List<BlacklistEntry> entries = getEntries(item);
|
||||
if (entries == null) {
|
||||
return true;
|
||||
}
|
||||
boolean ret = true;
|
||||
for (BlacklistEntry entry : entries) {
|
||||
if (!entry.onDestroyWith(item, player)) {
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on right click. Returns true to let the action pass through.
|
||||
*
|
||||
* @param item
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onCreate(int item, Player player) {
|
||||
List<BlacklistEntry> entries = getEntries(item);
|
||||
if (entries == null) {
|
||||
return true;
|
||||
}
|
||||
boolean ret = true;
|
||||
for (BlacklistEntry entry : entries) {
|
||||
if (!entry.onCreate(item, player)) {
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on right click upon. Returns true to let the action pass through.
|
||||
*
|
||||
* @param item
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onUse(Block block, Player player) {
|
||||
List<BlacklistEntry> entries = getEntries(block.getType());
|
||||
if (entries == null) {
|
||||
return true;
|
||||
}
|
||||
boolean ret = true;
|
||||
for (BlacklistEntry entry : entries) {
|
||||
if (!entry.onUse(block, player)) {
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on right click upon. Returns true to let the action pass through.
|
||||
*
|
||||
* @param item
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onSilentUse(Block block, Player player) {
|
||||
List<BlacklistEntry> entries = getEntries(block.getType());
|
||||
if (entries == null) {
|
||||
return true;
|
||||
}
|
||||
boolean ret = true;
|
||||
for (BlacklistEntry entry : entries) {
|
||||
if (!entry.onSilentUse(block, player)) {
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on drop. Returns true to let the action pass through.
|
||||
*
|
||||
* @param item
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onDrop(int item, Player player) {
|
||||
List<BlacklistEntry> entries = getEntries(item);
|
||||
if (entries == null) {
|
||||
return true;
|
||||
}
|
||||
boolean ret = true;
|
||||
for (BlacklistEntry entry : entries) {
|
||||
if (!entry.onDrop(item, player)) {
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on acquire. Returns true to let the action pass through.
|
||||
*
|
||||
* @param item
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onAcquire(int item, Player player) {
|
||||
List<BlacklistEntry> entries = getEntries(item);
|
||||
if (entries == null) {
|
||||
return true;
|
||||
}
|
||||
boolean ret = true;
|
||||
for (BlacklistEntry entry : entries) {
|
||||
if (!entry.onAcquire(item, player)) {
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on acquire. Returns true to let the action pass through.
|
||||
*
|
||||
* @param item
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onSilentAcquire(int item, Player player) {
|
||||
List<BlacklistEntry> entries = getEntries(item);
|
||||
if (entries == null) {
|
||||
return true;
|
||||
}
|
||||
boolean ret = true;
|
||||
for (BlacklistEntry entry : entries) {
|
||||
if (!entry.onSilentAcquire(item, player)) {
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the blacklist.
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public void load(File file) throws IOException {
|
||||
FileReader input = null;
|
||||
Map<Integer,List<BlacklistEntry>> blacklist =
|
||||
new HashMap<Integer,List<BlacklistEntry>>();
|
||||
|
||||
try {
|
||||
input = new FileReader(file);
|
||||
BufferedReader buff = new BufferedReader(input);
|
||||
|
||||
hasOnAcquire = false;
|
||||
|
||||
String line;
|
||||
List<BlacklistEntry> currentEntries = null;
|
||||
while ((line = buff.readLine()) != null) {
|
||||
line = line.trim();
|
||||
|
||||
// Blank line
|
||||
if (line.length() == 0) {
|
||||
continue;
|
||||
} else if (line.charAt(0) == ';' || line.charAt(0) == '#') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.matches("^\\[.*\\]$")) {
|
||||
String[] items = line.substring(1, line.length() - 1).split(",");
|
||||
currentEntries = new ArrayList<BlacklistEntry>();
|
||||
|
||||
for (String item : items) {
|
||||
int id = 0;
|
||||
|
||||
try {
|
||||
id = Integer.parseInt(item.trim());
|
||||
} catch (NumberFormatException e) {
|
||||
id = etc.getDataSource().getItem(item.trim());
|
||||
if (id == 0) {
|
||||
logger.log(Level.WARNING, "WorldGuard: Unknown block name: "
|
||||
+ item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BlacklistEntry entry = new BlacklistEntry(this);
|
||||
if (blacklist.containsKey(id)) {
|
||||
blacklist.get(id).add(entry);
|
||||
} else {
|
||||
List<BlacklistEntry> entries = new ArrayList<BlacklistEntry>();
|
||||
entries.add(entry);
|
||||
blacklist.put(id, entries);
|
||||
}
|
||||
currentEntries.add(entry);
|
||||
}
|
||||
} else if (currentEntries != null) {
|
||||
String[] parts = line.split("=");
|
||||
|
||||
if (parts.length == 1) {
|
||||
logger.log(Level.WARNING, "Found option with no value "
|
||||
+ file.getName() + " for '" + line + "'");
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean unknownOption = false;
|
||||
|
||||
for (BlacklistEntry entry : currentEntries) {
|
||||
if (parts[0].equalsIgnoreCase("ignore-groups")) {
|
||||
entry.setIgnoreGroups(parts[1].split(","));
|
||||
} else if (parts[0].equalsIgnoreCase("on-destroy")) {
|
||||
entry.setDestroyActions(parts[1].split(","));
|
||||
} else if (parts[0].equalsIgnoreCase("on-break")) {
|
||||
entry.setBreakActions(parts[1].split(","));
|
||||
} else if (parts[0].equalsIgnoreCase("on-left")
|
||||
|| parts[0].equalsIgnoreCase("on-destroy-with")) {
|
||||
entry.setDestroyWithActions(parts[1].split(","));
|
||||
} else if (parts[0].equalsIgnoreCase("on-right")
|
||||
|| parts[0].equalsIgnoreCase("on-create")) {
|
||||
entry.setCreateActions(parts[1].split(","));
|
||||
} else if (parts[0].equalsIgnoreCase("on-right-on")
|
||||
|| parts[0].equalsIgnoreCase("on-use")) {
|
||||
entry.setUseActions(parts[1].split(","));
|
||||
} else if (parts[0].equalsIgnoreCase("on-drop")) {
|
||||
entry.setDropActions(parts[1].split(","));
|
||||
} else if (parts[0].equalsIgnoreCase("on-acquire")) {
|
||||
hasOnAcquire = true;
|
||||
entry.setAcquireActions(parts[1].split(","));
|
||||
} else if (parts[0].equalsIgnoreCase("message")) {
|
||||
entry.setMessage(parts[1].trim());
|
||||
} else if (parts[0].equalsIgnoreCase("comment")) {
|
||||
entry.setComment(parts[1].trim());
|
||||
} else {
|
||||
unknownOption = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (unknownOption) {
|
||||
logger.log(Level.WARNING, "Unknown option '" + parts[0]
|
||||
+ "' in " + file.getName() + " for '" + line + "'");
|
||||
}
|
||||
} else {
|
||||
logger.log(Level.WARNING, "Found option with no heading "
|
||||
+ file.getName() + " for '" + line + "'");
|
||||
}
|
||||
}
|
||||
|
||||
this.blacklist = blacklist;
|
||||
} finally {
|
||||
try {
|
||||
if (input != null) {
|
||||
input.close();
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Blacklist contains on-acquire events.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean hasOnAcquire() {
|
||||
return hasOnAcquire;
|
||||
}
|
||||
}
|
||||
@@ -1,694 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class BlacklistEntry {
|
||||
/**
|
||||
* Used to prevent spamming.
|
||||
*/
|
||||
private static Map<String,BlacklistTrackedEvent> lastAffected =
|
||||
new HashMap<String,BlacklistTrackedEvent>();
|
||||
/**
|
||||
* Parent blacklist entry.
|
||||
*/
|
||||
private Blacklist blacklist;
|
||||
/**
|
||||
* List of groups to not affect.
|
||||
*/
|
||||
private Set<String> ignoreGroups;
|
||||
/**
|
||||
* List of actions to perform on destruction.
|
||||
*/
|
||||
private String[] destroyActions;
|
||||
/**
|
||||
* List of actions to perform on break.
|
||||
*/
|
||||
private String[] breakActions;
|
||||
/**
|
||||
* List of actions to perform on left click.
|
||||
*/
|
||||
private String[] destroyWithActions;
|
||||
/**
|
||||
* List of actions to perform on right click.
|
||||
*/
|
||||
private String[] createActions;
|
||||
/**
|
||||
* List of actions to perform on right click upon.
|
||||
*/
|
||||
private String[] useActions;
|
||||
/**
|
||||
* List of actions to perform on drop.
|
||||
*/
|
||||
private String[] dropActions;
|
||||
/**
|
||||
* List of actions to perform on drop.
|
||||
*/
|
||||
private String[] acquireActions;
|
||||
/**
|
||||
* Message for users.
|
||||
*/
|
||||
private String message;
|
||||
/**
|
||||
* Comment for administrators.
|
||||
*/
|
||||
private String comment;
|
||||
|
||||
/**
|
||||
* Used to ignore messages.
|
||||
*/
|
||||
private static ActionHandler silentHandler = new ActionHandler() {
|
||||
public void log(String itemName) {}
|
||||
public void kick(String itemName) {}
|
||||
public void ban(String itemName) {}
|
||||
public void notifyAdmins(String itemName) {}
|
||||
public void tell(String itemName) {}
|
||||
};
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param blacklist
|
||||
*/
|
||||
public BlacklistEntry(Blacklist blacklist) {
|
||||
this.blacklist = blacklist;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ignoreGroups
|
||||
*/
|
||||
public String[] getIgnoreGroups() {
|
||||
return ignoreGroups.toArray(new String[ignoreGroups.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ignoreGroups the ignoreGroups to set
|
||||
*/
|
||||
public void setIgnoreGroups(String[] ignoreGroups) {
|
||||
Set<String> ignoreGroupsSet = new HashSet<String>();
|
||||
for (String group : ignoreGroups) {
|
||||
ignoreGroupsSet.add(group.toLowerCase());
|
||||
}
|
||||
this.ignoreGroups = ignoreGroupsSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String[] getDestroyActions() {
|
||||
return destroyActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param actions
|
||||
*/
|
||||
public void setDestroyActions(String[] actions) {
|
||||
this.destroyActions = actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String[] getBreakActions() {
|
||||
return breakActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param actions
|
||||
*/
|
||||
public void setBreakActions(String[] actions) {
|
||||
this.breakActions = actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String[] getDestroyWithActions() {
|
||||
return destroyWithActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param action
|
||||
*/
|
||||
public void setDestroyWithActions(String[] actions) {
|
||||
this.destroyWithActions = actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the rightClickActions
|
||||
*/
|
||||
public String[] getCreateActions() {
|
||||
return createActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param actions
|
||||
*/
|
||||
public void setCreateActions(String[] actions) {
|
||||
this.createActions = actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String[] getUseActions() {
|
||||
return useActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param actions
|
||||
*/
|
||||
public void setUseActions(String[] actions) {
|
||||
this.useActions = actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String[] getDropActions() {
|
||||
return dropActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param actions
|
||||
*/
|
||||
public void setDropActions(String[] actions) {
|
||||
this.dropActions = actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String[] getAcquireActions() {
|
||||
return acquireActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param actions
|
||||
*/
|
||||
public void setAcquireActions(String[] actions) {
|
||||
this.acquireActions = actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the message
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message the message to set
|
||||
*/
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the comment
|
||||
*/
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param comment the comment to set
|
||||
*/
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this player should be ignored.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean shouldIgnore(Player player) {
|
||||
if (ignoreGroups == null) {
|
||||
return false;
|
||||
}
|
||||
for (String group : player.getGroups()) {
|
||||
if (ignoreGroups.contains(group.toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Announces a message to all administrators.
|
||||
*
|
||||
* @param str
|
||||
*/
|
||||
public void notifyAdmins(String str) {
|
||||
for (Player player : etc.getServer().getPlayerList()) {
|
||||
if (player.canUseCommand("/wprotectalerts")
|
||||
|| player.canUseCommand("/worldguardnotify")) {
|
||||
player.sendMessage(Colors.LightGray + "WG: " + str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ban a player.
|
||||
*
|
||||
* @param player
|
||||
* @param msg
|
||||
*/
|
||||
public void banPlayer(Player player, String msg) {
|
||||
etc.getServer().ban(player.getName());
|
||||
etc.getLoader().callHook(PluginLoader.Hook.BAN, new Object[]{
|
||||
player.getUser(), player.getUser(), msg
|
||||
});
|
||||
player.kick(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on block destruction. Returns true to let the action pass
|
||||
* through.
|
||||
*
|
||||
* @param block
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onDestroy(final Block block, final Player player) {
|
||||
if (destroyActions == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final BlacklistEntry entry = this;
|
||||
|
||||
ActionHandler handler = new ActionHandler() {
|
||||
public void log(String itemName) {
|
||||
blacklist.getLogger().logDestroyAttempt(player, block, comment);
|
||||
}
|
||||
public void kick(String itemName) {
|
||||
player.kick("You are not allowed to destroy " + itemName);
|
||||
}
|
||||
public void ban(String itemName) {
|
||||
entry.banPlayer(player, "Banned: You are not allowed to destroy " + itemName);
|
||||
}
|
||||
public void notifyAdmins(String itemName) {
|
||||
entry.notifyAdmins(player.getName() + " (destroy) " + itemName
|
||||
+ (comment != null ? " (" + comment + ")" : "") + ".");
|
||||
}
|
||||
public void tell(String itemName) {
|
||||
player.sendMessage(Colors.Yellow + "You are not allowed to destroy " + itemName + ".");
|
||||
}
|
||||
};
|
||||
|
||||
return process(block.getType(), player, destroyActions, handler, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on block break. Returns true to let the action pass
|
||||
* through.
|
||||
*
|
||||
* @param block
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onBreak(final Block block, final Player player) {
|
||||
if (breakActions == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final BlacklistEntry entry = this;
|
||||
|
||||
ActionHandler handler = new ActionHandler() {
|
||||
public void log(String itemName) {
|
||||
blacklist.getLogger().logBreakAttempt(player, block, comment);
|
||||
}
|
||||
public void kick(String itemName) {
|
||||
player.kick("You are not allowed to break " + itemName);
|
||||
}
|
||||
public void ban(String itemName) {
|
||||
entry.banPlayer(player, "Banned: You are not allowed to break " + itemName);
|
||||
}
|
||||
public void notifyAdmins(String itemName) {
|
||||
entry.notifyAdmins(player.getName() + " (break) " + itemName
|
||||
+ (comment != null ? " (" + comment + ")" : "") + ".");
|
||||
}
|
||||
public void tell(String itemName) {
|
||||
player.sendMessage(Colors.Yellow + "You are not allowed to break " + itemName + ".");
|
||||
}
|
||||
};
|
||||
|
||||
return process(block.getType(), player, breakActions, handler, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on left click. Returns true to let the action pass through.
|
||||
*
|
||||
* @param item
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onDestroyWith(final int item, final Player player) {
|
||||
if (destroyWithActions == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final BlacklistEntry entry = this;
|
||||
|
||||
ActionHandler handler = new ActionHandler() {
|
||||
public void log(String itemName) {
|
||||
blacklist.getLogger().logDestroyWithAttempt(player, item, comment);
|
||||
}
|
||||
public void kick(String itemName) {
|
||||
player.kick("You can't destroy with " + itemName);
|
||||
}
|
||||
public void ban(String itemName) {
|
||||
entry.banPlayer(player, "Banned: You can't destroy with " + itemName);
|
||||
}
|
||||
public void notifyAdmins(String itemName) {
|
||||
entry.notifyAdmins(player.getName() + " (destroy w/) " + itemName
|
||||
+ (comment != null ? " (" + comment + ")" : "") + ".");
|
||||
}
|
||||
public void tell(String itemName) {
|
||||
player.sendMessage(Colors.Yellow + "You can't destroy with " + itemName + ".");
|
||||
}
|
||||
};
|
||||
|
||||
return process(item, player, destroyWithActions, handler, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on right click. Returns true to let the action pass through.
|
||||
*
|
||||
* @param item
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onCreate(final int item, final Player player) {
|
||||
if (createActions == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final BlacklistEntry entry = this;
|
||||
|
||||
ActionHandler handler = new ActionHandler() {
|
||||
public void log(String itemName) {
|
||||
blacklist.getLogger().logCreateAttempt(player, item, comment);
|
||||
}
|
||||
public void kick(String itemName) {
|
||||
player.kick("You can't place " + itemName);
|
||||
}
|
||||
public void ban(String itemName) {
|
||||
entry.banPlayer(player, "Banned: You can't place " + itemName);
|
||||
}
|
||||
public void notifyAdmins(String itemName) {
|
||||
entry.notifyAdmins(player.getName() + " (place) " + itemName
|
||||
+ (comment != null ? " (" + comment + ")" : "") + ".");
|
||||
}
|
||||
public void tell(String itemName) {
|
||||
player.sendMessage(Colors.Yellow + "You can't place " + itemName + ".");
|
||||
}
|
||||
};
|
||||
|
||||
return process(item, player, createActions, handler, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on right click upon. Returns true to let the action pass through.
|
||||
*
|
||||
* @param item
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onUse(final Block block, final Player player) {
|
||||
if (useActions == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final BlacklistEntry entry = this;
|
||||
|
||||
ActionHandler handler = new ActionHandler() {
|
||||
public void log(String itemName) {
|
||||
blacklist.getLogger().logUseAttempt(player, block, comment);
|
||||
}
|
||||
public void kick(String itemName) {
|
||||
player.kick("You can't use " + itemName);
|
||||
}
|
||||
public void ban(String itemName) {
|
||||
entry.banPlayer(player, "Banned: You can't use " + itemName);
|
||||
}
|
||||
public void notifyAdmins(String itemName) {
|
||||
entry.notifyAdmins(player.getName() + " (use) " + itemName
|
||||
+ (comment != null ? " (" + comment + ")" : "") + ".");
|
||||
}
|
||||
public void tell(String itemName) {
|
||||
player.sendMessage(Colors.Yellow + "You're not allowed to use " + itemName + ".");
|
||||
}
|
||||
};
|
||||
|
||||
return process(block.getType(), player, useActions, handler, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on right click upon. Returns true to let the action pass through.
|
||||
*
|
||||
* @param item
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onSilentUse(final Block block, final Player player) {
|
||||
if (useActions == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return process(block.getType(), player, useActions, silentHandler, false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on item drop. Returns true to let the action pass through.
|
||||
*
|
||||
* @param item
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onDrop(final int item, final Player player) {
|
||||
if (dropActions == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final BlacklistEntry entry = this;
|
||||
|
||||
ActionHandler handler = new ActionHandler() {
|
||||
public void log(String itemName) {
|
||||
blacklist.getLogger().logDropAttempt(player, item, comment);
|
||||
}
|
||||
public void kick(String itemName) {
|
||||
player.kick("You can't drop " + itemName);
|
||||
}
|
||||
public void ban(String itemName) {
|
||||
entry.banPlayer(player, "Banned: You can't drop " + itemName);
|
||||
}
|
||||
public void notifyAdmins(String itemName) {
|
||||
entry.notifyAdmins(player.getName() + " (drop) " + itemName
|
||||
+ (comment != null ? " (" + comment + ")" : "") + ".");
|
||||
}
|
||||
public void tell(String itemName) {
|
||||
player.sendMessage(Colors.Yellow + "You're not allowed to drop " + itemName + ".");
|
||||
}
|
||||
};
|
||||
|
||||
return process(item, player, dropActions, handler, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on item acquire. Returns true to let the action pass through.
|
||||
*
|
||||
* @param item
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onAcquire(final int item, final Player player) {
|
||||
if (acquireActions == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final BlacklistEntry entry = this;
|
||||
|
||||
ActionHandler handler = new ActionHandler() {
|
||||
public void log(String itemName) {
|
||||
blacklist.getLogger().logAcquireAttempt(player, item, comment);
|
||||
}
|
||||
public void kick(String itemName) {
|
||||
player.kick("You can't acquire " + itemName);
|
||||
}
|
||||
public void ban(String itemName) {
|
||||
entry.banPlayer(player, "Banned: You can't acquire " + itemName);
|
||||
}
|
||||
public void notifyAdmins(String itemName) {
|
||||
entry.notifyAdmins(player.getName() + " (acquire) " + itemName
|
||||
+ (comment != null ? " (" + comment + ")" : "") + ".");
|
||||
}
|
||||
public void tell(String itemName) {
|
||||
player.sendMessage(Colors.Yellow + "You're not allowed to acquire " + itemName + ".");
|
||||
}
|
||||
};
|
||||
|
||||
return process(item, player, acquireActions, handler, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on item acquire. Returns true to let the action pass through.
|
||||
*
|
||||
* @param item
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onSilentAcquire(final int item, final Player player) {
|
||||
if (acquireActions == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return process(item, player, acquireActions, silentHandler, false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to handle the actions.
|
||||
*
|
||||
* @param id
|
||||
* @param player
|
||||
* @param actions
|
||||
* @param handler
|
||||
* @param allowRepeat
|
||||
* @param silent
|
||||
* @return
|
||||
*/
|
||||
private boolean process(int id, Player player, String[] actions,
|
||||
ActionHandler handler, boolean allowRepeat, boolean silent) {
|
||||
|
||||
if (shouldIgnore(player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String name = player.getName();
|
||||
long now = System.currentTimeMillis();
|
||||
boolean repeating = false;
|
||||
|
||||
// Check to see whether this event is being repeated
|
||||
BlacklistTrackedEvent tracked = lastAffected.get(name);
|
||||
if (tracked != null) {
|
||||
if (tracked.getId() == id && tracked.getTime() > now - 3000) {
|
||||
repeating = true;
|
||||
} else {
|
||||
tracked.setTime(now);
|
||||
tracked.setId(id);
|
||||
}
|
||||
} else {
|
||||
lastAffected.put(name, new BlacklistTrackedEvent(id, now));
|
||||
}
|
||||
|
||||
boolean ret = true;
|
||||
|
||||
for (String action : actions) {
|
||||
// Deny
|
||||
if (action.equalsIgnoreCase("deny")) {
|
||||
if (silent) {
|
||||
return false;
|
||||
}
|
||||
ret = false;
|
||||
|
||||
// Kick
|
||||
} else if (action.equalsIgnoreCase("kick")) {
|
||||
if (this.message != null) {
|
||||
player.kick(String.format(this.message,
|
||||
etc.getDataSource().getItem(id)));
|
||||
} else {
|
||||
handler.kick(etc.getDataSource().getItem(id));
|
||||
}
|
||||
|
||||
// Ban
|
||||
} else if (action.equalsIgnoreCase("ban")) {
|
||||
handler.ban(etc.getDataSource().getItem(id));
|
||||
if (this.message != null) {
|
||||
banPlayer(player, "Banned: " + String.format(this.message,
|
||||
etc.getDataSource().getItem(id)));
|
||||
} else {
|
||||
handler.ban(etc.getDataSource().getItem(id));
|
||||
}
|
||||
|
||||
} else if (!repeating || allowRepeat) {
|
||||
// Notify
|
||||
if (action.equalsIgnoreCase("notify")) {
|
||||
handler.notifyAdmins(etc.getDataSource().getItem(id));
|
||||
|
||||
// Log
|
||||
} else if (action.equalsIgnoreCase("log")) {
|
||||
handler.log(etc.getDataSource().getItem(id));
|
||||
|
||||
// Tell
|
||||
} else if (action.equalsIgnoreCase("tell")) {
|
||||
if (this.message != null) {
|
||||
player.sendMessage(Colors.Yellow +
|
||||
String.format(message, etc.getDataSource().getItem(id))
|
||||
+ ".");
|
||||
} else {
|
||||
handler.tell(etc.getDataSource().getItem(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forget a player.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public static void forgetPlayer(Player player) {
|
||||
lastAffected.remove(player.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Forget all players.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public static void forgetAllPlayers() {
|
||||
lastAffected.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets called for actions.
|
||||
*/
|
||||
private static interface ActionHandler {
|
||||
public void log(String itemName);
|
||||
public void kick(String itemName);
|
||||
public void ban(String itemName);
|
||||
public void notifyAdmins(String itemName);
|
||||
public void tell(String itemName);
|
||||
}
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class BlacklistLogger implements BlacklistLoggerHandler {
|
||||
/**
|
||||
* List of logger handlers.
|
||||
*/
|
||||
private Set<BlacklistLoggerHandler> handlers
|
||||
= new HashSet<BlacklistLoggerHandler>();
|
||||
|
||||
/**
|
||||
* Add a handler.
|
||||
*
|
||||
* @param handler
|
||||
*/
|
||||
public void addHandler(BlacklistLoggerHandler handler) {
|
||||
handlers.add(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a handler.
|
||||
*
|
||||
* @param handler
|
||||
*/
|
||||
public void removeHandler(BlacklistLoggerHandler handler) {
|
||||
handlers.remove(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a handler.
|
||||
*
|
||||
* @param handler
|
||||
*/
|
||||
public void clearHandlers() {
|
||||
handlers.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a block destroy attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param block
|
||||
*/
|
||||
public void logDestroyAttempt(Player player, Block block, String comment) {
|
||||
for (BlacklistLoggerHandler handler : handlers) {
|
||||
handler.logDestroyAttempt(player, block, comment);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a block break attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param block
|
||||
*/
|
||||
public void logBreakAttempt(Player player, Block block, String comment) {
|
||||
for (BlacklistLoggerHandler handler : handlers) {
|
||||
handler.logBreakAttempt(player, block, comment);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a right click on attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param block
|
||||
*/
|
||||
public void logUseAttempt(Player player, Block block, String comment) {
|
||||
for (BlacklistLoggerHandler handler : handlers) {
|
||||
handler.logUseAttempt(player, block, comment);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Right a left click attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logDestroyWithAttempt(Player player, int item, String comment) {
|
||||
for (BlacklistLoggerHandler handler : handlers) {
|
||||
handler.logDestroyWithAttempt(player, item, comment);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a right click attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logCreateAttempt(Player player, int item, String comment) {
|
||||
for (BlacklistLoggerHandler handler : handlers) {
|
||||
handler.logCreateAttempt(player, item, comment);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a drop attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logDropAttempt(Player player, int item, String comment) {
|
||||
for (BlacklistLoggerHandler handler : handlers) {
|
||||
handler.logDropAttempt(player, item, comment);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an acquire attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logAcquireAttempt(Player player, int item, String comment) {
|
||||
for (BlacklistLoggerHandler handler : handlers) {
|
||||
handler.logAcquireAttempt(player, item, comment);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the connection.
|
||||
*/
|
||||
public void close() {
|
||||
for (BlacklistLoggerHandler handler : handlers) {
|
||||
handler.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface for loggers for the blacklist.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public interface BlacklistLoggerHandler {
|
||||
/**
|
||||
* Log a block destroy attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param block
|
||||
*/
|
||||
public void logDestroyAttempt(Player player, Block block, String comment);
|
||||
/**
|
||||
* Log a block break attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param block
|
||||
*/
|
||||
public void logBreakAttempt(Player player, Block block, String comment);
|
||||
/**
|
||||
* Log a right click on attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param block
|
||||
*/
|
||||
public void logUseAttempt(Player player, Block block, String comment);
|
||||
/**
|
||||
* Right a left click attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logDestroyWithAttempt(Player player, int item, String comment);
|
||||
/**
|
||||
* Log a right click attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logCreateAttempt(Player player, int item, String comment);
|
||||
/**
|
||||
* Log a drop attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logDropAttempt(Player player, int item, String comment);
|
||||
/**
|
||||
* Log an acquire attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logAcquireAttempt(Player player, int item, String comment);
|
||||
/**
|
||||
* Close the logger.
|
||||
*/
|
||||
public void close();
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class BlacklistTrackedEvent {
|
||||
private int id;
|
||||
private long time;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param id
|
||||
* @param time
|
||||
*/
|
||||
public BlacklistTrackedEvent(int id, long time) {
|
||||
this.id = id;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the time
|
||||
*/
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param time the time to set
|
||||
*/
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class ConsoleLoggerHandler implements BlacklistLoggerHandler {
|
||||
/**
|
||||
* Logger.
|
||||
*/
|
||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
|
||||
|
||||
/**
|
||||
* Log a block destroy attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param block
|
||||
*/
|
||||
public void logDestroyAttempt(Player player, Block block, String comment) {
|
||||
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
||||
+ " tried to destroy " + getFriendlyItemName(block.getType())
|
||||
+ (comment != null ? " (" + comment + ")" : ""));
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a block break attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param block
|
||||
*/
|
||||
public void logBreakAttempt(Player player, Block block, String comment) {
|
||||
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
||||
+ " tried to break " + getFriendlyItemName(block.getType())
|
||||
+ (comment != null ? " (" + comment + ")" : ""));
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a right click on attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param block
|
||||
*/
|
||||
public void logUseAttempt(Player player, Block block, String comment) {
|
||||
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
||||
+ " tried to use " + getFriendlyItemName(block.getType())
|
||||
+ (comment != null ? " (" + comment + ")" : ""));
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an attempt to destroy with an item.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logDestroyWithAttempt(Player player, int item, String comment) {
|
||||
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
||||
+ " tried to destroy with " + getFriendlyItemName(item)
|
||||
+ (comment != null ? " (" + comment + ")" : ""));
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a block creation attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logCreateAttempt(Player player, int item, String comment) {
|
||||
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
||||
+ " tried to create " + getFriendlyItemName(item)
|
||||
+ (comment != null ? " (" + comment + ")" : ""));
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a drop attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logDropAttempt(Player player, int item, String comment) {
|
||||
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
||||
+ " tried to drop " + getFriendlyItemName(item)
|
||||
+ (comment != null ? " (" + comment + ")" : ""));
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an acquire attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logAcquireAttempt(Player player, int item, String comment) {
|
||||
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
||||
+ " tried to acquire " + getFriendlyItemName(item)
|
||||
+ (comment != null ? " (" + comment + ")" : ""));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an item's friendly name with its ID.
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
private static String getFriendlyItemName(int id) {
|
||||
return etc.getDataSource().getItem(id) + " (#" + id + ")";
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the connection.
|
||||
*/
|
||||
public void close() {
|
||||
}
|
||||
}
|
||||
@@ -1,215 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class DatabaseLoggerHandler implements BlacklistLoggerHandler {
|
||||
/**
|
||||
* Logger.
|
||||
*/
|
||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
|
||||
|
||||
/**
|
||||
* DSN.
|
||||
*/
|
||||
private String dsn;
|
||||
/**
|
||||
* Username.
|
||||
*/
|
||||
private String user;
|
||||
/**
|
||||
* Password.
|
||||
*/
|
||||
private String pass;
|
||||
/**
|
||||
* Table.
|
||||
*/
|
||||
private String table;
|
||||
/**
|
||||
* Database connection.
|
||||
*/
|
||||
private Connection conn;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param dsn
|
||||
* @param user
|
||||
* @param pass
|
||||
*/
|
||||
public DatabaseLoggerHandler(String dsn, String user, String pass, String table) {
|
||||
this.dsn = dsn;
|
||||
this.user = user;
|
||||
this.pass = pass;
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the database connection.
|
||||
*
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
private Connection getConnection() throws SQLException {
|
||||
if (conn == null || conn.isClosed()) {
|
||||
conn = DriverManager.getConnection(dsn, user, pass);
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an event to the database.
|
||||
*
|
||||
* @param event
|
||||
* @param name
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param item
|
||||
* @param comment
|
||||
*/
|
||||
private void logEvent(String event, String name, int x, int y, int z, int item,
|
||||
String comment) {
|
||||
try {
|
||||
Connection conn = getConnection();
|
||||
PreparedStatement stmt = conn.prepareStatement(
|
||||
"INSERT INTO " + table
|
||||
+ "(event, player, x, y, z, item, time, comment) VALUES "
|
||||
+ "(?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
stmt.setString(1, event);
|
||||
stmt.setString(2, name);
|
||||
stmt.setInt(3, x);
|
||||
stmt.setInt(4, y);
|
||||
stmt.setInt(5, z);
|
||||
stmt.setInt(6, item);
|
||||
stmt.setInt(7, (int)(System.currentTimeMillis() / 1000));
|
||||
stmt.setString(8, comment);
|
||||
stmt.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
logger.log(Level.SEVERE, "Failed to log blacklist event to database: "
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a block destroy attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param block
|
||||
*/
|
||||
public void logDestroyAttempt(Player player, Block block, String comment) {
|
||||
logEvent("DESTROY", player.getName(),
|
||||
block.getX(), block.getY(), block.getZ(), block.getType(),
|
||||
comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a block break attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param block
|
||||
*/
|
||||
public void logBreakAttempt(Player player, Block block, String comment) {
|
||||
logEvent("BREAK", player.getName(),
|
||||
block.getX(), block.getY(), block.getZ(), block.getType(),
|
||||
comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a right click on attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param block
|
||||
*/
|
||||
public void logUseAttempt(Player player, Block block, String comment) {
|
||||
logEvent("USE", player.getName(),
|
||||
block.getX(), block.getY(), block.getZ(), block.getType(),
|
||||
comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Right a left click attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logDestroyWithAttempt(Player player, int item, String comment) {
|
||||
logEvent("DESTROY_WITH", player.getName(),
|
||||
(int)Math.floor(player.getX()), (int)Math.floor(player.getY()),
|
||||
(int)Math.floor(player.getZ()), item, comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a right click attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logCreateAttempt(Player player, int item, String comment) {
|
||||
logEvent("CREATE", player.getName(),
|
||||
(int)Math.floor(player.getX()), (int)Math.floor(player.getY()),
|
||||
(int)Math.floor(player.getZ()), item, comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a drop attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logDropAttempt(Player player, int item, String comment) {
|
||||
logEvent("DROP", player.getName(),
|
||||
(int)Math.floor(player.getX()), (int)Math.floor(player.getY()),
|
||||
(int)Math.floor(player.getZ()), item, comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an aquire attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logAcquireAttempt(Player player, int item, String comment) {
|
||||
logEvent("AQUIRE", player.getName(),
|
||||
(int)Math.floor(player.getX()), (int)Math.floor(player.getY()),
|
||||
(int)Math.floor(player.getZ()), item, comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the connection.
|
||||
*/
|
||||
public void close() {
|
||||
try {
|
||||
if (conn != null && !conn.isClosed()) {
|
||||
conn.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class FileLoggerWriter implements Comparable<FileLoggerWriter> {
|
||||
/**
|
||||
* Path.
|
||||
*/
|
||||
public String path;
|
||||
/**
|
||||
* Writer.
|
||||
*/
|
||||
private BufferedWriter writer;
|
||||
/**
|
||||
* Last use.
|
||||
*/
|
||||
private long lastUse;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param writer
|
||||
*/
|
||||
public FileLoggerWriter(String path, BufferedWriter writer) {
|
||||
this.path = path;
|
||||
this.writer = writer;
|
||||
lastUse = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* File path.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the writer
|
||||
*/
|
||||
public BufferedWriter getWriter() {
|
||||
return writer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lastUse
|
||||
*/
|
||||
public long getLastUse() {
|
||||
return lastUse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update last use time.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public void updateLastUse() {
|
||||
lastUse = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparison function.
|
||||
*
|
||||
* @param other
|
||||
* @return
|
||||
*/
|
||||
public int compareTo(FileLoggerWriter other) {
|
||||
if (lastUse > other.lastUse) {
|
||||
return 1;
|
||||
} else if (lastUse < other.lastUse) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.net.URL;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
|
||||
/**
|
||||
* Entry point for the plugin for hey0's mod.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class WorldGuard extends Plugin {
|
||||
/**
|
||||
* Logger.
|
||||
*/
|
||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
|
||||
/**
|
||||
* Listener for the plugin system.
|
||||
*/
|
||||
private WorldGuardListener listener;
|
||||
|
||||
/**
|
||||
* Initialize the plugin.
|
||||
*/
|
||||
public WorldGuard() {
|
||||
listener = new WorldGuardListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the plugin.
|
||||
*/
|
||||
@Override
|
||||
public void initialize() {
|
||||
PluginLoader loader = etc.getLoader();
|
||||
|
||||
List<String> missingFeatures = new ArrayList<String>();
|
||||
|
||||
registerHook("COMMAND", PluginListener.Priority.MEDIUM);
|
||||
registerHook("SERVERCOMMAND", PluginListener.Priority.MEDIUM);
|
||||
if (!registerHook("EXPLODE", PluginListener.Priority.HIGH)) {
|
||||
missingFeatures.add("disabling TNT or creeper explosions");
|
||||
}
|
||||
if (!registerHook("IGNITE", PluginListener.Priority.HIGH)) {
|
||||
missingFeatures.add("disabling fire or lava fire");
|
||||
}
|
||||
if (!registerHook("FLOW", PluginListener.Priority.HIGH)) {
|
||||
missingFeatures.add("controlling lava flow");
|
||||
missingFeatures.add("sponge simulation");
|
||||
}
|
||||
registerHook("LOGINCHECK", PluginListener.Priority.HIGH);
|
||||
registerHook("LOGIN", PluginListener.Priority.MEDIUM);
|
||||
registerHook("BLOCK_CREATED", PluginListener.Priority.HIGH);
|
||||
registerHook("BLOCK_DESTROYED", PluginListener.Priority.CRITICAL);
|
||||
registerHook("BLOCK_BROKEN", PluginListener.Priority.HIGH);
|
||||
registerHook("DISCONNECT", PluginListener.Priority.HIGH);
|
||||
registerHook("ITEM_DROP", PluginListener.Priority.HIGH);
|
||||
if (!registerHook("ITEM_PICK_UP", PluginListener.Priority.HIGH)) {
|
||||
missingFeatures.add("denying item pickups");
|
||||
missingFeatures.add("the item durability fix");
|
||||
} else {
|
||||
try {
|
||||
Method method =
|
||||
Item.class.getDeclaredMethod("setDamage", new Class[]{ Integer.class });
|
||||
if (method == null) {
|
||||
missingFeatures.add("the item durability fix");
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
missingFeatures.add("the item durability fix");
|
||||
}
|
||||
}
|
||||
registerHook("COMPLEX_BLOCK_CHANGE", PluginListener.Priority.HIGH);
|
||||
registerHook("COMPLEX_BLOCK_SEND", PluginListener.Priority.HIGH);
|
||||
registerHook("INVENTORY_CHANGE", PluginListener.Priority.HIGH);
|
||||
if (!registerHook("BLOCK_PHYSICS", PluginListener.Priority.MEDIUM)) {
|
||||
missingFeatures.add("controlling the physics of gravel, sand, or portal blocks");
|
||||
}
|
||||
if (!registerHook("HEALTH_CHANGE", PluginListener.Priority.MEDIUM)) {
|
||||
missingFeatures.add("god mode");
|
||||
}
|
||||
|
||||
if (missingFeatures.size() > 0) {
|
||||
logger.log(Level.WARNING, "WorldGuard: Your version of hMod does not support "
|
||||
+ concatMissingFeatures(missingFeatures) + ".");
|
||||
} else {
|
||||
logger.log(Level.INFO, "WorldGuard: Your version of hMod appears to"
|
||||
+ " support all features.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditionally registers a hook.
|
||||
*
|
||||
* @param name
|
||||
* @param priority
|
||||
* @return where the hook was registered correctly
|
||||
*/
|
||||
public boolean registerHook(String name, PluginListener.Priority priority) {
|
||||
try {
|
||||
PluginLoader.Hook hook = PluginLoader.Hook.valueOf(name);
|
||||
etc.getLoader().addListener(hook, listener, this, priority);
|
||||
return true;
|
||||
} catch (IllegalArgumentException e) {
|
||||
//logger.log(Level.WARNING, "WorldGuard: Missing hook " + name + "!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the plugin.
|
||||
*/
|
||||
@Override
|
||||
public void enable() {
|
||||
logger.log(Level.INFO, "WorldGuard version " + getVersion() + " loaded");
|
||||
listener.loadConfiguration();
|
||||
|
||||
etc.getInstance().addCommand("/stopfire", "Globally stop fire spread");
|
||||
etc.getInstance().addCommand("/allowfire", "Globally re-enable fire spread");
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the plugin.
|
||||
*/
|
||||
@Override
|
||||
public void disable() {
|
||||
try {
|
||||
listener.disable();
|
||||
BlacklistEntry.forgetAllPlayers();
|
||||
} catch (Throwable t) {
|
||||
}
|
||||
|
||||
etc.getInstance().removeCommand("/stopfire");
|
||||
etc.getInstance().removeCommand("/allowfire");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the WorldGuard version.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getVersion() {
|
||||
try {
|
||||
String classContainer = WorldGuard.class.getProtectionDomain()
|
||||
.getCodeSource().getLocation().toString();
|
||||
URL manifestUrl = new URL("jar:" + classContainer + "!/META-INF/MANIFEST.MF");
|
||||
Manifest manifest = new Manifest(manifestUrl.openStream());
|
||||
Attributes attrib = manifest.getMainAttributes();
|
||||
String ver = (String)attrib.getValue("WorldGuard-Version");
|
||||
return ver != null ? ver : "(unavailable)";
|
||||
} catch (IOException e) {
|
||||
return "(unknown)";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Joins a string from an array of strings.
|
||||
*
|
||||
* @param str
|
||||
* @param delimiter
|
||||
* @return
|
||||
*/
|
||||
private static String concatMissingFeatures(List<String> str) {
|
||||
if (str.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
int size = str.size();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("(1) ");
|
||||
buffer.append(str.get(0));
|
||||
for (int i = 1; i < size; i++) {
|
||||
if (i == size - 1) {
|
||||
buffer.append(" or ");
|
||||
buffer.append("(");
|
||||
buffer.append(i + 1);
|
||||
buffer.append(") ");
|
||||
buffer.append(str.get(i));
|
||||
} else {
|
||||
buffer.append(", ");
|
||||
buffer.append("(");
|
||||
buffer.append(i + 1);
|
||||
buffer.append(") ");
|
||||
buffer.append(str.get(i));
|
||||
}
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,885 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* Event listener for Hey0's server mod.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class WorldGuardListener extends PluginListener {
|
||||
/**
|
||||
* Logger.
|
||||
*/
|
||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
|
||||
/**
|
||||
* Timer for threading.
|
||||
*/
|
||||
private static final Timer timer = new Timer();
|
||||
/**
|
||||
* Random number generator.
|
||||
*/
|
||||
private static Random rand = new Random();
|
||||
|
||||
/**
|
||||
* Plugin host.
|
||||
*/
|
||||
private WorldGuard plugin;
|
||||
/**
|
||||
* Properties file for WorldGuard.
|
||||
*/
|
||||
private PropertiesFile properties = new PropertiesFile("worldguard.properties");
|
||||
/**
|
||||
* List of players with god mode on.
|
||||
*/
|
||||
private Set<String> invinciblePlayers = new HashSet<String>();
|
||||
/**
|
||||
* Used to keep recent join times.
|
||||
*/
|
||||
private Map<String,Long> recentLogins = new HashMap<String,Long>();
|
||||
/**
|
||||
* Used to keep recent spawn times.
|
||||
*/
|
||||
private Map<String,Long> lastSpawn = new HashMap<String,Long>();
|
||||
|
||||
private boolean stopFireSpread = false;
|
||||
private boolean enforceOneSession;
|
||||
private boolean blockCreepers;
|
||||
private boolean blockTNT;
|
||||
private boolean blockLighter;
|
||||
private boolean preventLavaFire;
|
||||
private boolean disableAllFire;
|
||||
private boolean simulateSponge;
|
||||
private int spongeRadius;
|
||||
private boolean itemDurability;
|
||||
private Set<Integer> fireNoSpreadBlocks;
|
||||
private Set<Integer> allowedLavaSpreadOver;
|
||||
private Set<Integer> itemDropBlacklist;
|
||||
private boolean classicWater;
|
||||
private boolean noPhysicsGravel;
|
||||
private boolean noPhysicsSand;
|
||||
private boolean allowPortalAnywhere;
|
||||
private int loginProtection;
|
||||
private int spawnProtection;
|
||||
private boolean kickOnDeath;
|
||||
private Blacklist blacklist;
|
||||
|
||||
/**
|
||||
* Construct the listener.
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
public WorldGuardListener(WorldGuard plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a comma-delimited list to a set of integers.
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
private static Set<Integer> toBlockIDSet(String str) {
|
||||
if (str.trim().length() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String[] items = str.split(",");
|
||||
Set<Integer> result = new HashSet<Integer>();
|
||||
|
||||
for (String item : items) {
|
||||
try {
|
||||
result.add(Integer.parseInt(item.trim()));
|
||||
} catch (NumberFormatException e) {
|
||||
int id = etc.getDataSource().getItem(item.trim());
|
||||
if (id != 0) {
|
||||
result.add(id);
|
||||
} else {
|
||||
logger.log(Level.WARNING, "WorldGuard: Unknown block name: "
|
||||
+ item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the configuration
|
||||
*/
|
||||
public void loadConfiguration() {
|
||||
properties.load();
|
||||
|
||||
recentLogins.clear();
|
||||
|
||||
// Load basic options
|
||||
enforceOneSession = properties.getBoolean("enforce-single-session", true);
|
||||
blockCreepers = properties.getBoolean("block-creepers", false);
|
||||
blockTNT = properties.getBoolean("block-tnt", false);
|
||||
blockLighter = properties.getBoolean("block-lighter", false);
|
||||
preventLavaFire = properties.getBoolean("disable-lava-fire", true);
|
||||
disableAllFire = properties.getBoolean("disable-all-fire-spread", false);
|
||||
itemDropBlacklist = toBlockIDSet(properties.getString("item-drop-blacklist", ""));
|
||||
fireNoSpreadBlocks = toBlockIDSet(properties.getString("disallowed-fire-spread-blocks", ""));
|
||||
allowedLavaSpreadOver = toBlockIDSet(properties.getString("allowed-lava-spread-blocks", ""));
|
||||
classicWater = properties.getBoolean("classic-water", false);
|
||||
simulateSponge = properties.getBoolean("simulate-sponge", true);
|
||||
spongeRadius = Math.max(1, properties.getInt("sponge-radius", 3)) - 1;
|
||||
itemDurability = properties.getBoolean("item-durability", false);
|
||||
noPhysicsGravel = properties.getBoolean("no-physics-gravel", false);
|
||||
noPhysicsSand = properties.getBoolean("no-physics-sand", false);
|
||||
allowPortalAnywhere = properties.getBoolean("allow-portal-anywhere", false);
|
||||
loginProtection = properties.getInt("login-protection", 3);
|
||||
spawnProtection = properties.getInt("spawn-protection", 0);
|
||||
kickOnDeath = properties.getBoolean("kick-on-death", false);
|
||||
|
||||
// Console log configuration
|
||||
boolean logConsole = properties.getBoolean("log-console", true);
|
||||
|
||||
// Database log configuration
|
||||
boolean logDatabase = properties.getBoolean("log-database", false);
|
||||
String dsn = properties.getString("log-database-dsn", "jdbc:mysql://localhost:3306/minecraft");
|
||||
String user = properties.getString("log-database-user", "root");
|
||||
String pass = properties.getString("log-database-pass", "");
|
||||
String table = properties.getString("log-database-table", "blacklist_events");
|
||||
|
||||
// File log configuration
|
||||
boolean logFile = properties.getBoolean("log-file", false);
|
||||
String logFilePattern = properties.getString("log-file-path", "worldguard/logs/%Y-%m-%d.log");
|
||||
int logFileCacheSize = Math.max(1, properties.getInt("log-file-open-files", 10));
|
||||
|
||||
// Load the blacklist
|
||||
try {
|
||||
// If there was an existing blacklist, close loggers
|
||||
if (blacklist != null) {
|
||||
blacklist.getLogger().close();
|
||||
}
|
||||
|
||||
// First load the blacklist data from worldguard-blacklist.txt
|
||||
Blacklist blist = new Blacklist();
|
||||
blist.load(new File("worldguard-blacklist.txt"));
|
||||
|
||||
// If the blacklist is empty, then set the field to null
|
||||
// and save some resources
|
||||
if (blist.isEmpty()) {
|
||||
this.blacklist = null;
|
||||
} else {
|
||||
this.blacklist = blist;
|
||||
logger.log(Level.INFO, "WorldGuard: Blacklist loaded.");
|
||||
|
||||
BlacklistLogger blacklistLogger = blist.getLogger();
|
||||
|
||||
if (logDatabase) {
|
||||
blacklistLogger.addHandler(new DatabaseLoggerHandler(dsn, user, pass, table));
|
||||
}
|
||||
|
||||
if (logConsole) {
|
||||
blacklistLogger.addHandler(new ConsoleLoggerHandler());
|
||||
}
|
||||
|
||||
if (logFile) {
|
||||
FileLoggerHandler handler =
|
||||
new FileLoggerHandler(logFilePattern, logFileCacheSize);
|
||||
blacklistLogger.addHandler(handler);
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
logger.log(Level.WARNING, "WorldGuard blacklist does not exist.");
|
||||
} catch (IOException e) {
|
||||
logger.log(Level.WARNING, "Could not load WorldGuard blacklist: "
|
||||
+ e.getMessage());
|
||||
}
|
||||
|
||||
// Print an overview of settings
|
||||
if (properties.getBoolean("summary-on-start", true)) {
|
||||
logger.log(Level.INFO, enforceOneSession ? "WorldGuard: Single session is enforced."
|
||||
: "WorldGuard: Single session is NOT ENFORCED.");
|
||||
logger.log(Level.INFO, blockTNT ? "WorldGuard: TNT ignition is blocked."
|
||||
: "WorldGuard: TNT ignition is PERMITTED.");
|
||||
logger.log(Level.INFO, blockLighter ? "WorldGuard: Lighters are blocked."
|
||||
: "WorldGuard: Lighters are PERMITTED.");
|
||||
logger.log(Level.INFO, preventLavaFire ? "WorldGuard: Lava fire is blocked."
|
||||
: "WorldGuard: Lava fire is PERMITTED.");
|
||||
if (disableAllFire) {
|
||||
logger.log(Level.INFO, "WorldGuard: All fire spread is disabled.");
|
||||
} else {
|
||||
if (fireNoSpreadBlocks != null) {
|
||||
logger.log(Level.INFO, "WorldGuard: Fire spread is limited to "
|
||||
+ fireNoSpreadBlocks.size() + " block types.");
|
||||
} else {
|
||||
logger.log(Level.INFO, "WorldGuard: Fire spread is UNRESTRICTED.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called during the early login process to check whether or not to kick the
|
||||
* player
|
||||
*
|
||||
* @param user
|
||||
* @return kick reason. null if you don't want to kick the player.
|
||||
*/
|
||||
@Override
|
||||
public String onLoginChecks(String user) {
|
||||
if (enforceOneSession) {
|
||||
for (Player player : etc.getServer().getPlayerList()) {
|
||||
if (player.getName().equalsIgnoreCase(user)) {
|
||||
player.kick("Logged in from another location.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called during the later login process
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
@Override
|
||||
public void onLogin(Player player) {
|
||||
if (stopFireSpread) {
|
||||
player.sendMessage(Colors.Yellow + "Fire spread is currently globally disabled.");
|
||||
}
|
||||
|
||||
if (loginProtection > 0 || spawnProtection > 0 || kickOnDeath) {
|
||||
recentLogins.put(player.getName(), System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before the command is parsed. Return true if you don't want the
|
||||
* command to be parsed.
|
||||
*
|
||||
* @param player
|
||||
* @param split
|
||||
* @return false if you want the command to be parsed.
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(Player player, String[] split) {
|
||||
if (split[0].equalsIgnoreCase("/stopfire") &&
|
||||
player.canUseCommand("/stopfire")) {
|
||||
if (!stopFireSpread) {
|
||||
etc.getServer().messageAll(Colors.Yellow
|
||||
+ "Fire spread has been globally disabled by " + player.getName() + ".");
|
||||
} else {
|
||||
player.sendMessage(Colors.Yellow + "Fire spread was already globally disabled.");
|
||||
}
|
||||
stopFireSpread = true;
|
||||
return true;
|
||||
} else if (split[0].equalsIgnoreCase("/allowfire")
|
||||
&& player.canUseCommand("/stopfire")) {
|
||||
if (stopFireSpread) {
|
||||
etc.getServer().messageAll(Colors.Yellow
|
||||
+ "Fire spread has been globally re-enabled by " + player.getName() + ".");
|
||||
} else {
|
||||
player.sendMessage(Colors.Yellow + "Fire spread was already globally enabled.");
|
||||
}
|
||||
stopFireSpread = false;
|
||||
return true;
|
||||
} else if (split[0].equalsIgnoreCase("/god")
|
||||
&& player.canUseCommand("/god")) {
|
||||
// Allow setting other people invincible
|
||||
if (split.length > 1) {
|
||||
if (!player.canUseCommand("/godother")) {
|
||||
player.sendMessage(Colors.Rose + "You don't have permission to make others invincible.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player other = etc.getServer().matchPlayer(split[1]);
|
||||
if (other == null) {
|
||||
player.sendMessage(Colors.Rose + "Player not found.");
|
||||
} else {
|
||||
if (!invinciblePlayers.contains(other.getName())) {
|
||||
invinciblePlayers.add(other.getName());
|
||||
player.sendMessage(Colors.Yellow + other.getName() + " is now invincible!");
|
||||
other.sendMessage(Colors.Yellow + player.getName() + " has made you invincible!");
|
||||
} else {
|
||||
invinciblePlayers.remove(other.getName());
|
||||
player.sendMessage(Colors.Yellow + other.getName() + " is no longer invincible.");
|
||||
other.sendMessage(Colors.Yellow + player.getName() + " has taken away your invincibility.");
|
||||
}
|
||||
}
|
||||
// Invincibility for one's self
|
||||
} else {
|
||||
if (!invinciblePlayers.contains(player.getName())) {
|
||||
invinciblePlayers.add(player.getName());
|
||||
player.sendMessage(Colors.Yellow + "You are now invincible!");
|
||||
} else {
|
||||
invinciblePlayers.remove(player.getName());
|
||||
player.sendMessage(Colors.Yellow + "You are no longer invincible.");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before the console command is parsed. Return true if you don't
|
||||
* want the server command to be parsed by the server.
|
||||
*
|
||||
* @param split
|
||||
* @return false if you want the command to be parsed.
|
||||
*/
|
||||
@Override
|
||||
public boolean onConsoleCommand(String[] split) {
|
||||
if (split[0].equalsIgnoreCase("fire-stop")) {
|
||||
if (!stopFireSpread) {
|
||||
etc.getServer().messageAll(Colors.Yellow
|
||||
+ "Fire spread has been globally disabled by server console.");
|
||||
logger.log(Level.INFO, "Fire spread is now globally disabled.");
|
||||
} else {
|
||||
logger.log(Level.INFO, "Fire spread was already globally disabled.");
|
||||
}
|
||||
stopFireSpread = true;
|
||||
return true;
|
||||
} else if (split[0].equalsIgnoreCase("fire-allow")) {
|
||||
if (stopFireSpread) {
|
||||
etc.getServer().messageAll(Colors.Yellow
|
||||
+ "Fire spread has been globally re-enabled by server console.");
|
||||
logger.log(Level.INFO, "Fire spread is now globally enabled.");
|
||||
} else {
|
||||
logger.log(Level.INFO, "Fire spread was already globally enabled.");
|
||||
}
|
||||
stopFireSpread = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player drops an item.
|
||||
*
|
||||
* @param player
|
||||
* player who dropped the item
|
||||
* @param item
|
||||
* item that was dropped
|
||||
* @return true if you don't want the dropped item to be spawned in the
|
||||
* world
|
||||
*/
|
||||
@Override
|
||||
public boolean onItemDrop(Player player, Item item) {
|
||||
if (itemDropBlacklist != null) {
|
||||
int n = item.getItemId();
|
||||
if (itemDropBlacklist.contains(n)) {
|
||||
player.sendMessage(Colors.Rose + "Item was destroyed!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (blacklist != null) {
|
||||
if (!blacklist.onDrop(item.getItemId(), player)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*if (!itemDurability) {
|
||||
item.setDamage(0);
|
||||
}*/
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player picks up an item.
|
||||
*
|
||||
* @param player
|
||||
* player who picked up the item
|
||||
* @param item
|
||||
* item that was picked up
|
||||
* @return true if you want to leave the item where it was
|
||||
*/
|
||||
@Override
|
||||
public boolean onItemPickUp(Player player, Item item) {
|
||||
if (blacklist != null && blacklist.hasOnAcquire()) {
|
||||
if (!blacklist.onSilentAcquire(item.getItemId(), player)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player's inventory is modified.
|
||||
*
|
||||
* @param player
|
||||
* player who's inventory was modified
|
||||
* @return true if you want any changes to be reverted
|
||||
*/
|
||||
@Override
|
||||
public boolean onInventoryChange(Player player) {
|
||||
if (blacklist != null && blacklist.hasOnAcquire()) {
|
||||
hl[] items = player.getInventory().getArray();
|
||||
boolean needUpdate = false;
|
||||
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (items[i] != null) {
|
||||
if (!blacklist.onAcquire(items[i].c, player)) {
|
||||
items[i] = null;
|
||||
needUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (needUpdate) {
|
||||
player.getInventory().updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when someone presses right click. If they right clicked with a
|
||||
* block you can return true to cancel that. You can intercept this to add
|
||||
* your own right click actions to different item types (see itemInHand)
|
||||
*
|
||||
* @param player
|
||||
* @param blockPlaced
|
||||
* @param blockClicked
|
||||
* @param itemInHand
|
||||
* @return false if you want the action to go through
|
||||
*/
|
||||
@Override
|
||||
public boolean onBlockCreate(Player player, Block blockPlaced, Block blockClicked,
|
||||
int itemInHand) {
|
||||
if (blacklist != null) {
|
||||
if (!blacklist.onCreate(itemInHand, player)) {
|
||||
// Water/lava bucket fix
|
||||
if (itemInHand == 326 || itemInHand == 327) {
|
||||
final int x = blockPlaced.getX();
|
||||
final int y = blockPlaced.getY();
|
||||
final int z = blockPlaced.getZ();
|
||||
final int existingID = etc.getServer().getBlockIdAt(x, y, z);
|
||||
|
||||
// This is REALLY BAD, but there's no other choice
|
||||
// at the moment that is as reliable
|
||||
timer.schedule(new TimerTask() {
|
||||
public void run() {
|
||||
try {
|
||||
etc.getServer().setBlockAt(existingID, x, y, z);
|
||||
} catch (Throwable t) {}
|
||||
}
|
||||
}, 200); // Just in case
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!blacklist.onUse(blockClicked, player)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (simulateSponge && blockPlaced.getType() == 19) {
|
||||
int ox = blockPlaced.getX();
|
||||
int oy = blockPlaced.getY();
|
||||
int oz = blockPlaced.getZ();
|
||||
|
||||
Server server = etc.getServer();
|
||||
|
||||
for (int cx = -spongeRadius; cx <= spongeRadius; cx++) {
|
||||
for (int cy = -spongeRadius; cy <= spongeRadius; cy++) {
|
||||
for (int cz = -spongeRadius; cz <= spongeRadius; cz++) {
|
||||
int id = server.getBlockIdAt(ox + cx, oy + cy, oz + cz);
|
||||
if (id == 8 || id == 9) {
|
||||
server.setBlockAt(0, ox + cx, oy + cy, oz + cz);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a person left clicks a block.
|
||||
*
|
||||
* @param player
|
||||
* @param block
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onBlockDestroy(Player player, Block block) {
|
||||
int type = block.getType();
|
||||
|
||||
if (blacklist != null) {
|
||||
if (!blacklist.onDestroyWith(player.getItemInHand(), player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!blacklist.onDestroy(block, player)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a person actually breaks the block.
|
||||
*
|
||||
* @param player
|
||||
* @param block
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onBlockBreak(Player player, Block block) {
|
||||
if (blacklist != null) {
|
||||
if (!blacklist.onBreak(block, player)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when either a sign, chest or furnace is changed.
|
||||
*
|
||||
* @param player
|
||||
* player who changed it
|
||||
* @param complexBlock
|
||||
* complex block that changed
|
||||
* @return true if you want any changes to be reverted
|
||||
*/
|
||||
@Override
|
||||
public boolean onComplexBlockChange(Player player, ComplexBlock complexBlock) {
|
||||
if (blacklist != null) {
|
||||
if (complexBlock instanceof Chest) {
|
||||
Block block = new Block(54, complexBlock.getX(),
|
||||
complexBlock.getY(), complexBlock.getZ());
|
||||
|
||||
if (!blacklist.onSilentUse(block, player)) {
|
||||
return true;
|
||||
}
|
||||
} else if (complexBlock instanceof Furnace) {
|
||||
int id = etc.getServer().getBlockIdAt(complexBlock.getX(),
|
||||
complexBlock.getY(), complexBlock.getZ());
|
||||
Block block = new Block(id, complexBlock.getX(),
|
||||
complexBlock.getY(), complexBlock.getZ());
|
||||
|
||||
if (!blacklist.onSilentUse(block, player)) {
|
||||
return true;
|
||||
}
|
||||
} else if (complexBlock instanceof Sign) {
|
||||
int id = etc.getServer().getBlockIdAt(complexBlock.getX(),
|
||||
complexBlock.getY(), complexBlock.getZ());
|
||||
Block block = new Block(id, complexBlock.getX(),
|
||||
complexBlock.getY(), complexBlock.getZ());
|
||||
|
||||
if (!blacklist.onSilentUse(block, player)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when either a sign, chest or furnace is sent to a player
|
||||
*
|
||||
* @param player
|
||||
* player who the block is being sent to
|
||||
* @param complexBlock
|
||||
* complex block that's being sent
|
||||
* @return true if you want the chest, furnace or sign to be empty
|
||||
*/
|
||||
@Override
|
||||
public boolean onSendComplexBlock(Player player, ComplexBlock complexBlock) {
|
||||
if (blacklist != null) {
|
||||
if (complexBlock instanceof Chest) {
|
||||
Block block = new Block(54, complexBlock.getX(),
|
||||
complexBlock.getY(), complexBlock.getZ());
|
||||
|
||||
if (!blacklist.onSilentUse(block, player)) {
|
||||
return true;
|
||||
}
|
||||
} else if (complexBlock instanceof Furnace) {
|
||||
int id = etc.getServer().getBlockIdAt(complexBlock.getX(),
|
||||
complexBlock.getY(), complexBlock.getZ());
|
||||
Block block = new Block(id, complexBlock.getX(),
|
||||
complexBlock.getY(), complexBlock.getZ());
|
||||
|
||||
if (!blacklist.onSilentUse(block, player)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when either a lava block or a lighter tryes to light something on fire.
|
||||
* block status depends on the light source:
|
||||
* 1 = lava.
|
||||
* 2 = lighter (flint + steel).
|
||||
* 3 = spread (dynamic spreading of fire).
|
||||
* @param block
|
||||
* block that the fire wants to spawn in.
|
||||
*
|
||||
* @return true if you dont want the fire to ignite.
|
||||
*/
|
||||
@Override
|
||||
public boolean onIgnite(Block block, Player player) {
|
||||
if (preventLavaFire && block.getStatus() == 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (blockLighter && block.getStatus() == 2) {
|
||||
return !player.canUseCommand("/uselighter")
|
||||
&& !player.canUseCommand("/lighter");
|
||||
}
|
||||
|
||||
if (stopFireSpread && block.getStatus() == 3) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (disableAllFire && block.getStatus() == 3) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (fireNoSpreadBlocks != null && block.getStatus() == 3) {
|
||||
int x = block.getX();
|
||||
int y = block.getY();
|
||||
int z = block.getZ();
|
||||
if (fireNoSpreadBlocks.contains(etc.getServer().getBlockIdAt(x, y - 1, z))
|
||||
|| fireNoSpreadBlocks.contains(etc.getServer().getBlockIdAt(x + 1, y, z))
|
||||
|| fireNoSpreadBlocks.contains(etc.getServer().getBlockIdAt(x - 1, y, z))
|
||||
|| fireNoSpreadBlocks.contains(etc.getServer().getBlockIdAt(x, y, z - 1))
|
||||
|| fireNoSpreadBlocks.contains(etc.getServer().getBlockIdAt(x, y, z + 1))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when a dynamite block or a creeper is triggerd.
|
||||
* block status depends on explosive compound:
|
||||
* 1 = dynamite.
|
||||
* 2 = creeper.
|
||||
* @param block
|
||||
* dynamite block/creeper location block.
|
||||
*
|
||||
* @return true if you dont the block to explode.
|
||||
*/
|
||||
@Override
|
||||
public boolean onExplode(Block block) {
|
||||
if (blockCreepers && block.getStatus() == 2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (blockTNT && block.getStatus() == 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when fluid wants to flow to a certain block.
|
||||
* (10 & 11 for lava and 8 & 9 for water)
|
||||
*
|
||||
* @param blockFrom
|
||||
* the block where the fluid came from.
|
||||
* (blocktype = fluid type)
|
||||
* @param blockTo
|
||||
* the block where fluid wants to flow to.
|
||||
*
|
||||
*
|
||||
* @return true if you dont want the substance to flow.
|
||||
*/
|
||||
@Override
|
||||
public boolean onFlow(Block blockFrom, Block blockTo) {
|
||||
int x = blockFrom.getX();
|
||||
int y = blockFrom.getY();
|
||||
int z = blockFrom.getZ();
|
||||
|
||||
boolean isWater = blockFrom.getType() == 8 || blockFrom.getType() == 9;
|
||||
boolean isLava = blockFrom.getType() == 10 || blockFrom.getType() == 11;
|
||||
|
||||
if (simulateSponge && isWater) {
|
||||
int ox = blockTo.getX();
|
||||
int oy = blockTo.getY();
|
||||
int oz = blockTo.getZ();
|
||||
|
||||
Server server = etc.getServer();
|
||||
|
||||
for (int cx = -spongeRadius; cx <= spongeRadius; cx++) {
|
||||
for (int cy = -spongeRadius; cy <= spongeRadius; cy++) {
|
||||
for (int cz = -spongeRadius; cz <= spongeRadius; cz++) {
|
||||
if (server.getBlockIdAt(ox + cx, oy + cy, oz + cz) == 19) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (classicWater && isWater) {
|
||||
int blockBelow = etc.getServer().getBlockIdAt(blockFrom.getX(), blockFrom.getY() - 1, blockFrom.getZ());
|
||||
if (blockBelow != 0 && blockBelow != 8 && blockBelow != 9) {
|
||||
etc.getServer().setBlockAt(9, blockFrom.getX(), blockFrom.getY(), blockFrom.getZ());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (allowedLavaSpreadOver != null && isLava) {
|
||||
int targetId = etc.getServer().getBlockIdAt(
|
||||
blockTo.getX(), blockTo.getY() - 1, blockTo.getZ());
|
||||
if (!allowedLavaSpreadOver.contains(targetId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the game is checking the physics for a certain block.
|
||||
* This method is called frequently whenever a nearby block is changed,
|
||||
* or if the block has just been placed.
|
||||
* Currently the only supported blocks are sand, gravel and portals.
|
||||
*
|
||||
* @param block Block which requires special physics
|
||||
* @param boolean true if this block has just been placed
|
||||
* @return true if you do want to stop the default physics for this block
|
||||
*/
|
||||
public boolean onBlockPhysics(Block block, boolean placed) {
|
||||
int id = block.getType();
|
||||
|
||||
if (id == 13 && noPhysicsGravel) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (id == 12 && noPhysicsSand) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (id == 90 && allowPortalAnywhere) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a players health changes.
|
||||
* @param player
|
||||
* the player which health is changed.
|
||||
* @param oldValue
|
||||
* old lives value
|
||||
* @param newValue
|
||||
* new lives value
|
||||
* @return
|
||||
* return true to stop the change.
|
||||
*/
|
||||
@Override
|
||||
public boolean onHealthChange(Player player, int oldValue, int newValue) {
|
||||
String playerName = player.getName();
|
||||
|
||||
if (invinciblePlayers.contains(playerName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (loginProtection > 0 || spawnProtection > 0 || kickOnDeath) {
|
||||
long now = System.currentTimeMillis();
|
||||
boolean recentLogin = false;
|
||||
|
||||
if (recentLogins.containsKey(playerName)) {
|
||||
long time = recentLogins.get(playerName);
|
||||
long elapsed = now - time;
|
||||
|
||||
if (loginProtection > 0 && elapsed <= loginProtection * 1000
|
||||
&& newValue < oldValue) {
|
||||
return true;
|
||||
}
|
||||
|
||||
recentLogin = elapsed <= 2000;
|
||||
|
||||
if (elapsed > 2000 && elapsed > loginProtection * 1000) {
|
||||
recentLogins.remove(playerName);
|
||||
}
|
||||
}
|
||||
|
||||
if (kickOnDeath && oldValue == -1 && newValue == 20 && !recentLogin) {
|
||||
player.kick("You died! Rejoin please.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (spawnProtection > 0) {
|
||||
if (oldValue == -1 && newValue == 20 && !recentLogin) { // Player was just respawned
|
||||
lastSpawn.put(player.getName(), now);
|
||||
} else if (lastSpawn.containsKey(playerName)) {
|
||||
long time = lastSpawn.get(playerName);
|
||||
long elapsed = now - time;
|
||||
|
||||
if (elapsed < spawnProtection * 1000) {
|
||||
return newValue < oldValue;
|
||||
} else {
|
||||
lastSpawn.remove(playerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on player disconnect
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
@Override
|
||||
public void onDisconnect(Player player) {
|
||||
BlacklistEntry.forgetPlayer(player);
|
||||
invinciblePlayers.remove(player.getName());
|
||||
recentLogins.remove(player.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Call to disable the plugin.
|
||||
*/
|
||||
public void disable() {
|
||||
if (blacklist != null) {
|
||||
blacklist.getLogger().close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
#
|
||||
# This is the blacklist for WorldGuard. Comments start with # and they
|
||||
# are ignored so you can put your own notes.
|
||||
#
|
||||
# Format:
|
||||
# [item1,item2]
|
||||
# option1=options
|
||||
# event1=whatToDo1,whatToDo2,whatToDo3
|
||||
# event2=whatToDo1,whatToDo2
|
||||
#
|
||||
# Example to block ore and catch some events:
|
||||
# [coalore,goldore,ironore]
|
||||
# on-destroy-with=deny,log,kick
|
||||
# on-create=deny,tell
|
||||
#
|
||||
# Options:
|
||||
# - ignore-groups (comma-delimited list of groups to not affect)
|
||||
# - comment (message for yourself that is printed with 'log' and 'notify')
|
||||
# - message (optional message to show the user instead; %s is the item name)
|
||||
#
|
||||
# Events:
|
||||
# - on-destroy (when a block of this type is being destroyed)
|
||||
# - on-break (when a block of this type is about to be broken)
|
||||
# - on-destroy-with (the item/block held by the user while destroying)
|
||||
# - on-create (the item/block in the user's inventory is being created)
|
||||
# - on-use (the block is right clicked)
|
||||
# - on-drop (the item is being dropped from the player's inventory)
|
||||
# - on-acquire (the item enters a player's inventory via some method)
|
||||
#
|
||||
# Actions (for events):
|
||||
# - deny (deny completely)
|
||||
# - notify (notify admins)
|
||||
# - log (log to console/file/database)
|
||||
# - tell (tell a player that that's not allowed)
|
||||
# - kick (kick player)
|
||||
# - ban (ban player)
|
||||
#
|
||||
# With the on-acquire event, it will completely block item pick ups
|
||||
# (the item will still be on the ground) if you use 'deny' but the other
|
||||
# actions (notify, log, etc.) won't do anything. However, if the player
|
||||
# receives the item via a different method (i.e. from a chest), all actions
|
||||
# will work although the item is removed after a short delay rather than
|
||||
# blocked from the beginning (as it is part client-side).
|
||||
#
|
||||
# Users with the /worldguardnotify permission will be receive notifications.
|
||||
#
|
||||
# -------------
|
||||
#
|
||||
# You can have the same block or item used in two different sections and
|
||||
# they will both apply:
|
||||
#
|
||||
# [goldblock]
|
||||
# ignore-groups=vip
|
||||
# on-destroy=deny
|
||||
# [goldblock]
|
||||
# ignore-groups=admins
|
||||
# on-destroy=tell
|
||||
#
|
||||
# However, some events override others. For example, if you disable both
|
||||
# usage of the diamond pickaxe (with the on-destroy-with event) and
|
||||
# destruction of gold blocks (with the on-destroy event) and a player tries
|
||||
# to destroy a gold block with a diamond pickaxe, because the
|
||||
# on-destroy-with event comes first, the rules for the gold block
|
||||
# will not be applied (but the player will be denied nevertheless).
|
||||
#
|
||||
# -------------
|
||||
#
|
||||
# Some examples follow. Remember to remove # in front if you want them
|
||||
# to work for you!
|
||||
|
||||
#[lavabucket]
|
||||
#ignore-groups=admins,mods
|
||||
#on-destroy-with=deny,log,kick
|
||||
#on-create=deny,tell
|
||||
|
||||
#[coalore,goldore,ironore]
|
||||
#ignore-groups=admins,mods,vip
|
||||
#on-destroy=notify,deny,log
|
||||
|
||||
#[cobblestone]
|
||||
#on-create=deny,tell,log
|
||||
|
||||
#[lever]
|
||||
#on-break=deny
|
||||
|
||||
# This is an example of the 'durability cheat' workaround that destroys your
|
||||
# tool when you drop it
|
||||
#[256,257,258,259,267,268,269,270,271,272,273,274,275,276,277,278,279,283,284,285,286,290,291,292,293,294,346]
|
||||
#on-drop=deny,tell
|
||||
#comment=Durability Hacks
|
||||
#message=Your tool was destroyed
|
||||
@@ -0,0 +1,75 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.gradle.api.internal.HasConvention
|
||||
|
||||
plugins {
|
||||
id("java-library")
|
||||
id("net.ltgt.apt-eclipse")
|
||||
id("net.ltgt.apt-idea")
|
||||
}
|
||||
|
||||
applyPlatformAndCoreConfiguration()
|
||||
applyShadowConfiguration()
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven {
|
||||
name = "paper"
|
||||
url = uri("https://papermc.io/repo/repository/maven-public/")
|
||||
}
|
||||
maven {
|
||||
name = "bstats"
|
||||
url = uri("https://repo.codemc.org/repository/maven-public")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
"compile"(project(":worldguard-core"))
|
||||
//"compile"(project(":worldguard-libs:bukkit"))
|
||||
"api"("com.destroystokyo.paper:paper-api:1.15-R0.1-SNAPSHOT")
|
||||
"implementation"("io.papermc:paperlib:1.0.2")
|
||||
"api"("com.sk89q.worldedit:worldedit-bukkit:${Versions.WORLDEDIT}") { isTransitive = false }
|
||||
"implementation"("com.sk89q:commandbook:3.0-SNAPSHOT") { isTransitive = false }
|
||||
"implementation"("org.bstats:bstats-bukkit:1.5")
|
||||
}
|
||||
|
||||
tasks.named<Upload>("install") {
|
||||
(repositories as HasConvention).convention.getPlugin<MavenRepositoryHandlerConvention>().mavenInstaller {
|
||||
pom.whenConfigured {
|
||||
dependencies.firstOrNull { dep ->
|
||||
dep!!.withGroovyBuilder {
|
||||
getProperty("groupId") == "com.destroystokyo.paper" && getProperty("artifactId") == "paper-api"
|
||||
}
|
||||
}?.withGroovyBuilder {
|
||||
setProperty("groupId", "org.bukkit")
|
||||
setProperty("artifactId", "bukkit")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named<Copy>("processResources") {
|
||||
filesMatching("plugin.yml") {
|
||||
expand("internalVersion" to project.ext["internalVersion"])
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named<Jar>("jar") {
|
||||
manifest {
|
||||
attributes("Implementation-Version" to project.version)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
dependencies {
|
||||
relocate("org.bstats", "com.sk89q.worldguard.bukkit.bstats") {
|
||||
include(dependency("org.bstats:bstats-bukkit:1.5"))
|
||||
}
|
||||
relocate ("io.papermc.lib", "com.sk89q.worldguard.bukkit.paperlib") {
|
||||
include(dependency("io.papermc:paperlib:1.0.2"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named("assemble").configure {
|
||||
dependsOn("shadowJar")
|
||||
}
|
||||
@@ -1,21 +1,24 @@
|
||||
-- Blacklist table for MySQL.
|
||||
-- You must still configure WorldGuard to use your database.
|
||||
-- If you do not plan on using a database for logging blacklist events,
|
||||
-- you do not need to do anything with this file.
|
||||
|
||||
CREATE TABLE `blacklist_events` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`event` varchar(25) NOT NULL,
|
||||
`player` varchar(16) NOT NULL,
|
||||
`x` int(11) NOT NULL,
|
||||
`y` int(11) NOT NULL,
|
||||
`z` int(11) NOT NULL,
|
||||
`item` int(11) NOT NULL,
|
||||
`time` int(11) NOT NULL,
|
||||
`comment` varchar(255) NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
-- Required update if you have an older version of the table:
|
||||
|
||||
ALTER TABLE `blacklist_events` ADD `comment` VARCHAR( 255 ) NULL
|
||||
-- Blacklist table for MySQL.
|
||||
-- You must still configure WorldGuard to use your database.
|
||||
-- If you do not plan on using a database for logging blacklist events,
|
||||
-- you do not need to do anything with this file.
|
||||
|
||||
CREATE TABLE `blacklist_events` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`event` varchar(25) NOT NULL,
|
||||
`world` varchar(32) NOT NULL,
|
||||
`player` varchar(16) NOT NULL,
|
||||
`x` int(11) NOT NULL,
|
||||
`y` int(11) NOT NULL,
|
||||
`z` int(11) NOT NULL,
|
||||
`item` int(11) NOT NULL,
|
||||
`time` int(11) NOT NULL,
|
||||
`comment` varchar(255) NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
-- Required update if you have an older version of the table:
|
||||
|
||||
ALTER TABLE `blacklist_events` ADD `comment` VARCHAR( 255 ) NULL
|
||||
|
||||
ALTER TABLE `blacklist_events` ADD `world` VARCHAR( 32 ) NOT NULL
|
||||
@@ -0,0 +1,114 @@
|
||||
--
|
||||
-- This file only needs to be run if you are using a very old version
|
||||
-- of the region database (before 2011/03/25).
|
||||
--
|
||||
-- Otherwise, WG knows how to update your tables automatically, as well
|
||||
-- as set them up initially.
|
||||
--
|
||||
|
||||
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
|
||||
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
|
||||
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
|
||||
|
||||
ALTER TABLE `region_cuboid` DROP FOREIGN KEY `fk_region_cuboid_region` ;
|
||||
|
||||
ALTER TABLE `region_flag` DROP FOREIGN KEY `fk_flags_region1` ;
|
||||
|
||||
ALTER TABLE `region_groups` DROP FOREIGN KEY `fk_region_groups_region` ;
|
||||
|
||||
ALTER TABLE `region_players` DROP FOREIGN KEY `fk_region_players_user` , DROP FOREIGN KEY `fk_region_players_region` ;
|
||||
|
||||
ALTER TABLE `region_poly2d` DROP FOREIGN KEY `fk_region_poly2d_region` ;
|
||||
|
||||
ALTER TABLE `region_poly2d_point` DROP FOREIGN KEY `fk_region_poly2d_point_region_poly2d` ;
|
||||
|
||||
ALTER TABLE `group` COLLATE = utf8_bin ;
|
||||
|
||||
ALTER TABLE `region_cuboid` COLLATE = utf8_bin , ADD COLUMN `world_id` INT(10) UNSIGNED NOT NULL AFTER `region_id` , CHANGE COLUMN `min_x` `min_x` BIGINT(20) NOT NULL AFTER `world_id` , CHANGE COLUMN `min_y` `min_y` BIGINT(20) NOT NULL AFTER `min_x` , CHANGE COLUMN `max_x` `max_x` BIGINT(20) NOT NULL AFTER `min_z` , CHANGE COLUMN `max_y` `max_y` BIGINT(20) NOT NULL AFTER `max_x` ,
|
||||
ADD CONSTRAINT `fk_region_cuboid_region`
|
||||
FOREIGN KEY (`region_id` , `world_id` )
|
||||
REFERENCES `region` (`id` , `world_id` )
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE
|
||||
, DROP PRIMARY KEY
|
||||
, ADD PRIMARY KEY (`region_id`, `world_id`) ;
|
||||
|
||||
ALTER TABLE `region_flag` COLLATE = utf8_bin , ADD COLUMN `world_id` INT(10) UNSIGNED NOT NULL AFTER `region_id` , CHANGE COLUMN `flag` `flag` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_bin' NOT NULL ,
|
||||
ADD CONSTRAINT `fk_flags_region`
|
||||
FOREIGN KEY (`region_id` , `world_id` )
|
||||
REFERENCES `region` (`id` , `world_id` )
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE
|
||||
, DROP INDEX `fk_flags_region`
|
||||
, ADD INDEX `fk_flags_region` (`region_id` ASC, `world_id` ASC) ;
|
||||
|
||||
ALTER TABLE `region_groups` COLLATE = utf8_bin , ADD COLUMN `world_id` INT(10) UNSIGNED NOT NULL AFTER `region_id` , DROP FOREIGN KEY `fk_region_groups_group` ;
|
||||
|
||||
ALTER TABLE `region_groups`
|
||||
ADD CONSTRAINT `fk_region_groups_group`
|
||||
FOREIGN KEY (`group_id` )
|
||||
REFERENCES `group` (`id` )
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT `fk_region_groups_region`
|
||||
FOREIGN KEY (`region_id` , `world_id` )
|
||||
REFERENCES `region` (`id` , `world_id` )
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE
|
||||
, DROP PRIMARY KEY
|
||||
, ADD PRIMARY KEY (`region_id`, `world_id`, `group_id`) ;
|
||||
|
||||
ALTER TABLE `region_players` COLLATE = utf8_bin , ADD COLUMN `world_id` INT(10) UNSIGNED NOT NULL AFTER `region_id` ,
|
||||
ADD CONSTRAINT `fk_region_users_region`
|
||||
FOREIGN KEY (`region_id` , `world_id` )
|
||||
REFERENCES `region` (`id` , `world_id` )
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT `fk_region_users_user`
|
||||
FOREIGN KEY (`user_id` )
|
||||
REFERENCES `user` (`id` )
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE
|
||||
, DROP PRIMARY KEY
|
||||
, ADD PRIMARY KEY (`region_id`, `world_id`, `user_id`)
|
||||
, ADD INDEX `fk_region_users_user` (`user_id` ASC)
|
||||
, DROP INDEX `fk_region_players_user` ;
|
||||
|
||||
ALTER TABLE `region_poly2d` COLLATE = utf8_bin , ADD COLUMN `world_id` INT(10) UNSIGNED NOT NULL AFTER `region_id` , CHANGE COLUMN `min_y` `min_y` INT(11) NOT NULL AFTER `world_id` ,
|
||||
ADD CONSTRAINT `fk_region_poly2d_region`
|
||||
FOREIGN KEY (`region_id` , `world_id` )
|
||||
REFERENCES `region` (`id` , `world_id` )
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE
|
||||
, DROP PRIMARY KEY
|
||||
, ADD PRIMARY KEY (`region_id`, `world_id`) ;
|
||||
|
||||
ALTER TABLE `region_poly2d_point` COLLATE = utf8_bin , ADD COLUMN `world_id` INT(10) UNSIGNED NOT NULL AFTER `region_id` , CHANGE COLUMN `x` `x` BIGINT(20) NOT NULL AFTER `world_id` ,
|
||||
ADD CONSTRAINT `fk_region_poly2d_point_region_poly2d`
|
||||
FOREIGN KEY (`region_id` , `world_id` )
|
||||
REFERENCES `region_poly2d` (`region_id` , `world_id` )
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE
|
||||
, DROP INDEX `fk_region_poly2d_point_region_poly2d`
|
||||
, ADD INDEX `fk_region_poly2d_point_region_poly2d` (`region_id` ASC, `world_id` ASC) ;
|
||||
|
||||
ALTER TABLE `user` COLLATE = utf8_bin ;
|
||||
|
||||
ALTER TABLE `world` COLLATE = utf8_bin ;
|
||||
|
||||
|
||||
UPDATE `region_cuboid` AS c SET c.`world_id` = (SELECT p.`world_id` FROM `region` AS p WHERE p.`id` = c.`region_id`);
|
||||
|
||||
UPDATE `region_flag` AS c SET c.`world_id` = (SELECT p.`world_id` FROM `region` AS p WHERE p.`id` = c.`region_id`);
|
||||
|
||||
UPDATE `region_groups` AS c SET c.`world_id` = (SELECT p.`world_id` FROM `region` AS p WHERE p.`id` = c.`region_id`);
|
||||
|
||||
UPDATE `region_players` AS c SET c.`world_id` = (SELECT p.`world_id` FROM `region` AS p WHERE p.`id` = c.`region_id`);
|
||||
|
||||
UPDATE `region_poly2d` AS c SET c.`world_id` = (SELECT p.`world_id` FROM `region` AS p WHERE p.`id` = c.`region_id`);
|
||||
|
||||
UPDATE `region_poly2d_point` AS c SET c.`world_id` = (SELECT p.`world_id` FROM `region` AS p WHERE p.`id` = c.`region_id`);
|
||||
|
||||
SET SQL_MODE=@OLD_SQL_MODE;
|
||||
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
|
||||
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldguard.config.YamlConfigurationManager;
|
||||
import com.sk89q.worldedit.util.report.Unreported;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
public class BukkitConfigurationManager extends YamlConfigurationManager {
|
||||
|
||||
@Unreported private WorldGuardPlugin plugin;
|
||||
@Unreported private ConcurrentMap<String, BukkitWorldConfiguration> worlds = new ConcurrentHashMap<>();
|
||||
|
||||
private boolean hasCommandBookGodMode;
|
||||
boolean extraStats;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param plugin The plugin instance
|
||||
*/
|
||||
public BukkitConfigurationManager(WorldGuardPlugin plugin) {
|
||||
super();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public Collection<BukkitWorldConfiguration> getWorldConfigs() {
|
||||
return worlds.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
this.extraStats = getConfig().getBoolean("custom-metrics-charts", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDataFolder() {
|
||||
return plugin.getDataFolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyDefaults() {
|
||||
// Create the default configuration file
|
||||
plugin.createDefaultConfiguration(new File(plugin.getDataFolder(), "config.yml"), "config.yml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
worlds.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postLoad() {
|
||||
// Load configurations for each world
|
||||
for (World world : WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getWorlds()) {
|
||||
get(world);
|
||||
}
|
||||
getConfig().save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configuration for a world.
|
||||
*
|
||||
* @param world The world to get the configuration for
|
||||
* @return {@code world}'s configuration
|
||||
*/
|
||||
@Override
|
||||
public BukkitWorldConfiguration get(World world) {
|
||||
String worldName = world.getName();
|
||||
BukkitWorldConfiguration config = worlds.get(worldName);
|
||||
BukkitWorldConfiguration newConfig = null;
|
||||
|
||||
while (config == null) {
|
||||
if (newConfig == null) {
|
||||
newConfig = new BukkitWorldConfiguration(plugin, worldName, this.getConfig());
|
||||
}
|
||||
worlds.putIfAbsent(world.getName(), newConfig);
|
||||
config = worlds.get(world.getName());
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
public void updateCommandBookGodMode() {
|
||||
try {
|
||||
if (plugin.getServer().getPluginManager().isPluginEnabled("CommandBook")) {
|
||||
Class.forName("com.sk89q.commandbook.GodComponent");
|
||||
hasCommandBookGodMode = true;
|
||||
return;
|
||||
}
|
||||
} catch (ClassNotFoundException ignore) {}
|
||||
hasCommandBookGodMode = false;
|
||||
}
|
||||
|
||||
public boolean hasCommandBookGodMode() {
|
||||
return hasCommandBookGodMode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissionsException;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
import com.sk89q.worldedit.util.paste.ActorCallbackPaste;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.event.debug.CancelLogging;
|
||||
import com.sk89q.worldguard.bukkit.event.debug.LoggingBlockBreakEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.debug.LoggingBlockPlaceEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.debug.LoggingEntityDamageByEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.debug.LoggingPlayerInteractEvent;
|
||||
import com.sk89q.worldguard.bukkit.util.report.CancelReport;
|
||||
import com.sk89q.worldguard.internal.platform.DebugHandler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.util.BlockIterator;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class BukkitDebugHandler implements DebugHandler {
|
||||
|
||||
private static final Logger log = Logger.getLogger(BukkitDebugHandler.class.getCanonicalName());
|
||||
private static final int MAX_TRACE_DISTANCE = 20;
|
||||
|
||||
private final WorldGuardPlugin plugin;
|
||||
|
||||
BukkitDebugHandler(WorldGuardPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulate an event and print its report.
|
||||
*
|
||||
* @param receiver The receiver of the messages
|
||||
* @param target The target
|
||||
* @param event The event
|
||||
* @param stacktraceMode Whether stack traces should be generated and posted
|
||||
* @param <T> The type of event
|
||||
*/
|
||||
private <T extends Event & CancelLogging> void testEvent(CommandSender receiver, Player target, T event, boolean stacktraceMode) throws
|
||||
CommandPermissionsException {
|
||||
boolean isConsole = receiver instanceof ConsoleCommandSender;
|
||||
|
||||
if (!receiver.equals(target)) {
|
||||
if (!isConsole) {
|
||||
log.info(receiver.getName() + " is simulating an event on " + target.getName());
|
||||
}
|
||||
|
||||
target.sendMessage(
|
||||
ChatColor.RED + "(Please ignore any messages that may immediately follow.)");
|
||||
}
|
||||
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
int start = new Exception().getStackTrace().length;
|
||||
CancelReport report = new CancelReport(event, event.getCancels(), start);
|
||||
report.setDetectingPlugin(!stacktraceMode);
|
||||
String result = report.toString();
|
||||
|
||||
if (stacktraceMode) {
|
||||
receiver.sendMessage(ChatColor.GRAY + "The report was printed to console.");
|
||||
log.info("Event report for " + receiver.getName() + ":\n\n" + result);
|
||||
|
||||
plugin.checkPermission(receiver, "worldguard.debug.pastebin");
|
||||
ActorCallbackPaste.pastebin(WorldGuard.getInstance().getSupervisor(), plugin.wrapCommandSender(receiver),
|
||||
result, "Event debugging report: %s.txt");
|
||||
} else {
|
||||
receiver.sendMessage(result.replaceAll("(?m)^", ChatColor.AQUA.toString()));
|
||||
|
||||
if (result.length() >= 500 && !isConsole) {
|
||||
receiver.sendMessage(ChatColor.GRAY + "The report was also printed to console.");
|
||||
log.info("Event report for " + receiver.getName() + ":\n\n" + result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the source of the test.
|
||||
*
|
||||
* @param sender The message sender
|
||||
* @param target The provided target
|
||||
* @param fromTarget Whether the source should be the target
|
||||
* @return The source
|
||||
* @throws CommandException Thrown if a condition is not met
|
||||
*/
|
||||
private Player getSource(CommandSender sender, Player target, boolean fromTarget) throws CommandException {
|
||||
if (fromTarget) {
|
||||
return target;
|
||||
} else {
|
||||
if (sender instanceof Player) {
|
||||
return (Player) sender;
|
||||
} else {
|
||||
throw new CommandException(
|
||||
"If this command is not to be used in-game, use -t to run the test from the viewpoint of the given player rather than yourself.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the first non-air block in a ray trace.
|
||||
*
|
||||
* @param sender The sender
|
||||
* @param target The target
|
||||
* @param fromTarget Whether the trace should originate from the target
|
||||
* @return The block found
|
||||
* @throws CommandException Throw on an incorrect parameter
|
||||
*/
|
||||
private Block traceBlock(CommandSender sender, Player target, boolean fromTarget) throws CommandException {
|
||||
Player source = getSource(sender, target, fromTarget);
|
||||
|
||||
BlockIterator it = new BlockIterator(source);
|
||||
int i = 0;
|
||||
while (it.hasNext() && i < MAX_TRACE_DISTANCE) {
|
||||
Block block = it.next();
|
||||
if (block.getType() != Material.AIR) {
|
||||
return block;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
throw new CommandException("Not currently looking at a block that is close enough.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the first nearby entity in a ray trace.
|
||||
*
|
||||
* @param sender The sender
|
||||
* @param target The target
|
||||
* @param fromTarget Whether the trace should originate from the target
|
||||
* @return The entity found
|
||||
* @throws CommandException Throw on an incorrect parameter
|
||||
*/
|
||||
private Entity traceEntity(CommandSender sender, Player target, boolean fromTarget) throws CommandException {
|
||||
Player source = getSource(sender, target, fromTarget);
|
||||
|
||||
BlockIterator it = new BlockIterator(source);
|
||||
int i = 0;
|
||||
while (it.hasNext() && i < MAX_TRACE_DISTANCE) {
|
||||
Block block = it.next();
|
||||
|
||||
// A very in-accurate and slow search
|
||||
Entity[] entities = block.getChunk().getEntities();
|
||||
for (Entity entity : entities) {
|
||||
if (!entity.equals(target) && entity.getLocation().distanceSquared(block.getLocation()) < 10) {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
throw new CommandException("Not currently looking at an entity that is close enough.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testBreak(Actor sender, LocalPlayer target, boolean fromTarget, boolean stackTraceMode) throws CommandException {
|
||||
CommandSender bukkitSender = plugin.unwrapActor(sender);
|
||||
Player bukkitTarget = BukkitAdapter.adapt(target);
|
||||
|
||||
Block block = traceBlock(bukkitSender, bukkitTarget, fromTarget);
|
||||
sender.print(TextComponent.of("Testing BLOCK BREAK at ", TextColor.AQUA).append(TextComponent.of(block.toString(), TextColor.DARK_AQUA)));
|
||||
LoggingBlockBreakEvent event = new LoggingBlockBreakEvent(block, bukkitTarget);
|
||||
testEvent(bukkitSender, bukkitTarget, event, stackTraceMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testPlace(Actor sender, LocalPlayer target, boolean fromTarget, boolean stackTraceMode) throws CommandException {
|
||||
CommandSender bukkitSender = plugin.unwrapActor(sender);
|
||||
Player bukkitTarget = BukkitAdapter.adapt(target);
|
||||
|
||||
Block block = traceBlock(bukkitSender, bukkitTarget, fromTarget);
|
||||
sender.print(TextComponent.of("Testing BLOCK PLACE at ", TextColor.AQUA).append(TextComponent.of(block.toString(), TextColor.DARK_AQUA)));
|
||||
LoggingBlockPlaceEvent event = new LoggingBlockPlaceEvent(block, block.getState(), block.getRelative(BlockFace.DOWN), bukkitTarget.getItemInHand(), bukkitTarget, true);
|
||||
testEvent(bukkitSender, bukkitTarget, event, stackTraceMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testInteract(Actor sender, LocalPlayer target, boolean fromTarget, boolean stackTraceMode) throws CommandException {
|
||||
CommandSender bukkitSender = plugin.unwrapActor(sender);
|
||||
Player bukkitTarget = BukkitAdapter.adapt(target);
|
||||
|
||||
Block block = traceBlock(bukkitSender, bukkitTarget, fromTarget);
|
||||
sender.print(TextComponent.of("Testing BLOCK INTERACT at ", TextColor.AQUA).append(TextComponent.of(block.toString(), TextColor.DARK_AQUA)));
|
||||
LoggingPlayerInteractEvent event = new LoggingPlayerInteractEvent(bukkitTarget, Action.RIGHT_CLICK_BLOCK, bukkitTarget.getItemInHand(), block, BlockFace.SOUTH);
|
||||
testEvent(bukkitSender, bukkitTarget, event, stackTraceMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testDamage(Actor sender, LocalPlayer target, boolean fromTarget, boolean stackTraceMode) throws CommandException {
|
||||
CommandSender bukkitSender = plugin.unwrapActor(sender);
|
||||
Player bukkitTarget = BukkitAdapter.adapt(target);
|
||||
Entity entity = traceEntity(bukkitSender, bukkitTarget, fromTarget);
|
||||
sender.print(TextComponent.of("Testing ENTITY DAMAGE at ", TextColor.AQUA).append(TextComponent.of(entity.toString(), TextColor.DARK_AQUA)));
|
||||
LoggingEntityDamageByEntityEvent event = new LoggingEntityDamageByEntityEvent(bukkitTarget, entity, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 1);
|
||||
testEvent(bukkitSender, bukkitTarget, event, stackTraceMode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.session.SessionKey;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
class BukkitOfflinePlayer extends BukkitPlayer {
|
||||
|
||||
private final OfflinePlayer player;
|
||||
|
||||
BukkitOfflinePlayer(WorldGuardPlugin plugin, OfflinePlayer offlinePlayer) {
|
||||
super(plugin, offlinePlayer.getPlayer()); // null if they are offline
|
||||
this.player = offlinePlayer;
|
||||
}
|
||||
|
||||
/// ========================================
|
||||
/// These are checked for RegionAssociable
|
||||
/// (to see if a player belongs to a region)
|
||||
/// ========================================
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return player.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return player.getUniqueId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroup(String group) {
|
||||
return plugin.inGroup(player, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return plugin.getGroups(player);
|
||||
}
|
||||
|
||||
/// ==========================================
|
||||
/// None of the following should ever be used.
|
||||
/// ==========================================
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String perm) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kick(String msg) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ban(String msg) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHealth() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHealth(double health) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getFoodLevel() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFoodLevel(double foodLevel) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSaturation() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSaturation(double saturation) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExhaustion() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExhaustion(float exhaustion) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WeatherType getPlayerWeather() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerWeather(WeatherType weather) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetPlayerWeather() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerTimeRelative() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPlayerTimeOffset() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerTime(long time, boolean relative) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetPlayerTime() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printRaw(String msg) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printDebug(String msg) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String msg) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printError(String msg) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseItemStack getItemInHand(HandSide handSide) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveItem(BaseItemStack itemStack) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockBag getInventoryBlockBag() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector3 pos, float pitch, float yaw) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BaseEntity getState() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompassTarget(Location location) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionKey getSessionKey() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> T getFacet(Class<? extends T> cls) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.BanList.Type;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BukkitPlayer extends com.sk89q.worldedit.bukkit.BukkitPlayer implements LocalPlayer {
|
||||
|
||||
protected final WorldGuardPlugin plugin;
|
||||
private final boolean silenced;
|
||||
private String name;
|
||||
|
||||
public BukkitPlayer(WorldGuardPlugin plugin, Player player) {
|
||||
this(plugin, player, false);
|
||||
}
|
||||
|
||||
BukkitPlayer(WorldGuardPlugin plugin, Player player, boolean silenced) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.silenced = silenced;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (this.name == null) {
|
||||
// getName() takes longer than before in newer versions of Minecraft
|
||||
this.name = getPlayer().getName();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroup(String group) {
|
||||
return plugin.inGroup(getPlayer(), group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kick(String msg) {
|
||||
if (!silenced) {
|
||||
getPlayer().kickPlayer(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ban(String msg) {
|
||||
if (!silenced) {
|
||||
Bukkit.getBanList(Type.NAME).addBan(getName(), null, null, null);
|
||||
getPlayer().kickPlayer(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHealth() {
|
||||
return getPlayer().getHealth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHealth(double health) {
|
||||
getPlayer().setHealth(health);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth() {
|
||||
return getPlayer().getMaxHealth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getFoodLevel() {
|
||||
return getPlayer().getFoodLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFoodLevel(double foodLevel) {
|
||||
getPlayer().setFoodLevel((int) foodLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSaturation() {
|
||||
return getPlayer().getSaturation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSaturation(double saturation) {
|
||||
getPlayer().setSaturation((float) saturation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExhaustion() {
|
||||
return getPlayer().getExhaustion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExhaustion(float exhaustion) {
|
||||
getPlayer().setExhaustion(exhaustion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WeatherType getPlayerWeather() {
|
||||
org.bukkit.WeatherType playerWeather = getPlayer().getPlayerWeather();
|
||||
return playerWeather == null ? null : playerWeather == org.bukkit.WeatherType.CLEAR ? WeatherTypes.CLEAR : WeatherTypes.RAIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerWeather(WeatherType weather) {
|
||||
getPlayer().setPlayerWeather(weather == WeatherTypes.CLEAR ? org.bukkit.WeatherType.CLEAR : org.bukkit.WeatherType.DOWNFALL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetPlayerWeather() {
|
||||
getPlayer().resetPlayerWeather();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerTimeRelative() {
|
||||
return getPlayer().isPlayerTimeRelative();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPlayerTimeOffset() {
|
||||
return getPlayer().getPlayerTimeOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerTime(long time, boolean relative) {
|
||||
getPlayer().setPlayerTime(time, relative);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetPlayerTime() {
|
||||
getPlayer().resetPlayerTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireTicks() {
|
||||
return getPlayer().getFireTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFireTicks(int fireTicks) {
|
||||
getPlayer().setFireTicks(fireTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompassTarget(Location location) {
|
||||
getPlayer().setCompassTarget(BukkitAdapter.adapt(location));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(String title, String subtitle) {
|
||||
getPlayer().sendTitle(title, subtitle, -1, -1, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetFallDistance() {
|
||||
getPlayer().setFallDistance(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Location location, String successMessage, String failMessage) {
|
||||
PaperLib.teleportAsync(getPlayer(), BukkitAdapter.adapt(location))
|
||||
.thenApply(success -> {
|
||||
if (success) {
|
||||
print(successMessage);
|
||||
} else {
|
||||
printError(failMessage);
|
||||
}
|
||||
return success;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return plugin.getGroups(getPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printRaw(String msg) {
|
||||
if (!silenced) {
|
||||
super.printRaw(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String perm) {
|
||||
return plugin.hasPermission(getPlayer(), perm);
|
||||
}
|
||||
}
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BukkitRegionContainer extends RegionContainer {
|
||||
|
||||
/**
|
||||
* Invalidation frequency in ticks.
|
||||
*/
|
||||
private static final int CACHE_INVALIDATION_INTERVAL = 2;
|
||||
|
||||
private final WorldGuardPlugin plugin;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param plugin the plugin
|
||||
*/
|
||||
public BukkitRegionContainer(WorldGuardPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
Bukkit.getPluginManager().registerEvents(new Listener() {
|
||||
@EventHandler
|
||||
public void onWorldLoad(WorldLoadEvent event) {
|
||||
load(BukkitAdapter.adapt(event.getWorld()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldUnload(WorldUnloadEvent event) {
|
||||
unload(BukkitAdapter.adapt(event.getWorld()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChunkLoad(ChunkLoadEvent event) {
|
||||
RegionManager manager = get(BukkitAdapter.adapt(event.getWorld()));
|
||||
if (manager != null) {
|
||||
Chunk chunk = event.getChunk();
|
||||
manager.loadChunk(BlockVector2.at(chunk.getX(), chunk.getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChunkUnload(ChunkUnloadEvent event) {
|
||||
RegionManager manager = get(BukkitAdapter.adapt(event.getWorld()));
|
||||
if (manager != null) {
|
||||
Chunk chunk = event.getChunk();
|
||||
manager.unloadChunk(BlockVector2.at(chunk.getX(), chunk.getZ()));
|
||||
}
|
||||
}
|
||||
}, plugin);
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, cache::invalidateAll, CACHE_INVALIDATION_INTERVAL, CACHE_INVALIDATION_INTERVAL);
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
container.shutdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected RegionManager load(World world) {
|
||||
checkNotNull(world);
|
||||
|
||||
WorldConfiguration config = WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(world);
|
||||
if (!config.useRegions) {
|
||||
return null;
|
||||
}
|
||||
|
||||
RegionManager manager;
|
||||
|
||||
synchronized (lock) {
|
||||
manager = container.load(world.getName());
|
||||
|
||||
if (manager != null) {
|
||||
// Bias the region data for loaded chunks
|
||||
List<BlockVector2> positions = new ArrayList<>();
|
||||
for (Chunk chunk : ((BukkitWorld) world).getWorld().getLoadedChunks()) {
|
||||
positions.add(BlockVector2.at(chunk.getX(), chunk.getZ()));
|
||||
}
|
||||
manager.loadChunks(positions);
|
||||
}
|
||||
}
|
||||
|
||||
return manager;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.internal.platform.StringMatcher;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BukkitStringMatcher implements StringMatcher {
|
||||
|
||||
@Override
|
||||
public World matchWorld(Actor sender, String filter) throws CommandException {
|
||||
List<? extends World> worlds = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getWorlds();
|
||||
|
||||
// Handle special hash tag groups
|
||||
if (filter.charAt(0) == '#') {
|
||||
// #main for the main world
|
||||
if (filter.equalsIgnoreCase("#main")) {
|
||||
return worlds.get(0);
|
||||
|
||||
// #normal for the first normal world
|
||||
} else if (filter.equalsIgnoreCase("#normal")) {
|
||||
for (World world : worlds) {
|
||||
if (BukkitAdapter.adapt(world).getEnvironment() == org.bukkit.World.Environment.NORMAL) {
|
||||
return world;
|
||||
}
|
||||
}
|
||||
|
||||
throw new CommandException("No normal world found.");
|
||||
|
||||
// #nether for the first nether world
|
||||
} else if (filter.equalsIgnoreCase("#nether")) {
|
||||
for (World world : worlds) {
|
||||
if (BukkitAdapter.adapt(world).getEnvironment() == org.bukkit.World.Environment.NETHER) {
|
||||
return world;
|
||||
}
|
||||
}
|
||||
|
||||
throw new CommandException("No nether world found.");
|
||||
|
||||
// #end for the first nether world
|
||||
} else if (filter.equalsIgnoreCase("#end")) {
|
||||
for (World world : worlds) {
|
||||
if (BukkitAdapter.adapt(world).getEnvironment() == org.bukkit.World.Environment.THE_END) {
|
||||
return world;
|
||||
}
|
||||
}
|
||||
|
||||
throw new CommandException("No end world found.");
|
||||
|
||||
// Handle getting a world from a player
|
||||
} else if (filter.matches("^#player$")) {
|
||||
String[] parts = filter.split(":", 2);
|
||||
|
||||
// They didn't specify an argument for the player!
|
||||
if (parts.length == 1) {
|
||||
throw new CommandException("Argument expected for #player.");
|
||||
}
|
||||
|
||||
return matchPlayers(sender, parts[1]).iterator().next().getWorld();
|
||||
} else {
|
||||
throw new CommandException("Invalid identifier '" + filter + "'.");
|
||||
}
|
||||
}
|
||||
|
||||
for (World world : worlds) {
|
||||
if (world.getName().equals(filter)) {
|
||||
return world;
|
||||
}
|
||||
}
|
||||
|
||||
throw new CommandException("No world by that exact name found.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocalPlayer> matchPlayerNames(String filter) {
|
||||
List<LocalPlayer> wgPlayers = Bukkit.getServer().getOnlinePlayers().stream().map(player -> WorldGuardPlugin.inst().wrapPlayer(player)).collect(Collectors.toList());
|
||||
|
||||
filter = filter.toLowerCase();
|
||||
|
||||
// Allow exact name matching
|
||||
if (filter.charAt(0) == '@' && filter.length() >= 2) {
|
||||
filter = filter.substring(1);
|
||||
|
||||
for (LocalPlayer player : wgPlayers) {
|
||||
if (player.getName().equalsIgnoreCase(filter)) {
|
||||
List<LocalPlayer> list = new ArrayList<>();
|
||||
list.add(player);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
return new ArrayList<>();
|
||||
// Allow partial name matching
|
||||
} else if (filter.charAt(0) == '*' && filter.length() >= 2) {
|
||||
filter = filter.substring(1);
|
||||
|
||||
List<LocalPlayer> list = new ArrayList<>();
|
||||
|
||||
for (LocalPlayer player : wgPlayers) {
|
||||
if (player.getName().toLowerCase().contains(filter)) {
|
||||
list.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
|
||||
// Start with name matching
|
||||
} else {
|
||||
List<LocalPlayer> list = new ArrayList<>();
|
||||
|
||||
for (LocalPlayer player : wgPlayers) {
|
||||
if (player.getName().toLowerCase().startsWith(filter)) {
|
||||
list.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends LocalPlayer> matchPlayers(Actor source, String filter) throws CommandException {
|
||||
if (Bukkit.getServer().getOnlinePlayers().isEmpty()) {
|
||||
throw new CommandException("No players matched query.");
|
||||
}
|
||||
|
||||
List<LocalPlayer> wgPlayers = Bukkit.getServer().getOnlinePlayers().stream().map(player -> WorldGuardPlugin.inst().wrapPlayer(player)).collect(Collectors.toList());
|
||||
|
||||
if (filter.equals("*")) {
|
||||
return checkPlayerMatch(wgPlayers);
|
||||
}
|
||||
|
||||
// Handle special hash tag groups
|
||||
if (filter.charAt(0) == '#') {
|
||||
// Handle #world, which matches player of the same world as the
|
||||
// calling source
|
||||
if (filter.equalsIgnoreCase("#world")) {
|
||||
List<LocalPlayer> players = new ArrayList<>();
|
||||
LocalPlayer sourcePlayer = WorldGuard.getInstance().checkPlayer(source);
|
||||
World sourceWorld = sourcePlayer.getWorld();
|
||||
|
||||
for (LocalPlayer player : wgPlayers) {
|
||||
if (player.getWorld().equals(sourceWorld)) {
|
||||
players.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
return checkPlayerMatch(players);
|
||||
|
||||
// Handle #near, which is for nearby players.
|
||||
} else if (filter.equalsIgnoreCase("#near")) {
|
||||
List<LocalPlayer> players = new ArrayList<>();
|
||||
LocalPlayer sourcePlayer = WorldGuard.getInstance().checkPlayer(source);
|
||||
World sourceWorld = sourcePlayer.getWorld();
|
||||
Vector3 sourceVector = sourcePlayer.getLocation().toVector();
|
||||
|
||||
for (LocalPlayer player : wgPlayers) {
|
||||
if (player.getWorld().equals(sourceWorld) && player.getLocation().toVector().distanceSq(sourceVector) < 900) {
|
||||
players.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
return checkPlayerMatch(players);
|
||||
|
||||
} else {
|
||||
throw new CommandException("Invalid group '" + filter + "'.");
|
||||
}
|
||||
}
|
||||
|
||||
List<LocalPlayer> players = matchPlayerNames(filter);
|
||||
|
||||
return checkPlayerMatch(players);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Actor matchPlayerOrConsole(Actor sender, String filter) throws CommandException {
|
||||
// Let's see if console is wanted
|
||||
if (filter.equalsIgnoreCase("#console")
|
||||
|| filter.equalsIgnoreCase("*console*")
|
||||
|| filter.equalsIgnoreCase("!")) {
|
||||
return WorldGuardPlugin.inst().wrapCommandSender(Bukkit.getServer().getConsoleSender());
|
||||
}
|
||||
|
||||
return matchSinglePlayer(sender, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorldByName(String worldName) {
|
||||
final org.bukkit.World bukkitW = Bukkit.getServer().getWorld(worldName);
|
||||
if (bukkitW == null) {
|
||||
return null;
|
||||
}
|
||||
return BukkitAdapter.adapt(bukkitW);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String replaceMacros(Actor sender, String message) {
|
||||
Collection<? extends Player> online = Bukkit.getServer().getOnlinePlayers();
|
||||
|
||||
message = message.replace("%name%", sender.getName());
|
||||
message = message.replace("%id%", sender.getUniqueId().toString());
|
||||
message = message.replace("%online%", String.valueOf(online.size()));
|
||||
|
||||
if (sender instanceof LocalPlayer) {
|
||||
LocalPlayer player = (LocalPlayer) sender;
|
||||
World world = (World) player.getExtent();
|
||||
|
||||
message = message.replace("%world%", world.getName());
|
||||
message = message.replace("%health%", String.valueOf(player.getHealth()));
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.blacklist.target.BlockTarget;
|
||||
import com.sk89q.worldguard.blacklist.target.ItemTarget;
|
||||
import com.sk89q.worldguard.blacklist.target.Target;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class BukkitUtil {
|
||||
|
||||
private BukkitUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given potion is a vial of water.
|
||||
*
|
||||
* @param item the item to check
|
||||
* @return true if it's a water vial
|
||||
*/
|
||||
public static boolean isWaterPotion(ItemStack item) {
|
||||
return (item.getDurability() & 0x3F) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get just the potion effect bits. This is to work around bugs with potion
|
||||
* parsing.
|
||||
*
|
||||
* @param item item
|
||||
* @return new bits
|
||||
*/
|
||||
public static int getPotionEffectBits(ItemStack item) {
|
||||
return item.getDurability() & 0x3F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a blacklist target for the given block.
|
||||
*
|
||||
* @param block the block
|
||||
* @param effectiveMaterial The effective material, if different
|
||||
* @return a target
|
||||
*/
|
||||
public static Target createTarget(Block block, Material effectiveMaterial) {
|
||||
checkNotNull(block);
|
||||
checkNotNull(block.getType());
|
||||
if (block.getType() == effectiveMaterial) {
|
||||
return createTarget(block.getType());
|
||||
} else {
|
||||
return createTarget(effectiveMaterial);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a blacklist target for the given block.
|
||||
*
|
||||
* @param block the block
|
||||
* @return a target
|
||||
*/
|
||||
public static Target createTarget(Block block) {
|
||||
checkNotNull(block);
|
||||
checkNotNull(block.getType());
|
||||
return createTarget(block.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a blacklist target for the given item.
|
||||
*
|
||||
* @param item the item
|
||||
* @return a target
|
||||
*/
|
||||
public static Target createTarget(ItemStack item) {
|
||||
checkNotNull(item);
|
||||
checkNotNull(item.getType());
|
||||
return createTarget(item.getType()); // Delegate it, ItemStacks can contain both Blocks and Items in Spigot
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a blacklist target for the given material.
|
||||
*
|
||||
* @param material the material
|
||||
* @return a target
|
||||
*/
|
||||
public static Target createTarget(Material material) {
|
||||
checkNotNull(material);
|
||||
if (material.isBlock()) {
|
||||
return new BlockTarget(BukkitAdapter.asBlockType(material));
|
||||
} else {
|
||||
return new ItemTarget(BukkitAdapter.asItemType(material));
|
||||
}
|
||||
}
|
||||
}
|
||||
+432
@@ -0,0 +1,432 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLFormat;
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.report.Unreported;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.Blacklist;
|
||||
import com.sk89q.worldguard.blacklist.BlacklistLoggerHandler;
|
||||
import com.sk89q.worldguard.blacklist.logger.ConsoleHandler;
|
||||
import com.sk89q.worldguard.blacklist.logger.DatabaseHandler;
|
||||
import com.sk89q.worldguard.blacklist.logger.FileHandler;
|
||||
import com.sk89q.worldguard.blacklist.target.TargetMatcherParseException;
|
||||
import com.sk89q.worldguard.blacklist.target.TargetMatcherParser;
|
||||
import com.sk89q.worldguard.bukkit.chest.BukkitSignChestProtection;
|
||||
import com.sk89q.worldguard.bukkit.internal.TargetMatcherSet;
|
||||
import com.sk89q.worldguard.chest.ChestProtection;
|
||||
import com.sk89q.worldguard.commands.CommandUtils;
|
||||
import com.sk89q.worldguard.config.YamlWorldConfiguration;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.yaml.snakeyaml.parser.ParserException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Holds the configuration for individual worlds.
|
||||
*
|
||||
* @author sk89q
|
||||
* @author Michael
|
||||
*/
|
||||
public class BukkitWorldConfiguration extends YamlWorldConfiguration {
|
||||
|
||||
private static final TargetMatcherParser matcherParser = new TargetMatcherParser();
|
||||
|
||||
@Unreported private String worldName;
|
||||
|
||||
@Unreported private ChestProtection chestProtection = new BukkitSignChestProtection();
|
||||
|
||||
/* Configuration data start */
|
||||
public Set<PotionEffectType> blockPotions;
|
||||
public TargetMatcherSet allowAllInteract;
|
||||
public TargetMatcherSet blockUseAtFeet;
|
||||
public boolean usePaperEntityOrigin;
|
||||
/* Configuration data end */
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param plugin The WorldGuardPlugin instance
|
||||
* @param worldName The world name that this BukkitWorldConfiguration is for.
|
||||
* @param parentConfig The parent configuration to read defaults from
|
||||
*/
|
||||
public BukkitWorldConfiguration(WorldGuardPlugin plugin, String worldName, YAMLProcessor parentConfig) {
|
||||
File baseFolder = new File(plugin.getDataFolder(), "worlds/" + worldName);
|
||||
File configFile = new File(baseFolder, "config.yml");
|
||||
blacklistFile = new File(baseFolder, "blacklist.txt");
|
||||
|
||||
this.worldName = worldName;
|
||||
this.parentConfig = parentConfig;
|
||||
|
||||
plugin.createDefaultConfiguration(configFile, "config_world.yml");
|
||||
plugin.createDefaultConfiguration(blacklistFile, "blacklist.txt");
|
||||
|
||||
config = new YAMLProcessor(configFile, true, YAMLFormat.EXTENDED);
|
||||
loadConfiguration();
|
||||
|
||||
if (summaryOnStart) {
|
||||
log.info("Loaded configuration for world '" + worldName + "'");
|
||||
}
|
||||
}
|
||||
|
||||
private TargetMatcherSet getTargetMatchers(String node) {
|
||||
TargetMatcherSet set = new TargetMatcherSet();
|
||||
List<String> inputs = parentConfig.getStringList(node, null);
|
||||
|
||||
if (inputs == null || inputs.isEmpty()) {
|
||||
parentConfig.setProperty(node, new ArrayList<String>());
|
||||
return set;
|
||||
}
|
||||
|
||||
for (String input : inputs) {
|
||||
try {
|
||||
set.add(matcherParser.fromInput(input));
|
||||
} catch (TargetMatcherParseException e) {
|
||||
log.warning("Failed to parse the block / item type specified as '" + input + "'");
|
||||
}
|
||||
}
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the configuration.
|
||||
*/
|
||||
@Override
|
||||
public void loadConfiguration() {
|
||||
try {
|
||||
config.load();
|
||||
} catch (IOException e) {
|
||||
log.log(Level.SEVERE, "Error reading configuration for world " + worldName + ": ", e);
|
||||
} catch (ParserException e) {
|
||||
log.severe("Error parsing configuration for world " + worldName + ". ");
|
||||
throw e;
|
||||
}
|
||||
|
||||
summaryOnStart = getBoolean("summary-on-start", true);
|
||||
opPermissions = getBoolean("op-permissions", true);
|
||||
|
||||
buildPermissions = getBoolean("build-permission-nodes.enable", false);
|
||||
buildPermissionDenyMessage = CommandUtils.replaceColorMacros(
|
||||
getString("build-permission-nodes.deny-message", "&eSorry, but you are not permitted to do that here."));
|
||||
|
||||
strictEntitySpawn = getBoolean("event-handling.block-entity-spawns-with-untraceable-cause", false);
|
||||
allowAllInteract = getTargetMatchers("event-handling.interaction-whitelist");
|
||||
blockUseAtFeet = getTargetMatchers("event-handling.emit-block-use-at-feet");
|
||||
ignoreHopperMoveEvents = getBoolean("event-handling.ignore-hopper-item-move-events", false);
|
||||
|
||||
usePaperEntityOrigin = getBoolean("regions.use-paper-entity-origin", false);
|
||||
|
||||
itemDurability = getBoolean("protection.item-durability", true);
|
||||
removeInfiniteStacks = getBoolean("protection.remove-infinite-stacks", false);
|
||||
disableExpDrops = getBoolean("protection.disable-xp-orb-drops", false);
|
||||
disableObsidianGenerators = getBoolean("protection.disable-obsidian-generators", false);
|
||||
|
||||
blockPotions = new HashSet<>();
|
||||
for (String potionName : getStringList("gameplay.block-potions", null)) {
|
||||
PotionEffectType effect = PotionEffectType.getByName(potionName);
|
||||
|
||||
if (effect == null) {
|
||||
log.warning("Unknown potion effect type '" + potionName + "'");
|
||||
} else {
|
||||
blockPotions.add(effect);
|
||||
}
|
||||
}
|
||||
blockPotionsAlways = getBoolean("gameplay.block-potions-overly-reliably", false);
|
||||
disableConduitEffects = getBoolean("gameplay.disable-conduit-effects", false);
|
||||
|
||||
simulateSponge = getBoolean("simulation.sponge.enable", false);
|
||||
spongeRadius = Math.max(1, getInt("simulation.sponge.radius", 3)) - 1;
|
||||
redstoneSponges = getBoolean("simulation.sponge.redstone", false);
|
||||
|
||||
pumpkinScuba = getBoolean("default.pumpkin-scuba", false);
|
||||
disableHealthRegain = getBoolean("default.disable-health-regain", false);
|
||||
|
||||
noPhysicsGravel = getBoolean("physics.no-physics-gravel", false);
|
||||
noPhysicsSand = getBoolean("physics.no-physics-sand", false);
|
||||
ropeLadders = getBoolean("physics.vine-like-rope-ladders", false);
|
||||
allowPortalAnywhere = getBoolean("physics.allow-portal-anywhere", false);
|
||||
preventWaterDamage = new HashSet<>(convertLegacyBlocks(getStringList("physics.disable-water-damage-blocks", null)));
|
||||
|
||||
blockTNTExplosions = getBoolean("ignition.block-tnt", false);
|
||||
blockTNTBlockDamage = getBoolean("ignition.block-tnt-block-damage", false);
|
||||
blockLighter = getBoolean("ignition.block-lighter", false);
|
||||
|
||||
preventLavaFire = getBoolean("fire.disable-lava-fire-spread", false);
|
||||
disableFireSpread = getBoolean("fire.disable-all-fire-spread", false);
|
||||
disableFireSpreadBlocks = new HashSet<>(convertLegacyBlocks(getStringList("fire.disable-fire-spread-blocks", null)));
|
||||
allowedLavaSpreadOver = new HashSet<>(convertLegacyBlocks(getStringList("fire.lava-spread-blocks", null)));
|
||||
|
||||
blockCreeperExplosions = getBoolean("mobs.block-creeper-explosions", false);
|
||||
blockCreeperBlockDamage = getBoolean("mobs.block-creeper-block-damage", false);
|
||||
blockWitherExplosions = getBoolean("mobs.block-wither-explosions", false);
|
||||
blockWitherBlockDamage = getBoolean("mobs.block-wither-block-damage", false);
|
||||
blockWitherSkullExplosions = getBoolean("mobs.block-wither-skull-explosions", false);
|
||||
blockWitherSkullBlockDamage = getBoolean("mobs.block-wither-skull-block-damage", false);
|
||||
blockEnderDragonBlockDamage = getBoolean("mobs.block-enderdragon-block-damage", false);
|
||||
blockEnderDragonPortalCreation = getBoolean("mobs.block-enderdragon-portal-creation", false);
|
||||
blockFireballExplosions = getBoolean("mobs.block-fireball-explosions", false);
|
||||
blockFireballBlockDamage = getBoolean("mobs.block-fireball-block-damage", false);
|
||||
antiWolfDumbness = getBoolean("mobs.anti-wolf-dumbness", false);
|
||||
allowTamedSpawns = getBoolean("mobs.allow-tamed-spawns", true);
|
||||
disableEndermanGriefing = getBoolean("mobs.disable-enderman-griefing", false);
|
||||
disableSnowmanTrails = getBoolean("mobs.disable-snowman-trails", false);
|
||||
blockEntityPaintingDestroy = getBoolean("mobs.block-painting-destroy", false);
|
||||
blockEntityItemFrameDestroy = getBoolean("mobs.block-item-frame-destroy", false);
|
||||
blockEntityArmorStandDestroy = getBoolean("mobs.block-armor-stand-destroy", false);
|
||||
blockPluginSpawning = getBoolean("mobs.block-plugin-spawning", true);
|
||||
blockGroundSlimes = getBoolean("mobs.block-above-ground-slimes", false);
|
||||
blockOtherExplosions = getBoolean("mobs.block-other-explosions", false);
|
||||
blockZombieDoorDestruction = getBoolean("mobs.block-zombie-door-destruction", false);
|
||||
|
||||
disableFallDamage = getBoolean("player-damage.disable-fall-damage", false);
|
||||
disableLavaDamage = getBoolean("player-damage.disable-lava-damage", false);
|
||||
disableFireDamage = getBoolean("player-damage.disable-fire-damage", false);
|
||||
disableLightningDamage = getBoolean("player-damage.disable-lightning-damage", false);
|
||||
disableDrowningDamage = getBoolean("player-damage.disable-drowning-damage", false);
|
||||
disableSuffocationDamage = getBoolean("player-damage.disable-suffocation-damage", false);
|
||||
disableContactDamage = getBoolean("player-damage.disable-contact-damage", false);
|
||||
teleportOnSuffocation = getBoolean("player-damage.teleport-on-suffocation", false);
|
||||
disableVoidDamage = getBoolean("player-damage.disable-void-damage", false);
|
||||
teleportOnVoid = getBoolean("player-damage.teleport-on-void-falling", false);
|
||||
safeFallOnVoid = getBoolean("player-damage.reset-fall-on-void-teleport", false);
|
||||
disableExplosionDamage = getBoolean("player-damage.disable-explosion-damage", false);
|
||||
disableMobDamage = getBoolean("player-damage.disable-mob-damage", false);
|
||||
disableDeathMessages = getBoolean("player-damage.disable-death-messages", false);
|
||||
|
||||
signChestProtection = getBoolean("chest-protection.enable", false);
|
||||
disableSignChestProtectionCheck = getBoolean("chest-protection.disable-off-check", false);
|
||||
|
||||
disableCreatureCropTrampling = getBoolean("crops.disable-creature-trampling", false);
|
||||
disablePlayerCropTrampling = getBoolean("crops.disable-player-trampling", false);
|
||||
|
||||
disallowedLightningBlocks = new HashSet<>(convertLegacyBlocks(getStringList("weather.prevent-lightning-strike-blocks", null)));
|
||||
preventLightningFire = getBoolean("weather.disable-lightning-strike-fire", false);
|
||||
disableThunder = getBoolean("weather.disable-thunderstorm", false);
|
||||
disableWeather = getBoolean("weather.disable-weather", false);
|
||||
disablePigZap = getBoolean("weather.disable-pig-zombification", false);
|
||||
disableVillagerZap = getBoolean("weather.disable-villager-witchification", false);
|
||||
disableCreeperPower = getBoolean("weather.disable-powered-creepers", false);
|
||||
alwaysRaining = getBoolean("weather.always-raining", false);
|
||||
alwaysThundering = getBoolean("weather.always-thundering", false);
|
||||
|
||||
disableMushroomSpread = getBoolean("dynamics.disable-mushroom-spread", false);
|
||||
disableIceMelting = getBoolean("dynamics.disable-ice-melting", false);
|
||||
disableSnowMelting = getBoolean("dynamics.disable-snow-melting", false);
|
||||
disableSnowFormation = getBoolean("dynamics.disable-snow-formation", false);
|
||||
disableIceFormation = getBoolean("dynamics.disable-ice-formation", false);
|
||||
disableLeafDecay = getBoolean("dynamics.disable-leaf-decay", false);
|
||||
disableGrassGrowth = getBoolean("dynamics.disable-grass-growth", false);
|
||||
disableMyceliumSpread = getBoolean("dynamics.disable-mycelium-spread", false);
|
||||
disableVineGrowth = getBoolean("dynamics.disable-vine-growth", false);
|
||||
disableCropGrowth = getBoolean("dynamics.disable-crop-growth", false);
|
||||
disableSoilDehydration = getBoolean("dynamics.disable-soil-dehydration", false);
|
||||
allowedSnowFallOver = new HashSet<>(convertLegacyBlocks(getStringList("dynamics.snow-fall-blocks", null)));
|
||||
|
||||
useRegions = getBoolean("regions.enable", true);
|
||||
regionInvinciblityRemovesMobs = getBoolean("regions.invincibility-removes-mobs", false);
|
||||
regionCancelEmptyChatEvents = getBoolean("regions.cancel-chat-without-recipients", true);
|
||||
regionNetherPortalProtection = getBoolean("regions.nether-portal-protection", false);
|
||||
fakePlayerBuildOverride = getBoolean("regions.fake-player-build-override", true);
|
||||
explosionFlagCancellation = getBoolean("regions.explosion-flags-block-entity-damage", true);
|
||||
highFreqFlags = getBoolean("regions.high-frequency-flags", false);
|
||||
checkLiquidFlow = getBoolean("regions.protect-against-liquid-flow", false);
|
||||
regionWand = convertLegacyItem(getString("regions.wand", ItemTypes.LEATHER.getId()));
|
||||
maxClaimVolume = getInt("regions.max-claim-volume", 30000);
|
||||
claimOnlyInsideExistingRegions = getBoolean("regions.claim-only-inside-existing-regions", false);
|
||||
boundedLocationFlags = getBoolean("regions.location-flags-only-inside-regions", false);
|
||||
|
||||
maxRegionCountPerPlayer = getInt("regions.max-region-count-per-player.default", 7);
|
||||
maxRegionCounts = new HashMap<>();
|
||||
maxRegionCounts.put(null, maxRegionCountPerPlayer);
|
||||
|
||||
for (String key : getKeys("regions.max-region-count-per-player")) {
|
||||
if (!key.equalsIgnoreCase("default")) {
|
||||
Object val = getProperty("regions.max-region-count-per-player." + key);
|
||||
if (val instanceof Number) {
|
||||
maxRegionCounts.put(key, ((Number) val).intValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// useiConomy = getBoolean("iconomy.enable", false);
|
||||
// buyOnClaim = getBoolean("iconomy.buy-on-claim", false);
|
||||
// buyOnClaimPrice = getDouble("iconomy.buy-on-claim-price", 1.0);
|
||||
|
||||
blockCreatureSpawn = new HashSet<>();
|
||||
for (String creatureName : getStringList("mobs.block-creature-spawn", null)) {
|
||||
EntityType creature = EntityTypes.get(creatureName.toLowerCase());
|
||||
|
||||
if (creature == null) {
|
||||
log.warning("Unknown entity type '" + creatureName + "'");
|
||||
} else {
|
||||
blockCreatureSpawn.add(creature);
|
||||
}
|
||||
}
|
||||
|
||||
boolean useBlacklistAsWhitelist = getBoolean("blacklist.use-as-whitelist", false);
|
||||
|
||||
// Console log configuration
|
||||
boolean logConsole = getBoolean("blacklist.logging.console.enable", true);
|
||||
|
||||
// Database log configuration
|
||||
boolean logDatabase = getBoolean("blacklist.logging.database.enable", false);
|
||||
String dsn = getString("blacklist.logging.database.dsn", "jdbc:mysql://localhost:3306/minecraft");
|
||||
String user = getString("blacklist.logging.database.user", "root");
|
||||
String pass = getString("blacklist.logging.database.pass", "");
|
||||
String table = getString("blacklist.logging.database.table", "blacklist_events");
|
||||
|
||||
// File log configuration
|
||||
boolean logFile = getBoolean("blacklist.logging.file.enable", false);
|
||||
String logFilePattern = getString("blacklist.logging.file.path", "worldguard/logs/%Y-%m-%d.log");
|
||||
int logFileCacheSize = Math.max(1, getInt("blacklist.logging.file.open-files", 10));
|
||||
|
||||
// Load the blacklist
|
||||
try {
|
||||
// If there was an existing blacklist, close loggers
|
||||
if (blacklist != null) {
|
||||
blacklist.getLogger().close();
|
||||
}
|
||||
|
||||
// First load the blacklist data from worldguard-blacklist.txt
|
||||
Blacklist blist = new Blacklist(useBlacklistAsWhitelist);
|
||||
blist.load(blacklistFile);
|
||||
|
||||
// If the blacklist is empty, then set the field to null
|
||||
// and save some resources
|
||||
if (blist.isEmpty()) {
|
||||
this.blacklist = null;
|
||||
} else {
|
||||
this.blacklist = blist;
|
||||
if (summaryOnStart) {
|
||||
log.log(Level.INFO, "({0}) Blacklist loaded with {1} entries.",
|
||||
new Object[]{worldName, blacklist.getItemCount()});
|
||||
}
|
||||
|
||||
BlacklistLoggerHandler blacklistLogger = blist.getLogger();
|
||||
|
||||
if (logDatabase) {
|
||||
blacklistLogger.addHandler(new DatabaseHandler(dsn, user, pass, table, worldName, log));
|
||||
}
|
||||
|
||||
if (logConsole) {
|
||||
blacklistLogger.addHandler(new ConsoleHandler(worldName, log));
|
||||
}
|
||||
|
||||
if (logFile) {
|
||||
FileHandler handler =
|
||||
new FileHandler(logFilePattern, logFileCacheSize, worldName, log);
|
||||
blacklistLogger.addHandler(handler);
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
log.log(Level.WARNING, "WorldGuard blacklist does not exist.");
|
||||
} catch (IOException e) {
|
||||
log.log(Level.WARNING, "Could not load WorldGuard blacklist: "
|
||||
+ e.getMessage());
|
||||
}
|
||||
|
||||
// Print an overview of settings
|
||||
if (summaryOnStart) {
|
||||
log.log(Level.INFO, blockTNTExplosions
|
||||
? "(" + worldName + ") TNT ignition is blocked."
|
||||
: "(" + worldName + ") TNT ignition is PERMITTED.");
|
||||
log.log(Level.INFO, blockLighter
|
||||
? "(" + worldName + ") Lighters are blocked."
|
||||
: "(" + worldName + ") Lighters are PERMITTED.");
|
||||
log.log(Level.INFO, preventLavaFire
|
||||
? "(" + worldName + ") Lava fire is blocked."
|
||||
: "(" + worldName + ") Lava fire is PERMITTED.");
|
||||
|
||||
if (disableFireSpread) {
|
||||
log.log(Level.INFO, "(" + worldName + ") All fire spread is disabled.");
|
||||
} else {
|
||||
if (!disableFireSpreadBlocks.isEmpty()) {
|
||||
log.log(Level.INFO, "(" + worldName
|
||||
+ ") Fire spread is limited to "
|
||||
+ disableFireSpreadBlocks.size() + " block types.");
|
||||
} else {
|
||||
log.log(Level.INFO, "(" + worldName
|
||||
+ ") Fire spread is UNRESTRICTED.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
config.setHeader(CONFIG_HEADER);
|
||||
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean isChestProtected(Location block, LocalPlayer player) {
|
||||
if (!signChestProtection) {
|
||||
return false;
|
||||
}
|
||||
if (player.hasPermission("worldguard.chest-protection.override")
|
||||
|| player.hasPermission("worldguard.override.chest-protection")) {
|
||||
return false;
|
||||
}
|
||||
return chestProtection.isProtected(block, player);
|
||||
}
|
||||
|
||||
public boolean isChestProtected(Location block) {
|
||||
|
||||
return signChestProtection && chestProtection.isProtected(block, null);
|
||||
}
|
||||
|
||||
public boolean isChestProtectedPlacement(Location block, LocalPlayer player) {
|
||||
if (!signChestProtection) {
|
||||
return false;
|
||||
}
|
||||
if (player.hasPermission("worldguard.chest-protection.override")
|
||||
|| player.hasPermission("worldguard.override.chest-protection")) {
|
||||
return false;
|
||||
}
|
||||
return chestProtection.isProtectedPlacement(block, player);
|
||||
}
|
||||
|
||||
public boolean isAdjacentChestProtected(Location block, LocalPlayer player) {
|
||||
if (!signChestProtection) {
|
||||
return false;
|
||||
}
|
||||
if (player.hasPermission("worldguard.chest-protection.override")
|
||||
|| player.hasPermission("worldguard.override.chest-protection")) {
|
||||
return false;
|
||||
}
|
||||
return chestProtection.isAdjacentChestProtected(block, player);
|
||||
}
|
||||
|
||||
public ChestProtection getChestProtection() {
|
||||
return chestProtection;
|
||||
}
|
||||
|
||||
}
|
||||
+279
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.report.ReportList;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.util.profile.resolver.PaperProfileService;
|
||||
import com.sk89q.worldguard.bukkit.protection.events.flags.FlagContextCreateEvent;
|
||||
import com.sk89q.worldguard.bukkit.session.BukkitSessionManager;
|
||||
import com.sk89q.worldguard.bukkit.util.report.PerformanceReport;
|
||||
import com.sk89q.worldguard.bukkit.util.report.PluginReport;
|
||||
import com.sk89q.worldguard.bukkit.util.report.SchedulerReport;
|
||||
import com.sk89q.worldguard.bukkit.util.report.ServerReport;
|
||||
import com.sk89q.worldguard.bukkit.util.report.ServicesReport;
|
||||
import com.sk89q.worldguard.bukkit.util.report.WorldReport;
|
||||
import com.sk89q.worldguard.internal.platform.DebugHandler;
|
||||
import com.sk89q.worldguard.internal.platform.StringMatcher;
|
||||
import com.sk89q.worldguard.internal.platform.WorldGuardPlatform;
|
||||
import com.sk89q.worldguard.protection.flags.FlagContext;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import com.sk89q.worldguard.session.SessionManager;
|
||||
import com.sk89q.worldguard.util.profile.cache.ProfileCache;
|
||||
import com.sk89q.worldguard.util.profile.resolver.BukkitPlayerService;
|
||||
import com.sk89q.worldguard.util.profile.resolver.CacheForwardingService;
|
||||
import com.sk89q.worldguard.util.profile.resolver.CombinedProfileService;
|
||||
import com.sk89q.worldguard.util.profile.resolver.HttpRepositoryService;
|
||||
import com.sk89q.worldguard.util.profile.resolver.ProfileService;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BukkitWorldGuardPlatform implements WorldGuardPlatform {
|
||||
|
||||
private SessionManager sessionManager;
|
||||
private BukkitConfigurationManager configuration;
|
||||
private BukkitRegionContainer regionContainer;
|
||||
private BukkitDebugHandler debugHandler;
|
||||
private StringMatcher stringMatcher;
|
||||
|
||||
public BukkitWorldGuardPlatform() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformName() {
|
||||
return "Bukkit-Official";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformVersion() {
|
||||
return WorldGuardPlugin.inst().getDescription().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyFlagContextCreate(FlagContext.FlagContextBuilder flagContextBuilder) {
|
||||
Bukkit.getServer().getPluginManager().callEvent(new FlagContextCreateEvent(flagContextBuilder));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BukkitConfigurationManager getGlobalStateManager() {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringMatcher getMatcher() {
|
||||
return stringMatcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionManager getSessionManager() {
|
||||
return this.sessionManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastNotification(String message) {
|
||||
Bukkit.broadcast(message, "worldguard.notify");
|
||||
Set<Permissible> subs = Bukkit.getPluginManager().getPermissionSubscriptions("worldguard.notify");
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (!(subs.contains(player) && player.hasPermission("worldguard.notify")) &&
|
||||
WorldGuardPlugin.inst().hasPermission(player, "worldguard.notify")) { // Make sure the player wasn't already broadcasted to.
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
WorldGuard.logger.info(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastNotification(TextComponent component) {
|
||||
List<LocalPlayer>
|
||||
wgPlayers = Bukkit.getServer().getOnlinePlayers().stream().map(player -> WorldGuardPlugin.inst().wrapPlayer(player)).collect(
|
||||
Collectors.toList());
|
||||
|
||||
for (LocalPlayer player : wgPlayers) {
|
||||
if (player.hasPermission("worldguard.notify")) {
|
||||
player.print(component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
stringMatcher = new BukkitStringMatcher();
|
||||
sessionManager = new BukkitSessionManager();
|
||||
configuration = new BukkitConfigurationManager(WorldGuardPlugin.inst());
|
||||
configuration.load();
|
||||
regionContainer = new BukkitRegionContainer(WorldGuardPlugin.inst());
|
||||
regionContainer.initialize();
|
||||
debugHandler = new BukkitDebugHandler(WorldGuardPlugin.inst());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
configuration.unload();
|
||||
regionContainer.shutdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionContainer getRegionContainer() {
|
||||
return this.regionContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DebugHandler getDebugHandler() {
|
||||
return debugHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameMode getDefaultGameMode() {
|
||||
return GameModes.get(Bukkit.getServer().getDefaultGameMode().name().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getConfigDir() {
|
||||
return WorldGuardPlugin.inst().getDataFolder().toPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stackPlayerInventory(LocalPlayer localPlayer) {
|
||||
boolean ignoreMax = localPlayer.hasPermission("worldguard.stack.illegitimate");
|
||||
boolean ignoreDamaged = localPlayer.hasPermission("worldguard.stack.damaged");
|
||||
|
||||
Player player = ((BukkitPlayer) localPlayer).getPlayer();
|
||||
|
||||
ItemStack[] items = player.getInventory().getContents();
|
||||
int len = items.length;
|
||||
|
||||
int affected = 0;
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
ItemStack item = items[i];
|
||||
|
||||
// Avoid infinite stacks and stacks with durability
|
||||
if (item == null || item.getAmount() <= 0
|
||||
|| (!ignoreMax && item.getMaxStackSize() == 1)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int max = ignoreMax ? 64 : item.getMaxStackSize();
|
||||
|
||||
if (item.getAmount() < max) {
|
||||
int needed = max - item.getAmount(); // Number of needed items until max
|
||||
|
||||
// Find another stack of the same type
|
||||
for (int j = i + 1; j < len; j++) {
|
||||
ItemStack item2 = items[j];
|
||||
|
||||
// Avoid infinite stacks and stacks with durability
|
||||
if (item2 == null || item2.getAmount() <= 0
|
||||
|| (!ignoreMax && item.getMaxStackSize() == 1)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Same type?
|
||||
// Blocks store their color in the damage value
|
||||
if (item2.getType() == item.getType() &&
|
||||
(ignoreDamaged || item.getDurability() == item2.getDurability()) &&
|
||||
((item.getItemMeta() == null && item2.getItemMeta() == null)
|
||||
|| (item.getItemMeta() != null &&
|
||||
item.getItemMeta().equals(item2.getItemMeta())))) {
|
||||
// This stack won't fit in the parent stack
|
||||
if (item2.getAmount() > needed) {
|
||||
item.setAmount(max);
|
||||
item2.setAmount(item2.getAmount() - needed);
|
||||
break;
|
||||
// This stack will
|
||||
} else {
|
||||
items[j] = null;
|
||||
item.setAmount(item.getAmount() + item2.getAmount());
|
||||
needed = max - item.getAmount();
|
||||
}
|
||||
|
||||
affected++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (affected > 0) {
|
||||
player.getInventory().setContents(items);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlatformReports(ReportList report) {
|
||||
report.add(new ServerReport());
|
||||
report.add(new PluginReport());
|
||||
report.add(new SchedulerReport());
|
||||
report.add(new ServicesReport());
|
||||
report.add(new WorldReport());
|
||||
report.add(new PerformanceReport());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfileService createProfileService(ProfileCache profileCache) {
|
||||
List<ProfileService> services = new ArrayList<>();
|
||||
if (PaperLib.isPaper()) {
|
||||
// Paper has a shared cache
|
||||
services.add(PaperProfileService.getInstance());
|
||||
} else {
|
||||
services.add(BukkitPlayerService.getInstance());
|
||||
}
|
||||
services.add(HttpRepositoryService.forMinecraft());
|
||||
return new CacheForwardingService(new CombinedProfileService(services),
|
||||
profileCache);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ProtectedRegion getSpawnProtection(World world) {
|
||||
if (world instanceof BukkitWorld) {
|
||||
org.bukkit.World bWorld = ((BukkitWorld) world).getWorld();
|
||||
if (bWorld.getUID().equals(Bukkit.getServer().getWorlds().get(0).getUID())) {
|
||||
int radius = Bukkit.getServer().getSpawnRadius();
|
||||
if (radius > 0) {
|
||||
BlockVector3 spawnLoc = BukkitAdapter.asBlockVector(bWorld.getSpawnLocation());
|
||||
return new ProtectedCuboidRegion("__spawn_protection__",
|
||||
spawnLoc.subtract(radius, 0, radius).withY(world.getMinimumPoint().getY()),
|
||||
spawnLoc.add(radius, 0, radius).withY(world.getMaxY()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.cause.Cause;
|
||||
import com.sk89q.worldguard.bukkit.event.block.BreakBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.block.PlaceBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.block.UseBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.DamageEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.SpawnEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.UseEntityEvent;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.sk89q.worldguard.bukkit.event.DelegateEvents.setSilent;
|
||||
import static com.sk89q.worldguard.bukkit.util.Events.fireAndTestCancel;
|
||||
|
||||
/**
|
||||
* A helper class to query whether a block or entity is protected by
|
||||
* WorldGuard.
|
||||
*/
|
||||
public class ProtectionQuery {
|
||||
|
||||
/**
|
||||
* Test whether a block can be placed at a given location.
|
||||
*
|
||||
* <p>The cause does not have to be a player. It can be {@code null}
|
||||
* if the cause is not known, although the checks will executed
|
||||
* assuming that the actor is a non-member of all regions.</p>
|
||||
*
|
||||
* @param cause the cause, which can be a block, an entity, or a player, or {@code null} if unknown
|
||||
* @param location the location of the block
|
||||
* @param newMaterial the new material
|
||||
* @return true if the action is permitted
|
||||
*/
|
||||
public boolean testBlockPlace(@Nullable Object cause, Location location, Material newMaterial) {
|
||||
return !fireAndTestCancel(setSilent(new PlaceBlockEvent(null, Cause.create(cause), location, newMaterial)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether a block can be broken.
|
||||
*
|
||||
* <p>The cause does not have to be a player. It can be {@code null}
|
||||
* if the cause is not known, although the checks will executed
|
||||
* assuming that the actor is a non-member of all regions.</p>
|
||||
*
|
||||
* @param cause the cause, which can be a block, an entity, or a player, or {@code null} if unknown
|
||||
* @param block the block broken
|
||||
* @return true if the action is permitted
|
||||
*/
|
||||
public boolean testBlockBreak(@Nullable Object cause, Block block) {
|
||||
return !fireAndTestCancel(setSilent(new BreakBlockEvent(null, Cause.create(cause), block)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether a block can be interacted with.
|
||||
*
|
||||
* <p>The cause does not have to be a player. It can be {@code null}
|
||||
* if the cause is not known, although the checks will executed
|
||||
* assuming that the actor is a non-member of all regions.</p>
|
||||
*
|
||||
* @param cause the cause, which can be a block, an entity, or a player, or {@code null} if unknown
|
||||
* @param block the block that is interacted with
|
||||
* @return true if the action is permitted
|
||||
*/
|
||||
public boolean testBlockInteract(@Nullable Object cause, Block block) {
|
||||
return !fireAndTestCancel(setSilent(new UseBlockEvent(null, Cause.create(cause), block)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether an entity can be placed.
|
||||
*
|
||||
* <p>The cause does not have to be a player. It can be {@code null}
|
||||
* if the cause is not known, although the checks will executed
|
||||
* assuming that the actor is a non-member of all regions.</p>
|
||||
*
|
||||
* @param cause the cause, which can be a block, an entity, or a player, or {@code null} if unknown
|
||||
* @param location the location that the entity will be spawned at
|
||||
* @param type the type that is to be spawned
|
||||
* @return true if the action is permitted
|
||||
*/
|
||||
public boolean testEntityPlace(@Nullable Object cause, Location location, EntityType type) {
|
||||
return !fireAndTestCancel(setSilent(new SpawnEntityEvent(null, Cause.create(cause), location, type)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether an entity can be destroyed.
|
||||
*
|
||||
* <p>The cause does not have to be a player. It can be {@code null}
|
||||
* if the cause is not known, although the checks will executed
|
||||
* assuming that the actor is a non-member of all regions.</p>
|
||||
*
|
||||
* @param cause the cause, which can be a block, an entity, or a player, or {@code null} if unknown
|
||||
* @param entity the entity broken
|
||||
* @return true if the action is permitted
|
||||
*/
|
||||
public boolean testEntityDestroy(@Nullable Object cause, Entity entity) {
|
||||
return !fireAndTestCancel(setSilent(new SpawnEntityEvent(null, Cause.create(cause), entity)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether an entity can be interacted with.
|
||||
*
|
||||
* <p>The cause does not have to be a player. It can be {@code null}
|
||||
* if the cause is not known, although the checks will executed
|
||||
* assuming that the actor is a non-member of all regions.</p>
|
||||
*
|
||||
* @param cause the cause, which can be a block, an entity, or a player, or {@code null} if unknown
|
||||
* @param entity the entity interacted with
|
||||
* @return true if the action is permitted
|
||||
*/
|
||||
public boolean testEntityInteract(@Nullable Object cause, Entity entity) {
|
||||
return !fireAndTestCancel(setSilent(new UseEntityEvent(null, Cause.create(cause), entity)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether an entity can be damaged.
|
||||
*
|
||||
* <p>The cause does not have to be a player. It can be {@code null}
|
||||
* if the cause is not known, although the checks will executed
|
||||
* assuming that the actor is a non-member of all regions.</p>
|
||||
*
|
||||
* @param cause the cause, which can be a block, an entity, or a player, or {@code null} if unknown
|
||||
* @param entity the entity damaged
|
||||
* @return true if the action is permitted
|
||||
*/
|
||||
public boolean testEntityDamage(@Nullable Object cause, Entity entity) {
|
||||
return !fireAndTestCancel(setSilent(new DamageEntityEvent(null, Cause.create(cause), entity)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,536 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.sk89q.bukkit.util.CommandsManagerRegistration;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissionsException;
|
||||
import com.sk89q.minecraft.util.commands.CommandUsageException;
|
||||
import com.sk89q.minecraft.util.commands.CommandsManager;
|
||||
import com.sk89q.minecraft.util.commands.MissingNestedCommandException;
|
||||
import com.sk89q.minecraft.util.commands.SimpleInjector;
|
||||
import com.sk89q.minecraft.util.commands.WrappedCommandException;
|
||||
import com.sk89q.wepif.PermissionsResolverManager;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.BukkitCommandSender;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.blacklist.Blacklist;
|
||||
import com.sk89q.worldguard.bukkit.event.player.ProcessPlayerEvent;
|
||||
import com.sk89q.worldguard.bukkit.listener.BlacklistListener;
|
||||
import com.sk89q.worldguard.bukkit.listener.BlockedPotionsListener;
|
||||
import com.sk89q.worldguard.bukkit.listener.BuildPermissionListener;
|
||||
import com.sk89q.worldguard.bukkit.listener.ChestProtectionListener;
|
||||
import com.sk89q.worldguard.bukkit.listener.DebuggingListener;
|
||||
import com.sk89q.worldguard.bukkit.listener.EventAbstractionListener;
|
||||
import com.sk89q.worldguard.bukkit.listener.InvincibilityListener;
|
||||
import com.sk89q.worldguard.bukkit.listener.PlayerModesListener;
|
||||
import com.sk89q.worldguard.bukkit.listener.PlayerMoveListener;
|
||||
import com.sk89q.worldguard.bukkit.listener.RegionFlagsListener;
|
||||
import com.sk89q.worldguard.bukkit.listener.RegionProtectionListener;
|
||||
import com.sk89q.worldguard.bukkit.listener.WorldGuardBlockListener;
|
||||
import com.sk89q.worldguard.bukkit.listener.WorldGuardCommandBookListener;
|
||||
import com.sk89q.worldguard.bukkit.listener.WorldGuardEntityListener;
|
||||
import com.sk89q.worldguard.bukkit.listener.WorldGuardHangingListener;
|
||||
import com.sk89q.worldguard.bukkit.listener.WorldGuardPlayerListener;
|
||||
import com.sk89q.worldguard.bukkit.listener.WorldGuardServerListener;
|
||||
import com.sk89q.worldguard.bukkit.listener.WorldGuardVehicleListener;
|
||||
import com.sk89q.worldguard.bukkit.listener.WorldGuardWeatherListener;
|
||||
import com.sk89q.worldguard.bukkit.listener.WorldGuardWorldListener;
|
||||
import com.sk89q.worldguard.bukkit.listener.WorldRulesListener;
|
||||
import com.sk89q.worldguard.bukkit.session.BukkitSessionManager;
|
||||
import com.sk89q.worldguard.bukkit.util.Events;
|
||||
import com.sk89q.worldguard.bukkit.util.logging.ClassSourceValidator;
|
||||
import com.sk89q.worldguard.commands.GeneralCommands;
|
||||
import com.sk89q.worldguard.commands.ProtectionCommands;
|
||||
import com.sk89q.worldguard.commands.ToggleCommands;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.registry.SimpleFlagRegistry;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.managers.storage.RegionDriver;
|
||||
import com.sk89q.worldguard.protection.managers.storage.file.DirectoryYamlDriver;
|
||||
import com.sk89q.worldguard.protection.managers.storage.sql.SQLDriver;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.util.logging.RecordMessagePrefixer;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
/**
|
||||
* The main class for WorldGuard as a Bukkit plugin.
|
||||
*/
|
||||
public class WorldGuardPlugin extends JavaPlugin {
|
||||
|
||||
private static WorldGuardPlugin inst;
|
||||
private static BukkitWorldGuardPlatform platform;
|
||||
private final CommandsManager<Actor> commands;
|
||||
private PlayerMoveListener playerMoveListener;
|
||||
|
||||
/**
|
||||
* Construct objects. Actual loading occurs when the plugin is enabled, so
|
||||
* this merely instantiates the objects.
|
||||
*/
|
||||
public WorldGuardPlugin() {
|
||||
inst = this;
|
||||
commands = new CommandsManager<Actor>() {
|
||||
@Override
|
||||
public boolean hasPermission(Actor player, String perm) {
|
||||
return player.hasPermission(perm);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current instance of WorldGuard
|
||||
* @return WorldGuardPlugin instance
|
||||
*/
|
||||
public static WorldGuardPlugin inst() {
|
||||
return inst;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on plugin enable.
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
configureLogger();
|
||||
|
||||
getDataFolder().mkdirs(); // Need to create the plugins/WorldGuard folder
|
||||
|
||||
PermissionsResolverManager.initialize(this);
|
||||
|
||||
WorldGuard.getInstance().setPlatform(platform = new BukkitWorldGuardPlatform()); // Initialise WorldGuard
|
||||
WorldGuard.getInstance().setup();
|
||||
BukkitSessionManager sessionManager = (BukkitSessionManager) platform.getSessionManager();
|
||||
|
||||
// Set the proper command injector
|
||||
commands.setInjector(new SimpleInjector(WorldGuard.getInstance()));
|
||||
|
||||
// Catch bad things being done by naughty plugins that include
|
||||
// WorldGuard's classes
|
||||
ClassSourceValidator verifier = new ClassSourceValidator(this);
|
||||
verifier.reportMismatches(ImmutableList.of(ProtectedRegion.class, ProtectedCuboidRegion.class, Flag.class));
|
||||
|
||||
// Register command classes
|
||||
final CommandsManagerRegistration reg = new CommandsManagerRegistration(this, commands);
|
||||
reg.register(ToggleCommands.class);
|
||||
reg.register(ProtectionCommands.class);
|
||||
|
||||
getServer().getScheduler().scheduleSyncDelayedTask(this, () -> {
|
||||
if (!platform.getGlobalStateManager().hasCommandBookGodMode()) {
|
||||
reg.register(GeneralCommands.class);
|
||||
}
|
||||
}, 0L);
|
||||
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, sessionManager, BukkitSessionManager.RUN_DELAY, BukkitSessionManager.RUN_DELAY);
|
||||
|
||||
// Register events
|
||||
getServer().getPluginManager().registerEvents(sessionManager, this);
|
||||
(new WorldGuardPlayerListener(this)).registerEvents();
|
||||
(new WorldGuardBlockListener(this)).registerEvents();
|
||||
(new WorldGuardEntityListener(this)).registerEvents();
|
||||
(new WorldGuardWeatherListener(this)).registerEvents();
|
||||
(new WorldGuardVehicleListener(this)).registerEvents();
|
||||
(new WorldGuardServerListener(this)).registerEvents();
|
||||
(new WorldGuardHangingListener(this)).registerEvents();
|
||||
|
||||
// Modules
|
||||
(playerMoveListener = new PlayerMoveListener(this)).registerEvents();
|
||||
(new BlacklistListener(this)).registerEvents();
|
||||
(new ChestProtectionListener(this)).registerEvents();
|
||||
(new RegionProtectionListener(this)).registerEvents();
|
||||
(new RegionFlagsListener(this)).registerEvents();
|
||||
(new WorldRulesListener(this)).registerEvents();
|
||||
(new BlockedPotionsListener(this)).registerEvents();
|
||||
(new EventAbstractionListener(this)).registerEvents();
|
||||
(new PlayerModesListener(this)).registerEvents();
|
||||
(new BuildPermissionListener(this)).registerEvents();
|
||||
(new InvincibilityListener(this)).registerEvents();
|
||||
if ("true".equalsIgnoreCase(System.getProperty("worldguard.debug.listener"))) {
|
||||
(new DebuggingListener(this, WorldGuard.logger)).registerEvents();
|
||||
}
|
||||
|
||||
platform.getGlobalStateManager().updateCommandBookGodMode();
|
||||
|
||||
if (getServer().getPluginManager().isPluginEnabled("CommandBook")) {
|
||||
getServer().getPluginManager().registerEvents(new WorldGuardCommandBookListener(this), this);
|
||||
}
|
||||
|
||||
// handle worlds separately to initialize already loaded worlds
|
||||
WorldGuardWorldListener worldListener = (new WorldGuardWorldListener(this));
|
||||
for (World world : getServer().getWorlds()) {
|
||||
worldListener.initWorld(world);
|
||||
}
|
||||
worldListener.registerEvents();
|
||||
|
||||
Bukkit.getScheduler().runTask(this, () -> {
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
ProcessPlayerEvent event = new ProcessPlayerEvent(player);
|
||||
Events.fire(event);
|
||||
}
|
||||
});
|
||||
|
||||
((SimpleFlagRegistry) WorldGuard.getInstance().getFlagRegistry()).setInitialized(true);
|
||||
|
||||
// Enable metrics
|
||||
final Metrics metrics = new Metrics(this);
|
||||
if (metrics.isEnabled() && platform.getGlobalStateManager().extraStats) {
|
||||
setupCustomCharts(metrics);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupCustomCharts(Metrics metrics) {
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("region_count", () ->
|
||||
platform.getRegionContainer().getLoaded().stream().mapToInt(RegionManager::size).sum()));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("region_driver", () -> {
|
||||
RegionDriver driver = platform.getGlobalStateManager().selectedRegionStoreDriver;
|
||||
return driver instanceof DirectoryYamlDriver ? "yaml" : driver instanceof SQLDriver ? "sql" : "unknown";
|
||||
}));
|
||||
metrics.addCustomChart(new Metrics.DrilldownPie("blacklist", () -> {
|
||||
int empty = 0;
|
||||
Map<String, Integer> blacklistMap = new HashMap<>();
|
||||
Map<String, Integer> whitelistMap = new HashMap<>();
|
||||
for (BukkitWorldConfiguration worldConfig : platform.getGlobalStateManager().getWorldConfigs()) {
|
||||
Blacklist blacklist = worldConfig.getBlacklist();
|
||||
if (blacklist != null && !blacklist.isEmpty()) {
|
||||
Map<String, Integer> target = blacklist.isWhitelist() ? whitelistMap : blacklistMap;
|
||||
int floor = ((blacklist.getItemCount() - 1) / 10) * 10;
|
||||
String range = floor >= 100 ? "101+" : (floor + 1) + " - " + (floor + 10);
|
||||
target.merge(range, 1, Integer::sum);
|
||||
} else {
|
||||
empty++;
|
||||
}
|
||||
}
|
||||
Map<String, Map<String, Integer>> blacklistCounts = new HashMap<>();
|
||||
Map<String, Integer> emptyMap = new HashMap<>();
|
||||
emptyMap.put("empty", empty);
|
||||
blacklistCounts.put("empty", emptyMap);
|
||||
blacklistCounts.put("blacklist", blacklistMap);
|
||||
blacklistCounts.put("whitelist", whitelistMap);
|
||||
return blacklistCounts;
|
||||
}));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("chest_protection", () ->
|
||||
"" + platform.getGlobalStateManager().getWorldConfigs().stream().anyMatch(cfg -> cfg.signChestProtection)));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("build_permissions", () ->
|
||||
"" + platform.getGlobalStateManager().getWorldConfigs().stream().anyMatch(cfg -> cfg.buildPermissions)));
|
||||
|
||||
metrics.addCustomChart(new Metrics.SimplePie("custom_flags", () ->
|
||||
"" + (WorldGuard.getInstance().getFlagRegistry().size() > Flags.INBUILT_FLAGS.size())));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("custom_handlers", () ->
|
||||
"" + (WorldGuard.getInstance().getPlatform().getSessionManager().customHandlersRegistered())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
WorldGuard.getInstance().disable();
|
||||
this.getServer().getScheduler().cancelTasks(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
try {
|
||||
Actor actor = wrapCommandSender(sender);
|
||||
try {
|
||||
commands.execute(cmd.getName(), args, actor, actor);
|
||||
} catch (Throwable t) {
|
||||
Throwable next = t;
|
||||
do {
|
||||
try {
|
||||
WorldGuard.getInstance().getExceptionConverter().convert(next);
|
||||
} catch (org.enginehub.piston.exception.CommandException pce) {
|
||||
if (pce.getCause() instanceof CommandException) {
|
||||
throw ((CommandException) pce.getCause());
|
||||
}
|
||||
}
|
||||
next = next.getCause();
|
||||
} while (next != null);
|
||||
|
||||
throw t;
|
||||
}
|
||||
} catch (CommandPermissionsException e) {
|
||||
sender.sendMessage(ChatColor.RED + "You don't have permission.");
|
||||
} catch (MissingNestedCommandException e) {
|
||||
sender.sendMessage(ChatColor.RED + e.getUsage());
|
||||
} catch (CommandUsageException e) {
|
||||
sender.sendMessage(ChatColor.RED + e.getMessage());
|
||||
sender.sendMessage(ChatColor.RED + e.getUsage());
|
||||
} catch (WrappedCommandException e) {
|
||||
sender.sendMessage(ChatColor.RED + e.getCause().getMessage());
|
||||
} catch (CommandException e) {
|
||||
sender.sendMessage(ChatColor.RED + e.getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a player is in a group.
|
||||
* This calls the corresponding method in PermissionsResolverManager
|
||||
*
|
||||
* @param player The player to check
|
||||
* @param group The group
|
||||
* @return whether {@code player} is in {@code group}
|
||||
*/
|
||||
public boolean inGroup(OfflinePlayer player, String group) {
|
||||
try {
|
||||
return PermissionsResolverManager.getInstance().inGroup(player, group);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the groups of a player.
|
||||
* This calls the corresponding method in PermissionsResolverManager.
|
||||
* @param player The player to check
|
||||
* @return The names of each group the playe is in.
|
||||
*/
|
||||
public String[] getGroups(OfflinePlayer player) {
|
||||
try {
|
||||
return PermissionsResolverManager.getInstance().getGroups(player);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks permissions.
|
||||
*
|
||||
* @param sender The sender to check the permission on.
|
||||
* @param perm The permission to check the permission on.
|
||||
* @return whether {@code sender} has {@code perm}
|
||||
*/
|
||||
public boolean hasPermission(CommandSender sender, String perm) {
|
||||
if (sender.isOp()) {
|
||||
if (sender instanceof Player) {
|
||||
if (platform.getGlobalStateManager().get(BukkitAdapter.adapt(((Player) sender).getWorld())).opPermissions) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Invoke the permissions resolver
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
return PermissionsResolverManager.getInstance().hasPermission(player.getWorld().getName(), player, perm);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks permissions and throws an exception if permission is not met.
|
||||
*
|
||||
* @param sender The sender to check the permission on.
|
||||
* @param perm The permission to check the permission on.
|
||||
* @throws CommandPermissionsException if {@code sender} doesn't have {@code perm}
|
||||
*/
|
||||
public void checkPermission(CommandSender sender, String perm)
|
||||
throws CommandPermissionsException {
|
||||
if (!hasPermission(sender, perm)) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a copy of the WorldEdit plugin.
|
||||
*
|
||||
* @return The WorldEditPlugin instance
|
||||
* @throws CommandException If there is no WorldEditPlugin available
|
||||
*/
|
||||
public WorldEditPlugin getWorldEdit() throws CommandException {
|
||||
Plugin worldEdit = getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
if (worldEdit == null) {
|
||||
throw new CommandException("WorldEdit does not appear to be installed.");
|
||||
}
|
||||
|
||||
if (worldEdit instanceof WorldEditPlugin) {
|
||||
return (WorldEditPlugin) worldEdit;
|
||||
} else {
|
||||
throw new CommandException("WorldEdit detection failed (report error).");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a player as a LocalPlayer.
|
||||
*
|
||||
* @param player The player to wrap
|
||||
* @return The wrapped player
|
||||
*/
|
||||
public LocalPlayer wrapPlayer(Player player) {
|
||||
return new BukkitPlayer(this, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a player as a LocalPlayer.
|
||||
*
|
||||
* @param player The player to wrap
|
||||
* @param silenced True to silence messages
|
||||
* @return The wrapped player
|
||||
*/
|
||||
public LocalPlayer wrapPlayer(Player player, boolean silenced) {
|
||||
return new BukkitPlayer(this, player, silenced);
|
||||
}
|
||||
|
||||
public Actor wrapCommandSender(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
return wrapPlayer((Player) sender);
|
||||
}
|
||||
|
||||
try {
|
||||
return new BukkitCommandSender(getWorldEdit(), sender);
|
||||
} catch (CommandException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public CommandSender unwrapActor(Actor sender) {
|
||||
if (sender instanceof BukkitPlayer) {
|
||||
return ((BukkitPlayer) sender).getPlayer();
|
||||
} else if (sender instanceof BukkitCommandSender) {
|
||||
return Bukkit.getConsoleSender(); // TODO Fix
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown actor type. Please report");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a player as a LocalPlayer.
|
||||
*
|
||||
* <p>This implementation is incomplete -- permissions cannot be checked.</p>
|
||||
*
|
||||
* @param player The player to wrap
|
||||
* @return The wrapped player
|
||||
*/
|
||||
public LocalPlayer wrapOfflinePlayer(OfflinePlayer player) {
|
||||
return new BukkitOfflinePlayer(this, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a protection query helper object that can be used by another
|
||||
* plugin to test whether WorldGuard permits an action at a particular
|
||||
* place.
|
||||
*
|
||||
* @return an instance
|
||||
*/
|
||||
public ProtectionQuery createProtectionQuery() {
|
||||
return new ProtectionQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure WorldGuard's loggers.
|
||||
*/
|
||||
private void configureLogger() {
|
||||
RecordMessagePrefixer.register(Logger.getLogger("com.sk89q.worldguard"), "[WorldGuard] ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a default configuration file from the .jar.
|
||||
*
|
||||
* @param actual The destination file
|
||||
* @param defaultName The name of the file inside the jar's defaults folder
|
||||
*/
|
||||
public void createDefaultConfiguration(File actual, String defaultName) {
|
||||
|
||||
// Make parent directories
|
||||
File parent = actual.getParentFile();
|
||||
if (!parent.exists()) {
|
||||
parent.mkdirs();
|
||||
}
|
||||
|
||||
if (actual.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
InputStream input = null;
|
||||
try {
|
||||
JarFile file = new JarFile(getFile());
|
||||
ZipEntry copy = file.getEntry("defaults/" + defaultName);
|
||||
if (copy == null) throw new FileNotFoundException();
|
||||
input = file.getInputStream(copy);
|
||||
} catch (IOException e) {
|
||||
WorldGuard.logger.severe("Unable to read default configuration: " + defaultName);
|
||||
}
|
||||
|
||||
if (input != null) {
|
||||
FileOutputStream output = null;
|
||||
|
||||
try {
|
||||
output = new FileOutputStream(actual);
|
||||
byte[] buf = new byte[8192];
|
||||
int length = 0;
|
||||
while ((length = input.read(buf)) > 0) {
|
||||
output.write(buf, 0, length);
|
||||
}
|
||||
|
||||
WorldGuard.logger.info("Default configuration file written: "
|
||||
+ actual.getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException ignore) {
|
||||
}
|
||||
|
||||
try {
|
||||
if (output != null) {
|
||||
output.close();
|
||||
}
|
||||
} catch (IOException ignore) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerMoveListener getPlayerMoveListener() {
|
||||
return playerMoveListener;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,306 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.cause;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.sk89q.worldguard.bukkit.internal.WGMetadata;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.AreaEffectCloud;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Firework;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.metadata.Metadatable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* An instance of this object describes the actors that played a role in
|
||||
* causing an event, with the ability to describe a situation where one actor
|
||||
* controls several other actors to create the event.
|
||||
*
|
||||
* <p>For example, if a player fires an arrow that hits an item frame, the player
|
||||
* is the initiator, while the arrow is merely controlled by the player to
|
||||
* hit the item frame.</p>
|
||||
*/
|
||||
public final class Cause {
|
||||
|
||||
private static final String CAUSE_KEY = "worldguard.cause";
|
||||
private static final Cause UNKNOWN = new Cause(Collections.emptyList(), false);
|
||||
|
||||
private final List<Object> causes;
|
||||
private final boolean indirect;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param causes a list of causes
|
||||
* @param indirect whether the cause is indirect
|
||||
*/
|
||||
private Cause(List<Object> causes, boolean indirect) {
|
||||
checkNotNull(causes);
|
||||
this.causes = causes;
|
||||
this.indirect = indirect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether the traced cause is indirect.
|
||||
*
|
||||
* <p>If the cause is indirect, then the root cause may not be notified,
|
||||
* for example.</p>
|
||||
*
|
||||
* @return true if the cause is indirect
|
||||
*/
|
||||
public boolean isIndirect() {
|
||||
return indirect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether a cause is known. This method will return true if
|
||||
* the list of causes is empty or the list of causes only contains
|
||||
* objects that really are not root causes (i.e primed TNT).
|
||||
*
|
||||
* @return true if known
|
||||
*/
|
||||
public boolean isKnown() {
|
||||
if (causes.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean found = false;
|
||||
for (Object object : causes) {
|
||||
if (!(object instanceof TNTPrimed) && !(object instanceof Vehicle)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object getRootCause() {
|
||||
if (!causes.isEmpty()) {
|
||||
return causes.get(0);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Player getFirstPlayer() {
|
||||
for (Object object : causes) {
|
||||
if (object instanceof Player) {
|
||||
return (Player) object;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Entity getFirstEntity() {
|
||||
for (Object object : causes) {
|
||||
if (object instanceof Entity) {
|
||||
return (Entity) object;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Entity getFirstNonPlayerEntity() {
|
||||
for (Object object : causes) {
|
||||
if (object instanceof Entity && !(object instanceof Player)) {
|
||||
return (Entity) object;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Block getFirstBlock() {
|
||||
for (Object object : causes) {
|
||||
if (object instanceof Block) {
|
||||
return (Block) object;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the first type matching one in the given array.
|
||||
*
|
||||
* @param types an array of types
|
||||
* @return a found type or null
|
||||
*/
|
||||
@Nullable
|
||||
public EntityType find(EntityType... types) {
|
||||
for (Object object : causes) {
|
||||
if (object instanceof Entity) {
|
||||
for (EntityType type : types) {
|
||||
if (((Entity) object).getType() == type) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Joiner.on(" | ").join(causes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance with the given objects as the cause,
|
||||
* where the first-most object is the initial initiator and those
|
||||
* following it are controlled by the previous entry.
|
||||
*
|
||||
* @param cause an array of causing objects
|
||||
* @return a cause
|
||||
*/
|
||||
public static Cause create(@Nullable Object... cause) {
|
||||
if (cause != null) {
|
||||
Builder builder = new Builder(cause.length);
|
||||
builder.addAll(cause);
|
||||
return builder.build();
|
||||
} else {
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance that indicates that the cause is not known.
|
||||
*
|
||||
* @return a cause
|
||||
*/
|
||||
public static Cause unknown() {
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a parent cause to a {@code Metadatable} object.
|
||||
*
|
||||
* <p>Note that {@code target} cannot be an instance of
|
||||
* {@link Block} because {@link #create(Object...)} will not bother
|
||||
* checking for such data on blocks (because it is relatively costly
|
||||
* to do so).</p>
|
||||
*
|
||||
* @param target the target
|
||||
* @param parent the parent cause
|
||||
* @throws IllegalArgumentException thrown if {@code target} is an instance of {@link Block}
|
||||
*/
|
||||
public static void trackParentCause(Metadatable target, Object parent) {
|
||||
if (target instanceof Block) {
|
||||
throw new IllegalArgumentException("Can't track causes on Blocks because Cause doesn't check block metadata");
|
||||
}
|
||||
|
||||
WGMetadata.put(target, CAUSE_KEY, parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds causes.
|
||||
*/
|
||||
private static final class Builder {
|
||||
private final List<Object> causes;
|
||||
private final Set<Object> seen = Sets.newHashSet();
|
||||
private boolean indirect;
|
||||
|
||||
private Builder(int expectedSize) {
|
||||
this.causes = new ArrayList<>(expectedSize);
|
||||
}
|
||||
|
||||
private void addAll(@Nullable Object... element) {
|
||||
if (element != null) {
|
||||
for (Object o : element) {
|
||||
if (o == null || seen.contains(o)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
seen.add(o);
|
||||
|
||||
if (o instanceof TNTPrimed) {
|
||||
addAll(((TNTPrimed) o).getSource());
|
||||
} else if (o instanceof Projectile) {
|
||||
addAll(((Projectile) o).getShooter());
|
||||
} else if (o instanceof Firework && PaperLib.isPaper()) {
|
||||
UUID spawningUUID = ((Firework) o).getSpawningEntity();
|
||||
if (spawningUUID != null) {
|
||||
Entity spawningEntity = Bukkit.getEntity(spawningUUID);
|
||||
if (spawningEntity != null) {
|
||||
addAll(spawningEntity);
|
||||
}
|
||||
}
|
||||
} else if (o instanceof Vehicle) {
|
||||
((Vehicle) o).getPassengers().forEach(this::addAll);
|
||||
} else if (o instanceof AreaEffectCloud) {
|
||||
indirect = true;
|
||||
addAll(((AreaEffectCloud) o).getSource());
|
||||
} else if (o instanceof Creature && ((Creature) o).getTarget() != null) {
|
||||
indirect = true;
|
||||
addAll(((Creature) o).getTarget());
|
||||
} else if (o instanceof Tameable) {
|
||||
indirect = true;
|
||||
addAll(((Tameable) o).getOwner());
|
||||
}
|
||||
|
||||
// Add manually tracked parent causes
|
||||
Object source = o;
|
||||
int index = causes.size();
|
||||
while (source instanceof Metadatable && !(source instanceof Block)) {
|
||||
source = WGMetadata.getIfPresent((Metadatable) source, CAUSE_KEY, Object.class);
|
||||
if (source != null) {
|
||||
causes.add(index, source);
|
||||
seen.add(source);
|
||||
}
|
||||
}
|
||||
|
||||
causes.add(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Cause build() {
|
||||
return new Cause(causes, indirect);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.chest;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.chest.SignChestProtection;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
|
||||
public class BukkitSignChestProtection extends SignChestProtection {
|
||||
|
||||
private Boolean isProtectedSign(Sign sign, LocalPlayer player) {
|
||||
if (sign.getLine(0).equalsIgnoreCase("[Lock]")) {
|
||||
if (player == null) { // No player, no access
|
||||
return true;
|
||||
}
|
||||
|
||||
String name = player.getName();
|
||||
return !name.equalsIgnoreCase(sign.getLine(1).trim())
|
||||
&& !name.equalsIgnoreCase(sign.getLine(2).trim())
|
||||
&& !name.equalsIgnoreCase(sign.getLine(3).trim());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isProtectedSign(Location block, LocalPlayer player) {
|
||||
BlockState state = BukkitAdapter.adapt(block).getBlock().getState();
|
||||
if (!(state instanceof Sign)) {
|
||||
return null;
|
||||
}
|
||||
return isProtectedSign((Sign) state, player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event;
|
||||
|
||||
import org.bukkit.event.Event.Result;
|
||||
|
||||
/**
|
||||
* A bulk event contains several affected objects in a list.
|
||||
*/
|
||||
public interface BulkEvent {
|
||||
|
||||
/**
|
||||
* Get the actual result.
|
||||
*
|
||||
* <p>By default, bulk events will set the result to DENY if the number of
|
||||
* affected objects drops to zero. This method returns the true result.</p>
|
||||
*
|
||||
* @return the explicit result
|
||||
*/
|
||||
Result getExplicitResult();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.worldguard.bukkit.cause.Cause;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* This event is an internal event. We do not recommend handling or throwing
|
||||
* this event or its subclasses as the interface is highly subject to change.
|
||||
*/
|
||||
public abstract class DelegateEvent extends Event implements Cancellable, Handleable {
|
||||
|
||||
@Nullable
|
||||
private final Event originalEvent;
|
||||
private final Cause cause;
|
||||
private final List<StateFlag> relevantFlags = Lists.newArrayList();
|
||||
private Result result = Result.DEFAULT;
|
||||
private boolean silent;
|
||||
|
||||
/**
|
||||
* Create a new instance
|
||||
*
|
||||
* @param originalEvent the original event
|
||||
* @param cause the cause
|
||||
*/
|
||||
protected DelegateEvent(@Nullable Event originalEvent, Cause cause) {
|
||||
checkNotNull(cause);
|
||||
this.originalEvent = originalEvent;
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the original event.
|
||||
*
|
||||
* @return the original event, which may be {@code null} if unavailable
|
||||
*/
|
||||
@Nullable
|
||||
public Event getOriginalEvent() {
|
||||
return originalEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cause.
|
||||
*
|
||||
* @return the cause
|
||||
*/
|
||||
public Cause getCause() {
|
||||
return cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of relevant flags to consider for this event.
|
||||
*
|
||||
* @return A list of relevant flags
|
||||
*/
|
||||
public List<StateFlag> getRelevantFlags() {
|
||||
return relevantFlags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return getResult() == Result.DENY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
if (cancel) {
|
||||
setResult(Result.DENY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResult(Result result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether this should be a silent check.
|
||||
*
|
||||
* @return true if a silent check
|
||||
*/
|
||||
public boolean isSilent() {
|
||||
return silent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether this should be a silent check.
|
||||
*
|
||||
* @param silent true if silent
|
||||
* @return the same event
|
||||
*/
|
||||
public DelegateEvent setSilent(boolean silent) {
|
||||
this.silent = silent;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the event to {@link org.bukkit.event.Event.Result#ALLOW} if {@code allowed} is true.
|
||||
*
|
||||
* @param allowed true to set the result
|
||||
* @return the same event
|
||||
*/
|
||||
public DelegateEvent setAllowed(boolean allowed) {
|
||||
if (allowed) {
|
||||
setResult(Result.ALLOW);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event;
|
||||
|
||||
import org.bukkit.event.Event.Result;
|
||||
|
||||
/**
|
||||
* Utility methods for dealing with delegate events.
|
||||
*/
|
||||
public final class DelegateEvents {
|
||||
|
||||
private DelegateEvents() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an event to be silent.
|
||||
*
|
||||
* @param event the event
|
||||
* @param <T> the type of event
|
||||
* @return the same event
|
||||
*/
|
||||
public static <T extends DelegateEvent> T setSilent(T event) {
|
||||
event.setSilent(true);
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an event to be silent.
|
||||
*
|
||||
* @param event the event
|
||||
* @param silent true to set silent
|
||||
* @param <T> the type of event
|
||||
* @return the same event
|
||||
*/
|
||||
public static <T extends DelegateEvent> T setSilent(T event, boolean silent) {
|
||||
event.setSilent(silent);
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an event as handled as {@link Result#ALLOW} if {@code allowed} is
|
||||
* true, otherwise do nothing.
|
||||
*
|
||||
* @param event the event
|
||||
* @param <T> the type of event
|
||||
* @return the same event
|
||||
*/
|
||||
public static <T extends Handleable> T setAllowed(T event, boolean allowed) {
|
||||
if (allowed) {
|
||||
event.setResult(Result.ALLOW);
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event;
|
||||
|
||||
import org.bukkit.event.Event.Result;
|
||||
|
||||
public interface Handleable {
|
||||
|
||||
Result getResult();
|
||||
|
||||
void setResult(Result result);
|
||||
|
||||
}
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event.block;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.cause.Cause;
|
||||
import com.sk89q.worldguard.bukkit.event.BulkEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.DelegateEvent;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* This event is an internal event. We do not recommend handling or throwing
|
||||
* this event or its subclasses as the interface is highly subject to change.
|
||||
*/
|
||||
abstract class AbstractBlockEvent extends DelegateEvent implements BulkEvent {
|
||||
|
||||
private final World world;
|
||||
private List<Block> blocks;
|
||||
private final List<BlockState> blockStates;
|
||||
private final Material effectiveMaterial;
|
||||
|
||||
protected AbstractBlockEvent(@Nullable Event originalEvent, Cause cause, World world, List<Block> blocks, Material effectiveMaterial) {
|
||||
super(originalEvent, cause);
|
||||
checkNotNull(world);
|
||||
checkNotNull(blocks);
|
||||
checkNotNull(effectiveMaterial);
|
||||
this.world = world;
|
||||
this.blocks = blocks;
|
||||
this.effectiveMaterial = effectiveMaterial;
|
||||
this.blockStates = null;
|
||||
}
|
||||
|
||||
protected AbstractBlockEvent(@Nullable Event originalEvent, Cause cause, World world, List<BlockState> blocks) {
|
||||
super(originalEvent, cause);
|
||||
checkNotNull(world);
|
||||
checkNotNull(blocks);
|
||||
checkArgument(!blocks.isEmpty());
|
||||
this.world = world;
|
||||
this.blockStates = blocks;
|
||||
this.blocks = null;
|
||||
this.effectiveMaterial = blocks.get(0).getType();
|
||||
}
|
||||
|
||||
protected AbstractBlockEvent(@Nullable Event originalEvent, Cause cause, Block block) {
|
||||
this(originalEvent, cause, block.getWorld(), createList(checkNotNull(block)), block.getType());
|
||||
}
|
||||
|
||||
protected AbstractBlockEvent(@Nullable Event originalEvent, Cause cause, Location target, Material effectiveMaterial) {
|
||||
this(originalEvent, cause, target.getWorld(), createList(target.getBlock()), effectiveMaterial);
|
||||
}
|
||||
|
||||
private static List<Block> createList(Block block) {
|
||||
List<Block> blocks = new ArrayList<>();
|
||||
blocks.add(block);
|
||||
return blocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the world.
|
||||
*
|
||||
* @return the world
|
||||
*/
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the affected blocks.
|
||||
*
|
||||
* @return a list of affected block
|
||||
*/
|
||||
public List<Block> getBlocks() {
|
||||
if (blocks == null) { // be lazy here because we often don't call getBlocks internally, just filter
|
||||
blocks = blockStates.stream().map(BlockState::getBlock).collect(Collectors.toList());
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the list of affected blocks with the given predicate. If the
|
||||
* predicate returns {@code false}, then the block is removed.
|
||||
*
|
||||
* @param predicate the predicate
|
||||
* @param cancelEventOnFalse true to cancel the event and clear the block
|
||||
* list once the predicate returns {@code false}
|
||||
* @return true if one or more blocks were filtered out
|
||||
*/
|
||||
public boolean filter(Predicate<Location> predicate, boolean cancelEventOnFalse) {
|
||||
return blocks == null
|
||||
? filterInternal(blockStates, BlockState::getLocation, predicate, cancelEventOnFalse)
|
||||
: filterInternal(blocks, Block::getLocation, predicate, cancelEventOnFalse);
|
||||
}
|
||||
|
||||
private <B> boolean filterInternal(List<B> blockList, Function<B, Location> locFunc,
|
||||
Predicate<Location> predicate, boolean cancelEventOnFalse) {
|
||||
boolean hasRemoval = false;
|
||||
Iterator<B> it = blockList.iterator();
|
||||
while (it.hasNext()) {
|
||||
if (!predicate.test(locFunc.apply(it.next()))) {
|
||||
hasRemoval = true;
|
||||
|
||||
if (cancelEventOnFalse) {
|
||||
blockList.clear();
|
||||
setCancelled(true);
|
||||
break;
|
||||
} else {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
return hasRemoval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the list of affected blocks with the given predicate. If the
|
||||
* predicate returns {@code false}, then the block is removed.
|
||||
*
|
||||
* <p>This method will <strong>not</strong> fail fast and
|
||||
* cancel the event the first instance that the predicate returns
|
||||
* {@code false}. See {@link #filter(Predicate, boolean)} to adjust
|
||||
* this behavior.</p>
|
||||
*
|
||||
* @param predicate the predicate
|
||||
* @return true if one or more blocks were filtered out
|
||||
*/
|
||||
public boolean filter(Predicate<Location> predicate) {
|
||||
return filter(predicate, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the effective material of the block, regardless of what the block
|
||||
* currently is.
|
||||
*
|
||||
* @return the effective material
|
||||
*/
|
||||
public Material getEffectiveMaterial() {
|
||||
return effectiveMaterial;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result getResult() {
|
||||
if (blocks == null ? blockStates.isEmpty() : blocks.isEmpty()) {
|
||||
return Result.DENY;
|
||||
}
|
||||
return super.getResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result getExplicitResult() {
|
||||
return super.getResult();
|
||||
}
|
||||
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event.block;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.cause.Cause;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This event is an internal event. We do not recommend handling or throwing
|
||||
* this event or its subclasses as the interface is highly subject to change.
|
||||
*
|
||||
* <p>Thrown when a block is broken.</p>
|
||||
*/
|
||||
public class BreakBlockEvent extends AbstractBlockEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public BreakBlockEvent(@Nullable Event originalEvent, Cause cause, World world, List<Block> blocks, Material effectiveMaterial) {
|
||||
super(originalEvent, cause, world, blocks, effectiveMaterial);
|
||||
}
|
||||
|
||||
public BreakBlockEvent(@Nullable Event originalEvent, Cause cause, Block block) {
|
||||
super(originalEvent, cause, block);
|
||||
}
|
||||
|
||||
public BreakBlockEvent(@Nullable Event originalEvent, Cause cause, Location target, Material effectiveMaterial) {
|
||||
super(originalEvent, cause, target, effectiveMaterial);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event.block;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.cause.Cause;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This event is an internal event. We do not recommend handling or throwing
|
||||
* this event or its subclasses as the interface is highly subject to change.
|
||||
*
|
||||
* <p>Thrown when a block is placed.</p>
|
||||
*/
|
||||
public class PlaceBlockEvent extends AbstractBlockEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public PlaceBlockEvent(@Nullable Event originalEvent, Cause cause, World world, List<BlockState> blocks) {
|
||||
super(originalEvent, cause, world, blocks);
|
||||
}
|
||||
|
||||
public PlaceBlockEvent(@Nullable Event originalEvent, Cause cause, World world, List<Block> blocks, Material effectiveMaterial) {
|
||||
super(originalEvent, cause, world, blocks, effectiveMaterial);
|
||||
}
|
||||
|
||||
public PlaceBlockEvent(@Nullable Event originalEvent, Cause cause, Block block) {
|
||||
super(originalEvent, cause, block);
|
||||
}
|
||||
|
||||
public PlaceBlockEvent(@Nullable Event originalEvent, Cause cause, Location target, Material effectiveMaterial) {
|
||||
super(originalEvent, cause, target, effectiveMaterial);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event.block;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.cause.Cause;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This event is an internal event. We do not recommend handling or throwing
|
||||
* this event or its subclasses as the interface is highly subject to change.
|
||||
*
|
||||
* <p>Thrown when a block is interacted with.</p>
|
||||
*/
|
||||
public class UseBlockEvent extends AbstractBlockEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public UseBlockEvent(@Nullable Event originalEvent, Cause cause, World world, List<Block> blocks, Material effectiveMaterial) {
|
||||
super(originalEvent, cause, world, blocks, effectiveMaterial);
|
||||
}
|
||||
|
||||
public UseBlockEvent(@Nullable Event originalEvent, Cause cause, Block block) {
|
||||
super(originalEvent, cause, block);
|
||||
}
|
||||
|
||||
public UseBlockEvent(@Nullable Event originalEvent, Cause cause, Location target, Material effectiveMaterial) {
|
||||
super(originalEvent, cause, target, effectiveMaterial);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event.debug;
|
||||
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Represents call to {@link Cancellable#setCancelled(boolean)}.
|
||||
*/
|
||||
public class CancelAttempt {
|
||||
|
||||
private final boolean before;
|
||||
private final boolean after;
|
||||
private final StackTraceElement[] stackTrace;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param before The cancellation flag before the call
|
||||
* @param after The cancellation flag after the call
|
||||
* @param stackTrace The stack trace
|
||||
*/
|
||||
public CancelAttempt(boolean before, boolean after, StackTraceElement[] stackTrace) {
|
||||
checkNotNull(stackTrace, "stackTrace");
|
||||
this.before = before;
|
||||
this.after = after;
|
||||
this.stackTrace = stackTrace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cancellation state before the call.
|
||||
*
|
||||
* @return Whether the event was cancelled before
|
||||
*/
|
||||
public boolean getBefore() {
|
||||
return before;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cancellation state after the call.
|
||||
*
|
||||
* @return The new cancellation state
|
||||
*/
|
||||
public boolean getAfter() {
|
||||
return after;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the stack trace.
|
||||
*
|
||||
* @return The stack trace
|
||||
*/
|
||||
public StackTraceElement[] getStackTrace() {
|
||||
return stackTrace;
|
||||
}
|
||||
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event.debug;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Logs attempts at cancellation.
|
||||
*/
|
||||
public class CancelLogger {
|
||||
|
||||
private List<CancelAttempt> entries = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Log a call.
|
||||
*
|
||||
* @param before The cancellation flag before the call
|
||||
* @param after The cancellation flag after the call
|
||||
* @param stackTrace The stack trace
|
||||
*/
|
||||
public void log(boolean before, boolean after, StackTraceElement[] stackTrace) {
|
||||
entries.add(new CancelAttempt(before, after, stackTrace));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an immutable list of cancels.
|
||||
*
|
||||
* @return An immutable list
|
||||
*/
|
||||
public List<CancelAttempt> getCancels() {
|
||||
return ImmutableList.copyOf(entries);
|
||||
}
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event.debug;
|
||||
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CancelLogging extends Cancellable {
|
||||
|
||||
/**
|
||||
* Get an immutable list of cancels.
|
||||
*
|
||||
* @return An immutable list
|
||||
*/
|
||||
List<CancelAttempt> getCancels();
|
||||
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event.debug;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LoggingBlockBreakEvent extends BlockBreakEvent implements CancelLogging {
|
||||
|
||||
private final CancelLogger logger = new CancelLogger();
|
||||
|
||||
public LoggingBlockBreakEvent(Block block, Player player) {
|
||||
super(block, player);
|
||||
}
|
||||
|
||||
public List<CancelAttempt> getCancels() {
|
||||
return logger.getCancels();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.logger.log(isCancelled(), cancel, new Exception().getStackTrace());
|
||||
super.setCancelled(cancel);
|
||||
}
|
||||
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event.debug;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LoggingBlockPlaceEvent extends BlockPlaceEvent implements CancelLogging {
|
||||
|
||||
private final CancelLogger logger = new CancelLogger();
|
||||
|
||||
public LoggingBlockPlaceEvent(Block placedBlock, BlockState replacedBlockState, Block placedAgainst, ItemStack itemInHand, Player thePlayer, boolean canBuild) {
|
||||
super(placedBlock, replacedBlockState, placedAgainst, itemInHand, thePlayer, canBuild);
|
||||
}
|
||||
|
||||
public List<CancelAttempt> getCancels() {
|
||||
return logger.getCancels();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.logger.log(isCancelled(), cancel, new Exception().getStackTrace());
|
||||
super.setCancelled(cancel);
|
||||
}
|
||||
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event.debug;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LoggingEntityDamageByEntityEvent extends EntityDamageByEntityEvent implements CancelLogging {
|
||||
|
||||
private final CancelLogger logger = new CancelLogger();
|
||||
|
||||
public LoggingEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, double damage) {
|
||||
super(damager, damagee, cause, damage);
|
||||
}
|
||||
|
||||
public List<CancelAttempt> getCancels() {
|
||||
return logger.getCancels();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.logger.log(isCancelled(), cancel, new Exception().getStackTrace());
|
||||
super.setCancelled(cancel);
|
||||
}
|
||||
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event.debug;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LoggingPlayerInteractEvent extends PlayerInteractEvent implements CancelLogging {
|
||||
|
||||
private final CancelLogger logger = new CancelLogger();
|
||||
|
||||
public LoggingPlayerInteractEvent(Player who, Action action, ItemStack item, Block clickedBlock, BlockFace clickedFace) {
|
||||
super(who, action, item, clickedBlock, clickedFace);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CancelAttempt> getCancels() {
|
||||
return logger.getCancels();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseInteractedBlock(Result useInteractedBlock) {
|
||||
this.logger.log(useInteractedBlock() == Result.DENY, useInteractedBlock == Result.DENY, new Exception().getStackTrace());
|
||||
super.setUseInteractedBlock(useInteractedBlock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseItemInHand(Result useItemInHand) {
|
||||
this.logger.log(useItemInHand() == Result.DENY, useItemInHand == Result.DENY, new Exception().getStackTrace());
|
||||
super.setUseItemInHand(useItemInHand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.logger.log(isCancelled(), cancel, new Exception().getStackTrace());
|
||||
super.setCancelled(cancel);
|
||||
}
|
||||
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event.entity;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.sk89q.worldguard.bukkit.cause.Cause;
|
||||
import com.sk89q.worldguard.bukkit.event.DelegateEvent;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* This event is an internal event. We do not recommend handling or throwing
|
||||
* this event or its subclasses as the interface is highly subject to change.
|
||||
*/
|
||||
abstract class AbstractEntityEvent extends DelegateEvent {
|
||||
|
||||
private final Location target;
|
||||
@Nullable
|
||||
private final Entity entity;
|
||||
|
||||
protected AbstractEntityEvent(@Nullable Event originalEvent, Cause cause, Entity entity) {
|
||||
super(originalEvent, cause);
|
||||
checkNotNull(entity);
|
||||
this.target = entity.getLocation();
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
protected AbstractEntityEvent(@Nullable Event originalEvent, Cause cause, Location target) {
|
||||
super(originalEvent, cause);
|
||||
checkNotNull(target);
|
||||
this.target = target;
|
||||
this.entity = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the world.
|
||||
*
|
||||
* @return the world
|
||||
*/
|
||||
public World getWorld() {
|
||||
return target.getWorld();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the target location being affected.
|
||||
*
|
||||
* @return a location
|
||||
*/
|
||||
public Location getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the target entity being affected.
|
||||
*
|
||||
* @return a entity
|
||||
*/
|
||||
@Nullable
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the list of affected entities with the given predicate. If the
|
||||
* predicate returns {@code false}, then the entity is not affected.
|
||||
*
|
||||
* @param predicate the predicate
|
||||
* @param cancelEventOnFalse true to cancel the event and clear the entity
|
||||
* list once the predicate returns {@code false}
|
||||
* @return true if one or more entities were filtered out
|
||||
*/
|
||||
public boolean filter(Predicate<Location> predicate, boolean cancelEventOnFalse) {
|
||||
if (!isCancelled()) {
|
||||
if (!predicate.apply(getTarget())) {
|
||||
setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
return isCancelled();
|
||||
}
|
||||
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event.entity;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.cause.Cause;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* This event is an internal event. We do not recommend handling or throwing
|
||||
* this event or its subclasses as the interface is highly subject to change.
|
||||
*
|
||||
* <p>Thrown when an entity is damaged.</p>
|
||||
*/
|
||||
public class DamageEntityEvent extends AbstractEntityEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public DamageEntityEvent(@Nullable Event originalEvent, Cause cause, Entity target) {
|
||||
super(originalEvent, cause, checkNotNull(target));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public Entity getEntity() {
|
||||
return super.getEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event.entity;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.cause.Cause;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* This event is an internal event. We do not recommend handling or throwing
|
||||
* this event or its subclasses as the interface is highly subject to change.
|
||||
*
|
||||
* <p>Thrown when an entity is removed.</p>
|
||||
*/
|
||||
public class DestroyEntityEvent extends AbstractEntityEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public DestroyEntityEvent(@Nullable Event originalEvent, Cause cause, Entity target) {
|
||||
super(originalEvent, cause, checkNotNull(target));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public Entity getEntity() {
|
||||
return super.getEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event.entity;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.cause.Cause;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* This event is an internal event. We do not recommend handling or throwing
|
||||
* this event or its subclasses as the interface is highly subject to change.
|
||||
*
|
||||
* <p>Thrown when an entity is spawned.</p>
|
||||
*/
|
||||
public class SpawnEntityEvent extends AbstractEntityEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final EntityType effectiveType;
|
||||
|
||||
public SpawnEntityEvent(@Nullable Event originalEvent, Cause cause, Entity target) {
|
||||
super(originalEvent, cause, checkNotNull(target));
|
||||
this.effectiveType = target.getType();
|
||||
}
|
||||
|
||||
public SpawnEntityEvent(@Nullable Event originalEvent, Cause cause, Location location, EntityType type) {
|
||||
super(originalEvent, cause, location);
|
||||
checkNotNull(type);
|
||||
this.effectiveType = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the effective entity type of the spawned entity.
|
||||
*
|
||||
* @return the effective type
|
||||
*/
|
||||
public EntityType getEffectiveType() {
|
||||
return effectiveType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event.entity;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.cause.Cause;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* This event is an internal event. We do not recommend handling or throwing
|
||||
* this event or its subclasses as the interface is highly subject to change.
|
||||
*
|
||||
* <p>Thrown when an entity is used.</p>
|
||||
*/
|
||||
public class UseEntityEvent extends AbstractEntityEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public UseEntityEvent(@Nullable Event originalEvent, Cause cause, Entity target) {
|
||||
super(originalEvent, cause, checkNotNull(target));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public Entity getEntity() {
|
||||
return super.getEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event.inventory;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.cause.Cause;
|
||||
import com.sk89q.worldguard.bukkit.event.DelegateEvent;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* This event is an internal event. We do not recommend handling or throwing
|
||||
* this event or its subclasses as the interface is highly subject to change.
|
||||
*
|
||||
* <p>Thrown when an item is used.</p>
|
||||
*/
|
||||
public class UseItemEvent extends DelegateEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final World world;
|
||||
private final ItemStack itemStack;
|
||||
|
||||
public UseItemEvent(@Nullable Event originalEvent, Cause cause, World world, ItemStack itemStack) {
|
||||
super(originalEvent, cause);
|
||||
checkNotNull(world);
|
||||
checkNotNull(itemStack);
|
||||
this.world = world;
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the world.
|
||||
*
|
||||
* @return the world
|
||||
*/
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item stack.
|
||||
*
|
||||
* @return the item stack
|
||||
*/
|
||||
public ItemStack getItemStack() {
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.event.player;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* This event is an internal event. We do not recommend handling or throwing
|
||||
* this event or its subclasses as the interface is highly subject to change.
|
||||
*
|
||||
* <p>Posted when a player has to be processed, either because a world has been
|
||||
* loaded, the server has started, or WorldGuard has been reloaded.</p>
|
||||
*/
|
||||
public class ProcessPlayerEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private final Player player;
|
||||
|
||||
public ProcessPlayerEvent(Player player) {
|
||||
checkNotNull(player);
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.internal;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.blacklist.target.BlockTarget;
|
||||
import com.sk89q.worldguard.blacklist.target.ItemTarget;
|
||||
import com.sk89q.worldguard.blacklist.target.Target;
|
||||
import com.sk89q.worldguard.blacklist.target.TargetMatcher;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class TargetMatcherSet {
|
||||
|
||||
private final Multimap<String, TargetMatcher> entries = HashMultimap.create();
|
||||
|
||||
public boolean add(TargetMatcher matcher) {
|
||||
checkNotNull(matcher);
|
||||
return entries.put(matcher.getMatchedTypeId(), matcher);
|
||||
}
|
||||
|
||||
public boolean test(Target target) {
|
||||
Collection<TargetMatcher> matchers = entries.get(target.getTypeId());
|
||||
|
||||
for (TargetMatcher matcher : matchers) {
|
||||
if (matcher.test(target)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean test(Material material) {
|
||||
if (material.isBlock()) {
|
||||
return test(new BlockTarget(BukkitAdapter.asBlockType(material)));
|
||||
} else {
|
||||
return test(new ItemTarget(BukkitAdapter.asItemType(material)));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean test(Block block) {
|
||||
return test(new BlockTarget(BukkitAdapter.asBlockType(block.getType())));
|
||||
}
|
||||
|
||||
public boolean test(BlockState state) {
|
||||
return test(new BlockTarget(BukkitAdapter.asBlockType(state.getType())));
|
||||
}
|
||||
|
||||
public boolean test(ItemStack itemStack) {
|
||||
return test(new ItemTarget(BukkitAdapter.asItemType(itemStack.getType())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return entries.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.internal;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.metadata.Metadatable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Utility methods for dealing with metadata on entities.
|
||||
*
|
||||
* <p>WorldGuard is placed as the owner of all values.</p>
|
||||
*/
|
||||
public final class WGMetadata {
|
||||
|
||||
private WGMetadata() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add some metadata to a target.
|
||||
*
|
||||
* @param target the target
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
public static void put(Metadatable target, String key, Object value) {
|
||||
target.setMetadata(key, new FixedMetadataValue(WorldGuardPlugin.inst(), value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the (first) metadata value on the given target that has the given
|
||||
* key and is of the given class type.
|
||||
*
|
||||
* @param target the target
|
||||
* @param key the key
|
||||
* @param expected the type of the value
|
||||
* @param <T> the type of the value
|
||||
* @return a value, or {@code null} if one does not exists
|
||||
*/
|
||||
@Nullable
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getIfPresent(Metadatable target, String key, Class<T> expected) {
|
||||
List<MetadataValue> values = target.getMetadata(key);
|
||||
WorldGuardPlugin owner = WorldGuardPlugin.inst();
|
||||
for (MetadataValue value : values) {
|
||||
if (value.getOwningPlugin() == owner) {
|
||||
Object v = value.value();
|
||||
if (expected.isInstance(v)) {
|
||||
return (T) v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.cause.Cause;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||
import com.sk89q.worldguard.domains.Association;
|
||||
import com.sk89q.worldguard.protection.DelayedRegionOverlapAssociation;
|
||||
import com.sk89q.worldguard.protection.association.Associables;
|
||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
/**
|
||||
* Abstract listener to ease creation of listeners.
|
||||
*/
|
||||
class AbstractListener implements Listener {
|
||||
|
||||
private final WorldGuardPlugin plugin;
|
||||
|
||||
/**
|
||||
* Construct the listener.
|
||||
*
|
||||
* @param plugin an instance of WorldGuardPlugin
|
||||
*/
|
||||
public AbstractListener(WorldGuardPlugin plugin) {
|
||||
checkNotNull(plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register events.
|
||||
*/
|
||||
public void registerEvents() {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin.
|
||||
*
|
||||
* @return the plugin
|
||||
*/
|
||||
protected WorldGuardPlugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the global configuration.
|
||||
*
|
||||
* @return the configuration
|
||||
*/
|
||||
protected static ConfigurationManager getConfig() {
|
||||
return WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the world configuration given a world.
|
||||
*
|
||||
* @param world The world to get the configuration for.
|
||||
* @return The configuration for {@code world}
|
||||
*/
|
||||
protected static WorldConfiguration getWorldConfig(World world) {
|
||||
return getConfig().get(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the world configuration given a player.
|
||||
*
|
||||
* @param player The player to get the wold from
|
||||
* @return The {@link WorldConfiguration} for the player's world
|
||||
*/
|
||||
protected static WorldConfiguration getWorldConfig(LocalPlayer player) {
|
||||
return getWorldConfig((World) player.getExtent());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether region support is enabled.
|
||||
*
|
||||
* @param world the world
|
||||
* @return true if region support is enabled
|
||||
*/
|
||||
protected static boolean isRegionSupportEnabled(World world) {
|
||||
return getWorldConfig(world).useRegions;
|
||||
}
|
||||
|
||||
protected RegionAssociable createRegionAssociable(Cause cause) {
|
||||
Object rootCause = cause.getRootCause();
|
||||
|
||||
if (!cause.isKnown()) {
|
||||
return Associables.constant(Association.NON_MEMBER);
|
||||
} else if (rootCause instanceof Player) {
|
||||
return getPlugin().wrapPlayer((Player) rootCause);
|
||||
} else if (rootCause instanceof OfflinePlayer) {
|
||||
return getPlugin().wrapOfflinePlayer((OfflinePlayer) rootCause);
|
||||
} else if (rootCause instanceof Entity) {
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
final Entity entity = (Entity) rootCause;
|
||||
Location loc;
|
||||
if (PaperLib.isPaper()
|
||||
&& ((BukkitWorldConfiguration) getWorldConfig(BukkitAdapter.adapt(entity.getWorld()))).usePaperEntityOrigin) {
|
||||
loc = entity.getOrigin();
|
||||
if (loc == null) {
|
||||
loc = entity.getLocation();
|
||||
}
|
||||
} else {
|
||||
loc = entity.getLocation();
|
||||
}
|
||||
return new DelayedRegionOverlapAssociation(query, BukkitAdapter.adapt(loc));
|
||||
} else if (rootCause instanceof Block) {
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
return new DelayedRegionOverlapAssociation(query, BukkitAdapter.adapt(((Block) rootCause).getLocation()));
|
||||
} else {
|
||||
return Associables.constant(Association.NON_MEMBER);
|
||||
}
|
||||
}
|
||||
}
|
||||
+395
@@ -0,0 +1,395 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.blacklist.event.BlockBreakBlacklistEvent;
|
||||
import com.sk89q.worldguard.blacklist.event.BlockDispenseBlacklistEvent;
|
||||
import com.sk89q.worldguard.blacklist.event.BlockInteractBlacklistEvent;
|
||||
import com.sk89q.worldguard.blacklist.event.BlockPlaceBlacklistEvent;
|
||||
import com.sk89q.worldguard.blacklist.event.ItemAcquireBlacklistEvent;
|
||||
import com.sk89q.worldguard.blacklist.event.ItemDestroyWithBlacklistEvent;
|
||||
import com.sk89q.worldguard.blacklist.event.ItemDropBlacklistEvent;
|
||||
import com.sk89q.worldguard.blacklist.event.ItemEquipBlacklistEvent;
|
||||
import com.sk89q.worldguard.blacklist.event.ItemUseBlacklistEvent;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.event.block.BreakBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.block.PlaceBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.block.UseBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.DestroyEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.SpawnEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.inventory.UseItemEvent;
|
||||
import com.sk89q.worldguard.bukkit.util.Materials;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockDispenseArmorEvent;
|
||||
import org.bukkit.event.block.BlockDispenseEvent;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCreativeEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.createTarget;
|
||||
|
||||
/**
|
||||
* Handle events that need to be processed by the blacklist.
|
||||
*/
|
||||
public class BlacklistListener extends AbstractListener {
|
||||
|
||||
/**
|
||||
* Construct the listener.
|
||||
*
|
||||
* @param plugin an instance of WorldGuardPlugin
|
||||
*/
|
||||
public BlacklistListener(WorldGuardPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onBreakBlock(final BreakBlockEvent event) {
|
||||
final Player player = event.getCause().getFirstPlayer();
|
||||
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
final WorldConfiguration wcfg = getWorldConfig(localPlayer);
|
||||
|
||||
// Blacklist guard
|
||||
if (wcfg.getBlacklist() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.filter(target -> {
|
||||
if (!wcfg.getBlacklist().check(
|
||||
new BlockBreakBlacklistEvent(localPlayer, BukkitAdapter.asBlockVector(target),
|
||||
createTarget(target.getBlock(), event.getEffectiveMaterial())), false, false)) {
|
||||
return false;
|
||||
} else if (!wcfg.getBlacklist().check(
|
||||
new ItemDestroyWithBlacklistEvent(localPlayer, BukkitAdapter.asBlockVector(target),
|
||||
createTarget(player.getInventory().getItemInMainHand())), false, false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlaceBlock(final PlaceBlockEvent event) {
|
||||
Player player = event.getCause().getFirstPlayer();
|
||||
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
final WorldConfiguration wcfg = getWorldConfig(localPlayer);
|
||||
|
||||
// Blacklist guard
|
||||
if (wcfg.getBlacklist() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.filter(target -> wcfg.getBlacklist().check(new BlockPlaceBlacklistEvent(
|
||||
localPlayer, BukkitAdapter.asBlockVector(target), createTarget(target.getBlock(), event.getEffectiveMaterial())), false, false));
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onUseBlock(final UseBlockEvent event) {
|
||||
Player player = event.getCause().getFirstPlayer();
|
||||
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
final WorldConfiguration wcfg = getWorldConfig(localPlayer);
|
||||
|
||||
// Blacklist guard
|
||||
if (wcfg.getBlacklist() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.filter(target -> wcfg.getBlacklist().check(new BlockInteractBlacklistEvent(
|
||||
localPlayer, BukkitAdapter.asBlockVector(target), createTarget(target.getBlock(), event.getEffectiveMaterial())), false, false));
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onSpawnEntity(SpawnEntityEvent event) {
|
||||
Player player = event.getCause().getFirstPlayer();
|
||||
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
WorldConfiguration wcfg = getWorldConfig(localPlayer);
|
||||
|
||||
// Blacklist guard
|
||||
if (wcfg.getBlacklist() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Material material = Materials.getRelatedMaterial(event.getEffectiveType());
|
||||
if (material != null) {
|
||||
if (!wcfg.getBlacklist().check(new ItemUseBlacklistEvent(
|
||||
localPlayer, BukkitAdapter.asBlockVector(event.getTarget()), createTarget(material)), false, false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onDestroyEntity(DestroyEntityEvent event) {
|
||||
Player player = event.getCause().getFirstPlayer();
|
||||
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
Entity target = event.getEntity();
|
||||
WorldConfiguration wcfg = getWorldConfig(localPlayer);
|
||||
|
||||
// Blacklist guard
|
||||
if (wcfg.getBlacklist() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (target instanceof Item) {
|
||||
Item item = (Item) target;
|
||||
if (!wcfg.getBlacklist().check(
|
||||
new ItemAcquireBlacklistEvent(localPlayer,
|
||||
BukkitAdapter.asBlockVector(target.getLocation()), createTarget(item.getItemStack())), false, true)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Material material = Materials.getRelatedMaterial(target.getType());
|
||||
if (material != null) {
|
||||
// Not really a block but we only have one on-break blacklist event
|
||||
if (!wcfg.getBlacklist().check(new BlockBreakBlacklistEvent(
|
||||
localPlayer, BukkitAdapter.asBlockVector(event.getTarget()), createTarget(material)), false, false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onUseItem(UseItemEvent event) {
|
||||
Player player = event.getCause().getFirstPlayer();
|
||||
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
ItemStack target = event.getItemStack();
|
||||
WorldConfiguration wcfg = getWorldConfig(localPlayer);
|
||||
|
||||
// Blacklist guard
|
||||
if (wcfg.getBlacklist() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!wcfg.getBlacklist().check(new ItemUseBlacklistEvent(
|
||||
localPlayer, BukkitAdapter.asBlockVector(player.getLocation()), createTarget(target)), false, false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Materials.isArmor(target.getType()) && !wcfg.getBlacklist().check(new ItemEquipBlacklistEvent(
|
||||
localPlayer, BukkitAdapter.asBlockVector(player.getLocation()), createTarget(target)), false, false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(event.getPlayer().getWorld()));
|
||||
|
||||
if (wcfg.getBlacklist() != null) {
|
||||
Item ci = event.getItemDrop();
|
||||
|
||||
if (!wcfg.getBlacklist().check(
|
||||
new ItemDropBlacklistEvent(getPlugin().wrapPlayer(event.getPlayer()),
|
||||
BukkitAdapter.asBlockVector(ci.getLocation()), createTarget(ci.getItemStack())), false, false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onBlockDispense(BlockDispenseEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(event.getBlock().getWorld()));
|
||||
|
||||
if (wcfg.getBlacklist() != null) {
|
||||
if (!wcfg.getBlacklist().check(new BlockDispenseBlacklistEvent(null, BukkitAdapter.asBlockVector(event.getBlock().getLocation()),
|
||||
createTarget(event.getItem())), false, false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
HumanEntity entity = event.getWhoClicked();
|
||||
if (!(entity instanceof Player)) return;
|
||||
Inventory inventory = event.getInventory();
|
||||
ItemStack item = event.getCurrentItem();
|
||||
|
||||
if (item != null && inventory.getHolder() != null) {
|
||||
Player player = (Player) entity;
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(entity.getWorld()));
|
||||
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
|
||||
if (wcfg.getBlacklist() != null && !wcfg.getBlacklist().check(
|
||||
new ItemAcquireBlacklistEvent(localPlayer, BukkitAdapter.asBlockVector(entity.getLocation()), createTarget(item)), false, false)) {
|
||||
event.setCancelled(true);
|
||||
|
||||
if (inventory.getHolder().equals(player)) {
|
||||
event.setCurrentItem(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ItemStack equipped = checkEquipped(event);
|
||||
if (equipped != null) {
|
||||
if (wcfg.getBlacklist() != null && !wcfg.getBlacklist().check(new ItemEquipBlacklistEvent(localPlayer,
|
||||
BukkitAdapter.asBlockVector(player.getLocation()), createTarget(equipped)), false, false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onInventoryDrag(InventoryDragEvent event) {
|
||||
HumanEntity entity = event.getWhoClicked();
|
||||
if (!(entity instanceof Player)) return;
|
||||
if (event.getInventory().getType() != InventoryType.PLAYER
|
||||
&& event.getInventory().getType() != InventoryType.CRAFTING) return;
|
||||
if (event.getRawSlots().stream().anyMatch(i -> i >= 5 && i <= 8)) { // dropped on armor slots
|
||||
Player player = (Player) entity;
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(entity.getWorld()));
|
||||
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
if (wcfg.getBlacklist() != null && !wcfg.getBlacklist().check(new ItemEquipBlacklistEvent(localPlayer,
|
||||
BukkitAdapter.asBlockVector(player.getLocation()), createTarget(event.getOldCursor())), false, false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ItemStack checkEquipped(InventoryClickEvent event) {
|
||||
final Inventory clickedInventory = event.getClickedInventory();
|
||||
if (event.getSlotType() == InventoryType.SlotType.ARMOR) {
|
||||
switch (event.getAction()) {
|
||||
case PLACE_ONE:
|
||||
case PLACE_SOME:
|
||||
case PLACE_ALL:
|
||||
case SWAP_WITH_CURSOR:
|
||||
final ItemStack cursor = event.getCursor();
|
||||
if (cursor != null) {
|
||||
return cursor;
|
||||
}
|
||||
case HOTBAR_SWAP:
|
||||
return clickedInventory == null ? null : clickedInventory.getItem(event.getHotbarButton());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (clickedInventory != null && clickedInventory.getType() == InventoryType.PLAYER
|
||||
&& event.getView().getTopInventory().getType() == InventoryType.PLAYER
|
||||
&& event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
|
||||
return event.getCurrentItem();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onInventoryCreative(InventoryCreativeEvent event) {
|
||||
HumanEntity entity = event.getWhoClicked();
|
||||
ItemStack item = event.getCursor();
|
||||
|
||||
if (item.getType() != Material.AIR && entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(entity.getWorld()));
|
||||
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
|
||||
if (wcfg.getBlacklist() != null && !wcfg.getBlacklist().check(
|
||||
new ItemAcquireBlacklistEvent(localPlayer, BukkitAdapter.asBlockVector(entity.getLocation()), createTarget(item)), false, false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerItemHeld(PlayerItemHeldEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Inventory inventory = player.getInventory();
|
||||
ItemStack item = inventory.getItem(event.getNewSlot());
|
||||
|
||||
if (item != null) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(player.getWorld()));
|
||||
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
|
||||
if (wcfg.getBlacklist() != null && !wcfg.getBlacklist().check(
|
||||
new ItemAcquireBlacklistEvent(localPlayer, BukkitAdapter.asBlockVector(player.getLocation()), createTarget(item)), false, false)) {
|
||||
inventory.setItem(event.getNewSlot(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onBlockDispenseArmor(BlockDispenseArmorEvent event) {
|
||||
if (!(event.getTargetEntity() instanceof Player)) return;
|
||||
Player player = ((Player) event.getTargetEntity());
|
||||
ItemStack stack = event.getItem();
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(player.getWorld()));
|
||||
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
if (wcfg.getBlacklist() != null && !wcfg.getBlacklist().check(
|
||||
new ItemEquipBlacklistEvent(localPlayer, BukkitAdapter.asBlockVector(player.getLocation()), createTarget(stack)), false, true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.DamageEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.inventory.UseItemEvent;
|
||||
import com.sk89q.worldguard.bukkit.util.Entities;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.SpectralArrow;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
/**
|
||||
* Handles blocked potions.
|
||||
*/
|
||||
public class BlockedPotionsListener extends AbstractListener {
|
||||
|
||||
/**
|
||||
* Construct the listener.
|
||||
*
|
||||
* @param plugin an instance of WorldGuardPlugin
|
||||
*/
|
||||
public BlockedPotionsListener(WorldGuardPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onProjectile(DamageEntityEvent event) {
|
||||
if (event.getOriginalEvent() instanceof EntityDamageByEntityEvent) {
|
||||
EntityDamageByEntityEvent originalEvent = (EntityDamageByEntityEvent) event.getOriginalEvent();
|
||||
if (Entities.isPotionArrow(originalEvent.getDamager())) { // should take care of backcompat
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(event.getWorld()));
|
||||
PotionEffectType blockedEffect = null;
|
||||
if (originalEvent.getDamager() instanceof SpectralArrow) {
|
||||
if (wcfg.blockPotions.contains(PotionEffectType.GLOWING)) {
|
||||
blockedEffect = PotionEffectType.GLOWING;
|
||||
}
|
||||
} else if (originalEvent.getDamager() instanceof Arrow) {
|
||||
Arrow tippedArrow = (Arrow) originalEvent.getDamager();
|
||||
PotionEffectType baseEffect = tippedArrow.getBasePotionData().getType().getEffectType();
|
||||
if (wcfg.blockPotions.contains(baseEffect)) {
|
||||
blockedEffect = baseEffect;
|
||||
} else {
|
||||
for (PotionEffect potionEffect : tippedArrow.getCustomEffects()) {
|
||||
if (wcfg.blockPotions.contains(potionEffect.getType())) {
|
||||
blockedEffect = potionEffect.getType();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (blockedEffect != null) {
|
||||
Player player = event.getCause().getFirstPlayer();
|
||||
if (player != null) {
|
||||
if (getPlugin().hasPermission(player, "worldguard.override.potions")) {
|
||||
return;
|
||||
}
|
||||
player.sendMessage(ChatColor.RED + "Sorry, arrows with "
|
||||
+ blockedEffect.getName() + " are presently disabled.");
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemInteract(UseItemEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(event.getWorld()));
|
||||
ItemStack item = event.getItemStack();
|
||||
|
||||
if (item.getType() != Material.POTION
|
||||
&& item.getType() != Material.SPLASH_POTION
|
||||
&& item.getType() != Material.LINGERING_POTION) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!wcfg.blockPotions.isEmpty()) {
|
||||
PotionEffectType blockedEffect = null;
|
||||
|
||||
PotionMeta meta;
|
||||
if (item.getItemMeta() instanceof PotionMeta) {
|
||||
meta = ((PotionMeta) item.getItemMeta());
|
||||
} else {
|
||||
return; // ok...?
|
||||
}
|
||||
|
||||
// Find the first blocked effect
|
||||
PotionEffectType baseEffect = meta.getBasePotionData().getType().getEffectType();
|
||||
if (wcfg.blockPotions.contains(baseEffect)) {
|
||||
blockedEffect = baseEffect;
|
||||
}
|
||||
|
||||
if (blockedEffect == null && meta.hasCustomEffects()) {
|
||||
for (PotionEffect effect : meta.getCustomEffects()) {
|
||||
if (wcfg.blockPotions.contains(effect.getType())) {
|
||||
blockedEffect = effect.getType();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (blockedEffect != null) {
|
||||
Player player = event.getCause().getFirstPlayer();
|
||||
|
||||
if (player != null) {
|
||||
if (getPlugin().hasPermission(player, "worldguard.override.potions")) {
|
||||
if (wcfg.blockPotionsAlways && (item.getType() == Material.SPLASH_POTION
|
||||
|| item.getType() == Material.LINGERING_POTION)) {
|
||||
player.sendMessage(ChatColor.RED + "Sorry, potions with " +
|
||||
blockedEffect.getName() + " can't be thrown, " +
|
||||
"even if you have a permission to bypass it, " +
|
||||
"due to limitations (and because overly-reliable potion blocking is on).");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "Sorry, potions with "
|
||||
+ blockedEffect.getName() + " are presently disabled.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+209
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.event.block.BreakBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.block.PlaceBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.block.UseBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.DamageEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.DestroyEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.SpawnEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.UseEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.inventory.UseItemEvent;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
public class BuildPermissionListener extends AbstractListener {
|
||||
|
||||
/**
|
||||
* Construct the listener.
|
||||
*
|
||||
* @param plugin an instance of WorldGuardPlugin
|
||||
*/
|
||||
public BuildPermissionListener(WorldGuardPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
private boolean hasBuildPermission(CommandSender sender, String perm) {
|
||||
return getPlugin().hasPermission(sender, "worldguard.build." + perm);
|
||||
}
|
||||
|
||||
private void tellErrorMessage(CommandSender sender, World world) {
|
||||
String message = getWorldConfig(BukkitAdapter.adapt(world)).buildPermissionDenyMessage;
|
||||
if (!message.isEmpty()) {
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlaceBlock(final PlaceBlockEvent event) {
|
||||
if (!getWorldConfig(BukkitAdapter.adapt(event.getWorld())).buildPermissions) return;
|
||||
|
||||
Object rootCause = event.getCause().getRootCause();
|
||||
|
||||
if (rootCause instanceof Player) {
|
||||
final Player player = (Player) rootCause;
|
||||
final Material material = event.getEffectiveMaterial();
|
||||
|
||||
if (!hasBuildPermission(player, "block." + material.name().toLowerCase() + ".place")
|
||||
&& !hasBuildPermission(player, "block.place." + material.name().toLowerCase())) {
|
||||
tellErrorMessage(player, event.getWorld());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onBreakBlock(final BreakBlockEvent event) {
|
||||
if (!getWorldConfig(BukkitAdapter.adapt(event.getWorld())).buildPermissions) return;
|
||||
|
||||
Object rootCause = event.getCause().getRootCause();
|
||||
|
||||
if (rootCause instanceof Player) {
|
||||
final Player player = (Player) rootCause;
|
||||
final Material material = event.getEffectiveMaterial();
|
||||
|
||||
if (!hasBuildPermission(player, "block." + material.name().toLowerCase() + ".remove")
|
||||
&& !hasBuildPermission(player, "block.remove." + material.name().toLowerCase())) {
|
||||
tellErrorMessage(player, event.getWorld());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onUseBlock(final UseBlockEvent event) {
|
||||
if (!getWorldConfig(BukkitAdapter.adapt(event.getWorld())).buildPermissions) return;
|
||||
|
||||
Object rootCause = event.getCause().getRootCause();
|
||||
|
||||
if (rootCause instanceof Player) {
|
||||
final Player player = (Player) rootCause;
|
||||
final Material material = event.getEffectiveMaterial();
|
||||
|
||||
if (!hasBuildPermission(player, "block." + material.name().toLowerCase() + ".interact")
|
||||
&& !hasBuildPermission(player, "block.interact." + material.name().toLowerCase())) {
|
||||
tellErrorMessage(player, event.getWorld());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onSpawnEntity(SpawnEntityEvent event) {
|
||||
if (!getWorldConfig(BukkitAdapter.adapt(event.getWorld())).buildPermissions) return;
|
||||
|
||||
Object rootCause = event.getCause().getRootCause();
|
||||
|
||||
if (rootCause instanceof Player) {
|
||||
final Player player = (Player) rootCause;
|
||||
final EntityType type = event.getEffectiveType();
|
||||
|
||||
if (!hasBuildPermission(player, "entity." + type.name().toLowerCase() + ".place")
|
||||
&& !hasBuildPermission(player, "entity.place." + type.name().toLowerCase())) {
|
||||
tellErrorMessage(player, event.getWorld());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onDestroyEntity(DestroyEntityEvent event) {
|
||||
if (!getWorldConfig(BukkitAdapter.adapt(event.getWorld())).buildPermissions) return;
|
||||
|
||||
Object rootCause = event.getCause().getRootCause();
|
||||
|
||||
if (rootCause instanceof Player) {
|
||||
final Player player = (Player) rootCause;
|
||||
final EntityType type = event.getEntity().getType();
|
||||
|
||||
if (!hasBuildPermission(player, "entity." + type.name().toLowerCase() + ".remove")
|
||||
&& !hasBuildPermission(player, "entity.remove." + type.name().toLowerCase())) {
|
||||
tellErrorMessage(player, event.getWorld());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onUseEntity(UseEntityEvent event) {
|
||||
if (!getWorldConfig(BukkitAdapter.adapt(event.getWorld())).buildPermissions) return;
|
||||
|
||||
Object rootCause = event.getCause().getRootCause();
|
||||
|
||||
if (rootCause instanceof Player) {
|
||||
final Player player = (Player) rootCause;
|
||||
final EntityType type = event.getEntity().getType();
|
||||
|
||||
if (!hasBuildPermission(player, "entity." + type.name().toLowerCase() + ".interact")
|
||||
&& !hasBuildPermission(player, "entity.interact." + type.name().toLowerCase())) {
|
||||
tellErrorMessage(player, event.getWorld());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onDamageEntity(DamageEntityEvent event) {
|
||||
if (!getWorldConfig(BukkitAdapter.adapt(event.getWorld())).buildPermissions) return;
|
||||
|
||||
Object rootCause = event.getCause().getRootCause();
|
||||
|
||||
if (rootCause instanceof Player) {
|
||||
final Player player = (Player) rootCause;
|
||||
final EntityType type = event.getEntity().getType();
|
||||
|
||||
if (!hasBuildPermission(player, "entity." + type.name().toLowerCase() + ".damage")
|
||||
&& !hasBuildPermission(player, "entity.damage." + type.name().toLowerCase())) {
|
||||
tellErrorMessage(player, event.getWorld());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onUseItem(UseItemEvent event) {
|
||||
if (!getWorldConfig(BukkitAdapter.adapt(event.getWorld())).buildPermissions) return;
|
||||
|
||||
Object rootCause = event.getCause().getRootCause();
|
||||
|
||||
if (rootCause instanceof Player) {
|
||||
Player player = (Player) rootCause;
|
||||
Material material = event.getItemStack().getType();
|
||||
|
||||
if (material.isBlock()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hasBuildPermission(player, "item." + material.name().toLowerCase() + ".use")
|
||||
&& !hasBuildPermission(player, "item.use." + material.name().toLowerCase())) {
|
||||
tellErrorMessage(player, event.getWorld());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+192
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.event.DelegateEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.block.BreakBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.block.PlaceBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.block.UseBlockEvent;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
/**
|
||||
* Handle events that need to be processed by the chest protection.
|
||||
*/
|
||||
public class ChestProtectionListener extends AbstractListener {
|
||||
|
||||
/**
|
||||
* Construct the listener.
|
||||
*
|
||||
* @param plugin an instance of WorldGuardPlugin
|
||||
*/
|
||||
public ChestProtectionListener(WorldGuardPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
private void sendMessage(DelegateEvent event, Player player, String message) {
|
||||
if (!event.isSilent()) {
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlaceBlock(final PlaceBlockEvent event) {
|
||||
final Player player = event.getCause().getFirstPlayer();
|
||||
|
||||
if (player != null) {
|
||||
final BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) getWorldConfig(WorldGuardPlugin.inst().wrapPlayer(player));
|
||||
|
||||
// Early guard
|
||||
if (!wcfg.signChestProtection) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.filter(target -> {
|
||||
if (wcfg.getChestProtection().isChest(BukkitAdapter.asBlockType(event.getEffectiveMaterial())) && wcfg.isChestProtected(BukkitAdapter.adapt(target.getBlock().getLocation()),
|
||||
WorldGuardPlugin.inst().wrapPlayer(player))) {
|
||||
sendMessage(event, player, ChatColor.DARK_RED + "This spot is for a chest that you don't have permission for.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onBreakBlock(final BreakBlockEvent event) {
|
||||
final Player player = event.getCause().getFirstPlayer();
|
||||
|
||||
final BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) getWorldConfig(BukkitAdapter.adapt(event.getWorld()));
|
||||
|
||||
// Early guard
|
||||
if (!wcfg.signChestProtection) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player != null) {
|
||||
final LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
event.filter(target -> {
|
||||
if (wcfg.isChestProtected(BukkitAdapter.adapt(target.getBlock().getLocation()), localPlayer)) {
|
||||
sendMessage(event, player, ChatColor.DARK_RED + "This chest is protected.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}, true);
|
||||
} else {
|
||||
event.filter(target -> !wcfg.isChestProtected(BukkitAdapter.adapt(target.getBlock().getLocation())));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onUseBlock(final UseBlockEvent event) {
|
||||
final Player player = event.getCause().getFirstPlayer();
|
||||
|
||||
final BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) getWorldConfig(BukkitAdapter.adapt(event.getWorld()));
|
||||
|
||||
// Early guard
|
||||
if (!wcfg.signChestProtection) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player != null) {
|
||||
final LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
event.filter(target -> {
|
||||
if (wcfg.isChestProtected(BukkitAdapter.adapt(target.getBlock().getLocation()), localPlayer)) {
|
||||
sendMessage(event, player, ChatColor.DARK_RED + "This chest is protected.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}, true);
|
||||
} else {
|
||||
event.filter(target -> !wcfg.isChestProtected(BukkitAdapter.adapt(target.getBlock().getLocation())));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onSignChange(SignChangeEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) getWorldConfig(WorldGuardPlugin.inst().wrapPlayer(player));
|
||||
|
||||
if (wcfg.signChestProtection) {
|
||||
if ("[Lock]".equalsIgnoreCase(event.getLine(0))) {
|
||||
if (wcfg.isChestProtectedPlacement(BukkitAdapter.adapt(event.getBlock().getLocation()), WorldGuardPlugin.inst().wrapPlayer(player))) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You do not own the adjacent chest.");
|
||||
event.getBlock().breakNaturally();
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Tag.STANDING_SIGNS.isTagged(event.getBlock().getType())) {
|
||||
player.sendMessage(ChatColor.RED
|
||||
+ "The [Lock] sign must be a sign post, not a wall sign.");
|
||||
|
||||
event.getBlock().breakNaturally();
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.getName().equalsIgnoreCase(event.getLine(1))) {
|
||||
player.sendMessage(ChatColor.RED
|
||||
+ "The first owner line must be your name.");
|
||||
|
||||
event.getBlock().breakNaturally();
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Material below = event.getBlock().getRelative(0, -1, 0).getType();
|
||||
|
||||
if (below == Material.TNT || below == Material.SAND
|
||||
|| below == Material.GRAVEL || Tag.STANDING_SIGNS.isTagged(below)) {
|
||||
player.sendMessage(ChatColor.RED
|
||||
+ "That is not a safe block that you're putting this sign on.");
|
||||
|
||||
event.getBlock().breakNaturally();
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
event.setLine(0, "[Lock]");
|
||||
player.sendMessage(ChatColor.YELLOW
|
||||
+ "A chest or double chest above is now protected.");
|
||||
}
|
||||
} else if (!wcfg.disableSignChestProtectionCheck) {
|
||||
if ("[Lock]".equalsIgnoreCase(event.getLine(0))) {
|
||||
player.sendMessage(ChatColor.RED
|
||||
+ "WorldGuard's sign chest protection is disabled.");
|
||||
|
||||
event.getBlock().breakNaturally();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+229
@@ -0,0 +1,229 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.event.block.BreakBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.block.PlaceBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.block.UseBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.DamageEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.DestroyEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.SpawnEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.UseEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.inventory.UseItemEvent;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Event.Result;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class DebuggingListener extends AbstractListener {
|
||||
|
||||
private final Logger logger;
|
||||
|
||||
/**
|
||||
* Construct the listener.
|
||||
*
|
||||
* @param plugin an instance of WorldGuardPlugin
|
||||
* @param logger the logger
|
||||
*/
|
||||
public DebuggingListener(WorldGuardPlugin plugin, Logger logger) {
|
||||
super(plugin);
|
||||
checkNotNull(logger);
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlaceBlock(PlaceBlockEvent event) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("PLACE");
|
||||
builder.append(" ");
|
||||
builder.append(event.getEffectiveMaterial());
|
||||
builder.append(" ");
|
||||
builder.append("@").append(toBlockString(event.getBlocks()));
|
||||
builder.append(" ");
|
||||
builder.append("[").append(event.getCause()).append("]");
|
||||
builder.append(" ");
|
||||
builder.append(": ").append(getEventName(event.getOriginalEvent()));
|
||||
if (event.getResult() != Result.DEFAULT) {
|
||||
builder.append(" [").append(event.getResult()).append("]");
|
||||
}
|
||||
logger.info(builder.toString());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onBreakBlock(BreakBlockEvent event) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("DIG");
|
||||
builder.append(" ");
|
||||
builder.append(event.getEffectiveMaterial());
|
||||
builder.append(" ");
|
||||
builder.append("[").append(event.getCause()).append("]");
|
||||
builder.append(" ");
|
||||
builder.append("@").append(toBlockString(event.getBlocks()));
|
||||
builder.append(" ");
|
||||
builder.append(": ").append(getEventName(event.getOriginalEvent()));
|
||||
if (event.getResult() != Result.DEFAULT) {
|
||||
builder.append(" [").append(event.getResult()).append("]");
|
||||
}
|
||||
logger.info(builder.toString());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onUseBlock(UseBlockEvent event) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("INTERACT");
|
||||
builder.append(" ");
|
||||
builder.append(event.getEffectiveMaterial());
|
||||
builder.append(" ");
|
||||
builder.append("[").append(event.getCause()).append("]");
|
||||
builder.append(" ");
|
||||
builder.append("@").append(toBlockString(event.getBlocks()));
|
||||
builder.append(" ");
|
||||
builder.append(": ").append(getEventName(event.getOriginalEvent()));
|
||||
if (event.getOriginalEvent() instanceof PlayerInteractEvent) {
|
||||
builder.append(".").append(((PlayerInteractEvent) event.getOriginalEvent()).getAction());
|
||||
}
|
||||
if (event.getResult() != Result.DEFAULT) {
|
||||
builder.append(" [").append(event.getResult()).append("]");
|
||||
}
|
||||
logger.info(builder.toString());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onSpawnEntity(SpawnEntityEvent event) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("SPAWN");
|
||||
builder.append(" ");
|
||||
builder.append(event.getEffectiveType());
|
||||
builder.append(" ");
|
||||
builder.append("[").append(event.getCause()).append("]");
|
||||
builder.append(" ");
|
||||
builder.append("@").append(toBlockString(event.getTarget()));
|
||||
builder.append(" ");
|
||||
builder.append(": ").append(getEventName(event.getOriginalEvent()));
|
||||
if (event.getResult() != Result.DEFAULT) {
|
||||
builder.append(" [").append(event.getResult()).append("]");
|
||||
}
|
||||
logger.info(builder.toString());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onDestroyEntity(DestroyEntityEvent event) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("DESTROY");
|
||||
builder.append(" ");
|
||||
builder.append(event.getEntity().getType());
|
||||
builder.append(" ");
|
||||
builder.append("[").append(event.getCause()).append("]");
|
||||
builder.append(" ");
|
||||
builder.append("@").append(toBlockString(event.getTarget()));
|
||||
builder.append(" ");
|
||||
builder.append(": ").append(getEventName(event.getOriginalEvent()));
|
||||
if (event.getResult() != Result.DEFAULT) {
|
||||
builder.append(" [").append(event.getResult()).append("]");
|
||||
}
|
||||
logger.info(builder.toString());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onUseEntity(UseEntityEvent event) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("INTERACT");
|
||||
builder.append(" ");
|
||||
builder.append(event.getEntity().getType());
|
||||
builder.append(" ");
|
||||
builder.append("[").append(event.getCause()).append("]");
|
||||
builder.append(" ");
|
||||
builder.append("@").append(toBlockString(event.getTarget()));
|
||||
builder.append(" ");
|
||||
builder.append(": ").append(getEventName(event.getOriginalEvent()));
|
||||
if (event.getResult() != Result.DEFAULT) {
|
||||
builder.append(" [").append(event.getResult()).append("]");
|
||||
}
|
||||
logger.info(builder.toString());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onDamageEntity(DamageEntityEvent event) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("DAMAGE");
|
||||
builder.append(" ");
|
||||
builder.append(event.getEntity().getType());
|
||||
builder.append(" ");
|
||||
builder.append("[").append(event.getCause()).append("]");
|
||||
builder.append(" ");
|
||||
builder.append("@").append(toBlockString(event.getTarget()));
|
||||
builder.append(" ");
|
||||
builder.append(": ").append(getEventName(event.getOriginalEvent()));
|
||||
if (event.getResult() != Result.DEFAULT) {
|
||||
builder.append(" [").append(event.getResult()).append("]");
|
||||
}
|
||||
logger.info(builder.toString());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onUseItem(UseItemEvent event) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("USE");
|
||||
builder.append(" ");
|
||||
builder.append(event.getItemStack().getType());
|
||||
builder.append(" ");
|
||||
builder.append("[").append(event.getCause()).append("]");
|
||||
builder.append(" ");
|
||||
builder.append("@").append(event.getWorld().getName());
|
||||
builder.append(" ");
|
||||
builder.append(": ").append(getEventName(event.getOriginalEvent()));
|
||||
if (event.getResult() != Result.DEFAULT) {
|
||||
builder.append(" [").append(event.getResult()).append("]");
|
||||
}
|
||||
logger.info(builder.toString());
|
||||
}
|
||||
|
||||
private static String toBlockString(Location location) {
|
||||
return location.getBlockX() + "," + location.getBlockY() + "," + location.getBlockZ();
|
||||
}
|
||||
|
||||
private static String toBlockString(List<Block> blocks) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
boolean first = true;
|
||||
for (Block block : blocks) {
|
||||
if (!first) {
|
||||
builder.append("|");
|
||||
}
|
||||
builder.append(block.getX()).append(",").append(block.getY()).append(",").append(block.getZ());
|
||||
first = false;
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private String getEventName(@Nullable Event event) {
|
||||
return event != null ? event.getEventName() : "?";
|
||||
}
|
||||
|
||||
}
|
||||
+1149
File diff suppressed because it is too large.
Load diff
+118
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
|
||||
public class InvincibilityListener extends AbstractListener {
|
||||
|
||||
/**
|
||||
* Construct the listener.
|
||||
*
|
||||
* @param plugin an instance of WorldGuardPlugin
|
||||
*/
|
||||
public InvincibilityListener(WorldGuardPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether a player should be invincible.
|
||||
*
|
||||
* @param player The player
|
||||
* @return True if invincible
|
||||
*/
|
||||
private boolean isInvincible(LocalPlayer player) {
|
||||
return WorldGuard.getInstance().getPlatform().getSessionManager().get(player).isInvincible(player);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
Entity victim = event.getEntity();
|
||||
|
||||
if (victim instanceof Player) {
|
||||
Player player = (Player) victim;
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
|
||||
BukkitWorldConfiguration worldConfig =
|
||||
(BukkitWorldConfiguration) WorldGuard.getInstance().getPlatform().getGlobalStateManager().get((World) localPlayer.getExtent());
|
||||
|
||||
if (isInvincible(localPlayer)) {
|
||||
player.setFireTicks(0);
|
||||
event.setCancelled(true);
|
||||
|
||||
if (event instanceof EntityDamageByEntityEvent) {
|
||||
EntityDamageByEntityEvent byEntityEvent = (EntityDamageByEntityEvent) event;
|
||||
Entity attacker = byEntityEvent.getDamager();
|
||||
|
||||
if (attacker instanceof Projectile && ((Projectile) attacker).getShooter() instanceof Entity) {
|
||||
attacker = (Entity) ((Projectile) attacker).getShooter();
|
||||
}
|
||||
|
||||
if (worldConfig.regionInvinciblityRemovesMobs
|
||||
&& attacker instanceof LivingEntity && !(attacker instanceof Player)
|
||||
&& !(attacker instanceof Tameable && ((Tameable) attacker).isTamed())) {
|
||||
attacker.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onEntityCombust(EntityCombustEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
|
||||
if (isInvincible(localPlayer)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
|
||||
if (event.getFoodLevel() < player.getFoodLevel() && isInvincible(localPlayer)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.event.player.ProcessPlayerEvent;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
import com.sk89q.worldguard.session.handler.GodMode;
|
||||
import com.sk89q.worldguard.session.handler.WaterBreathing;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class PlayerModesListener extends AbstractListener {
|
||||
|
||||
private static final Logger log = Logger.getLogger(PlayerModesListener.class.getCanonicalName());
|
||||
|
||||
private static final String INVINCIBLE_PERMISSION = "worldguard.auto-invincible";
|
||||
private static final String INVINCIBLE_GROUP = "wg-invincible";
|
||||
private static final String AMPHIBIOUS_GROUP = "wg-amphibious";
|
||||
|
||||
/**
|
||||
* Construct the listener.
|
||||
*
|
||||
* @param plugin an instance of WorldGuardPlugin
|
||||
*/
|
||||
public PlayerModesListener(WorldGuardPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
private boolean hasGodModeGroup(Player player) {
|
||||
return getConfig().useGodGroup && getPlugin().inGroup(player, INVINCIBLE_GROUP);
|
||||
}
|
||||
|
||||
private boolean hasGodModePermission(Player player) {
|
||||
return getConfig().useGodPermission && getPlugin().hasPermission(player, INVINCIBLE_PERMISSION);
|
||||
}
|
||||
|
||||
private boolean hasAmphibiousGroup(Player player) {
|
||||
return getConfig().useAmphibiousGroup && getPlugin().inGroup(player, AMPHIBIOUS_GROUP);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onProcessPlayer(ProcessPlayerEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().get(localPlayer);
|
||||
|
||||
if (hasGodModeGroup(player) || hasGodModePermission(player)) {
|
||||
if (GodMode.set(localPlayer, session, true)) {
|
||||
log.log(Level.INFO, "Enabled auto-god mode for " + player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (hasAmphibiousGroup(player)) {
|
||||
if (WaterBreathing.set(localPlayer, session, true)) {
|
||||
log.log(Level.INFO, "Enabled water breathing mode for " + player.getName() + " (player is in group 'wg-amphibious')");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.session.MoveType;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class PlayerMoveListener implements Listener {
|
||||
|
||||
private final WorldGuardPlugin plugin;
|
||||
|
||||
public PlayerMoveListener(WorldGuardPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void registerEvents() {
|
||||
if (WorldGuard.getInstance().getPlatform().getGlobalStateManager().usePlayerMove) {
|
||||
PluginManager pm = plugin.getServer().getPluginManager();
|
||||
pm.registerEvents(this, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
LocalPlayer player = plugin.wrapPlayer(event.getPlayer());
|
||||
|
||||
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().get(player);
|
||||
session.testMoveTo(player, BukkitAdapter.adapt(event.getRespawnLocation()), MoveType.RESPAWN, true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onVehicleEnter(VehicleEnterEvent event) {
|
||||
Entity entity = event.getEntered();
|
||||
if (entity instanceof Player) {
|
||||
LocalPlayer player = plugin.wrapPlayer((Player) entity);
|
||||
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().get(player);
|
||||
if (null != session.testMoveTo(player, BukkitAdapter.adapt(event.getVehicle().getLocation()), MoveType.EMBARK, true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().get(localPlayer);
|
||||
MoveType moveType = MoveType.MOVE;
|
||||
if (event.getPlayer().isGliding()) {
|
||||
moveType = MoveType.GLIDE;
|
||||
} else if (event.getPlayer().isSwimming()) {
|
||||
moveType = MoveType.SWIM;
|
||||
} else if (event.getPlayer().getVehicle() != null && event.getPlayer().getVehicle() instanceof Horse) {
|
||||
moveType = MoveType.RIDE;
|
||||
}
|
||||
com.sk89q.worldedit.util.Location weLocation = session.testMoveTo(localPlayer, BukkitAdapter.adapt(event.getTo()), moveType);
|
||||
|
||||
if (weLocation != null) {
|
||||
final Location override = BukkitAdapter.adapt(weLocation);
|
||||
override.setX(override.getBlockX() + 0.5);
|
||||
override.setY(override.getBlockY());
|
||||
override.setZ(override.getBlockZ() + 0.5);
|
||||
override.setPitch(event.getTo().getPitch());
|
||||
override.setYaw(event.getTo().getYaw());
|
||||
|
||||
event.setTo(override.clone());
|
||||
|
||||
Entity vehicle = player.getVehicle();
|
||||
if (vehicle != null) {
|
||||
vehicle.eject();
|
||||
|
||||
Entity current = vehicle;
|
||||
while (current != null) {
|
||||
current.eject();
|
||||
vehicle.setVelocity(new Vector());
|
||||
if (vehicle instanceof LivingEntity) {
|
||||
vehicle.teleport(override.clone());
|
||||
} else {
|
||||
vehicle.teleport(override.clone().add(0, 1, 0));
|
||||
}
|
||||
current = current.getVehicle();
|
||||
}
|
||||
|
||||
player.teleport(override.clone().add(0, 1, 0));
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> player.teleport(override.clone().add(0, 1, 0)), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.event.block.BreakBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.block.PlaceBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.util.Materials;
|
||||
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class RegionFlagsListener extends AbstractListener {
|
||||
|
||||
/**
|
||||
* Construct the listener.
|
||||
*
|
||||
* @param plugin an instance of WorldGuardPlugin
|
||||
*/
|
||||
public RegionFlagsListener(WorldGuardPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlaceBlock(final PlaceBlockEvent event) {
|
||||
com.sk89q.worldedit.world.World weWorld = BukkitAdapter.adapt(event.getWorld());
|
||||
if (!isRegionSupportEnabled(weWorld)) return; // Region support disabled
|
||||
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
|
||||
Block block;
|
||||
if ((block = event.getCause().getFirstBlock()) != null) {
|
||||
if (Materials.isPistonBlock(block.getType())) {
|
||||
event.filter(testState(query, Flags.PISTONS), false);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getCause().find(EntityType.SNOWMAN) != null) {
|
||||
event.filter(testState(query, Flags.SNOWMAN_TRAILS), false);
|
||||
}
|
||||
|
||||
if (event.getCause().find(EntityType.ENDERMAN) != null) {
|
||||
event.filter(testState(query, Flags.ENDER_BUILD), false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBreakBlock(final BreakBlockEvent event) {
|
||||
com.sk89q.worldedit.world.World weWorld = BukkitAdapter.adapt(event.getWorld());
|
||||
if (!isRegionSupportEnabled(weWorld)) return; // Region support disabled
|
||||
|
||||
WorldConfiguration config = getWorldConfig(weWorld);
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
|
||||
Block block;
|
||||
if ((block = event.getCause().getFirstBlock()) != null) {
|
||||
if (Materials.isPistonBlock(block.getType())) {
|
||||
event.filter(testState(query, Flags.PISTONS), false);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getCause().find(EntityType.CREEPER) != null) { // Creeper
|
||||
event.filter(testState(query, Flags.CREEPER_EXPLOSION), config.explosionFlagCancellation);
|
||||
}
|
||||
|
||||
if (event.getCause().find(EntityType.ENDER_DRAGON) != null) { // Enderdragon
|
||||
event.filter(testState(query, Flags.ENDERDRAGON_BLOCK_DAMAGE), config.explosionFlagCancellation);
|
||||
}
|
||||
|
||||
if (event.getCause().find(EntityType.ENDER_CRYSTAL) != null) { // EnderCrystal
|
||||
event.filter(testState(query, Flags.OTHER_EXPLOSION), config.explosionFlagCancellation);
|
||||
}
|
||||
|
||||
if (event.getCause().find(EntityType.ENDERMAN) != null) {
|
||||
event.filter(testState(query, Flags.ENDER_BUILD), false);
|
||||
}
|
||||
|
||||
if (event.getCause().find(EntityType.RAVAGER) != null) {
|
||||
event.filter(testState(query, Flags.RAVAGER_RAVAGE), false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
World world = entity.getWorld();
|
||||
|
||||
if (!isRegionSupportEnabled(BukkitAdapter.adapt(world))) return; // Region support disabled
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
|
||||
if (entity instanceof Player && event.getCause() == DamageCause.FALL) {
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer((Player) entity);
|
||||
if (!query.testState(BukkitAdapter.adapt(entity.getLocation()), localPlayer, Flags.FALL_DAMAGE)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (entity instanceof Player && event.getCause() == DamageCause.FLY_INTO_WALL) {
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer((Player) entity);
|
||||
if (!query.testState(BukkitAdapter.adapt(entity.getLocation()), localPlayer, Flags.FALL_DAMAGE)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new predicate to test a state flag for each location.
|
||||
*
|
||||
* @param query the query
|
||||
* @param flag the flag
|
||||
* @return a predicate
|
||||
*/
|
||||
private Predicate<Location> testState(final RegionQuery query, final StateFlag flag) {
|
||||
return location -> query.testState(BukkitAdapter.adapt(location), (RegionAssociable) null, flag);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+556
@@ -0,0 +1,556 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.cause.Cause;
|
||||
import com.sk89q.worldguard.bukkit.event.DelegateEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.block.BreakBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.block.PlaceBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.block.UseBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.DamageEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.DestroyEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.SpawnEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.UseEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.internal.WGMetadata;
|
||||
import com.sk89q.worldguard.bukkit.protection.events.DisallowedPVPEvent;
|
||||
import com.sk89q.worldguard.bukkit.util.Entities;
|
||||
import com.sk89q.worldguard.bukkit.util.Events;
|
||||
import com.sk89q.worldguard.bukkit.util.InteropUtils;
|
||||
import com.sk89q.worldguard.bukkit.util.Materials;
|
||||
import com.sk89q.worldguard.commands.CommandUtils;
|
||||
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||
import com.sk89q.worldguard.internal.permission.RegionPermissionModel;
|
||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag.State;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.event.Event.Result;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Handle events that need to be processed by region protection.
|
||||
*/
|
||||
public class RegionProtectionListener extends AbstractListener {
|
||||
|
||||
private static final String DENY_MESSAGE_KEY = "worldguard.region.lastMessage";
|
||||
private static final String DISEMBARK_MESSAGE_KEY = "worldguard.region.disembarkMessage";
|
||||
private static final int LAST_MESSAGE_DELAY = 500;
|
||||
|
||||
/**
|
||||
* Construct the listener.
|
||||
*
|
||||
* @param plugin an instance of WorldGuardPlugin
|
||||
*/
|
||||
public RegionProtectionListener(WorldGuardPlugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell a sender that s/he cannot do something 'here'.
|
||||
*
|
||||
* @param event the event
|
||||
* @param cause the cause
|
||||
* @param location the location
|
||||
* @param what what was done
|
||||
*/
|
||||
private void tellErrorMessage(DelegateEvent event, Cause cause, Location location, String what) {
|
||||
if (event.isSilent() || cause.isIndirect()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object rootCause = cause.getRootCause();
|
||||
|
||||
if (rootCause instanceof Player) {
|
||||
Player player = (Player) rootCause;
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
Long lastTime = WGMetadata.getIfPresent(player, DENY_MESSAGE_KEY, Long.class);
|
||||
if (lastTime == null || now - lastTime >= LAST_MESSAGE_DELAY) {
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
String message = query.queryValue(BukkitAdapter.adapt(location), localPlayer, Flags.DENY_MESSAGE);
|
||||
formatAndSendDenyMessage(what, localPlayer, message);
|
||||
WGMetadata.put(player, DENY_MESSAGE_KEY, now);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void formatAndSendDenyMessage(String what, LocalPlayer localPlayer, String message) {
|
||||
if (message == null || message.isEmpty()) return;
|
||||
message = WorldGuard.getInstance().getPlatform().getMatcher().replaceMacros(localPlayer, message);
|
||||
message = CommandUtils.replaceColorMacros(message);
|
||||
localPlayer.printRaw(message.replace("%what%", what));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the given cause is whitelist (should be ignored).
|
||||
*
|
||||
* @param cause the cause
|
||||
* @param world the world
|
||||
* @param pvp whether the event in question is PvP combat
|
||||
* @return true if whitelisted
|
||||
*/
|
||||
private boolean isWhitelisted(Cause cause, World world, boolean pvp) {
|
||||
Object rootCause = cause.getRootCause();
|
||||
|
||||
if (rootCause instanceof Player) {
|
||||
Player player = (Player) rootCause;
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
com.sk89q.worldedit.world.World localWorld = BukkitAdapter.adapt(world);
|
||||
WorldConfiguration config = getWorldConfig(localWorld);
|
||||
|
||||
if (config.fakePlayerBuildOverride && InteropUtils.isFakePlayer(player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return !pvp && WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, localWorld);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlaceBlock(final PlaceBlockEvent event) {
|
||||
if (event.getResult() == Result.ALLOW) return; // Don't care about events that have been pre-allowed
|
||||
if (!isRegionSupportEnabled(BukkitAdapter.adapt(event.getWorld()))) return; // Region support disabled
|
||||
if (isWhitelisted(event.getCause(), event.getWorld(), false)) return; // Whitelisted cause
|
||||
|
||||
final Material type = event.getEffectiveMaterial();
|
||||
final RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
final RegionAssociable associable = createRegionAssociable(event.getCause());
|
||||
|
||||
// Don't check liquid flow unless it's enabled
|
||||
if (event.getCause().getRootCause() instanceof Block
|
||||
&& Materials.isLiquid(type)
|
||||
&& !getWorldConfig(BukkitAdapter.adapt(event.getWorld())).checkLiquidFlow) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.filter((Predicate<Location>) target -> {
|
||||
boolean canPlace;
|
||||
String what;
|
||||
|
||||
/* Flint and steel, fire charge, etc. */
|
||||
if (type == Material.FIRE) {
|
||||
Block block = event.getCause().getFirstBlock();
|
||||
boolean fire = block != null && block.getType() == Material.FIRE;
|
||||
boolean lava = block != null && Materials.isLava(block.getType());
|
||||
List<StateFlag> flags = new ArrayList<>();
|
||||
flags.add(Flags.BLOCK_PLACE);
|
||||
flags.add(Flags.LIGHTER);
|
||||
if (fire) flags.add(Flags.FIRE_SPREAD);
|
||||
if (lava) flags.add(Flags.LAVA_FIRE);
|
||||
canPlace = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, flags.toArray(new StateFlag[flags.size()])));
|
||||
what = "place fire";
|
||||
|
||||
} else if (type == Material.FROSTED_ICE) {
|
||||
event.setSilent(true); // gets spammy
|
||||
canPlace = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.BLOCK_PLACE, Flags.FROSTED_ICE_FORM));
|
||||
what = "use frostwalker"; // hidden anyway
|
||||
/* Everything else */
|
||||
} else {
|
||||
canPlace = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.BLOCK_PLACE));
|
||||
what = "place that block";
|
||||
}
|
||||
|
||||
if (!canPlace) {
|
||||
tellErrorMessage(event, event.getCause(), target, what);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onBreakBlock(final BreakBlockEvent event) {
|
||||
if (event.getResult() == Result.ALLOW) return; // Don't care about events that have been pre-allowed
|
||||
if (!isRegionSupportEnabled(BukkitAdapter.adapt(event.getWorld()))) return; // Region support disabled
|
||||
if (isWhitelisted(event.getCause(), event.getWorld(), false)) return; // Whitelisted cause
|
||||
|
||||
final RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
final RegionAssociable associable = createRegionAssociable(event.getCause());
|
||||
|
||||
event.filter((Predicate<Location>) target -> {
|
||||
boolean canBreak;
|
||||
String what;
|
||||
|
||||
/* TNT */
|
||||
if (event.getCause().find(EntityType.PRIMED_TNT, EntityType.MINECART_TNT) != null) {
|
||||
canBreak = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.BLOCK_BREAK, Flags.TNT));
|
||||
what = "use dynamite";
|
||||
|
||||
/* Everything else */
|
||||
} else {
|
||||
canBreak = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.BLOCK_BREAK));
|
||||
what = "break that block";
|
||||
}
|
||||
|
||||
if (!canBreak) {
|
||||
tellErrorMessage(event, event.getCause(), target, what);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onUseBlock(final UseBlockEvent event) {
|
||||
if (event.getResult() == Result.ALLOW) return; // Don't care about events that have been pre-allowed
|
||||
if (!isRegionSupportEnabled(BukkitAdapter.adapt(event.getWorld()))) return; // Region support disabled
|
||||
if (isWhitelisted(event.getCause(), event.getWorld(), false)) return; // Whitelisted cause
|
||||
|
||||
final Material type = event.getEffectiveMaterial();
|
||||
final RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
final RegionAssociable associable = createRegionAssociable(event.getCause());
|
||||
|
||||
event.filter((Predicate<Location>) target -> {
|
||||
boolean canUse;
|
||||
String what;
|
||||
|
||||
/* Saplings, etc. */
|
||||
if (Materials.isConsideredBuildingIfUsed(type)) {
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event));
|
||||
what = "use that";
|
||||
|
||||
/* Inventory */
|
||||
} else if (Materials.isInventoryBlock(type)) {
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.INTERACT, Flags.CHEST_ACCESS));
|
||||
what = "open that";
|
||||
|
||||
/* Beds */
|
||||
} else if (Materials.isBed(type)) {
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.INTERACT, Flags.SLEEP));
|
||||
what = "sleep";
|
||||
|
||||
/* TNT */
|
||||
} else if (type == Material.TNT) {
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.INTERACT, Flags.TNT));
|
||||
what = "use explosives";
|
||||
|
||||
/* Legacy USE flag */
|
||||
} else if (Materials.isUseFlagApplicable(type)) {
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.INTERACT, Flags.USE));
|
||||
what = "use that";
|
||||
|
||||
/* Everything else */
|
||||
} else {
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.INTERACT));
|
||||
what = "use that";
|
||||
}
|
||||
|
||||
if (!canUse) {
|
||||
tellErrorMessage(event, event.getCause(), target, what);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onSpawnEntity(SpawnEntityEvent event) {
|
||||
if (event.getResult() == Result.ALLOW) return; // Don't care about events that have been pre-allowed
|
||||
if (!isRegionSupportEnabled(BukkitAdapter.adapt(event.getWorld()))) return; // Region support disabled
|
||||
if (isWhitelisted(event.getCause(), event.getWorld(), false)) return; // Whitelisted cause
|
||||
|
||||
Location target = event.getTarget();
|
||||
EntityType type = event.getEffectiveType();
|
||||
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
RegionAssociable associable = createRegionAssociable(event.getCause());
|
||||
|
||||
boolean canSpawn;
|
||||
String what;
|
||||
|
||||
/* Vehicles */
|
||||
if (Entities.isVehicle(type)) {
|
||||
canSpawn = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.PLACE_VEHICLE));
|
||||
what = "place vehicles";
|
||||
|
||||
/* Item pickup */
|
||||
} else if (event.getEntity() instanceof Item) {
|
||||
canSpawn = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.ITEM_DROP));
|
||||
what = "drop items";
|
||||
|
||||
/* XP drops */
|
||||
} else if (type == EntityType.EXPERIENCE_ORB) {
|
||||
canSpawn = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.EXP_DROPS));
|
||||
what = "drop XP";
|
||||
|
||||
} else if (Entities.isAoECloud(type)) {
|
||||
canSpawn = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.POTION_SPLASH));
|
||||
what = "use lingering potions";
|
||||
|
||||
/* Everything else */
|
||||
} else {
|
||||
canSpawn = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event));
|
||||
|
||||
if (event.getEntity() instanceof Item) {
|
||||
what = "drop items";
|
||||
} else {
|
||||
what = "place things";
|
||||
}
|
||||
}
|
||||
|
||||
if (!canSpawn) {
|
||||
tellErrorMessage(event, event.getCause(), target, what);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onDestroyEntity(DestroyEntityEvent event) {
|
||||
if (event.getResult() == Result.ALLOW) return; // Don't care about events that have been pre-allowed
|
||||
if (!isRegionSupportEnabled(BukkitAdapter.adapt(event.getWorld()))) return; // Region support disabled
|
||||
if (isWhitelisted(event.getCause(), event.getWorld(), false)) return; // Whitelisted cause
|
||||
|
||||
Location target = event.getTarget();
|
||||
EntityType type = event.getEntity().getType();
|
||||
RegionAssociable associable = createRegionAssociable(event.getCause());
|
||||
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
boolean canDestroy;
|
||||
String what;
|
||||
|
||||
/* Vehicles */
|
||||
if (Entities.isVehicle(type)) {
|
||||
canDestroy = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.DESTROY_VEHICLE));
|
||||
what = "break vehicles";
|
||||
|
||||
/* Item pickup */
|
||||
} else if (event.getEntity() instanceof Item || event.getEntity() instanceof ExperienceOrb) {
|
||||
canDestroy = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.ITEM_PICKUP));
|
||||
what = "pick up items";
|
||||
|
||||
/* Everything else */
|
||||
} else {
|
||||
canDestroy = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event));
|
||||
what = "break things";
|
||||
}
|
||||
|
||||
if (!canDestroy) {
|
||||
tellErrorMessage(event, event.getCause(), target, what);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onUseEntity(UseEntityEvent event) {
|
||||
if (event.getResult() == Result.ALLOW) return; // Don't care about events that have been pre-allowed
|
||||
if (!isRegionSupportEnabled(BukkitAdapter.adapt(event.getWorld()))) return; // Region support disabled
|
||||
if (isWhitelisted(event.getCause(), event.getWorld(), false)) return; // Whitelisted cause
|
||||
|
||||
Location target = event.getTarget();
|
||||
RegionAssociable associable = createRegionAssociable(event.getCause());
|
||||
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
boolean canUse;
|
||||
String what;
|
||||
|
||||
/* Hostile / ambient mob override */
|
||||
final Entity entity = event.getEntity();
|
||||
final EntityType type = entity.getType();
|
||||
if (Entities.isHostile(entity) || Entities.isAmbient(entity)
|
||||
|| Entities.isNPC(entity) || entity instanceof Player) {
|
||||
canUse = event.getRelevantFlags().isEmpty() || query.queryState(BukkitAdapter.adapt(target), associable, combine(event)) != State.DENY;
|
||||
what = "use that";
|
||||
/* Paintings, item frames, etc. */
|
||||
} else if (Entities.isConsideredBuildingIfUsed(entity)) {
|
||||
if (type == EntityType.ITEM_FRAME && event.getCause().getFirstPlayer() != null
|
||||
&& ((ItemFrame) entity).getItem().getType() != Material.AIR) {
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.ITEM_FRAME_ROTATE));
|
||||
what = "change that";
|
||||
} else if (Entities.isMinecart(type)) {
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.CHEST_ACCESS));
|
||||
what = "open that";
|
||||
} else {
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event));
|
||||
what = "change that";
|
||||
}
|
||||
/* Ridden on use */
|
||||
} else if (Entities.isRiddenOnUse(entity)) {
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.RIDE, Flags.INTERACT));
|
||||
what = "ride that";
|
||||
|
||||
/* Everything else */
|
||||
} else {
|
||||
canUse = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.INTERACT));
|
||||
what = "use that";
|
||||
}
|
||||
|
||||
if (!canUse) {
|
||||
tellErrorMessage(event, event.getCause(), target, what);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onDamageEntity(DamageEntityEvent event) {
|
||||
if (event.getResult() == Result.ALLOW) return; // Don't care about events that have been pre-allowed
|
||||
if (!isRegionSupportEnabled(BukkitAdapter.adapt(event.getWorld()))) return; // Region support disabled
|
||||
// Whitelist check is below
|
||||
|
||||
com.sk89q.worldedit.util.Location target = BukkitAdapter.adapt(event.getTarget());
|
||||
RegionAssociable associable = createRegionAssociable(event.getCause());
|
||||
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
Player playerAttacker = event.getCause().getFirstPlayer();
|
||||
boolean canDamage;
|
||||
String what;
|
||||
|
||||
// Block PvP like normal even if the player has an override permission
|
||||
// because (1) this is a frequent source of confusion and
|
||||
// (2) some users want to block PvP even with the bypass permission
|
||||
boolean pvp = event.getEntity() instanceof Player && playerAttacker != null && !playerAttacker.equals(event.getEntity());
|
||||
if (isWhitelisted(event.getCause(), event.getWorld(), pvp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Hostile / ambient mob override */
|
||||
if (Entities.isHostile(event.getEntity()) || Entities.isAmbient(event.getEntity())
|
||||
|| Entities.isVehicle(event.getEntity().getType())) {
|
||||
canDamage = event.getRelevantFlags().isEmpty() || query.queryState(target, associable, combine(event)) != State.DENY;
|
||||
what = "hit that";
|
||||
|
||||
/* Paintings, item frames, etc. */
|
||||
} else if (Entities.isConsideredBuildingIfUsed(event.getEntity())) {
|
||||
canDamage = query.testBuild(target, associable, combine(event));
|
||||
what = "change that";
|
||||
|
||||
/* PVP */
|
||||
} else if (pvp) {
|
||||
LocalPlayer localAttacker = WorldGuardPlugin.inst().wrapPlayer(playerAttacker);
|
||||
Player defender = (Player) event.getEntity();
|
||||
|
||||
// if defender is an NPC
|
||||
if (Entities.isNPC(defender)) {
|
||||
return;
|
||||
}
|
||||
|
||||
canDamage = query.testBuild(target, associable, combine(event, Flags.PVP))
|
||||
&& query.queryState(localAttacker.getLocation(), localAttacker, combine(event, Flags.PVP)) != State.DENY
|
||||
&& query.queryState(target, localAttacker, combine(event, Flags.PVP)) != State.DENY;
|
||||
|
||||
// Fire the disallow PVP event
|
||||
if (!canDamage && Events.fireAndTestCancel(new DisallowedPVPEvent(playerAttacker, defender, event.getOriginalEvent()))) {
|
||||
canDamage = true;
|
||||
}
|
||||
|
||||
what = "PvP";
|
||||
|
||||
/* Player damage not caused by another player */
|
||||
} else if (event.getEntity() instanceof Player) {
|
||||
canDamage = event.getRelevantFlags().isEmpty() || query.queryState(target, associable, combine(event)) != State.DENY;
|
||||
what = "damage that";
|
||||
|
||||
/* damage to non-hostile mobs (e.g. animals) */
|
||||
} else if (Entities.isNonHostile(event.getEntity())) {
|
||||
canDamage = query.testBuild(target, associable, combine(event, Flags.DAMAGE_ANIMALS));
|
||||
what = "harm that";
|
||||
|
||||
/* Everything else */
|
||||
} else {
|
||||
canDamage = query.testBuild(target, associable, combine(event, Flags.INTERACT));
|
||||
what = "hit that";
|
||||
}
|
||||
|
||||
if (!canDamage) {
|
||||
tellErrorMessage(event, event.getCause(), event.getTarget(), what);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onVehicleExit(VehicleExitEvent event) {
|
||||
Entity vehicle = event.getVehicle();
|
||||
if (!isRegionSupportEnabled(BukkitAdapter.adapt(vehicle.getWorld()))) return; // Region support disabled
|
||||
Entity exited = event.getExited();
|
||||
|
||||
if (vehicle instanceof Tameable && exited instanceof Player) {
|
||||
Player player = (Player) exited;
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
if (!isWhitelisted(Cause.create(player), vehicle.getWorld(), false)) {
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
Location location = vehicle.getLocation();
|
||||
if (!query.testBuild(BukkitAdapter.adapt(location), localPlayer, Flags.RIDE, Flags.INTERACT)) {
|
||||
long now = System.currentTimeMillis();
|
||||
Long lastTime = WGMetadata.getIfPresent(player, DISEMBARK_MESSAGE_KEY, Long.class);
|
||||
if (lastTime == null || now - lastTime >= LAST_MESSAGE_DELAY) {
|
||||
player.sendMessage("" + ChatColor.GOLD + "Don't disembark here!" + ChatColor.GRAY + " You can't get back on.");
|
||||
WGMetadata.put(player, DISEMBARK_MESSAGE_KEY, now);
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isWhitelistedEntity(Entity entity) {
|
||||
return Entities.isNonPlayerCreature(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine the flags from a delegate event with an array of flags.
|
||||
*
|
||||
* <p>The delegate event's flags appear at the end.</p>
|
||||
*
|
||||
* @param event The event
|
||||
* @param flag An array of flags
|
||||
* @return An array of flags
|
||||
*/
|
||||
private static StateFlag[] combine(DelegateEvent event, StateFlag... flag) {
|
||||
List<StateFlag> extra = event.getRelevantFlags();
|
||||
StateFlag[] flags = Arrays.copyOf(flag, flag.length + extra.size());
|
||||
for (int i = 0; i < extra.size(); i++) {
|
||||
flags[flag.length + i] = extra.get(i);
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
}
|
||||
+703
@@ -0,0 +1,703 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.util.Materials;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.util.SpongeUtil;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Snowman;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockExplodeEvent;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.block.BlockFormEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockGrowEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
import org.bukkit.event.block.BlockSpreadEvent;
|
||||
import org.bukkit.event.block.EntityBlockFormEvent;
|
||||
import org.bukkit.event.block.LeavesDecayEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
/**
|
||||
* The listener for block events.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class WorldGuardBlockListener implements Listener {
|
||||
|
||||
private WorldGuardPlugin plugin;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param plugin The plugin instance
|
||||
*/
|
||||
public WorldGuardBlockListener(WorldGuardPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register events.
|
||||
*/
|
||||
public void registerEvents() {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the world configuration given a world.
|
||||
*
|
||||
* @param world The world to get the configuration for.
|
||||
* @return The configuration for {@code world}
|
||||
*/
|
||||
private WorldConfiguration getWorldConfig(World world) {
|
||||
return WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(BukkitAdapter.adapt(world));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the world configuration given a player.
|
||||
*
|
||||
* @param player The player to get the wold from
|
||||
* @return The {@link BukkitWorldConfiguration} for the player's world
|
||||
*/
|
||||
private WorldConfiguration getWorldConfig(Player player) {
|
||||
return getWorldConfig(player.getWorld());
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when a block is broken.
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
WorldConfiguration wcfg = getWorldConfig(player);
|
||||
|
||||
if (!wcfg.itemDurability) {
|
||||
ItemStack held = player.getInventory().getItemInMainHand();
|
||||
ItemMeta meta = held.getItemMeta();
|
||||
if (meta != null) {
|
||||
((Damageable) meta).setDamage(0);
|
||||
held.setItemMeta(meta);
|
||||
player.getInventory().setItemInMainHand(held);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when fluids flow.
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onBlockFromTo(BlockFromToEvent event) {
|
||||
World world = event.getBlock().getWorld();
|
||||
Block blockFrom = event.getBlock();
|
||||
Block blockTo = event.getToBlock();
|
||||
|
||||
boolean isWater = blockFrom.getType() == Material.WATER;
|
||||
boolean isLava = blockFrom.getType() == Material.LAVA;
|
||||
boolean isAir = blockFrom.getType() == Material.AIR;
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());
|
||||
|
||||
if (cfg.activityHaltToggle) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.simulateSponge && isWater) {
|
||||
int ox = blockTo.getX();
|
||||
int oy = blockTo.getY();
|
||||
int oz = blockTo.getZ();
|
||||
|
||||
for (int cx = -wcfg.spongeRadius; cx <= wcfg.spongeRadius; cx++) {
|
||||
for (int cy = -wcfg.spongeRadius; cy <= wcfg.spongeRadius; cy++) {
|
||||
for (int cz = -wcfg.spongeRadius; cz <= wcfg.spongeRadius; cz++) {
|
||||
Block sponge = world.getBlockAt(ox + cx, oy + cy, oz + cz);
|
||||
if (sponge.getType() == Material.SPONGE
|
||||
&& (!wcfg.redstoneSponges || !sponge.isBlockIndirectlyPowered())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*if (plugin.classicWater && isWater) {
|
||||
int blockBelow = blockFrom.getRelative(0, -1, 0).getTypeId();
|
||||
if (blockBelow != 0 && blockBelow != 8 && blockBelow != 9) {
|
||||
blockFrom.setTypeId(9);
|
||||
if (blockTo.getTypeId() == 0) {
|
||||
blockTo.setTypeId(9);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
// Check the fluid block (from) whether it is air.
|
||||
// If so and the target block is protected, cancel the event
|
||||
if (!wcfg.preventWaterDamage.isEmpty()) {
|
||||
Material targetId = blockTo.getType();
|
||||
|
||||
if ((isAir || isWater) &&
|
||||
wcfg.preventWaterDamage.contains(BukkitAdapter.asBlockType(targetId).getId())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!wcfg.allowedLavaSpreadOver.isEmpty() && isLava) {
|
||||
Material targetId = blockTo.getRelative(0, -1, 0).getType();
|
||||
|
||||
if (!wcfg.allowedLavaSpreadOver.contains(BukkitAdapter.asBlockType(targetId).getId())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (wcfg.highFreqFlags && isWater
|
||||
&& WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(blockFrom.getLocation()), (RegionAssociable) null, Flags.WATER_FLOW) == StateFlag.State.DENY) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.highFreqFlags && isLava
|
||||
&& !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(blockFrom.getLocation()), (RegionAssociable) null, Flags.LAVA_FLOW))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.disableObsidianGenerators && (isAir || isLava)
|
||||
&& (blockTo.getType() == Material.REDSTONE_WIRE
|
||||
|| blockTo.getType() == Material.TRIPWIRE)) {
|
||||
blockTo.setType(Material.AIR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when a block gets ignited.
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBlockIgnite(BlockIgniteEvent event) {
|
||||
IgniteCause cause = event.getCause();
|
||||
Block block = event.getBlock();
|
||||
World world = block.getWorld();
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = getWorldConfig(world);
|
||||
|
||||
if (cfg.activityHaltToggle) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
boolean isFireSpread = cause == IgniteCause.SPREAD;
|
||||
|
||||
if (wcfg.preventLightningFire && cause == IgniteCause.LIGHTNING) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.preventLavaFire && cause == IgniteCause.LAVA) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.disableFireSpread && isFireSpread) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.blockLighter && (cause == IgniteCause.FLINT_AND_STEEL || cause == IgniteCause.FIREBALL)
|
||||
&& event.getPlayer() != null
|
||||
&& !plugin.hasPermission(event.getPlayer(), "worldguard.override.lighter")) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.fireSpreadDisableToggle && isFireSpread) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!wcfg.disableFireSpreadBlocks.isEmpty() && isFireSpread) {
|
||||
int x = block.getX();
|
||||
int y = block.getY();
|
||||
int z = block.getZ();
|
||||
|
||||
if (wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(world.getBlockAt(x, y - 1, z).getType()).getId())
|
||||
|| wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(world.getBlockAt(x + 1, y, z).getType()).getId())
|
||||
|| wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(world.getBlockAt(x - 1, y, z).getType()).getId())
|
||||
|| wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(world.getBlockAt(x, y, z - 1).getType()).getId())
|
||||
|| wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(world.getBlockAt(x, y, z + 1).getType()).getId())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
ApplicableRegionSet set =
|
||||
WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(block.getLocation()));
|
||||
|
||||
if (wcfg.highFreqFlags && isFireSpread
|
||||
&& !set.testState(null, Flags.FIRE_SPREAD)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.highFreqFlags && cause == IgniteCause.LAVA
|
||||
&& !set.testState(null, Flags.LAVA_FIRE)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cause == IgniteCause.FIREBALL && event.getPlayer() == null) {
|
||||
// wtf bukkit, FIREBALL is supposed to be reserved to players
|
||||
if (!set.testState(null, Flags.GHAST_FIREBALL)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (cause == IgniteCause.LIGHTNING && !set.testState(null, Flags.LIGHTNING)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when a block is destroyed from burning.
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBlockBurn(BlockBurnEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) getWorldConfig(event.getBlock().getWorld());
|
||||
|
||||
if (cfg.activityHaltToggle) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.disableFireSpread) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.fireSpreadDisableToggle) {
|
||||
Block block = event.getBlock();
|
||||
event.setCancelled(true);
|
||||
checkAndDestroyAround(block.getWorld(), block.getX(), block.getY(), block.getZ(), Material.FIRE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!wcfg.disableFireSpreadBlocks.isEmpty()) {
|
||||
Block block = event.getBlock();
|
||||
|
||||
if (wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(block.getType()).getId())) {
|
||||
event.setCancelled(true);
|
||||
checkAndDestroyAround(block.getWorld(), block.getX(), block.getY(), block.getZ(), Material.FIRE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (wcfg.isChestProtected(BukkitAdapter.adapt(event.getBlock().getLocation()))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
Block block = event.getBlock();
|
||||
int x = block.getX();
|
||||
int y = block.getY();
|
||||
int z = block.getZ();
|
||||
ApplicableRegionSet set =
|
||||
WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(block.getLocation()));
|
||||
|
||||
if (!set.testState(null, Flags.FIRE_SPREAD)) {
|
||||
checkAndDestroyAround(block.getWorld(), x, y, z, Material.FIRE);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void checkAndDestroyAround(World world, int x, int y, int z, Material required) {
|
||||
checkAndDestroy(world, x, y, z + 1, required);
|
||||
checkAndDestroy(world, x, y, z - 1, required);
|
||||
checkAndDestroy(world, x, y + 1, z, required);
|
||||
checkAndDestroy(world, x, y - 1, z, required);
|
||||
checkAndDestroy(world, x + 1, y, z, required);
|
||||
checkAndDestroy(world, x - 1, y, z, required);
|
||||
}
|
||||
|
||||
private void checkAndDestroy(World world, int x, int y, int z, Material required) {
|
||||
if (world.getBlockAt(x, y, z).getType() == required) {
|
||||
world.getBlockAt(x, y, z).setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when block physics occurs.
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());
|
||||
|
||||
if (cfg.activityHaltToggle) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Material id = event.getBlock().getType();
|
||||
|
||||
if (id == Material.GRAVEL && wcfg.noPhysicsGravel) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (id == Material.SAND && wcfg.noPhysicsSand) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (id == Material.NETHER_PORTAL && wcfg.allowPortalAnywhere) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.ropeLadders && event.getBlock().getType() == Material.LADDER) {
|
||||
if (event.getBlock().getRelative(0, 1, 0).getType() == Material.LADDER) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when a player places a block.
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
Block target = event.getBlock();
|
||||
World world = target.getWorld();
|
||||
|
||||
WorldConfiguration wcfg = getWorldConfig(world);
|
||||
|
||||
if (wcfg.simulateSponge && target.getType() == Material.SPONGE) {
|
||||
if (wcfg.redstoneSponges && target.isBlockIndirectlyPowered()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int ox = target.getX();
|
||||
int oy = target.getY();
|
||||
int oz = target.getZ();
|
||||
|
||||
SpongeUtil.clearSpongeWater(BukkitAdapter.adapt(world), ox, oy, oz);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when redstone changes.
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockRedstoneChange(BlockRedstoneEvent event) {
|
||||
Block blockTo = event.getBlock();
|
||||
World world = blockTo.getWorld();
|
||||
|
||||
WorldConfiguration wcfg = getWorldConfig(world);
|
||||
|
||||
if (wcfg.simulateSponge && wcfg.redstoneSponges) {
|
||||
int ox = blockTo.getX();
|
||||
int oy = blockTo.getY();
|
||||
int oz = blockTo.getZ();
|
||||
|
||||
for (int cx = -1; cx <= 1; cx++) {
|
||||
for (int cy = -1; cy <= 1; cy++) {
|
||||
for (int cz = -1; cz <= 1; cz++) {
|
||||
Block sponge = world.getBlockAt(ox + cx, oy + cy, oz + cz);
|
||||
if (sponge.getType() == Material.SPONGE
|
||||
&& sponge.isBlockIndirectlyPowered()) {
|
||||
SpongeUtil.clearSpongeWater(BukkitAdapter.adapt(world), ox + cx, oy + cy, oz + cz);
|
||||
} else if (sponge.getType() == Material.SPONGE
|
||||
&& !sponge.isBlockIndirectlyPowered()) {
|
||||
SpongeUtil.addSpongeWater(BukkitAdapter.adapt(world), ox + cx, oy + cy, oz + cz);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onLeavesDecay(LeavesDecayEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());
|
||||
|
||||
if (cfg.activityHaltToggle) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.disableLeafDecay) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
if (!StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.LEAF_DECAY))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when a block is formed based on world conditions.
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBlockForm(BlockFormEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());
|
||||
|
||||
if (cfg.activityHaltToggle) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Material type = event.getNewState().getType();
|
||||
|
||||
if (event instanceof EntityBlockFormEvent) {
|
||||
if (((EntityBlockFormEvent) event).getEntity() instanceof Snowman) {
|
||||
if (wcfg.disableSnowmanTrails) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == Material.ICE) {
|
||||
if (wcfg.disableIceFormation) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.ICE_FORM))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (type == Material.SNOW) {
|
||||
if (wcfg.disableSnowFormation) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!wcfg.allowedSnowFallOver.isEmpty()) {
|
||||
Material targetId = event.getBlock().getRelative(0, -1, 0).getType();
|
||||
|
||||
if (!wcfg.allowedSnowFallOver.contains(BukkitAdapter.asBlockType(targetId).getId())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.SNOW_FALL))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when a block spreads based on world conditions.
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBlockSpread(BlockSpreadEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());
|
||||
|
||||
if (cfg.activityHaltToggle) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Material newType = event.getNewState().getType(); // craftbukkit randomly gives AIR as event.getSource even if that block is not air
|
||||
|
||||
if (Materials.isMushroom(newType)) {
|
||||
if (wcfg.disableMushroomSpread) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.MUSHROOMS))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (newType == Material.GRASS_BLOCK) {
|
||||
if (wcfg.disableGrassGrowth) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.GRASS_SPREAD))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (newType == Material.MYCELIUM) {
|
||||
if (wcfg.disableMyceliumSpread) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.MYCELIUM_SPREAD))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (newType == Material.VINE || newType == Material.KELP) {
|
||||
if (wcfg.disableVineGrowth) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.VINE_GROWTH))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBlockGrow(BlockGrowEvent event) {
|
||||
WorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());
|
||||
final Material type = event.getNewState().getType();
|
||||
|
||||
if (Materials.isCrop(type)) {
|
||||
if (wcfg.disableCropGrowth) {
|
||||
event.setCancelled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.CROP_GROWTH))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when a block fades.
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBlockFade(BlockFadeEvent event) {
|
||||
|
||||
WorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());
|
||||
|
||||
if (event.getBlock().getType() == Material.ICE) {
|
||||
if (wcfg.disableIceMelting) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.ICE_MELT))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (event.getBlock().getType() == Material.FROSTED_ICE) {
|
||||
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.FROSTED_ICE_MELT))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (event.getBlock().getType() == Material.SNOW) {
|
||||
if (wcfg.disableSnowMelting) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.SNOW_MELT))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (event.getBlock().getType() == Material.FARMLAND) {
|
||||
if (wcfg.disableSoilDehydration) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||
.queryState(BukkitAdapter.adapt(event.getBlock().getLocation()), (RegionAssociable) null, Flags.SOIL_DRY))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onBlockExplode(BlockExplodeEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
|
||||
if (cfg.activityHaltToggle) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
WorldConfiguration wcfg = getWorldConfig(event.getBlock().getWorld());
|
||||
if (wcfg.blockOtherExplosions) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.commandbook.component.info.InfoComponent;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class WorldGuardCommandBookListener implements Listener {
|
||||
private final WorldGuardPlugin plugin;
|
||||
|
||||
public WorldGuardCommandBookListener(WorldGuardPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerWhois(InfoComponent.PlayerWhoisEvent event) {
|
||||
if (event.getPlayer() instanceof Player) {
|
||||
Player player = (Player) event.getPlayer();
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
if (WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(localPlayer.getWorld()).useRegions) {
|
||||
ApplicableRegionSet regions =
|
||||
WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(localPlayer.getLocation());
|
||||
|
||||
// Current regions
|
||||
StringBuilder regionStr = new StringBuilder();
|
||||
boolean first = true;
|
||||
|
||||
for (ProtectedRegion region : regions) {
|
||||
if (!first) {
|
||||
regionStr.append(", ");
|
||||
}
|
||||
|
||||
if (region.isOwner(localPlayer)) {
|
||||
regionStr.append("+");
|
||||
} else if (region.isMemberOnly(localPlayer)) {
|
||||
regionStr.append("-");
|
||||
}
|
||||
|
||||
regionStr.append(region.getId());
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
||||
if (regions.size() > 0) {
|
||||
event.addWhoisInformation("Current Regions", regionStr);
|
||||
}
|
||||
event.addWhoisInformation("Can build", regions.testState(localPlayer, Flags.BUILD));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+826
@@ -0,0 +1,826 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.util.Entities;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.EnderCrystal;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.Enderman;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Wither;
|
||||
import org.bukkit.entity.WitherSkull;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.event.entity.CreeperPowerEvent;
|
||||
import org.bukkit.event.entity.EntityBreakDoorEvent;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityInteractEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityTransformEvent;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.entity.PigZapEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.world.PortalCreateEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Listener for entity related events.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class WorldGuardEntityListener implements Listener {
|
||||
|
||||
private WorldGuardPlugin plugin;
|
||||
|
||||
/**
|
||||
* Construct the object;
|
||||
*
|
||||
* @param plugin The plugin instance
|
||||
*/
|
||||
public WorldGuardEntityListener(WorldGuardPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register events.
|
||||
*/
|
||||
public void registerEvents() {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onEntityInteract(EntityInteractEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
Block block = event.getBlock();
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(entity.getWorld()));
|
||||
|
||||
if (block.getType() == Material.FARMLAND) {
|
||||
if (/* entity instanceof Creature && // catch for any entity (not thrown for players) */
|
||||
wcfg.disableCreatureCropTrampling) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
WorldConfiguration wcfg =
|
||||
WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
||||
|
||||
if (event instanceof PlayerDeathEvent && wcfg.disableDeathMessages) {
|
||||
((PlayerDeathEvent) event).setDeathMessage("");
|
||||
}
|
||||
}
|
||||
|
||||
private void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
|
||||
Entity defender = event.getEntity();
|
||||
DamageCause type = event.getCause();
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(defender.getWorld()));
|
||||
|
||||
if (defender instanceof Wolf && ((Wolf) defender).isTamed()) {
|
||||
if (wcfg.antiWolfDumbness && !(type == DamageCause.VOID)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (defender instanceof Player) {
|
||||
Player player = (Player) defender;
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
|
||||
if (wcfg.disableLavaDamage && type == DamageCause.LAVA) {
|
||||
event.setCancelled(true);
|
||||
player.setFireTicks(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.disableContactDamage && type == DamageCause.CONTACT) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.teleportOnVoid && type == DamageCause.VOID) {
|
||||
localPlayer.findFreePosition();
|
||||
if (wcfg.safeFallOnVoid) {
|
||||
localPlayer.resetFallDistance();
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.disableVoidDamage && type == DamageCause.VOID) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == DamageCause.BLOCK_EXPLOSION
|
||||
&& (wcfg.disableExplosionDamage || wcfg.blockOtherExplosions
|
||||
|| (wcfg.explosionFlagCancellation
|
||||
&& !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||
.queryState(localPlayer.getLocation(), (RegionAssociable) null, Flags.OTHER_EXPLOSION))))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
||||
// for whatever reason, plugin-caused explosions with a null entity count as block explosions and aren't
|
||||
// handled anywhere else
|
||||
if (type == DamageCause.BLOCK_EXPLOSION
|
||||
&& (wcfg.blockOtherExplosions
|
||||
|| (wcfg.explosionFlagCancellation
|
||||
&& !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery()
|
||||
.queryState(BukkitAdapter.adapt(defender.getLocation()), (RegionAssociable) null, Flags.OTHER_EXPLOSION))))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
|
||||
if (event.getDamager() instanceof Projectile) {
|
||||
onEntityDamageByProjectile(event);
|
||||
return;
|
||||
}
|
||||
|
||||
Entity attacker = event.getDamager();
|
||||
Entity defender = event.getEntity();
|
||||
|
||||
WorldConfiguration wcfg =
|
||||
WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(BukkitAdapter.adapt(defender.getWorld()));
|
||||
|
||||
if (defender instanceof ItemFrame) {
|
||||
if (checkItemFrameProtection(attacker, (ItemFrame) defender)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (defender instanceof ArmorStand && !(attacker instanceof Player)) {
|
||||
if (wcfg.blockEntityArmorStandDestroy) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (attacker instanceof EnderCrystal) {
|
||||
// this isn't handled elsewhere because ender crystal explosions don't carry a player cause
|
||||
// in the same way that creepers or tnt can
|
||||
if (wcfg.useRegions && wcfg.explosionFlagCancellation) {
|
||||
if (!WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(defender.getLocation()))
|
||||
.testState(null, Flags.OTHER_EXPLOSION)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (defender instanceof Player) {
|
||||
Player player = (Player) defender;
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
if (wcfg.disableLightningDamage && event.getCause() == DamageCause.LIGHTNING) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.disableExplosionDamage) {
|
||||
switch (event.getCause()) {
|
||||
case BLOCK_EXPLOSION:
|
||||
case ENTITY_EXPLOSION:
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (attacker != null) {
|
||||
if (attacker instanceof TNTPrimed || attacker instanceof ExplosiveMinecart) {
|
||||
// The check for explosion damage should be handled already... But... What ever...
|
||||
if (wcfg.blockTNTExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (attacker instanceof LivingEntity && !(attacker instanceof Player)) {
|
||||
if (attacker instanceof Creeper && wcfg.blockCreeperExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.disableMobDamage) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
ApplicableRegionSet set = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(localPlayer.getLocation());
|
||||
|
||||
if (!set.testState(localPlayer, Flags.MOB_DAMAGE) && !(attacker instanceof Tameable)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onEntityDamageByProjectile(EntityDamageByEntityEvent event) {
|
||||
Entity defender = event.getEntity();
|
||||
Entity attacker;
|
||||
ProjectileSource source = ((Projectile) event.getDamager()).getShooter();
|
||||
if (source instanceof LivingEntity) {
|
||||
attacker = (LivingEntity) source;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(defender.getWorld()));
|
||||
if (defender instanceof Player) {
|
||||
Player player = (Player) defender;
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
|
||||
// Check Mob
|
||||
if (!(attacker instanceof Player)) {
|
||||
if (wcfg.disableMobDamage) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions) {
|
||||
if (!WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(localPlayer.getLocation()).testState(localPlayer, Flags.MOB_DAMAGE)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (event.getDamager() instanceof Fireball) {
|
||||
Fireball fireball = (Fireball) event.getDamager();
|
||||
if (fireball instanceof WitherSkull) {
|
||||
if (wcfg.blockWitherSkullExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (wcfg.blockFireballExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (wcfg.useRegions) {
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
if (!query.testState(localPlayer.getLocation(), localPlayer, Flags.GHAST_FIREBALL) && wcfg.explosionFlagCancellation) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (defender instanceof ItemFrame) {
|
||||
if (checkItemFrameProtection(attacker, (ItemFrame) defender)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (defender instanceof ArmorStand && Entities.isNonPlayerCreature(attacker)) {
|
||||
if (wcfg.blockEntityArmorStandDestroy) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
|
||||
if (event instanceof EntityDamageByEntityEvent) {
|
||||
this.onEntityDamageByEntity((EntityDamageByEntityEvent) event);
|
||||
return;
|
||||
} else if (event instanceof EntityDamageByBlockEvent) {
|
||||
this.onEntityDamageByBlock((EntityDamageByBlockEvent) event);
|
||||
return;
|
||||
}
|
||||
|
||||
Entity defender = event.getEntity();
|
||||
DamageCause type = event.getCause();
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(defender.getWorld()));
|
||||
|
||||
if (defender instanceof Wolf && ((Wolf) defender).isTamed()) {
|
||||
if (wcfg.antiWolfDumbness) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (defender instanceof Player) {
|
||||
Player player = (Player) defender;
|
||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||
|
||||
if (type == DamageCause.WITHER) {
|
||||
// wither boss DoT tick
|
||||
if (wcfg.disableMobDamage) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
ApplicableRegionSet set = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(localPlayer.getLocation());
|
||||
|
||||
if (!set.testState(plugin.wrapPlayer(player), Flags.MOB_DAMAGE)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type == DamageCause.DROWNING && cfg.hasAmphibiousMode(localPlayer)) {
|
||||
player.setRemainingAir(player.getMaximumAir());
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack helmet = player.getInventory().getHelmet();
|
||||
|
||||
if (type == DamageCause.DROWNING && wcfg.pumpkinScuba
|
||||
&& helmet != null
|
||||
&& (helmet.getType() == Material.CARVED_PUMPKIN
|
||||
|| helmet.getType() == Material.JACK_O_LANTERN)) {
|
||||
player.setRemainingAir(player.getMaximumAir());
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.disableFallDamage && type == DamageCause.FALL) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.disableFireDamage && (type == DamageCause.FIRE
|
||||
|| type == DamageCause.FIRE_TICK)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.disableDrowningDamage && type == DamageCause.DROWNING) {
|
||||
player.setRemainingAir(player.getMaximumAir());
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.teleportOnSuffocation && type == DamageCause.SUFFOCATION) {
|
||||
localPlayer.findFreePosition();
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.disableSuffocationDamage && type == DamageCause.SUFFOCATION) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called on entity explode.
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
Location l = event.getLocation();
|
||||
World world = l.getWorld();
|
||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(world));
|
||||
Entity ent = event.getEntity();
|
||||
|
||||
if (cfg.activityHaltToggle) {
|
||||
ent.remove();
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ent instanceof Creeper) {
|
||||
if (wcfg.blockCreeperExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.blockCreeperBlockDamage) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
} else if (ent instanceof EnderDragon) {
|
||||
if (wcfg.blockEnderDragonBlockDamage) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
} else if (ent instanceof TNTPrimed || ent instanceof ExplosiveMinecart) {
|
||||
if (wcfg.blockTNTExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.blockTNTBlockDamage) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
} else if (ent instanceof Fireball) {
|
||||
if (ent instanceof WitherSkull) {
|
||||
if (wcfg.blockWitherSkullExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.blockWitherSkullBlockDamage) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (wcfg.blockFireballExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.blockFireballBlockDamage) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// allow wither skull blocking since there is no dedicated flag atm
|
||||
if (wcfg.useRegions) {
|
||||
for (Block block : event.blockList()) {
|
||||
if (!WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(block.getLocation())).testState(null, Flags.GHAST_FIREBALL)) {
|
||||
event.blockList().clear();
|
||||
if (wcfg.explosionFlagCancellation) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (ent instanceof Wither) {
|
||||
if (wcfg.blockWitherExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.blockWitherBlockDamage) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions) {
|
||||
for (Block block : event.blockList()) {
|
||||
if (!StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(block.getLocation()),
|
||||
(RegionAssociable) null, Flags.WITHER_DAMAGE))) {
|
||||
event.blockList().clear();
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// unhandled entity
|
||||
if (wcfg.blockOtherExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions) {
|
||||
for (Block block : event.blockList()) {
|
||||
if (!WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(block.getLocation())).testState(null, Flags.OTHER_EXPLOSION)) {
|
||||
event.blockList().clear();
|
||||
if (wcfg.explosionFlagCancellation) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (wcfg.signChestProtection) {
|
||||
for (Block block : event.blockList()) {
|
||||
if (wcfg.isChestProtected(BukkitAdapter.adapt(block.getLocation()))) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Called on explosion prime
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onExplosionPrime(ExplosionPrimeEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
||||
Entity ent = event.getEntity();
|
||||
|
||||
if (cfg.activityHaltToggle) {
|
||||
ent.remove();
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getEntityType() == EntityType.WITHER) {
|
||||
if (wcfg.blockWitherExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (event.getEntityType() == EntityType.WITHER_SKULL) {
|
||||
if (wcfg.blockWitherSkullExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (event.getEntityType() == EntityType.FIREBALL) {
|
||||
if (wcfg.blockFireballExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (event.getEntityType() == EntityType.CREEPER) {
|
||||
if (wcfg.blockCreeperExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (event.getEntityType() == EntityType.PRIMED_TNT
|
||||
|| event.getEntityType() == EntityType.MINECART_TNT) {
|
||||
if (wcfg.blockTNTExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
|
||||
if (cfg.activityHaltToggle) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
||||
|
||||
// allow spawning of creatures from plugins
|
||||
if (!wcfg.blockPluginSpawning && event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.CUSTOM) {
|
||||
return;
|
||||
}
|
||||
|
||||
// armor stands are living entities, but we check them as blocks/non-living entities, so ignore them here
|
||||
if (Entities.isConsideredBuildingIfUsed(event.getEntity())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.allowTamedSpawns
|
||||
&& event.getEntity() instanceof Tameable // nullsafe check
|
||||
&& ((Tameable) event.getEntity()).isTamed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityType entityType = event.getEntityType();
|
||||
|
||||
com.sk89q.worldedit.world.entity.EntityType weEntityType = BukkitAdapter.adapt(entityType);
|
||||
|
||||
if (weEntityType != null && wcfg.blockCreatureSpawn.contains(weEntityType)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Location eventLoc = event.getLocation();
|
||||
|
||||
if (wcfg.useRegions && cfg.useRegionsCreatureSpawnEvent) {
|
||||
ApplicableRegionSet set =
|
||||
WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(eventLoc));
|
||||
|
||||
if (!set.testState(null, Flags.MOB_SPAWNING)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Set<com.sk89q.worldedit.world.entity.EntityType> entityTypes = set.queryValue(null, Flags.DENY_SPAWN);
|
||||
if (entityTypes != null && weEntityType != null && entityTypes.contains(weEntityType)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (wcfg.blockGroundSlimes && entityType == EntityType.SLIME
|
||||
&& eventLoc.getY() >= 60
|
||||
&& event.getSpawnReason() == SpawnReason.NATURAL) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onCreatePortal(PortalCreateEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
final com.sk89q.worldedit.world.World world = BukkitAdapter.adapt(event.getWorld());
|
||||
WorldConfiguration wcfg = cfg.get(world);
|
||||
|
||||
if (wcfg.regionNetherPortalProtection
|
||||
&& event.getReason() == PortalCreateEvent.CreateReason.NETHER_PAIR
|
||||
&& !event.getBlocks().isEmpty()) {
|
||||
final RegionManager regionManager = WorldGuard.getInstance().getPlatform().getRegionContainer()
|
||||
.get(world);
|
||||
if (regionManager == null) return;
|
||||
LocalPlayer associable = null;
|
||||
if (event.getEntity() instanceof Player) {
|
||||
associable = plugin.wrapPlayer(((Player) event.getEntity()));
|
||||
if (WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(associable, world)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
BlockVector3 min = null;
|
||||
BlockVector3 max = null;
|
||||
for (BlockState block : event.getBlocks()) {
|
||||
BlockVector3 loc = BlockVector3.at(block.getX(), block.getY(), block.getZ());
|
||||
min = min == null ? loc : loc.getMinimum(min);
|
||||
max = max == null ? loc : loc.getMaximum(max);
|
||||
}
|
||||
ProtectedCuboidRegion target = new ProtectedCuboidRegion("__portal_check", true, min, max);
|
||||
final ApplicableRegionSet regions = regionManager.getApplicableRegions(target);
|
||||
if (!regions.testState(associable, Flags.BUILD, Flags.BLOCK_PLACE)) {
|
||||
if (associable != null) {
|
||||
// NB there is no way to cancel the teleport without PTA (since PlayerPortal doesn't have block info)
|
||||
// removing PTA was a mistake
|
||||
associable.print("Destination is an a protected area.");
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: as of right now, bukkit doesn't fire this event for this (despite deprecating EntityCreatePortalEvent for it)
|
||||
// maybe one day this code will be useful
|
||||
if (event.getEntity() instanceof EnderDragon && wcfg.blockEnderDragonPortalCreation) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onEntityTransform(EntityTransformEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
final Entity entity = event.getEntity();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(entity.getWorld()));
|
||||
|
||||
final EntityType type = entity.getType();
|
||||
if (wcfg.disableVillagerZap && type == EntityType.VILLAGER
|
||||
&& event.getTransformReason() == EntityTransformEvent.TransformReason.LIGHTNING) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPigZap(PigZapEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
final Entity entity = event.getEntity();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(entity.getWorld()));
|
||||
|
||||
if (wcfg.disablePigZap) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onCreeperPower(CreeperPowerEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
||||
|
||||
if (wcfg.disableCreeperPower) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
|
||||
|
||||
Entity ent = event.getEntity();
|
||||
World world = ent.getWorld();
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(world));
|
||||
|
||||
if (wcfg.disableHealthRegain) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an entity changes a block somehow
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||
Entity ent = event.getEntity();
|
||||
Block block = event.getBlock();
|
||||
Location location = block.getLocation();
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(ent.getWorld()));
|
||||
if (ent instanceof Enderman) {
|
||||
if (wcfg.disableEndermanGriefing) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (ent.getType() == EntityType.WITHER) {
|
||||
if (wcfg.blockWitherBlockDamage || wcfg.blockWitherExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions) {
|
||||
if (!StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(location), (RegionAssociable) null, Flags.WITHER_DAMAGE))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (/*ent instanceof Zombie && */event instanceof EntityBreakDoorEvent) {
|
||||
if (wcfg.blockZombieDoorDestruction) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks regions and config settings to protect items from being knocked
|
||||
* out of item frames.
|
||||
* @param attacker attacking entity
|
||||
* @param defender item frame being damaged
|
||||
* @return true if the event should be cancelled
|
||||
*/
|
||||
private boolean checkItemFrameProtection(Entity attacker, ItemFrame defender) {
|
||||
World world = attacker.getWorld();
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(world));
|
||||
if (wcfg.useRegions) {
|
||||
// bukkit throws this event when a player attempts to remove an item from a frame
|
||||
if (!(attacker instanceof Player)) {
|
||||
if (!StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(defender.getLocation()), (RegionAssociable) null, Flags.ENTITY_ITEM_FRAME_DESTROY))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (wcfg.blockEntityItemFrameDestroy && !(attacker instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Hanging;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Painting;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
/**
|
||||
* Listener for painting related events.
|
||||
*
|
||||
* @author BangL <henno.rickowski@gmail.com>
|
||||
*/
|
||||
public class WorldGuardHangingListener implements Listener {
|
||||
|
||||
private WorldGuardPlugin plugin;
|
||||
|
||||
/**
|
||||
* Construct the object;
|
||||
*
|
||||
* @param plugin The plugin instance
|
||||
*/
|
||||
public WorldGuardHangingListener(WorldGuardPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register events.
|
||||
*/
|
||||
public void registerEvents() {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onHangingBreak(HangingBreakEvent event) {
|
||||
Hanging hanging = event.getEntity();
|
||||
World world = hanging.getWorld();
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(world));
|
||||
|
||||
if (event instanceof HangingBreakByEntityEvent) {
|
||||
HangingBreakByEntityEvent entityEvent = (HangingBreakByEntityEvent) event;
|
||||
Entity removerEntity = entityEvent.getRemover();
|
||||
if (removerEntity instanceof Projectile) {
|
||||
Projectile projectile = (Projectile) removerEntity;
|
||||
ProjectileSource remover = projectile.getShooter();
|
||||
removerEntity = (remover instanceof LivingEntity ? (LivingEntity) remover : null);
|
||||
}
|
||||
|
||||
if (!(removerEntity instanceof Player)) {
|
||||
if (removerEntity instanceof Creeper) {
|
||||
if (wcfg.blockCreeperBlockDamage || wcfg.blockCreeperExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions && !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(hanging.getLocation()), (RegionAssociable) null, Flags.CREEPER_EXPLOSION))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// this now covers dispensers as well, if removerEntity is null above,
|
||||
// due to a non-LivingEntity ProjectileSource
|
||||
if (hanging instanceof Painting
|
||||
&& (wcfg.blockEntityPaintingDestroy
|
||||
|| (wcfg.useRegions
|
||||
&& !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(hanging.getLocation()), (RegionAssociable) null, Flags.ENTITY_PAINTING_DESTROY))))) {
|
||||
event.setCancelled(true);
|
||||
} else if (hanging instanceof ItemFrame
|
||||
&& (wcfg.blockEntityItemFrameDestroy
|
||||
|| (wcfg.useRegions
|
||||
&& !StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(hanging.getLocation()), (RegionAssociable) null, Flags.ENTITY_ITEM_FRAME_DESTROY))))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Explosions from mobs are not covered by HangingBreakByEntity
|
||||
if (hanging instanceof Painting && wcfg.blockEntityPaintingDestroy
|
||||
&& event.getCause() == RemoveCause.EXPLOSION) {
|
||||
event.setCancelled(true);
|
||||
} else if (hanging instanceof ItemFrame && wcfg.blockEntityItemFrameDestroy
|
||||
&& event.getCause() == RemoveCause.EXPLOSION) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+454
@@ -0,0 +1,454 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.event.player.ProcessPlayerEvent;
|
||||
import com.sk89q.worldguard.bukkit.util.Events;
|
||||
import com.sk89q.worldguard.bukkit.util.Materials;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import com.sk89q.worldguard.session.MoveType;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
import com.sk89q.worldguard.session.handler.GameModeFlag;
|
||||
import com.sk89q.worldguard.util.Entities;
|
||||
import com.sk89q.worldguard.util.command.CommandFilter;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Handles all events thrown in relation to a player.
|
||||
*/
|
||||
public class WorldGuardPlayerListener implements Listener {
|
||||
|
||||
private static final Logger log = Logger.getLogger(WorldGuardPlayerListener.class.getCanonicalName());
|
||||
private static final Pattern opPattern = Pattern.compile("^/(?:minecraft:)?(?:bukkit:)?(?:de)?op(?:\\s.*)?$", Pattern.CASE_INSENSITIVE);
|
||||
private WorldGuardPlugin plugin;
|
||||
|
||||
/**
|
||||
* Construct the object;
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
public WorldGuardPlayerListener(WorldGuardPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register events.
|
||||
*/
|
||||
public void registerEvents() {
|
||||
PluginManager pm = plugin.getServer().getPluginManager();
|
||||
pm.registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
WorldConfiguration wcfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(localPlayer.getWorld());
|
||||
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().getIfPresent(localPlayer);
|
||||
if (session != null) {
|
||||
GameModeFlag handler = session.getHandler(GameModeFlag.class);
|
||||
if (handler != null && wcfg.useRegions && !WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer,
|
||||
localPlayer.getWorld())) {
|
||||
GameMode expected = handler.getSetGameMode();
|
||||
if (handler.getOriginalGameMode() != null && expected != null && expected != BukkitAdapter.adapt(event.getNewGameMode())) {
|
||||
log.info("Game mode change on " + player.getName() + " has been blocked due to the region GAMEMODE flag");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
World world = player.getWorld();
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(localPlayer.getWorld());
|
||||
|
||||
if (cfg.activityHaltToggle) {
|
||||
player.sendMessage(ChatColor.YELLOW
|
||||
+ "Intensive server activity has been HALTED.");
|
||||
|
||||
int removed = 0;
|
||||
|
||||
for (Entity entity : world.getEntities()) {
|
||||
if (Entities.isIntensiveEntity(BukkitAdapter.adapt(entity))) {
|
||||
entity.remove();
|
||||
removed++;
|
||||
}
|
||||
}
|
||||
|
||||
if (removed > 10) {
|
||||
log.info("Halt-Act: " + removed + " entities (>10) auto-removed from "
|
||||
+ player.getWorld());
|
||||
}
|
||||
}
|
||||
|
||||
if (wcfg.fireSpreadDisableToggle) {
|
||||
player.sendMessage(ChatColor.YELLOW
|
||||
+ "Fire spread is currently globally disabled for this world.");
|
||||
}
|
||||
|
||||
Events.fire(new ProcessPlayerEvent(player));
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
WorldConfiguration wcfg =
|
||||
WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(localPlayer.getWorld());
|
||||
if (wcfg.useRegions) {
|
||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||
ApplicableRegionSet chatFrom = query.getApplicableRegions(localPlayer.getLocation());
|
||||
|
||||
if (!chatFrom.testState(localPlayer, Flags.SEND_CHAT)) {
|
||||
String message = chatFrom.queryValue(localPlayer, Flags.DENY_MESSAGE);
|
||||
RegionProtectionListener.formatAndSendDenyMessage("chat", localPlayer, message);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean anyRemoved = false;
|
||||
for (Iterator<Player> i = event.getRecipients().iterator(); i.hasNext();) {
|
||||
Player rPlayer = i.next();
|
||||
LocalPlayer rLocal = plugin.wrapPlayer(rPlayer);
|
||||
if (!query.testState(rLocal.getLocation(), rLocal, Flags.RECEIVE_CHAT)) {
|
||||
i.remove();
|
||||
anyRemoved = true;
|
||||
}
|
||||
}
|
||||
if (anyRemoved && event.getRecipients().isEmpty() && wcfg.regionCancelEmptyChatEvents) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
|
||||
String hostKey = cfg.hostKeys.get(player.getUniqueId().toString());
|
||||
if (hostKey == null) {
|
||||
hostKey = cfg.hostKeys.get(player.getName().toLowerCase());
|
||||
}
|
||||
|
||||
if (hostKey != null) {
|
||||
String hostname = event.getHostname();
|
||||
int colonIndex = hostname.indexOf(':');
|
||||
if (colonIndex != -1) {
|
||||
hostname = hostname.substring(0, colonIndex);
|
||||
}
|
||||
|
||||
if (!hostname.equals(hostKey)
|
||||
&& !(cfg.hostKeysAllowFMLClients && hostname.equals(hostKey + "\u0000FML\u0000"))) {
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
|
||||
"You did not join with the valid host key!");
|
||||
log.warning("WorldGuard host key check: " +
|
||||
player.getName() + " joined with '" + hostname +
|
||||
"' but '" + hostKey + "' was expected. Kicked!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (cfg.deopOnJoin) {
|
||||
player.setOp(false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
World world = player.getWorld();
|
||||
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
handleBlockRightClick(event);
|
||||
} else if (event.getAction() == Action.PHYSICAL) {
|
||||
handlePhysicalInteract(event);
|
||||
}
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(world));
|
||||
|
||||
if (wcfg.removeInfiniteStacks
|
||||
&& !plugin.hasPermission(player, "worldguard.override.infinite-stack")) {
|
||||
int slot = player.getInventory().getHeldItemSlot();
|
||||
ItemStack heldItem = player.getInventory().getItem(slot);
|
||||
if (heldItem != null && heldItem.getAmount() < 0) {
|
||||
player.getInventory().setItem(slot, null);
|
||||
player.sendMessage(ChatColor.RED + "Infinite stack removed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player right clicks a block.
|
||||
*
|
||||
* @param event Thrown event
|
||||
*/
|
||||
private void handleBlockRightClick(PlayerInteractEvent event) {
|
||||
if (event.useItemInHand() == Event.Result.DENY) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
World world = block.getWorld();
|
||||
Material type = block.getType();
|
||||
Player player = event.getPlayer();
|
||||
@Nullable ItemStack item = event.getItem();
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(world));
|
||||
|
||||
// Infinite stack removal
|
||||
if (Materials.isInventoryBlock(type)
|
||||
&& wcfg.removeInfiniteStacks
|
||||
&& !plugin.hasPermission(player, "worldguard.override.infinite-stack")) {
|
||||
for (int slot = 0; slot < 40; slot++) {
|
||||
ItemStack heldItem = player.getInventory().getItem(slot);
|
||||
if (heldItem != null && heldItem.getAmount() < 0) {
|
||||
player.getInventory().setItem(slot, null);
|
||||
player.sendMessage(ChatColor.RED + "Infinite stack in slot #" + slot + " removed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
//Block placedIn = block.getRelative(event.getBlockFace());
|
||||
ApplicableRegionSet set =
|
||||
WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(block.getLocation()));
|
||||
//ApplicableRegionSet placedInSet = plugin.getRegionContainer().createQuery().getApplicableRegions(placedIn.getLocation());
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
if (item != null && item.getType().getKey().toString().equals(wcfg.regionWand) && plugin.hasPermission(player, "worldguard.region.wand")) {
|
||||
if (set.size() > 0) {
|
||||
player.sendMessage(ChatColor.YELLOW + "Can you build? " + (set.testState(localPlayer, Flags.BUILD) ? "Yes" : "No"));
|
||||
|
||||
StringBuilder str = new StringBuilder();
|
||||
for (Iterator<ProtectedRegion> it = set.iterator(); it.hasNext();) {
|
||||
str.append(it.next().getId());
|
||||
if (it.hasNext()) {
|
||||
str.append(", ");
|
||||
}
|
||||
}
|
||||
|
||||
localPlayer.print("Applicable regions: " + str);
|
||||
} else {
|
||||
localPlayer.print("WorldGuard: No defined regions here!");
|
||||
}
|
||||
|
||||
event.setUseItemInHand(Event.Result.DENY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player steps on a pressure plate or tramples crops.
|
||||
*
|
||||
* @param event Thrown event
|
||||
*/
|
||||
private void handlePhysicalInteract(PlayerInteractEvent event) {
|
||||
if (event.useInteractedBlock() == Event.Result.DENY) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getClickedBlock(); //not actually clicked but whatever
|
||||
//int type = block.getTypeId();
|
||||
World world = player.getWorld();
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(world));
|
||||
|
||||
if (block.getType() == Material.FARMLAND && wcfg.disablePlayerCropTrampling) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(localPlayer.getWorld());
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
ApplicableRegionSet set =
|
||||
WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(localPlayer.getLocation());
|
||||
|
||||
com.sk89q.worldedit.util.Location spawn = set.queryValue(localPlayer, Flags.SPAWN_LOC);
|
||||
|
||||
if (spawn != null) {
|
||||
event.setRespawnLocation(BukkitAdapter.adapt(spawn));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onItemHeldChange(PlayerItemHeldEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(player.getWorld()));
|
||||
|
||||
if (wcfg.removeInfiniteStacks
|
||||
&& !plugin.hasPermission(player, "worldguard.override.infinite-stack")) {
|
||||
int newSlot = event.getNewSlot();
|
||||
ItemStack heldItem = player.getInventory().getItem(newSlot);
|
||||
if (heldItem != null && heldItem.getAmount() < 0) {
|
||||
player.getInventory().setItem(newSlot, null);
|
||||
player.sendMessage(ChatColor.RED + "Infinite stack removed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(localPlayer.getWorld());
|
||||
|
||||
if (wcfg.useRegions && cfg.usePlayerTeleports) {
|
||||
ApplicableRegionSet set =
|
||||
WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(event.getTo()));
|
||||
ApplicableRegionSet setFrom =
|
||||
WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(event.getFrom()));
|
||||
|
||||
if (event.getCause() == TeleportCause.ENDER_PEARL) {
|
||||
if (!WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, localPlayer.getWorld())) {
|
||||
boolean cancel = false;
|
||||
String message = null;
|
||||
if (!setFrom.testState(localPlayer, Flags.ENDERPEARL)) {
|
||||
cancel = true;
|
||||
message = setFrom.queryValue(localPlayer, Flags.EXIT_DENY_MESSAGE);
|
||||
} else if (!set.testState(localPlayer, Flags.ENDERPEARL)) {
|
||||
cancel = true;
|
||||
message = set.queryValue(localPlayer, Flags.ENTRY_DENY_MESSAGE);
|
||||
}
|
||||
if (cancel) {
|
||||
if (message != null) {
|
||||
player.sendMessage(message);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (event.getCause() == TeleportCause.CHORUS_FRUIT) {
|
||||
if (!WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, localPlayer.getWorld())) {
|
||||
boolean cancel = false;
|
||||
String message = null;
|
||||
if (!setFrom.testState(localPlayer, Flags.CHORUS_TELEPORT)) {
|
||||
cancel = true;
|
||||
message = setFrom.queryValue(localPlayer, Flags.EXIT_DENY_MESSAGE);
|
||||
} else if (!set.testState(localPlayer, Flags.CHORUS_TELEPORT)) {
|
||||
cancel = true;
|
||||
message = set.queryValue(localPlayer, Flags.ENTRY_DENY_MESSAGE);
|
||||
}
|
||||
if (cancel) {
|
||||
if (message != null) {
|
||||
player.sendMessage(message);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null != WorldGuard.getInstance().getPlatform().getSessionManager().get(localPlayer)
|
||||
.testMoveTo(localPlayer, BukkitAdapter.adapt(event.getTo()), MoveType.TELEPORT)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(localPlayer.getWorld());
|
||||
|
||||
if (wcfg.useRegions && !WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, localPlayer.getWorld())) {
|
||||
ApplicableRegionSet set =
|
||||
WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(localPlayer.getLocation());
|
||||
|
||||
Set<String> allowedCommands = set.queryValue(localPlayer, Flags.ALLOWED_CMDS);
|
||||
Set<String> blockedCommands = set.queryValue(localPlayer, Flags.BLOCKED_CMDS);
|
||||
CommandFilter test = new CommandFilter(allowedCommands, blockedCommands);
|
||||
|
||||
if (!test.apply(event.getMessage())) {
|
||||
String message = set.queryValue(localPlayer, Flags.DENY_MESSAGE);
|
||||
RegionProtectionListener.formatAndSendDenyMessage("use " + event.getMessage(), localPlayer, message);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (cfg.blockInGameOp) {
|
||||
if (opPattern.matcher(event.getMessage()).matches()) {
|
||||
player.sendMessage(ChatColor.RED + "/op and /deop can only be used in console (as set by a WG setting).");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.BukkitConfigurationManager;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class WorldGuardServerListener implements Listener {
|
||||
|
||||
private final WorldGuardPlugin plugin;
|
||||
|
||||
public WorldGuardServerListener(WorldGuardPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void registerEvents() {
|
||||
PluginManager pm = plugin.getServer().getPluginManager();
|
||||
pm.registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("CommandBook")) {
|
||||
((BukkitConfigurationManager) WorldGuard.getInstance().getPlatform().getGlobalStateManager()).updateCommandBookGodMode();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("CommandBook")) {
|
||||
((BukkitConfigurationManager) WorldGuard.getInstance().getPlatform().getGlobalStateManager()).updateCommandBookGodMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||
import com.sk89q.worldguard.session.MoveType;
|
||||
import com.sk89q.worldguard.util.Locations;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.vehicle.VehicleMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WorldGuardVehicleListener implements Listener {
|
||||
|
||||
private WorldGuardPlugin plugin;
|
||||
|
||||
/**
|
||||
* Construct the object;
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
public WorldGuardVehicleListener(WorldGuardPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register events.
|
||||
*/
|
||||
public void registerEvents() {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onVehicleMove(VehicleMoveEvent event) {
|
||||
Vehicle vehicle = event.getVehicle();
|
||||
if (vehicle.getPassengers().isEmpty()) return;
|
||||
List<Player> playerPassengers = vehicle.getPassengers().stream()
|
||||
.filter(ent -> ent instanceof Player).map(ent -> (Player) ent).collect(Collectors.toList());
|
||||
if (playerPassengers.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
World world = vehicle.getWorld();
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(world));
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
// Did we move a block?
|
||||
if (Locations.isDifferentBlock(BukkitAdapter.adapt(event.getFrom()), BukkitAdapter.adapt(event.getTo()))) {
|
||||
for (Player player : playerPassengers) {
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
Location lastValid;
|
||||
if ((lastValid = WorldGuard.getInstance().getPlatform().getSessionManager().get(localPlayer)
|
||||
.testMoveTo(localPlayer, BukkitAdapter.adapt(event.getTo()), MoveType.RIDE)) != null) {
|
||||
vehicle.setVelocity(new Vector(0, 0, 0));
|
||||
vehicle.teleport(event.getFrom());
|
||||
if (Locations.isDifferentBlock(lastValid, BukkitAdapter.adapt(event.getFrom()))) {
|
||||
Vector dir = player.getLocation().getDirection();
|
||||
player.teleport(BukkitAdapter.adapt(lastValid).setDirection(dir));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.weather.LightningStrikeEvent;
|
||||
import org.bukkit.event.weather.ThunderChangeEvent;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
|
||||
public class WorldGuardWeatherListener implements Listener {
|
||||
|
||||
/**
|
||||
* Plugin.
|
||||
*/
|
||||
private WorldGuardPlugin plugin;
|
||||
|
||||
/**
|
||||
* Construct the object;
|
||||
*
|
||||
* @param plugin The plugin instance
|
||||
*/
|
||||
public WorldGuardWeatherListener(WorldGuardPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void registerEvents() {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onWeatherChange(WeatherChangeEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(event.getWorld()));
|
||||
|
||||
if (event.toWeatherState()) {
|
||||
if (wcfg.disableWeather) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
if (!wcfg.disableWeather && wcfg.alwaysRaining) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onThunderChange(ThunderChangeEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(event.getWorld()));
|
||||
|
||||
if (event.toThunderState()) {
|
||||
if (wcfg.disableThunder) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
if (!wcfg.disableWeather && wcfg.alwaysThundering) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onLightningStrike(LightningStrikeEvent event) {
|
||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(event.getWorld()));
|
||||
|
||||
if (!wcfg.disallowedLightningBlocks.isEmpty()) {
|
||||
final Block target = event.getLightning().getLocation().getBlock();
|
||||
Material targetId = target.getType();
|
||||
if (targetId == Material.AIR) {
|
||||
targetId = target.getRelative(BlockFace.DOWN).getType();
|
||||
}
|
||||
if (wcfg.disallowedLightningBlocks.contains(BukkitAdapter.asBlockType(targetId).getId())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
Location loc = event.getLightning().getLocation();
|
||||
if (wcfg.useRegions) {
|
||||
if (!StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(loc), (RegionAssociable) null, Flags.LIGHTNING))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 377 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user