mirror of
https://github.com/essentials/Essentials.git
synced 2025-09-16 17:32:10 +02:00
Compare commits
735 Commits
stable-2.9
...
stable-2.1
Author | SHA1 | Date | |
---|---|---|---|
|
d522a4230f | ||
|
f17485b112 | ||
|
1f932434c2 | ||
|
92b0178ca7 | ||
|
d30c3ca2a6 | ||
|
fb60272439 | ||
|
80ad075f02 | ||
|
3f31dc179b | ||
|
5b975672e8 | ||
|
335d8b7f20 | ||
|
379e75f3e6 | ||
|
2ca171a3f4 | ||
|
8036cc9924 | ||
|
6442e793a9 | ||
|
d745b866c0 | ||
|
4493d7d00c | ||
|
631692d763 | ||
|
d0e3c1d946 | ||
|
82137e0703 | ||
|
a3b2ffdeef | ||
|
46fc6c192c | ||
|
6506c290c8 | ||
|
b1bc73f938 | ||
|
09851acd1b | ||
|
df42c9051b | ||
|
24c93c11c0 | ||
|
5a13e9bbe5 | ||
|
05f337c63c | ||
|
eea0c9682c | ||
|
2f567812d2 | ||
|
88c1b785af | ||
|
5225fb22f8 | ||
|
fae5780e09 | ||
|
7ec65bf213 | ||
|
d40484d016 | ||
|
971902ae38 | ||
|
844be04d75 | ||
|
ef01332114 | ||
|
705b193450 | ||
|
20b9111495 | ||
|
1661eddc02 | ||
|
15be319d3e | ||
|
fddbd7a52a | ||
|
360e3e8801 | ||
|
4edc39360a | ||
|
cd126264e0 | ||
|
df0ccb5832 | ||
|
8afcd41ab2 | ||
|
b8a71761ec | ||
|
738ded7ae5 | ||
|
5535435215 | ||
|
4167dd2590 | ||
|
623ff0f629 | ||
|
6e4ba4302f | ||
|
3d4d616414 | ||
|
d6c91d2d04 | ||
|
cef8cf7b75 | ||
|
12786a260e | ||
|
6ea956b11c | ||
|
132aa0cc1d | ||
|
b5733d6597 | ||
|
7fc4a75d4d | ||
|
e9e9efd2d7 | ||
|
9e4493fbb4 | ||
|
a64cb31211 | ||
|
57de3f3ed2 | ||
|
74b63a6f2d | ||
|
faad91849d | ||
|
ce7d83adb6 | ||
|
76d1ea5cab | ||
|
9fb42375b8 | ||
|
2a7f3c6525 | ||
|
c65353350f | ||
|
1ae58d05b4 | ||
|
4f35a72174 | ||
|
addd55228b | ||
|
bb29d48268 | ||
|
d9ee9b036c | ||
|
95e630de92 | ||
|
2836c0862d | ||
|
286091cd32 | ||
|
20786654a4 | ||
|
8fde5102b9 | ||
|
133fdac343 | ||
|
2361b9e724 | ||
|
972d831d0d | ||
|
bfa34130a0 | ||
|
befe1fb39e | ||
|
378eaaaf1f | ||
|
51a55318d0 | ||
|
4663c89dd6 | ||
|
2a1c3fb8e0 | ||
|
0ac1a90b93 | ||
|
ab6b3bff90 | ||
|
2d00fd0c1e | ||
|
e5f4cb9a4d | ||
|
91701e8c2f | ||
|
9cef107bc3 | ||
|
76fd829e8c | ||
|
6ea422015c | ||
|
443a317184 | ||
|
50dca9abf5 | ||
|
f1e3d48248 | ||
|
63ce4a99b9 | ||
|
1ccda52e9f | ||
|
1679790157 | ||
|
6170540a24 | ||
|
987b2ff4d5 | ||
|
23a15cb11a | ||
|
41547e3243 | ||
|
a586edfd0b | ||
|
762bb65677 | ||
|
73c92bf742 | ||
|
2b8435342d | ||
|
9566499a2f | ||
|
343c3a1bdd | ||
|
9aeb49f6c3 | ||
|
7dae04759f | ||
|
e2f6e5a7fd | ||
|
d26fa6c5b8 | ||
|
82f9505a2e | ||
|
f8ce80c18a | ||
|
313fd30ce9 | ||
|
da216b05d9 | ||
|
d8132548f6 | ||
|
6fdeddd96b | ||
|
8082508db9 | ||
|
78e6da9504 | ||
|
0014d5cfcb | ||
|
6aeba173b9 | ||
|
a2813358af | ||
|
8e663b53ce | ||
|
214d9414da | ||
|
6d7881f876 | ||
|
19ccdf2193 | ||
|
35036ecc18 | ||
|
b3cc4dbe09 | ||
|
04bd9e8baf | ||
|
fdc262a205 | ||
|
32ea86bfd3 | ||
|
4807fb39e5 | ||
|
4ffe61a505 | ||
|
d74952927a | ||
|
f8cf3be87f | ||
|
ada266a0f9 | ||
|
115c4fa1d0 | ||
|
0c19b2feed | ||
|
04c833f648 | ||
|
4533d09fc9 | ||
|
7337b86a16 | ||
|
3db015b1c1 | ||
|
659d602b57 | ||
|
f82d7e806f | ||
|
a8088fb8c8 | ||
|
84c06fb746 | ||
|
ffe2a283d2 | ||
|
7e3fd48956 | ||
|
bd22aec38a | ||
|
675c4b7897 | ||
|
ad7009c77e | ||
|
3f783bb43b | ||
|
9fe7712bd6 | ||
|
24f56892ad | ||
|
b860e943f6 | ||
|
5dc2665377 | ||
|
dd9b7e0d3c | ||
|
18a15ca63c | ||
|
ef1492a2a2 | ||
|
298ab846c1 | ||
|
7fdb2ad7d3 | ||
|
3afe8d18f4 | ||
|
0b581580c7 | ||
|
01e78cd666 | ||
|
29d28456aa | ||
|
f3812786d0 | ||
|
999d922fb9 | ||
|
2d4a07b95b | ||
|
5c99eee0c0 | ||
|
1fc502a4ff | ||
|
e73983649f | ||
|
465cdae989 | ||
|
341cb89bb7 | ||
|
79004c7098 | ||
|
2988db08ca | ||
|
b04fa82be2 | ||
|
5d210d81dc | ||
|
c14b32123f | ||
|
f256930269 | ||
|
cde95d832e | ||
|
b9af4fb35c | ||
|
5056210a38 | ||
|
eacb847305 | ||
|
27ff43c0ac | ||
|
368c33a843 | ||
|
c210e8730b | ||
|
6c48e02c14 | ||
|
c54d68a660 | ||
|
33d3123104 | ||
|
df0b1cedd8 | ||
|
2b57381fb8 | ||
|
67b9a82e51 | ||
|
c4e10da646 | ||
|
fbb1c1278c | ||
|
9b49c5e0f4 | ||
|
186d4e2fd1 | ||
|
437b01e371 | ||
|
3bf36fecf9 | ||
|
c57332be63 | ||
|
292fb0cea1 | ||
|
3c4388f8be | ||
|
f930ff48a2 | ||
|
ef7b940e96 | ||
|
6497db837d | ||
|
87cb6190eb | ||
|
74c4c604da | ||
|
0937a35470 | ||
|
121f09caf0 | ||
|
ef8bd3422a | ||
|
2232d859fd | ||
|
0258abee29 | ||
|
9b8991788b | ||
|
9a91c99391 | ||
|
c6dd921f0c | ||
|
63e622374d | ||
|
ca25c71010 | ||
|
b5e559ff66 | ||
|
555bb76428 | ||
|
f210f8e20b | ||
|
e572e7c94c | ||
|
5c9d3c6b1a | ||
|
ccfc23d629 | ||
|
b5dd0fc671 | ||
|
8e3ee8576e | ||
|
4cec7fe5c1 | ||
|
6c3b2076ff | ||
|
cbc1aeacbe | ||
|
a1b2773bf5 | ||
|
9ecb501e00 | ||
|
3dcdad2233 | ||
|
3725a5e6d4 | ||
|
ed88f8aa06 | ||
|
d551e8c6d2 | ||
|
69ad186839 | ||
|
fc89867e4a | ||
|
bbb478c51f | ||
|
03445e5b9b | ||
|
0755fbf089 | ||
|
3a789bdcfe | ||
|
93db8bc7c1 | ||
|
62832ad43a | ||
|
52b104aca5 | ||
|
1f98fe710f | ||
|
a73986a358 | ||
|
257165584e | ||
|
8e92150cb7 | ||
|
4bb275e1b7 | ||
|
e5fc579071 | ||
|
26306f6fa3 | ||
|
0bfb079cbb | ||
|
6b18259af6 | ||
|
99c750d18b | ||
|
bb64fa468a | ||
|
66db3c6cfb | ||
|
c97763c3c8 | ||
|
ad3e8a3aba | ||
|
617959a11b | ||
|
a480091617 | ||
|
13a847e0ab | ||
|
a8a8b52977 | ||
|
226a75472c | ||
|
a1c88a140e | ||
|
2c3218b056 | ||
|
27db9e8c3b | ||
|
cf0e36c973 | ||
|
1218a0b217 | ||
|
adb75b69c2 | ||
|
010df964a1 | ||
|
0e2e8e16af | ||
|
6f28540d59 | ||
|
ce78125028 | ||
|
10b972bd07 | ||
|
371a6437ae | ||
|
78666ade2b | ||
|
8f00aa5542 | ||
|
b2d68fe213 | ||
|
a6c13974c4 | ||
|
fb0cd8fbf0 | ||
|
01d1ae442e | ||
|
dc13f46ff1 | ||
|
f125ac3b4a | ||
|
be29a373ab | ||
|
b28db7e435 | ||
|
3ac6cc11e3 | ||
|
9097bef728 | ||
|
68e401821f | ||
|
7f9a52c3f7 | ||
|
79671d08e4 | ||
|
d01d6bcd1b | ||
|
79a44b919c | ||
|
477e1a4f58 | ||
|
c028c385b6 | ||
|
f9bcc3100c | ||
|
3ea3d18922 | ||
|
3faedec602 | ||
|
2a88a314ce | ||
|
38293560d7 | ||
|
f57b3595ed | ||
|
e2e6bb3876 | ||
|
4e399778b4 | ||
|
9ba5f43315 | ||
|
0bde364125 | ||
|
87f5ec491e | ||
|
1f8a0a811f | ||
|
74d5590d3b | ||
|
258fbdb0e8 | ||
|
bd4a48c441 | ||
|
00bd6a3e02 | ||
|
28ad7b96d2 | ||
|
97204c0e8c | ||
|
46645cb39f | ||
|
dfd6fc78f0 | ||
|
ecf5d47e97 | ||
|
77df82eaff | ||
|
020f2c3ea5 | ||
|
5a855eede5 | ||
|
8b4273cbd1 | ||
|
30bc597851 | ||
|
13efadbb65 | ||
|
6bc3d7f0f4 | ||
|
e706614a3b | ||
|
cf68031110 | ||
|
5741cea3f5 | ||
|
7b879331db | ||
|
0a27a631e3 | ||
|
d8c6587532 | ||
|
d600f160fe | ||
|
d23c324035 | ||
|
52bfeff5b4 | ||
|
3dcb2a828e | ||
|
0b95a691a6 | ||
|
eba2bad113 | ||
|
4f21490ec8 | ||
|
f7daa20be8 | ||
|
a9ace1163f | ||
|
ba380e61ee | ||
|
bbc306970f | ||
|
7b997634ef | ||
|
1efbc3856c | ||
|
f769f96f74 | ||
|
3f69473072 | ||
|
d7bcf6508d | ||
|
61c4d8cb5e | ||
|
f7361eed98 | ||
|
deaa72b05d | ||
|
92bdd51cd4 | ||
|
0ed29c029d | ||
|
61903355cd | ||
|
889f60e58e | ||
|
c4f292f4ef | ||
|
36687e2659 | ||
|
948647926d | ||
|
4a4f443fee | ||
|
18d52821b7 | ||
|
ad7d751856 | ||
|
1151f1a29c | ||
|
0b1625f4c1 | ||
|
1363406b84 | ||
|
4b875ed4d9 | ||
|
42872650d2 | ||
|
fd87933aa9 | ||
|
269cf85457 | ||
|
5728f964a5 | ||
|
a7aa8be37a | ||
|
237c896fff | ||
|
fbb3d7344f | ||
|
8b660d32ac | ||
|
98bccf6cec | ||
|
936606ce7c | ||
|
a63748ca3a | ||
|
a1ce340ce0 | ||
|
a8df79661a | ||
|
f52e0ae7a8 | ||
|
648a5ef8dd | ||
|
0d610f761b | ||
|
e7afe4109e | ||
|
b11a1a7cf2 | ||
|
6a8a2dd28b | ||
|
a370a8e01c | ||
|
5e38a2180c | ||
|
f3bc94a547 | ||
|
ba0db53c44 | ||
|
ef98a6b54c | ||
|
8c9b755671 | ||
|
6c1da1d552 | ||
|
0df0be5762 | ||
|
83120f707f | ||
|
9d98edb4ee | ||
|
a50b0ac71d | ||
|
d674e65c11 | ||
|
4967279b8c | ||
|
4722e687fa | ||
|
332a59f3fc | ||
|
587f532991 | ||
|
10244d5f90 | ||
|
6f1a70dc8b | ||
|
7369155166 | ||
|
28d4609c8c | ||
|
d2966b64eb | ||
|
c8f8680ce9 | ||
|
9fcb412774 | ||
|
296af1069e | ||
|
b22e97b3cf | ||
|
dcf90cbf5a | ||
|
4dc2e2e3fd | ||
|
4d4779ecdc | ||
|
1c25d317dd | ||
|
651a62890a | ||
|
39b38f0619 | ||
|
4a194e8758 | ||
|
5a35da53a0 | ||
|
8d64c7c81b | ||
|
bea3583192 | ||
|
618d115233 | ||
|
5e476f4d61 | ||
|
5bc1b8df70 | ||
|
72e0ab2cb2 | ||
|
e0d189a5e0 | ||
|
91c193b773 | ||
|
4a18130354 | ||
|
7c6268fe20 | ||
|
6f213c23e2 | ||
|
cc606fe1aa | ||
|
ee8638841d | ||
|
9864a75c32 | ||
|
520427239f | ||
|
614a229ea7 | ||
|
2a4d40020e | ||
|
d6efae202a | ||
|
7b9c711486 | ||
|
e2bd22d984 | ||
|
2310b41b21 | ||
|
2ae9c577db | ||
|
7c9375ce2e | ||
|
9addc2ccd5 | ||
|
e180f6e6b3 | ||
|
f0e29552bc | ||
|
48d04216a7 | ||
|
ff6221f1a8 | ||
|
0bc33554f3 | ||
|
7c480e88d6 | ||
|
c357d19c56 | ||
|
86124b2705 | ||
|
99cefb2d74 | ||
|
600f99eb6b | ||
|
8ba7a24fd2 | ||
|
ef608c7595 | ||
|
2ea453110a | ||
|
a86efb5ebe | ||
|
e61fa58d2b | ||
|
ec5edf7bd2 | ||
|
8dbcebda53 | ||
|
28d2a9ed2e | ||
|
d47e9145f3 | ||
|
ae7c64619c | ||
|
bdef1780ac | ||
|
ced192e8fd | ||
|
0a9e9ca41d | ||
|
4982cc950e | ||
|
140a9100b7 | ||
|
0097f961b4 | ||
|
98d657ec4b | ||
|
63149d0b50 | ||
|
7a410919a0 | ||
|
aa7a39d0b0 | ||
|
9b88107897 | ||
|
147a2fc227 | ||
|
732dc3bf34 | ||
|
227cde75a7 | ||
|
e670d0af45 | ||
|
cd0fde05b7 | ||
|
8cf2ce7b73 | ||
|
1ecf592893 | ||
|
0dd0dba338 | ||
|
678ae78767 | ||
|
d8b6742543 | ||
|
2671f39951 | ||
|
d7ddf3c828 | ||
|
2b7cba936d | ||
|
2757c707bb | ||
|
f50c5276e4 | ||
|
a7e692fe37 | ||
|
02d273f15e | ||
|
778f5649c8 | ||
|
d7829bef28 | ||
|
d436d10b00 | ||
|
2d9254eb28 | ||
|
23393aea5f | ||
|
e1562e38bf | ||
|
4dcce2544e | ||
|
29fa2f0f19 | ||
|
b850ae93e9 | ||
|
21cb8efb90 | ||
|
cd7be1bb86 | ||
|
69cd17a1b1 | ||
|
872bc4df4c | ||
|
3083ba2627 | ||
|
35259892b8 | ||
|
fbc0f13b2b | ||
|
aa7f49cb85 | ||
|
720676542e | ||
|
1d7eb77f27 | ||
|
895f6269fc | ||
|
4bf0d3ab24 | ||
|
afccda6350 | ||
|
c0a176825c | ||
|
db6512b702 | ||
|
46d3f0827a | ||
|
838d7dd8f9 | ||
|
b9e5c8827f | ||
|
b8e000c7f9 | ||
|
5e7af93c77 | ||
|
077ad8cd0f | ||
|
0bf954e467 | ||
|
8a55afc4e1 | ||
|
2bc9f2e386 | ||
|
920e1a3b1f | ||
|
353253b9c5 | ||
|
1438230b70 | ||
|
240aebde98 | ||
|
d4e2ed782e | ||
|
f025cd9d2f | ||
|
1ff7082892 | ||
|
15fa10dd29 | ||
|
00b4bdadd4 | ||
|
3055dd93a5 | ||
|
94dc29cc4d | ||
|
22d1db5463 | ||
|
f2b4bb00b6 | ||
|
d2546ebd36 | ||
|
f1930e76d6 | ||
|
d722e6a9f0 | ||
|
8e6d4b1595 | ||
|
72065c81f3 | ||
|
2864d0186c | ||
|
9c9b2be011 | ||
|
2f40264c46 | ||
|
5cc24827fc | ||
|
da01bdc2b0 | ||
|
dfb81dd50f | ||
|
567d52459b | ||
|
80a96e2a73 | ||
|
c2f8467ca9 | ||
|
155ca46fef | ||
|
0952150235 | ||
|
30faa39070 | ||
|
3e367912ec | ||
|
f8cff25bda | ||
|
3e80bf479e | ||
|
84afc80873 | ||
|
27a943217e | ||
|
16834d85c5 | ||
|
44d8c85450 | ||
|
2a8e44dda8 | ||
|
00e3957190 | ||
|
a79b76e8d2 | ||
|
0a092ff5b3 | ||
|
e6aeefb12d | ||
|
924b6bd2ba | ||
|
f701090c89 | ||
|
b9195a561f | ||
|
d94e4095da | ||
|
fd61cd1750 | ||
|
e7ae8bcc47 | ||
|
edc4d62004 | ||
|
cdff690bb5 | ||
|
aa14cc39d9 | ||
|
cdf2c8beed | ||
|
3e06c06827 | ||
|
a2886d76d2 | ||
|
cc0a65bace | ||
|
d988546ef3 | ||
|
b7f2add7b4 | ||
|
b07f65c58b | ||
|
18e315a048 | ||
|
d3967297bb | ||
|
ea3631ddc2 | ||
|
992e473b72 | ||
|
0296f4fcf1 | ||
|
2fc16250a3 | ||
|
75f7b06a23 | ||
|
a7e834e5f9 | ||
|
59086932bd | ||
|
5611acf12c | ||
|
60142d872f | ||
|
1cf0ebbd7f | ||
|
736a6d273a | ||
|
71179e3dfd | ||
|
24cdc37987 | ||
|
b606f153f4 | ||
|
96ab1b4533 | ||
|
8718d59286 | ||
|
5d372b8149 | ||
|
1d62de7e5e | ||
|
3691417848 | ||
|
029162bba7 | ||
|
161a61e0c6 | ||
|
587addb73f | ||
|
d71bd7fb71 | ||
|
699ec273dd | ||
|
c1eed8ebcd | ||
|
b8d0cf4cc4 | ||
|
ff0dd00d79 | ||
|
e18d12f109 | ||
|
0a09b355b2 | ||
|
f9659dae68 | ||
|
78a580bc40 | ||
|
8c4d6ad4df | ||
|
9c9d4e1da5 | ||
|
ce50e1448b | ||
|
8e885a3a6e | ||
|
ecd96a81dd | ||
|
427108574e | ||
|
62381a7f52 | ||
|
b1b09ea542 | ||
|
e502a7e6fd | ||
|
acf4d0bcf5 | ||
|
6c3b13a7a4 | ||
|
cababcbfcf | ||
|
a032d0f19f | ||
|
f808e6fa8e | ||
|
842d9f73a4 | ||
|
c2893788e7 | ||
|
0b8a6c45c6 | ||
|
2049e630fb | ||
|
6fd82480a3 | ||
|
e919897f1b | ||
|
0fb5fc6bcc | ||
|
a7d61b1b8d | ||
|
be9a58457a | ||
|
b1cfc8a8ed | ||
|
6b9b6ba420 | ||
|
79c70b1f65 | ||
|
cfe634e8f7 | ||
|
8c8c6fe73a | ||
|
a4353bc8f2 | ||
|
4015351c85 | ||
|
e89f1d8a03 | ||
|
ff461be45d | ||
|
93f5a05f17 | ||
|
3eba7fb90f | ||
|
25d51cd79e | ||
|
a39824abb6 | ||
|
2ac4c8e665 | ||
|
a84afbaa6e | ||
|
41f7b4ec2d | ||
|
ce90e9710e | ||
|
930eb7ae86 | ||
|
cf79a8fdca | ||
|
1773a6060d | ||
|
5755d647a3 | ||
|
5032142a49 | ||
|
15e996f485 | ||
|
b37c08fd31 | ||
|
eaca7f9c09 | ||
|
00072501c9 | ||
|
b50bb03814 | ||
|
f55316281c | ||
|
413a7beaa4 | ||
|
88140f0610 | ||
|
4996171b6e | ||
|
d201286fc5 | ||
|
12b527be99 | ||
|
e666c27d96 | ||
|
56cfc47ef6 | ||
|
c4e4235f30 | ||
|
e045f9d983 | ||
|
ba8d060927 | ||
|
5f73bf12d7 | ||
|
616f92c214 | ||
|
298f3dc3b2 | ||
|
65741403e0 | ||
|
2b6d41ac5f | ||
|
a4936355b5 | ||
|
02d6eade28 | ||
|
089fa8c19b | ||
|
7c687831bc | ||
|
d43cb95d72 | ||
|
d588c3f271 | ||
|
eaa93d545d | ||
|
e324a21b60 | ||
|
b9cfd44588 | ||
|
44e9c6ebfc | ||
|
a836576211 | ||
|
1ad8c95e3e | ||
|
2dff343c10 | ||
|
fa2a041102 | ||
|
86f8f9c83f | ||
|
e359e8ab6e | ||
|
2f8f3aaa8d | ||
|
f5bf5ed251 | ||
|
979da6e713 | ||
|
6c86fe6117 | ||
|
9018fc8324 | ||
|
2f57961ce4 | ||
|
4478d438d6 | ||
|
9261b259a9 | ||
|
3f3d8c58bc | ||
|
e42f7e4ffa | ||
|
8a9353fd09 | ||
|
7d5e0352d2 | ||
|
05eef76134 | ||
|
e6ef67f7bf | ||
|
bbd93f333d | ||
|
84f7859ca9 | ||
|
1c0dffa67c | ||
|
5f3fb9b595 | ||
|
4ce1e2d9bf | ||
|
e40f364c1e | ||
|
6bd2d2c4b9 | ||
|
47f06e5c1b | ||
|
4c4df13c2f | ||
|
6ca037ae3e | ||
|
47c708fd33 | ||
|
c40b23d80e | ||
|
f17a790d78 | ||
|
bdf67db6ed | ||
|
3e203d193c | ||
|
a92eb4dee6 | ||
|
ed411ee217 | ||
|
368d3a4046 | ||
|
8aab57e86b | ||
|
e198b61eae | ||
|
9824cd75b6 | ||
|
562274706b | ||
|
8fdd32a210 |
85
.gitignore
vendored
85
.gitignore
vendored
@@ -1,42 +1,47 @@
|
||||
.DS_Store
|
||||
/BuildAll/nbproject/private/
|
||||
/EssentialsProtect/nbproject/private/
|
||||
/EssentialsChat/nbproject/private/
|
||||
/EssentialsGroupBridge/nbproject/private/
|
||||
/EssentialsGeoIP/nbproject/private/
|
||||
/EssentialsSpawn/nbproject/private/
|
||||
/EssentialsXMPP/nbproject/private/
|
||||
/EssentialsGroupManager/nbproject/private/
|
||||
/BuildAll/build/
|
||||
/EssentialsGroupBridge/dist/
|
||||
/EssentialsGroupBridge/build/
|
||||
/EssentialsGeoIP/dist/
|
||||
/EssentialsGeoIP/build/
|
||||
/EssentialsGroupManager/build/
|
||||
/EssentialsGroupManager/dist/
|
||||
/BuildAll/dist/
|
||||
/EssentialsChat/build/
|
||||
/EssentialsChat/dist/
|
||||
/EssentialsSpawn/build/
|
||||
/EssentialsSpawn/dist/
|
||||
/EssentialsXMPP/dist/
|
||||
/EssentialsXMPP/build/
|
||||
/EssentialsProtect/dist/
|
||||
/EssentialsProtect/build/
|
||||
/EssentialsPermissionsCommands/nbproject/private/
|
||||
/EssentialsPermissionsCommands/build/
|
||||
/EssentialsPermissionsCommands/dist/
|
||||
/Essentials/nbproject/private/
|
||||
/Essentials/dist/
|
||||
/Essentials/build/
|
||||
/YamlAnnotations/
|
||||
/EssentialsUpdate/nbproject/private/
|
||||
/EssentialsRelease/
|
||||
/EssentialsUpdate/dist/
|
||||
/EssentialsUpdate/build/
|
||||
/WebPush/apikey.php
|
||||
/WebPush/nbproject/private
|
||||
/.idea
|
||||
.DS_Store
|
||||
/BuildAll/nbproject/private/
|
||||
/EssentialsProtect/nbproject/private/
|
||||
/EssentialsChat/nbproject/private/
|
||||
/EssentialsGroupBridge/nbproject/private/
|
||||
/EssentialsGeoIP/nbproject/private/
|
||||
/EssentialsSpawn/nbproject/private/
|
||||
/EssentialsXMPP/nbproject/private/
|
||||
/EssentialsGroupManager/nbproject/private/
|
||||
/BuildAll/build/
|
||||
/EssentialsGroupBridge/dist/
|
||||
/EssentialsGroupBridge/build/
|
||||
/EssentialsGeoIP/dist/
|
||||
/EssentialsGeoIP/build/
|
||||
/EssentialsGroupManager/build/
|
||||
/EssentialsGroupManager/dist/
|
||||
/BuildAll/dist/
|
||||
/EssentialsChat/build/
|
||||
/EssentialsChat/dist/
|
||||
/EssentialsSpawn/build/
|
||||
/EssentialsSpawn/dist/
|
||||
/EssentialsXMPP/dist/
|
||||
/EssentialsXMPP/build/
|
||||
/EssentialsProtect/dist/
|
||||
/EssentialsProtect/build/
|
||||
/EssentialsPermissionsCommands/nbproject/private/
|
||||
/EssentialsPermissionsCommands/build/
|
||||
/EssentialsPermissionsCommands/dist/
|
||||
/Essentials/nbproject/private/
|
||||
/Essentials/dist/
|
||||
/Essentials/build/
|
||||
/YamlAnnotations/
|
||||
/EssentialsUpdate/nbproject/private/
|
||||
/EssentialsRelease/
|
||||
/EssentialsUpdate/dist/
|
||||
/EssentialsUpdate/build/
|
||||
/WebPush/apikey.php
|
||||
/WebPush/nbproject/private
|
||||
/.idea
|
||||
*.iml
|
||||
/EssentialsGroupManager/bin
|
||||
/EssentialsGroupManager/.externalToolBuilders
|
||||
/EssentialsGroupManager/.externalToolBuilders
|
||||
/EssentialsAntiBuild/nbproject/private/
|
||||
/EssentialsAntiBuild/dist/
|
||||
/EssentialsAntiBuild/build/
|
||||
/jars
|
||||
/out
|
@@ -948,6 +948,13 @@ is divided into following sections:
|
||||
<param name="call.target" value="jar"/>
|
||||
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
|
||||
</antcall>
|
||||
<antcall target="-maybe-call-dep">
|
||||
<param name="call.built.properties" value="${built-jar.properties}"/>
|
||||
<param location="${project.EssentialsAntiBuild}" name="call.subproject"/>
|
||||
<param location="${project.EssentialsAntiBuild}/build.xml" name="call.script"/>
|
||||
<param name="call.target" value="jar"/>
|
||||
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
|
||||
</antcall>
|
||||
<antcall target="-maybe-call-dep">
|
||||
<param name="call.built.properties" value="${built-jar.properties}"/>
|
||||
<param location="${project.EssentialsProtect}" name="call.subproject"/>
|
||||
@@ -1484,6 +1491,13 @@ is divided into following sections:
|
||||
<param name="call.target" value="clean"/>
|
||||
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
|
||||
</antcall>
|
||||
<antcall target="-maybe-call-dep">
|
||||
<param name="call.built.properties" value="${built-clean.properties}"/>
|
||||
<param location="${project.EssentialsAntiBuild}" name="call.subproject"/>
|
||||
<param location="${project.EssentialsAntiBuild}/build.xml" name="call.script"/>
|
||||
<param name="call.target" value="clean"/>
|
||||
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
|
||||
</antcall>
|
||||
<antcall target="-maybe-call-dep">
|
||||
<param name="call.built.properties" value="${built-clean.properties}"/>
|
||||
<param location="${project.EssentialsProtect}" name="call.subproject"/>
|
||||
|
@@ -1,8 +1,8 @@
|
||||
build.xml.data.CRC32=51b33957
|
||||
build.xml.data.CRC32=b4df970c
|
||||
build.xml.script.CRC32=7a797370
|
||||
build.xml.stylesheet.CRC32=28e38971@1.44.1.45
|
||||
build.xml.stylesheet.CRC32=28e38971@1.50.3.46
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=51b33957
|
||||
nbproject/build-impl.xml.script.CRC32=2a17f1e9
|
||||
nbproject/build-impl.xml.data.CRC32=b4df970c
|
||||
nbproject/build-impl.xml.script.CRC32=8905537e
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46
|
||||
|
@@ -66,6 +66,7 @@ jar.compress=true
|
||||
javac.classpath=\
|
||||
${reference.Essentials.jar}:\
|
||||
${reference.EssentialsChat.jar}:\
|
||||
${reference.EssentialsAntiBuild.jar}:\
|
||||
${reference.EssentialsProtect.jar}:\
|
||||
${reference.EssentialsSpawn.jar}:\
|
||||
${reference.EssentialsGeoIP.jar}:\
|
||||
@@ -103,6 +104,7 @@ project.EssentialsChat=../EssentialsChat
|
||||
project.EssentialsGeoIP=../EssentialsGeoIP
|
||||
project.EssentialsGroupBridge=../EssentialsGroupBridge
|
||||
project.EssentialsGroupManager=../EssentialsGroupManager
|
||||
project.EssentialsAntiBuild=../EssentialsAntiBuild
|
||||
project.EssentialsProtect=../EssentialsProtect
|
||||
project.EssentialsSpawn=../EssentialsSpawn
|
||||
project.EssentialsXMPP=../EssentialsXMPP
|
||||
@@ -111,6 +113,7 @@ reference.EssentialsChat.jar=${project.EssentialsChat}/dist/EssentialsChat.jar
|
||||
reference.EssentialsGeoIP.jar=${project.EssentialsGeoIP}/dist/EssentialsGeoIP.jar
|
||||
reference.EssentialsGroupBridge.jar=${project.EssentialsGroupBridge}/dist/EssentialsGroupBridge.jar
|
||||
reference.EssentialsGroupManager.jar=${project.EssentialsGroupManager}/dist/EssentialsGroupManager.jar
|
||||
reference.EssentialsAntiBuild.jar=${project.EssentialsAntiBuild}/dist/EssentialsAntiBuild.jar
|
||||
reference.EssentialsProtect.jar=${project.EssentialsProtect}/dist/EssentialsProtect.jar
|
||||
reference.EssentialsSpawn.jar=${project.EssentialsSpawn}/dist/EssentialsSpawn.jar
|
||||
reference.EssentialsXMPP.jar=${project.EssentialsXMPP}/dist/EssentialsXMPP.jar
|
||||
|
@@ -55,6 +55,14 @@
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
<reference>
|
||||
<foreign-project>EssentialsAntiBuild</foreign-project>
|
||||
<artifact-type>jar</artifact-type>
|
||||
<script>build.xml</script>
|
||||
<target>jar</target>
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
<reference>
|
||||
<foreign-project>EssentialsProtect</foreign-project>
|
||||
<artifact-type>jar</artifact-type>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
annotation.processing.enabled=true
|
||||
annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.enabled.in.editor=true
|
||||
annotation.processing.processors.list=lombok.core.AnnotationProcessor
|
||||
annotation.processing.run.all.processors=false
|
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||
@@ -68,7 +68,6 @@ file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar
|
||||
file.reference.bPermissions.jar=../lib/bPermissions.jar
|
||||
file.reference.bpermissions2.jar=../lib/bpermissions2.jar
|
||||
file.reference.bukkit.jar=../lib/bukkit.jar
|
||||
file.reference.craftbukkit.jar=../lib/craftbukkit.jar
|
||||
file.reference.iCo4.jar=../lib/iCo4.jar
|
||||
file.reference.iCo5.jar=../lib/iCo5.jar
|
||||
file.reference.iCo6.jar=../lib/iCo6.jar
|
||||
@@ -79,6 +78,7 @@ file.reference.PermissionsBukkit-1.2.jar=../lib/PermissionsBukkit-1.2.jar
|
||||
file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar
|
||||
file.reference.Privileges.jar=..\\lib\\Privileges.jar
|
||||
file.reference.Vault.jar=../lib/Vault.jar
|
||||
file.reference.SimplyPerms.jar=../lib/SimplyPerms.jar
|
||||
includes=**
|
||||
jar.archive.disabled=${jnlp.enabled}
|
||||
jar.compress=true
|
||||
@@ -96,12 +96,12 @@ javac.classpath=\
|
||||
${file.reference.lombok.jar}:\
|
||||
${reference.EssentialsGroupManager.jar}:\
|
||||
${file.reference.bukkit.jar}:\
|
||||
${file.reference.craftbukkit.jar}:\
|
||||
${file.reference.Vault.jar}:\
|
||||
${file.reference.Privileges.jar}:\
|
||||
${file.reference.bpermissions2.jar}
|
||||
${file.reference.bpermissions2.jar}:\
|
||||
${file.reference.SimplyPerms.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.compilerargs=-Xlint:unchecked
|
||||
javac.deprecation=false
|
||||
javac.processorpath=\
|
||||
${javac.classpath}
|
||||
|
18
Essentials/src/book.txt
Normal file
18
Essentials/src/book.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
This is the book file.
|
||||
|
||||
This file format works similar to the info.txt, motd.txt and rules.txt
|
||||
|
||||
Place content in here that you would like to be used by books ingame.
|
||||
|
||||
You can use this content by using the book:<section> meta option in kits or item spawning.
|
||||
|
||||
#Colors
|
||||
Minecraft colors:
|
||||
&0 &&0 &1 &&1 &2 &&2 &3 &&3
|
||||
&4 &&4 &5 &&5 &6 &&6 &7 &&7
|
||||
&8 &&8 &9 &&9 &a &&a &b &&b
|
||||
&c &&c &d &&d &e &&e &f &&f
|
||||
&0
|
||||
&&k &kMagic&r &&l &lBold
|
||||
&&m &mStrike&r &&n &nUline
|
||||
&&o &oItalic&r &&r &rReset
|
@@ -121,13 +121,14 @@ public class AlternativeCommandsHandler
|
||||
return commands.get(0);
|
||||
}
|
||||
|
||||
public void executed(final String label, final String otherLabel)
|
||||
public void executed(final String label, final PluginCommand pc)
|
||||
{
|
||||
final String altString = pc.getPlugin().getName() + ":" + pc.getLabel();
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials: Alternative command " + label + " found, using " + otherLabel);
|
||||
LOGGER.log(Level.INFO, "Essentials: Alternative command " + label + " found, using " + altString);
|
||||
}
|
||||
disabledList.put(label, otherLabel);
|
||||
disabledList.put(label, altString);
|
||||
}
|
||||
|
||||
public Map<String, String> disabledCommands()
|
||||
|
@@ -72,7 +72,7 @@ public class Backup implements Runnable
|
||||
server.dispatchCommand(cs, "save-all");
|
||||
server.dispatchCommand(cs, "save-off");
|
||||
|
||||
ess.scheduleAsyncDelayedTask(
|
||||
ess.runTaskAsynchronously(
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
|
@@ -269,11 +269,11 @@ public final class DescParseTickFormat
|
||||
|
||||
// How many ingame days have passed since the server start?
|
||||
final long days = ticks / ticksPerDay;
|
||||
ticks = ticks - days * ticksPerDay;
|
||||
ticks -= days * ticksPerDay;
|
||||
|
||||
// How many hours on the last day?
|
||||
final long hours = ticks / ticksPerHour;
|
||||
ticks = ticks - hours * ticksPerHour;
|
||||
ticks -= hours * ticksPerHour;
|
||||
|
||||
// How many minutes on the last day?
|
||||
final long minutes = (long)Math.floor(ticks / ticksPerMinute);
|
||||
|
@@ -5,114 +5,144 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
|
||||
public class Enchantments
|
||||
{
|
||||
private static final transient Pattern NUMPATTERN = Pattern.compile("\\d+");
|
||||
private static final Map<String, Enchantment> ENCHANTMENTS = new HashMap<String, Enchantment>();
|
||||
private static final Map<String, Enchantment> ALIASENCHANTMENTS = new HashMap<String, Enchantment>();
|
||||
|
||||
static
|
||||
{
|
||||
ENCHANTMENTS.put("alldamage", Enchantment.DAMAGE_ALL);
|
||||
ENCHANTMENTS.put("alldmg", Enchantment.DAMAGE_ALL);
|
||||
ALIASENCHANTMENTS.put("alldmg", Enchantment.DAMAGE_ALL);
|
||||
ENCHANTMENTS.put("sharpness", Enchantment.DAMAGE_ALL);
|
||||
ENCHANTMENTS.put("sharp", Enchantment.DAMAGE_ALL);
|
||||
|
||||
ENCHANTMENTS.put("arthropodsdamage", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ALIASENCHANTMENTS.put("sharp", Enchantment.DAMAGE_ALL);
|
||||
ALIASENCHANTMENTS.put("dal", Enchantment.DAMAGE_ALL);
|
||||
|
||||
ENCHANTMENTS.put("ardmg", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ENCHANTMENTS.put("baneofarthropods", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ENCHANTMENTS.put("baneofarthropod", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ENCHANTMENTS.put("arthropod", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ALIASENCHANTMENTS.put("baneofarthropod", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ALIASENCHANTMENTS.put("arthropod", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ALIASENCHANTMENTS.put("dar", Enchantment.DAMAGE_ARTHROPODS);
|
||||
|
||||
ENCHANTMENTS.put("undeaddamage", Enchantment.DAMAGE_UNDEAD);
|
||||
ENCHANTMENTS.put("smite", Enchantment.DAMAGE_UNDEAD);
|
||||
ALIASENCHANTMENTS.put("du", Enchantment.DAMAGE_UNDEAD);
|
||||
|
||||
ENCHANTMENTS.put("digspeed", Enchantment.DIG_SPEED);
|
||||
ENCHANTMENTS.put("efficiency", Enchantment.DIG_SPEED);
|
||||
ENCHANTMENTS.put("minespeed", Enchantment.DIG_SPEED);
|
||||
ENCHANTMENTS.put("cutspeed", Enchantment.DIG_SPEED);
|
||||
ALIASENCHANTMENTS.put("minespeed", Enchantment.DIG_SPEED);
|
||||
ALIASENCHANTMENTS.put("cutspeed", Enchantment.DIG_SPEED);
|
||||
ALIASENCHANTMENTS.put("ds", Enchantment.DIG_SPEED);
|
||||
ALIASENCHANTMENTS.put("eff", Enchantment.DIG_SPEED);
|
||||
|
||||
ENCHANTMENTS.put("durability", Enchantment.DURABILITY);
|
||||
ENCHANTMENTS.put("dura", Enchantment.DURABILITY);
|
||||
ALIASENCHANTMENTS.put("dura", Enchantment.DURABILITY);
|
||||
ENCHANTMENTS.put("unbreaking", Enchantment.DURABILITY);
|
||||
ALIASENCHANTMENTS.put("d", Enchantment.DURABILITY);
|
||||
|
||||
ENCHANTMENTS.put("thorns", Enchantment.THORNS);
|
||||
ENCHANTMENTS.put("highcrit", Enchantment.THORNS);
|
||||
ALIASENCHANTMENTS.put("thorn", Enchantment.THORNS);
|
||||
ALIASENCHANTMENTS.put("highercrit", Enchantment.THORNS);
|
||||
ALIASENCHANTMENTS.put("t", Enchantment.THORNS);
|
||||
|
||||
ENCHANTMENTS.put("fireaspect", Enchantment.FIRE_ASPECT);
|
||||
ENCHANTMENTS.put("fire", Enchantment.FIRE_ASPECT);
|
||||
ENCHANTMENTS.put("meleefire", Enchantment.FIRE_ASPECT);
|
||||
ENCHANTMENTS.put("meleeflame", Enchantment.FIRE_ASPECT);
|
||||
ALIASENCHANTMENTS.put("meleefire", Enchantment.FIRE_ASPECT);
|
||||
ALIASENCHANTMENTS.put("meleeflame", Enchantment.FIRE_ASPECT);
|
||||
ALIASENCHANTMENTS.put("fa", Enchantment.FIRE_ASPECT);
|
||||
|
||||
ENCHANTMENTS.put("knockback", Enchantment.KNOCKBACK);
|
||||
ALIASENCHANTMENTS.put("kback", Enchantment.KNOCKBACK);
|
||||
ALIASENCHANTMENTS.put("kb", Enchantment.KNOCKBACK);
|
||||
ALIASENCHANTMENTS.put("k", Enchantment.KNOCKBACK);
|
||||
|
||||
ENCHANTMENTS.put("blockslootbonus", Enchantment.LOOT_BONUS_BLOCKS);
|
||||
ALIASENCHANTMENTS.put("blockslootbonus", Enchantment.LOOT_BONUS_BLOCKS);
|
||||
ENCHANTMENTS.put("fortune", Enchantment.LOOT_BONUS_BLOCKS);
|
||||
ALIASENCHANTMENTS.put("fort", Enchantment.LOOT_BONUS_BLOCKS);
|
||||
ALIASENCHANTMENTS.put("lbb", Enchantment.LOOT_BONUS_BLOCKS);
|
||||
|
||||
ENCHANTMENTS.put("mobslootbonus", Enchantment.LOOT_BONUS_MOBS);
|
||||
ALIASENCHANTMENTS.put("mobslootbonus", Enchantment.LOOT_BONUS_MOBS);
|
||||
ENCHANTMENTS.put("mobloot", Enchantment.LOOT_BONUS_MOBS);
|
||||
ENCHANTMENTS.put("looting", Enchantment.LOOT_BONUS_MOBS);
|
||||
ALIASENCHANTMENTS.put("lbm", Enchantment.LOOT_BONUS_MOBS);
|
||||
|
||||
ENCHANTMENTS.put("oxygen", Enchantment.OXYGEN);
|
||||
ALIASENCHANTMENTS.put("oxygen", Enchantment.OXYGEN);
|
||||
ENCHANTMENTS.put("respiration", Enchantment.OXYGEN);
|
||||
ENCHANTMENTS.put("breathing", Enchantment.OXYGEN);
|
||||
ALIASENCHANTMENTS.put("breathing", Enchantment.OXYGEN);
|
||||
ENCHANTMENTS.put("breath", Enchantment.OXYGEN);
|
||||
ALIASENCHANTMENTS.put("o", Enchantment.OXYGEN);
|
||||
|
||||
ENCHANTMENTS.put("protection", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
ENCHANTMENTS.put("prot", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
ALIASENCHANTMENTS.put("prot", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
ENCHANTMENTS.put("protect", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
ALIASENCHANTMENTS.put("p", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
|
||||
ENCHANTMENTS.put("explosionsprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ENCHANTMENTS.put("explosionprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ENCHANTMENTS.put("expprot", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ENCHANTMENTS.put("blastprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ALIASENCHANTMENTS.put("explosionsprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ALIASENCHANTMENTS.put("explosionprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ALIASENCHANTMENTS.put("expprot", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ALIASENCHANTMENTS.put("blastprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ENCHANTMENTS.put("blastprotect", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ALIASENCHANTMENTS.put("pe", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
|
||||
ENCHANTMENTS.put("fallprotection", Enchantment.PROTECTION_FALL);
|
||||
ALIASENCHANTMENTS.put("fallprotection", Enchantment.PROTECTION_FALL);
|
||||
ENCHANTMENTS.put("fallprot", Enchantment.PROTECTION_FALL);
|
||||
ENCHANTMENTS.put("featherfall", Enchantment.PROTECTION_FALL);
|
||||
ENCHANTMENTS.put("featherfalling", Enchantment.PROTECTION_FALL);
|
||||
ALIASENCHANTMENTS.put("featherfalling", Enchantment.PROTECTION_FALL);
|
||||
ALIASENCHANTMENTS.put("pfa", Enchantment.PROTECTION_FALL);
|
||||
|
||||
ENCHANTMENTS.put("fireprotection", Enchantment.PROTECTION_FIRE);
|
||||
ENCHANTMENTS.put("flameprotection", Enchantment.PROTECTION_FIRE);
|
||||
ALIASENCHANTMENTS.put("fireprotection", Enchantment.PROTECTION_FIRE);
|
||||
ALIASENCHANTMENTS.put("flameprotection", Enchantment.PROTECTION_FIRE);
|
||||
ENCHANTMENTS.put("fireprotect", Enchantment.PROTECTION_FIRE);
|
||||
ENCHANTMENTS.put("flameprotect", Enchantment.PROTECTION_FIRE);
|
||||
ALIASENCHANTMENTS.put("flameprotect", Enchantment.PROTECTION_FIRE);
|
||||
ENCHANTMENTS.put("fireprot", Enchantment.PROTECTION_FIRE);
|
||||
ENCHANTMENTS.put("flameprot", Enchantment.PROTECTION_FIRE);
|
||||
ALIASENCHANTMENTS.put("flameprot", Enchantment.PROTECTION_FIRE);
|
||||
ALIASENCHANTMENTS.put("pf", Enchantment.PROTECTION_FIRE);
|
||||
|
||||
ENCHANTMENTS.put("projectileprotection", Enchantment.PROTECTION_PROJECTILE);
|
||||
ENCHANTMENTS.put("projprot", Enchantment.PROTECTION_PROJECTILE);
|
||||
ALIASENCHANTMENTS.put("pp", Enchantment.PROTECTION_PROJECTILE);
|
||||
|
||||
ENCHANTMENTS.put("silktouch", Enchantment.SILK_TOUCH);
|
||||
ENCHANTMENTS.put("softtouch", Enchantment.SILK_TOUCH);
|
||||
ALIASENCHANTMENTS.put("softtouch", Enchantment.SILK_TOUCH);
|
||||
ALIASENCHANTMENTS.put("st", Enchantment.SILK_TOUCH);
|
||||
|
||||
ENCHANTMENTS.put("waterworker", Enchantment.WATER_WORKER);
|
||||
ENCHANTMENTS.put("aquaaffinity", Enchantment.WATER_WORKER);
|
||||
ALIASENCHANTMENTS.put("watermine", Enchantment.WATER_WORKER);
|
||||
ALIASENCHANTMENTS.put("ww", Enchantment.WATER_WORKER);
|
||||
|
||||
ENCHANTMENTS.put("firearrow", Enchantment.ARROW_FIRE);
|
||||
ALIASENCHANTMENTS.put("firearrow", Enchantment.ARROW_FIRE);
|
||||
ENCHANTMENTS.put("flame", Enchantment.ARROW_FIRE);
|
||||
ENCHANTMENTS.put("flamearrow", Enchantment.ARROW_FIRE);
|
||||
ALIASENCHANTMENTS.put("af", Enchantment.ARROW_FIRE);
|
||||
|
||||
ENCHANTMENTS.put("arrowdamage", Enchantment.ARROW_DAMAGE);
|
||||
ENCHANTMENTS.put("power", Enchantment.ARROW_DAMAGE);
|
||||
ENCHANTMENTS.put("arrowpower", Enchantment.ARROW_DAMAGE);
|
||||
ALIASENCHANTMENTS.put("arrowpower", Enchantment.ARROW_DAMAGE);
|
||||
ALIASENCHANTMENTS.put("ad", Enchantment.ARROW_DAMAGE);
|
||||
|
||||
ENCHANTMENTS.put("arrowknockback", Enchantment.ARROW_KNOCKBACK);
|
||||
ENCHANTMENTS.put("arrowkb", Enchantment.ARROW_KNOCKBACK);
|
||||
ALIASENCHANTMENTS.put("arrowkb", Enchantment.ARROW_KNOCKBACK);
|
||||
ENCHANTMENTS.put("punch", Enchantment.ARROW_KNOCKBACK);
|
||||
ENCHANTMENTS.put("arrowpunch", Enchantment.ARROW_KNOCKBACK);
|
||||
ALIASENCHANTMENTS.put("arrowpunch", Enchantment.ARROW_KNOCKBACK);
|
||||
ALIASENCHANTMENTS.put("ak", Enchantment.ARROW_KNOCKBACK);
|
||||
|
||||
ENCHANTMENTS.put("infinitearrows", Enchantment.ARROW_INFINITE);
|
||||
ALIASENCHANTMENTS.put("infinitearrows", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("infarrows", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("infinity", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("infinite", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("unlimited", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("unlimitedarrows", Enchantment.ARROW_INFINITE);
|
||||
ALIASENCHANTMENTS.put("infinite", Enchantment.ARROW_INFINITE);
|
||||
ALIASENCHANTMENTS.put("unlimited", Enchantment.ARROW_INFINITE);
|
||||
ALIASENCHANTMENTS.put("unlimitedarrows", Enchantment.ARROW_INFINITE);
|
||||
ALIASENCHANTMENTS.put("ai", Enchantment.ARROW_INFINITE);
|
||||
}
|
||||
|
||||
public static Enchantment getByName(String name) {
|
||||
Enchantment enchantment;
|
||||
if (NUMPATTERN.matcher(name).matches()) {
|
||||
if (Util.isInt(name)) {
|
||||
enchantment = Enchantment.getById(Integer.parseInt(name));
|
||||
} else {
|
||||
enchantment = Enchantment.getByName(name.toUpperCase(Locale.ENGLISH));
|
||||
@@ -121,6 +151,10 @@ public class Enchantments
|
||||
{
|
||||
enchantment = ENCHANTMENTS.get(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
if (enchantment == null)
|
||||
{
|
||||
enchantment = ALIASENCHANTMENTS.get(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
return enchantment;
|
||||
}
|
||||
|
||||
|
@@ -20,7 +20,6 @@ package com.earth2me.essentials;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.Economy;
|
||||
import com.earth2me.essentials.api.IJails;
|
||||
import com.earth2me.essentials.commands.EssentialsCommand;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.commands.NoChargeException;
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
@@ -36,7 +35,6 @@ import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -49,9 +47,12 @@ import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.SimpleCommandMap;
|
||||
import org.bukkit.command.defaults.VanillaCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
@@ -62,12 +63,13 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.yaml.snakeyaml.error.YAMLException;
|
||||
|
||||
|
||||
public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
public static final int BUKKIT_VERSION = 2317;
|
||||
public static final int BUKKIT_VERSION = 2624;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient ISettings settings;
|
||||
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);
|
||||
@@ -86,6 +88,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
private transient Metrics metrics;
|
||||
private transient EssentialsTimer timer;
|
||||
private transient List<String> vanishedPlayers = new ArrayList<String>();
|
||||
private transient SimpleCommandMap scm;
|
||||
|
||||
@Override
|
||||
public ISettings getSettings()
|
||||
@@ -124,6 +127,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
i18n = new I18n(this);
|
||||
i18n.onEnable();
|
||||
execTimer.mark("I18n1");
|
||||
scm = new SimpleCommandMap(this.getServer());
|
||||
final PluginManager pm = getServer().getPluginManager();
|
||||
for (Plugin plugin : pm.getPlugins())
|
||||
{
|
||||
@@ -178,6 +182,8 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
itemDb = new ItemDb(this);
|
||||
confList.add(itemDb);
|
||||
execTimer.mark("Init(Worth/ItemDB)");
|
||||
jails = new Jails(this);
|
||||
confList.add(jails);
|
||||
reload();
|
||||
}
|
||||
catch (YAMLException exception)
|
||||
@@ -209,6 +215,40 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
backup = new Backup(this);
|
||||
permissionsHandler = new PermissionsHandler(this, settings.useBukkitPermissions());
|
||||
alternativeCommandsHandler = new AlternativeCommandsHandler(this);
|
||||
|
||||
timer = new EssentialsTimer(this);
|
||||
getScheduler().scheduleSyncRepeatingTask(this, timer, 100, 100);
|
||||
|
||||
Economy.setEss(this);
|
||||
execTimer.mark("RegHandler");
|
||||
|
||||
final MetricsStarter metricsStarter = new MetricsStarter(this);
|
||||
if (metricsStarter.getStart() != null && metricsStarter.getStart() == true)
|
||||
{
|
||||
getScheduler().runTaskLaterAsynchronously(this, metricsStarter, 1);
|
||||
}
|
||||
else if (metricsStarter.getStart() != null && metricsStarter.getStart() == false)
|
||||
{
|
||||
final MetricsListener metricsListener = new MetricsListener(this, metricsStarter);
|
||||
pm.registerEvents(metricsListener, this);
|
||||
}
|
||||
|
||||
final String timeroutput = execTimer.end();
|
||||
if (getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials load " + timeroutput);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerListeners(PluginManager pm)
|
||||
{
|
||||
HandlerList.unregisterAll(this);
|
||||
|
||||
if (getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Registering Listeners");
|
||||
}
|
||||
|
||||
final EssentialsPluginListener serverListener = new EssentialsPluginListener(this);
|
||||
pm.registerEvents(serverListener, this);
|
||||
confList.add(serverListener);
|
||||
@@ -234,34 +274,9 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
final EssentialsWorldListener worldListener = new EssentialsWorldListener(this);
|
||||
pm.registerEvents(worldListener, this);
|
||||
|
||||
//TODO: Check if this should be here, and not above before reload()
|
||||
jails = new Jails(this);
|
||||
confList.add(jails);
|
||||
|
||||
pm.registerEvents(tntListener, this);
|
||||
|
||||
timer = new EssentialsTimer(this);
|
||||
getScheduler().scheduleSyncRepeatingTask(this, timer, 100, 100);
|
||||
|
||||
Economy.setEss(this);
|
||||
execTimer.mark("RegListeners");
|
||||
|
||||
final MetricsStarter metricsStarter = new MetricsStarter(this);
|
||||
if (metricsStarter.getStart() != null && metricsStarter.getStart() == true)
|
||||
{
|
||||
getScheduler().scheduleAsyncDelayedTask(this, metricsStarter, 1);
|
||||
}
|
||||
else if (metricsStarter.getStart() != null && metricsStarter.getStart() == false)
|
||||
{
|
||||
final MetricsListener metricsListener = new MetricsListener(this, metricsStarter);
|
||||
pm.registerEvents(metricsListener, this);
|
||||
}
|
||||
|
||||
final String timeroutput = execTimer.end();
|
||||
if (getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials load " + timeroutput);
|
||||
}
|
||||
jails.resetListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -293,6 +308,9 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
|
||||
i18n.updateLocale(settings.getLocale());
|
||||
|
||||
final PluginManager pm = getServer().getPluginManager();
|
||||
registerListeners(pm);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -310,7 +328,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
final PluginCommand pc = alternativeCommandsHandler.getAlternative(commandLabel);
|
||||
if (pc != null)
|
||||
{
|
||||
alternativeCommandsHandler.executed(commandLabel, pc.getLabel());
|
||||
alternativeCommandsHandler.executed(commandLabel, pc);
|
||||
try
|
||||
{
|
||||
return pc.execute(sender, commandLabel, args);
|
||||
@@ -330,7 +348,6 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
user = getUser(sender);
|
||||
LOGGER.log(Level.INFO, String.format("[PLAYER_COMMAND] %s: /%s %s ", ((Player)sender).getName(), commandLabel, EssentialsCommand.getFinalArg(args, 0)));
|
||||
}
|
||||
|
||||
// New mail notification
|
||||
@@ -346,6 +363,16 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
// Check for disabled commands
|
||||
if (getSettings().isCommandDisabled(commandLabel))
|
||||
{
|
||||
if (scm != null)
|
||||
{
|
||||
for (VanillaCommand cmd : scm.getFallbackCommands())
|
||||
{
|
||||
if (cmd.matches(commandLabel))
|
||||
{
|
||||
cmd.execute(sender, commandLabel, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -371,6 +398,19 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
return true;
|
||||
}
|
||||
|
||||
if (user != null && user.isJailed() && !user.isAuthorized(cmd, "essentials.jail.allow."))
|
||||
{
|
||||
if (user.getJailTimeout() > 0)
|
||||
{
|
||||
user.sendMessage(_("playerJailedFor", user.getName(), Util.formatDateDiff(user.getJailTimeout())));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(_("jailMessage"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Run the command
|
||||
try
|
||||
{
|
||||
@@ -470,16 +510,22 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
if (base instanceof String)
|
||||
{
|
||||
final User user = userMap.getUser((String)base);
|
||||
if (user != null && user.getBase() instanceof OfflinePlayer)
|
||||
{
|
||||
((OfflinePlayer)user.getBase()).setName((String)base);
|
||||
}
|
||||
return user;
|
||||
return getOfflineUser((String)base);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getOfflineUser(final String name)
|
||||
{
|
||||
final User user = userMap.getUser(name);
|
||||
if (user != null && user.getBase() instanceof OfflinePlayer)
|
||||
{
|
||||
((OfflinePlayer)user.getBase()).setName(name);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
private <T extends Player> User getUser(final T base)
|
||||
{
|
||||
if (base == null)
|
||||
@@ -491,12 +537,13 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
return (User)base;
|
||||
}
|
||||
|
||||
if (userMap == null) {
|
||||
|
||||
if (userMap == null)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "Essentials userMap not initialized");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
User user = userMap.getUser(base.getName());
|
||||
|
||||
if (user == null)
|
||||
@@ -510,17 +557,6 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getOfflineUser(final String name)
|
||||
{
|
||||
final User user = userMap.getUser(name);
|
||||
if (user != null && user.getBase() instanceof OfflinePlayer)
|
||||
{
|
||||
((OfflinePlayer)user.getBase()).setName(name);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld(final String name)
|
||||
{
|
||||
@@ -573,9 +609,14 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleAsyncDelayedTask(final Runnable run)
|
||||
public BukkitTask runTaskAsynchronously(final Runnable run)
|
||||
{
|
||||
return this.getScheduler().scheduleAsyncDelayedTask(this, run);
|
||||
return this.getScheduler().runTaskAsynchronously(this, run);
|
||||
}
|
||||
@Override
|
||||
public BukkitTask runTaskLaterAsynchronously(final Runnable run, final long delay)
|
||||
{
|
||||
return this.getScheduler().runTaskLaterAsynchronously(this, run, delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -644,6 +685,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
return vanishedPlayers;
|
||||
}
|
||||
|
||||
|
||||
private static class EssentialsWorldListener implements Listener, Runnable
|
||||
{
|
||||
private transient final IEssentials ess;
|
||||
|
@@ -28,8 +28,7 @@ public class EssentialsBlockListener implements Listener
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final boolean unlimitedForUser = user.hasUnlimited(is);
|
||||
if (unlimitedForUser && user.getGameMode() == GameMode.SURVIVAL)
|
||||
if (user.hasUnlimited(is) && user.getGameMode() == GameMode.SURVIVAL)
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
|
@@ -5,25 +5,20 @@ import com.google.common.io.Files;
|
||||
import java.io.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.channels.ClosedByInterruptException;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
|
||||
public class EssentialsConf extends YamlConfiguration
|
||||
@@ -96,18 +91,7 @@ public class EssentialsConf extends YamlConfiguration
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("creatingEmptyConfig", configFile.toString()));
|
||||
if (!configFile.createNewFile())
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()));
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()), ex);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,6 +221,69 @@ public class EssentialsConf extends YamlConfiguration
|
||||
this.resourceClass = resClass;
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
try
|
||||
{
|
||||
save(configFile);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveWithError() throws IOException
|
||||
{
|
||||
save(configFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void save(final File file) throws IOException
|
||||
{
|
||||
if (file == null)
|
||||
{
|
||||
throw new IllegalArgumentException("File cannot be null");
|
||||
}
|
||||
|
||||
Files.createParentDirs(file);
|
||||
|
||||
final String data = saveToString();
|
||||
|
||||
if (data.length() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!configFile.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("creatingEmptyConfig", configFile.toString()));
|
||||
if (!configFile.createNewFile())
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()));
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()), ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), UTF8);
|
||||
|
||||
try
|
||||
{
|
||||
writer.write(data);
|
||||
}
|
||||
finally
|
||||
{
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasProperty(final String path)
|
||||
{
|
||||
return isSet(path);
|
||||
@@ -321,67 +368,14 @@ public class EssentialsConf extends YamlConfiguration
|
||||
set(path, map);
|
||||
}
|
||||
|
||||
public long getLong(final String path, final long def)
|
||||
public void setProperty(String path, List object)
|
||||
{
|
||||
try
|
||||
{
|
||||
final Number num = (Number)get(path);
|
||||
return num == null ? def : num.longValue();
|
||||
}
|
||||
catch (ClassCastException ex)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
set(path, new ArrayList(object));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(final String path, final double def)
|
||||
public void setProperty(String path, Map object)
|
||||
{
|
||||
try
|
||||
{
|
||||
Number num = (Number)get(path);
|
||||
return num == null ? def : num.doubleValue();
|
||||
}
|
||||
catch (ClassCastException ex)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
try
|
||||
{
|
||||
save(configFile);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void save(final File file) throws IOException
|
||||
{
|
||||
if (file == null)
|
||||
{
|
||||
throw new IllegalArgumentException("File cannot be null");
|
||||
}
|
||||
|
||||
Files.createParentDirs(file);
|
||||
|
||||
final String data = saveToString();
|
||||
|
||||
final OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), UTF8);
|
||||
|
||||
try
|
||||
{
|
||||
writer.write(data);
|
||||
}
|
||||
finally
|
||||
{
|
||||
writer.close();
|
||||
}
|
||||
set(path, new LinkedHashMap(object));
|
||||
}
|
||||
|
||||
public Object getProperty(String path)
|
||||
@@ -398,4 +392,273 @@ public class EssentialsConf extends YamlConfiguration
|
||||
{
|
||||
set(path, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Object get(String path)
|
||||
{
|
||||
return super.get(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Object get(String path, Object def)
|
||||
{
|
||||
return super.get(path, def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean getBoolean(String path)
|
||||
{
|
||||
return super.getBoolean(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean getBoolean(String path, boolean def)
|
||||
{
|
||||
return super.getBoolean(path, def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<Boolean> getBooleanList(String path)
|
||||
{
|
||||
return super.getBooleanList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<Byte> getByteList(String path)
|
||||
{
|
||||
return super.getByteList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<Character> getCharacterList(String path)
|
||||
{
|
||||
return super.getCharacterList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ConfigurationSection getConfigurationSection(String path)
|
||||
{
|
||||
return super.getConfigurationSection(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized double getDouble(String path)
|
||||
{
|
||||
return super.getDouble(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized double getDouble(final String path, final double def)
|
||||
{
|
||||
return super.getDouble(path, def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<Double> getDoubleList(String path)
|
||||
{
|
||||
return super.getDoubleList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<Float> getFloatList(String path)
|
||||
{
|
||||
return super.getFloatList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized int getInt(String path)
|
||||
{
|
||||
return super.getInt(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized int getInt(String path, int def)
|
||||
{
|
||||
return super.getInt(path, def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<Integer> getIntegerList(String path)
|
||||
{
|
||||
return super.getIntegerList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ItemStack getItemStack(String path, ItemStack def)
|
||||
{
|
||||
return super.getItemStack(path, def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Set<String> getKeys(boolean deep)
|
||||
{
|
||||
return super.getKeys(deep);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<?> getList(String path)
|
||||
{
|
||||
return super.getList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<?> getList(String path, List<?> def)
|
||||
{
|
||||
return super.getList(path, def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized long getLong(String path)
|
||||
{
|
||||
return super.getLong(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized long getLong(final String path, final long def)
|
||||
{
|
||||
return super.getLong(path, def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<Long> getLongList(String path)
|
||||
{
|
||||
return super.getLongList(path);
|
||||
}
|
||||
|
||||
public synchronized Map<String, Object> getMap()
|
||||
{
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<Map<?, ?>> getMapList(String path)
|
||||
{
|
||||
return super.getMapList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized OfflinePlayer getOfflinePlayer(String path)
|
||||
{
|
||||
return super.getOfflinePlayer(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized OfflinePlayer getOfflinePlayer(String path, OfflinePlayer def)
|
||||
{
|
||||
return super.getOfflinePlayer(path, def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<Short> getShortList(String path)
|
||||
{
|
||||
return super.getShortList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized String getString(String path)
|
||||
{
|
||||
return super.getString(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized String getString(String path, String def)
|
||||
{
|
||||
return super.getString(path, def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<String> getStringList(String path)
|
||||
{
|
||||
return super.getStringList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Map<String, Object> getValues(boolean deep)
|
||||
{
|
||||
return super.getValues(deep);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Vector getVector(String path)
|
||||
{
|
||||
return super.getVector(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Vector getVector(String path, Vector def)
|
||||
{
|
||||
return super.getVector(path, def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isBoolean(String path)
|
||||
{
|
||||
return super.isBoolean(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isConfigurationSection(String path)
|
||||
{
|
||||
return super.isConfigurationSection(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isDouble(String path)
|
||||
{
|
||||
return super.isDouble(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isInt(String path)
|
||||
{
|
||||
return super.isInt(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isItemStack(String path)
|
||||
{
|
||||
return super.isItemStack(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isList(String path)
|
||||
{
|
||||
return super.isList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isLong(String path)
|
||||
{
|
||||
return super.isLong(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isOfflinePlayer(String path)
|
||||
{
|
||||
return super.isOfflinePlayer(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isSet(String path)
|
||||
{
|
||||
return super.isSet(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isString(String path)
|
||||
{
|
||||
return super.isString(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isVector(String path)
|
||||
{
|
||||
return super.isVector(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void set(String path, Object value)
|
||||
{
|
||||
super.set(path, value);
|
||||
}
|
||||
}
|
||||
|
@@ -2,10 +2,10 @@ package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -16,6 +16,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class EssentialsEntityListener implements Listener
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final IEssentials ess;
|
||||
|
||||
public EssentialsEntityListener(IEssentials ess)
|
||||
@@ -23,62 +24,95 @@ public class EssentialsEntityListener implements Listener
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
// This method does something undocumented reguarding certain bucket types #EasterEgg
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onEntityDamage(final EntityDamageByEntityEvent event)
|
||||
{
|
||||
final Entity eAttack = event.getDamager();
|
||||
final Entity eDefend = event.getEntity();
|
||||
if (eDefend instanceof Player && eAttack instanceof Player)
|
||||
if (eAttack instanceof Player)
|
||||
{
|
||||
final User defender = ess.getUser(eDefend);
|
||||
final User attacker = ess.getUser(eAttack);
|
||||
|
||||
if (ess.getSettings().getLoginAttackDelay() > 0 && !attacker.isAuthorized("essentials.pvpdelay.exempt")
|
||||
&& (System.currentTimeMillis() < (attacker.getLastLogin() + ess.getSettings().getLoginAttackDelay())))
|
||||
if (eDefend instanceof Player)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
onPlayerVsPlayerDamage(event, (Player)eDefend, attacker);
|
||||
}
|
||||
|
||||
if (attacker.hasInvulnerabilityAfterTeleport() || defender.hasInvulnerabilityAfterTeleport())
|
||||
else if (eDefend instanceof Ageable)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
attacker.updateActivity(true);
|
||||
final List<String> commandList = attacker.getPowertool(attacker.getItemInHand());
|
||||
if (commandList != null && !commandList.isEmpty())
|
||||
{
|
||||
for (final String command : commandList)
|
||||
final ItemStack hand = attacker.getItemInHand();
|
||||
if (hand != null && hand.getType() == Material.MILK_BUCKET)
|
||||
{
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
attacker.getServer().dispatchCommand(attacker.getBase(), command.replaceAll("\\{player\\}", defender.getName()));
|
||||
}
|
||||
});
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
((Ageable)eDefend).setBaby();
|
||||
hand.setType(Material.BUCKET);
|
||||
attacker.setItemInHand(hand);
|
||||
attacker.updateInventory();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
attacker.updateActivity(true);
|
||||
}
|
||||
else if (eDefend instanceof Ageable && eAttack instanceof Player)
|
||||
else if (eAttack instanceof Projectile && eDefend instanceof Player)
|
||||
{
|
||||
final Player player = (Player)eAttack;
|
||||
final ItemStack hand = player.getItemInHand();
|
||||
if (hand != null && hand.getType() == Material.MILK_BUCKET)
|
||||
Entity shooter = ((Projectile)event.getDamager()).getShooter();
|
||||
if (shooter instanceof Player)
|
||||
{
|
||||
((Ageable)eDefend).setBaby();
|
||||
hand.setType(Material.BUCKET);
|
||||
player.setItemInHand(hand);
|
||||
player.updateInventory();
|
||||
event.setCancelled(true);
|
||||
final User attacker = ess.getUser(shooter);
|
||||
onPlayerVsPlayerDamage(event, (Player)eDefend, attacker);
|
||||
attacker.updateActivity(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onPlayerVsPlayerDamage(final EntityDamageByEntityEvent event, final Player defender, final User attacker)
|
||||
{
|
||||
if (ess.getSettings().getLoginAttackDelay() > 0 && !attacker.isAuthorized("essentials.pvpdelay.exempt")
|
||||
&& (System.currentTimeMillis() < (attacker.getLastLogin() + ess.getSettings().getLoginAttackDelay())))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (!defender.equals(attacker.getBase()) && (attacker.hasInvulnerabilityAfterTeleport() || ess.getUser(defender).hasInvulnerabilityAfterTeleport()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (attacker.isGodModeEnabled() && !attacker.isAuthorized("essentials.god.pvp"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (attacker.isHidden() && !attacker.isAuthorized("essentials.vanish.pvp"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
onPlayerVsPlayerPowertool(event, defender, attacker);
|
||||
}
|
||||
|
||||
private void onPlayerVsPlayerPowertool(final EntityDamageByEntityEvent event, final Player defender, final User attacker)
|
||||
{
|
||||
final List<String> commandList = attacker.getPowertool(attacker.getItemInHand());
|
||||
if (commandList != null && !commandList.isEmpty())
|
||||
{
|
||||
for (final String tempCommand : commandList)
|
||||
{
|
||||
final String command = tempCommand.replaceAll("\\{player\\}", defender.getName());
|
||||
if (command != null && !command.isEmpty() && !command.equals(tempCommand))
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
attacker.getServer().dispatchCommand(attacker.getBase(), command);
|
||||
LOGGER.log(Level.INFO, String.format("[PT] %s issued server command: /%s", attacker.getName(), command));
|
||||
}
|
||||
});
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,6 +169,9 @@ public class EssentialsEntityListener implements Listener
|
||||
{
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
final Player player = (Player)event.getEntity();
|
||||
player.setFoodLevel(20);
|
||||
player.setSaturation(10);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -148,4 +185,16 @@ public class EssentialsEntityListener implements Listener
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPotionSplashEvent(final PotionSplashEvent event)
|
||||
{
|
||||
for (LivingEntity entity : event.getAffectedEntities())
|
||||
{
|
||||
if (entity instanceof Player && ess.getUser(entity).isGodModeEnabled())
|
||||
{
|
||||
event.setIntensity(entity, 0d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -6,14 +6,15 @@ import com.earth2me.essentials.textreader.KeywordReplacer;
|
||||
import com.earth2me.essentials.textreader.TextInput;
|
||||
import com.earth2me.essentials.textreader.TextPager;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -22,9 +23,10 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -75,10 +77,20 @@ public class EssentialsPlayerListener implements Listener
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerMove(final PlayerMoveEvent event)
|
||||
{
|
||||
if ((!ess.getSettings().cancelAfkOnMove() && !ess.getSettings().getFreezeAfkPlayers())
|
||||
|| event.getFrom().getBlockX() == event.getTo().getBlockX()
|
||||
&& event.getFrom().getBlockZ() == event.getTo().getBlockZ()
|
||||
&& event.getFrom().getBlockY() == event.getTo().getBlockY())
|
||||
if (!ess.getSettings().cancelAfkOnMove() && !ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
event.getHandlers().unregister(this);
|
||||
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Unregistering move listener");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
if (event.getFrom().getBlockX() == event.getTo().getBlockX()
|
||||
&& event.getFrom().getBlockZ() == event.getTo().getBlockZ()
|
||||
&& event.getFrom().getBlockY() == event.getTo().getBlockY())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -87,7 +99,13 @@ public class EssentialsPlayerListener implements Listener
|
||||
if (user.isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
final Location from = event.getFrom();
|
||||
final Location to = event.getTo().clone();
|
||||
final Location origTo = event.getTo();
|
||||
final Location to = origTo.clone();
|
||||
if (ess.getSettings().cancelAfkOnMove() && origTo.getY() >= from.getBlockY() + 1)
|
||||
{
|
||||
user.updateActivity(true);
|
||||
return;
|
||||
}
|
||||
to.setX(from.getX());
|
||||
to.setY(from.getY());
|
||||
to.setZ(from.getZ());
|
||||
@@ -120,7 +138,11 @@ public class EssentialsPlayerListener implements Listener
|
||||
{
|
||||
user.toggleVanished();
|
||||
}
|
||||
user.setLastLocation();
|
||||
user.setLogoutLocation();
|
||||
if (user.isRecipeSee())
|
||||
{
|
||||
user.getPlayer().getOpenInventory().getTopInventory().clear();
|
||||
}
|
||||
user.updateActivity(false);
|
||||
user.dispose();
|
||||
}
|
||||
@@ -128,7 +150,7 @@ public class EssentialsPlayerListener implements Listener
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
ess.scheduleAsyncDelayedTask(new Runnable()
|
||||
ess.runTaskAsynchronously(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
@@ -146,60 +168,96 @@ public class EssentialsPlayerListener implements Listener
|
||||
}
|
||||
ess.getBackup().onPlayerJoin();
|
||||
final User user = ess.getUser(player);
|
||||
user.setDisplayNick();
|
||||
updateCompass(user);
|
||||
user.setLastLogin(System.currentTimeMillis());
|
||||
user.updateActivity(false);
|
||||
|
||||
for (String p : ess.getVanishedPlayers())
|
||||
ess.scheduleSyncDelayedTask(new Runnable()
|
||||
{
|
||||
if (!user.isAuthorized("essentials.vanish.see"))
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
user.hidePlayer(ess.getUser(p).getBase());
|
||||
}
|
||||
}
|
||||
user.setDisplayNick();
|
||||
updateCompass(user);
|
||||
|
||||
if (user.isAuthorized("essentials.sleepingignored"))
|
||||
{
|
||||
user.setSleepingIgnored(true);
|
||||
}
|
||||
|
||||
if (!ess.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final IText input = new TextInput(user, "motd", true, ess);
|
||||
final IText output = new KeywordReplacer(input, user, ess);
|
||||
final TextPager pager = new TextPager(output, true);
|
||||
pager.showPage("1", null, "motd", user);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
if (!ess.getVanishedPlayers().isEmpty() && !user.isAuthorized("essentials.vanish.see"))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, ex.getMessage(), ex);
|
||||
for (String p : ess.getVanishedPlayers())
|
||||
{
|
||||
Player toVanish = ess.getServer().getPlayerExact(p);
|
||||
if (toVanish != null && toVanish.isOnline())
|
||||
{
|
||||
user.hidePlayer(toVanish);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (user.isAuthorized("essentials.sleepingignored"))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, ex.getMessage());
|
||||
user.setSleepingIgnored(true);
|
||||
}
|
||||
|
||||
if (!ess.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final IText input = new TextInput(user, "motd", true, ess);
|
||||
final IText output = new KeywordReplacer(input, user, ess);
|
||||
final TextPager pager = new TextPager(output, true);
|
||||
pager.showPage("1", null, "motd", user);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.log(Level.WARNING, ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!ess.getSettings().isCommandDisabled("mail") && user.isAuthorized("essentials.mail"))
|
||||
{
|
||||
final List<String> mail = user.getMails();
|
||||
if (mail.isEmpty())
|
||||
{
|
||||
final String msg = _("noNewMail");
|
||||
if (!msg.isEmpty())
|
||||
{
|
||||
user.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(_("youHaveNewMail", mail.size()));
|
||||
}
|
||||
}
|
||||
|
||||
if (user.isAuthorized("essentials.fly.safelogin"))
|
||||
{
|
||||
final World world = user.getLocation().getWorld();
|
||||
final int x = user.getLocation().getBlockX();
|
||||
int y = user.getLocation().getBlockY();
|
||||
final int z = user.getLocation().getBlockZ();
|
||||
while (Util.isBlockUnsafe(world, x, y, z) && y > -1)
|
||||
{
|
||||
y--;
|
||||
}
|
||||
|
||||
if (user.getLocation().getBlockY() - y > 1 || y < 0)
|
||||
{
|
||||
user.setAllowFlight(true);
|
||||
user.setFlying(true);
|
||||
user.sendMessage(_("flyMode", _("enabled"), user.getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!ess.getSettings().isCommandDisabled("mail") && user.isAuthorized("essentials.mail"))
|
||||
{
|
||||
final List<String> mail = user.getMails();
|
||||
if (mail.isEmpty())
|
||||
{
|
||||
user.sendMessage(_("noNewMail"));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(_("youHaveNewMail", mail.size()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Makes the compass item ingame always point to the first essentials home. #EasterEgg
|
||||
private void updateCompass(final User user)
|
||||
{
|
||||
Location loc = user.getHome(user.getLocation());
|
||||
@@ -210,14 +268,7 @@ public class EssentialsPlayerListener implements Listener
|
||||
if (loc != null)
|
||||
{
|
||||
final Location updateLoc = loc;
|
||||
ess.scheduleSyncDelayedTask(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
user.setCompassTarget(updateLoc);
|
||||
}
|
||||
});
|
||||
user.setCompassTarget(updateLoc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,8 +298,17 @@ public class EssentialsPlayerListener implements Listener
|
||||
|
||||
if (!banExpired && (user.isBanned() || event.getResult() == Result.KICK_BANNED))
|
||||
{
|
||||
final String banReason = user.getBanReason();
|
||||
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : _("defaultBanReason"));
|
||||
String banReason = user.getBanReason();
|
||||
if (banReason == null || banReason.isEmpty() || banReason.equalsIgnoreCase("ban"))
|
||||
{
|
||||
banReason = _("defaultBanReason");
|
||||
}
|
||||
if (user.getBanTimeout() > 0)
|
||||
{
|
||||
//TODO: TL This
|
||||
banReason += "\n\n" + "Expires in " + Util.formatDateDiff(user.getBanTimeout());
|
||||
}
|
||||
event.disallow(Result.KICK_BANNED, banReason);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -309,14 +369,13 @@ public class EssentialsPlayerListener implements Listener
|
||||
});
|
||||
}
|
||||
}
|
||||
private final static List<String> COMMANDS = Arrays.asList("msg", "r", "mail", "m", "t", "whisper", "emsg", "tell", "er", "reply", "ereply", "email", "action", "describe", "eme", "eaction", "edescribe", "etell", "ewhisper", "pm");
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
final String cmd = event.getMessage().toLowerCase(Locale.ENGLISH).split(" ")[0].replace("/", "").toLowerCase(Locale.ENGLISH);
|
||||
if (COMMANDS.contains(cmd))
|
||||
if (ess.getSettings().getSocialSpyCommands().contains(cmd))
|
||||
{
|
||||
for (Player onlinePlayer : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
@@ -334,6 +393,18 @@ public class EssentialsPlayerListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerChangedWorldHack(final PlayerChangedWorldEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.getGameMode() != GameMode.CREATIVE && !user.isAuthorized("essentials.fly"))
|
||||
{
|
||||
user.setAllowFlight(false);
|
||||
}
|
||||
user.setFlySpeed(0.1f);
|
||||
user.setWalkSpeed(0.2f);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerChangedWorld(final PlayerChangedWorldEvent event)
|
||||
{
|
||||
@@ -346,10 +417,14 @@ public class EssentialsPlayerListener implements Listener
|
||||
user.sendMessage(_("noGodWorldWarning"));
|
||||
}
|
||||
|
||||
if (!event.getPlayer().getWorld().getName().equals(newWorld))
|
||||
if (!user.getWorld().getName().equals(newWorld))
|
||||
{
|
||||
user.sendMessage(_("currentWorld", newWorld));
|
||||
}
|
||||
if (user.isVanished())
|
||||
{
|
||||
user.setVanished(user.isAuthorized("essentials.vanish"));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@@ -360,16 +435,29 @@ public class EssentialsPlayerListener implements Listener
|
||||
case RIGHT_CLICK_BLOCK:
|
||||
if (!event.isCancelled() && event.getClickedBlock().getTypeId() == BED && ess.getSettings().getUpdateBedAtDaytime())
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
player.setBedSpawnLocation(event.getClickedBlock().getLocation());
|
||||
player.sendMessage(_("homeSet", player.getLocation().getWorld().getName(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()));
|
||||
User player = ess.getUser(event.getPlayer());
|
||||
if (player.isAuthorized("essentials.sethome.bed"))
|
||||
{
|
||||
player.setBedSpawnLocation(event.getClickedBlock().getLocation());
|
||||
player.sendMessage(_("homeSet", player.getLocation().getWorld().getName(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LEFT_CLICK_AIR:
|
||||
if (event.getPlayer().isFlying())
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isFlyClickJump())
|
||||
{
|
||||
useFlyClickJump(user);
|
||||
return;
|
||||
}
|
||||
}
|
||||
case LEFT_CLICK_BLOCK:
|
||||
if (event.getItem() != null && event.getItem().getTypeId() != AIR)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.updateActivity(true);
|
||||
if (user.hasPowerTools() && user.arePowerToolsEnabled() && usePowertools(user, event.getItem().getTypeId()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
@@ -381,6 +469,39 @@ public class EssentialsPlayerListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
// This method allows the /jump lock feature to work, allows teleporting while flying #EasterEgg
|
||||
private void useFlyClickJump(final User user)
|
||||
{
|
||||
try
|
||||
{
|
||||
final Location otarget = Util.getTarget(user);
|
||||
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Location loc = user.getLocation();
|
||||
loc.setX(otarget.getX());
|
||||
loc.setZ(otarget.getZ());
|
||||
while (Util.isBlockDamaging(loc.getWorld(), loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ()))
|
||||
{
|
||||
loc.setY(loc.getY() + 1d);
|
||||
}
|
||||
user.getBase().teleport(loc, TeleportCause.PLUGIN);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean usePowertools(final User user, final int id)
|
||||
{
|
||||
final List<String> commandList = user.getPowertool(id);
|
||||
@@ -411,6 +532,7 @@ public class EssentialsPlayerListener implements Listener
|
||||
public void run()
|
||||
{
|
||||
user.getServer().dispatchCommand(user.getBase(), command);
|
||||
LOGGER.log(Level.INFO, String.format("[PT] %s issued server command: /%s", user.getName(), command));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -430,13 +552,16 @@ public class EssentialsPlayerListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onInventoryClickEvent(final InventoryClickEvent event)
|
||||
{
|
||||
if (event.getView().getTopInventory().getType() == InventoryType.PLAYER)
|
||||
final Inventory top = event.getView().getTopInventory();
|
||||
final InventoryType type = top.getType();
|
||||
|
||||
if (type == InventoryType.PLAYER)
|
||||
{
|
||||
final User user = ess.getUser(event.getWhoClicked());
|
||||
final InventoryHolder invHolder = event.getView().getTopInventory().getHolder();
|
||||
final InventoryHolder invHolder = top.getHolder();
|
||||
if (invHolder != null && invHolder instanceof HumanEntity)
|
||||
{
|
||||
final User invOwner = ess.getUser((HumanEntity)invHolder);
|
||||
@@ -445,18 +570,76 @@ public class EssentialsPlayerListener implements Listener
|
||||
|| !invOwner.isOnline()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
user.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (type == InventoryType.ENDER_CHEST)
|
||||
{
|
||||
final User user = ess.getUser(event.getWhoClicked());
|
||||
if (user.isEnderSee() && (!user.isAuthorized("essentials.enderchest.modify")))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
else if (type == InventoryType.WORKBENCH)
|
||||
{
|
||||
User user = ess.getUser(event.getWhoClicked());
|
||||
if (user.isRecipeSee())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
else if (type == InventoryType.CHEST && top.getSize() == 9)
|
||||
{
|
||||
final User user = ess.getUser(event.getWhoClicked());
|
||||
final InventoryHolder invHolder = top.getHolder();
|
||||
if (invHolder != null && invHolder instanceof HumanEntity && user.isInvSee())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onInventoryCloseEvent(final InventoryCloseEvent event)
|
||||
{
|
||||
if (event.getView().getTopInventory().getType() == InventoryType.PLAYER)
|
||||
final Inventory top = event.getView().getTopInventory();
|
||||
final InventoryType type = top.getType();
|
||||
if (type == InventoryType.PLAYER)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.setInvSee(false);
|
||||
}
|
||||
else if (type == InventoryType.ENDER_CHEST)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.setEnderSee(false);
|
||||
}
|
||||
else if (type == InventoryType.WORKBENCH)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isRecipeSee())
|
||||
{
|
||||
user.setRecipeSee(false);
|
||||
event.getView().getTopInventory().clear();
|
||||
}
|
||||
}
|
||||
else if (type == InventoryType.CHEST && top.getSize() == 9)
|
||||
{
|
||||
final InventoryHolder invHolder = top.getHolder();
|
||||
if (invHolder != null && invHolder instanceof HumanEntity)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.setInvSee(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerFishEvent(final PlayerFishEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.updateActivity(true);
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,9 @@ public class EssentialsPluginListener implements Listener, IConf
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(final PluginEnableEvent event)
|
||||
{
|
||||
if (event.getPlugin().getName().equals("EssentialsChat")) {
|
||||
ess.getSettings().setEssentialsChatActive(true);
|
||||
}
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
ess.getAlternativeCommandsHandler().addPlugin(event.getPlugin());
|
||||
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(ess.getServer().getPluginManager()))
|
||||
@@ -31,6 +34,9 @@ public class EssentialsPluginListener implements Listener, IConf
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(final PluginDisableEvent event)
|
||||
{
|
||||
if (event.getPlugin().getName().equals("EssentialsChat")) {
|
||||
ess.getSettings().setEssentialsChatActive(false);
|
||||
}
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
ess.getAlternativeCommandsHandler().removePlugin(event.getPlugin());
|
||||
// Check to see if the plugin thats being disabled is the one we are using
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.craftbukkit.FakeWorld;
|
||||
import com.earth2me.essentials.settings.Spawns;
|
||||
import com.earth2me.essentials.storage.YamlStorageWriter;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.security.DigestInputStream;
|
||||
|
@@ -70,7 +70,8 @@ public class I18n implements II18n
|
||||
|
||||
public static String _(final String string, final Object... objects)
|
||||
{
|
||||
if (instance == null) {
|
||||
if (instance == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
if (objects.length == 0)
|
||||
@@ -85,11 +86,20 @@ public class I18n implements II18n
|
||||
|
||||
public String format(final String string, final Object... objects)
|
||||
{
|
||||
final String format = translate(string);
|
||||
String format = translate(string);
|
||||
MessageFormat messageFormat = messageFormatCache.get(format);
|
||||
if (messageFormat == null)
|
||||
{
|
||||
messageFormat = new MessageFormat(format);
|
||||
try
|
||||
{
|
||||
messageFormat = new MessageFormat(format);
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
ess.getLogger().log(Level.SEVERE, "Invalid Translation key for '" + string + "': " + e.getMessage());
|
||||
format = format.replaceAll("\\{(\\D*?)\\}", "\\[$1\\]");
|
||||
messageFormat = new MessageFormat(format);
|
||||
}
|
||||
messageFormatCache.put(format, messageFormat);
|
||||
}
|
||||
return messageFormat.format(objects);
|
||||
@@ -133,7 +143,7 @@ public class I18n implements II18n
|
||||
{
|
||||
private final transient File dataFolder;
|
||||
|
||||
public FileResClassLoader(final ClassLoader classLoader, final IEssentials ess)
|
||||
FileResClassLoader(final ClassLoader classLoader, final IEssentials ess)
|
||||
{
|
||||
super(classLoader);
|
||||
this.dataFolder = ess.getDataFolder();
|
||||
|
@@ -1,9 +1,5 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
/**
|
||||
* @deprecated New interface will be IReload in api package
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IConf {
|
||||
public void reloadConfig();
|
||||
}
|
||||
|
@@ -10,12 +10,9 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated This will be moved to the api package soon
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IEssentials extends Plugin
|
||||
{
|
||||
void addReloadListener(IConf listener);
|
||||
@@ -48,7 +45,9 @@ public interface IEssentials extends Plugin
|
||||
|
||||
Methods getPaymentMethod();
|
||||
|
||||
int scheduleAsyncDelayedTask(Runnable run);
|
||||
BukkitTask runTaskAsynchronously(Runnable run);
|
||||
|
||||
BukkitTask runTaskLaterAsynchronously(Runnable run, long delay);
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run);
|
||||
|
||||
|
@@ -42,6 +42,8 @@ public interface ISettings extends IConf
|
||||
|
||||
double getHealCooldown();
|
||||
|
||||
Set<String> getSocialSpyCommands();
|
||||
|
||||
Map<String, Object> getKit(String name);
|
||||
|
||||
ConfigurationSection getKits();
|
||||
@@ -92,10 +94,6 @@ public interface ISettings extends IConf
|
||||
|
||||
boolean isCommandOverridden(String name);
|
||||
|
||||
boolean isCommandRestricted(IEssentialsCommand cmd);
|
||||
|
||||
boolean isCommandRestricted(String label);
|
||||
|
||||
boolean isDebug();
|
||||
|
||||
boolean isEcoDisabled();
|
||||
@@ -110,8 +108,6 @@ public interface ISettings extends IConf
|
||||
|
||||
boolean showNonEssCommandsInHelp();
|
||||
|
||||
boolean spawnIfNoHome();
|
||||
|
||||
boolean warnOnBuildDisallow();
|
||||
|
||||
boolean warnOnSmite();
|
||||
@@ -147,6 +143,8 @@ public interface ISettings extends IConf
|
||||
boolean getFreezeAfkPlayers();
|
||||
|
||||
boolean cancelAfkOnMove();
|
||||
|
||||
boolean cancelAfkOnInteract();
|
||||
|
||||
boolean areDeathMessagesEnabled();
|
||||
|
||||
@@ -155,11 +153,13 @@ public interface ISettings extends IConf
|
||||
Set<String> getNoGodWorlds();
|
||||
|
||||
boolean getUpdateBedAtDaytime();
|
||||
|
||||
boolean allowUnsafeEnchantments();
|
||||
|
||||
boolean getRepairEnchanted();
|
||||
|
||||
boolean isWorldTeleportPermissions();
|
||||
|
||||
|
||||
boolean isWorldHomePermissions();
|
||||
|
||||
boolean registerBackInListener();
|
||||
@@ -177,8 +177,18 @@ public interface ISettings extends IConf
|
||||
long getTeleportInvulnerability();
|
||||
|
||||
boolean isTeleportInvulnerability();
|
||||
|
||||
|
||||
long getLoginAttackDelay();
|
||||
|
||||
|
||||
int getSignUsePerSecond();
|
||||
|
||||
double getMaxFlySpeed();
|
||||
|
||||
double getMaxWalkSpeed();
|
||||
|
||||
public int getMailsPerMinute();
|
||||
|
||||
public void setEssentialsChatActive(boolean b);
|
||||
|
||||
long getMaxTempban();
|
||||
}
|
||||
|
@@ -5,10 +5,6 @@ import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated This will be moved to the api package soon
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IUser extends Player
|
||||
{
|
||||
long getLastTeleportTimestamp();
|
||||
@@ -46,4 +42,14 @@ public interface IUser extends Player
|
||||
Teleport getTeleport();
|
||||
|
||||
void setJail(String jail);
|
||||
|
||||
boolean isIgnoreExempt();
|
||||
|
||||
boolean isAfk();
|
||||
|
||||
void setAfk(final boolean set);
|
||||
|
||||
void setLogoutLocation();
|
||||
|
||||
Location getLogoutLocation();
|
||||
}
|
||||
|
@@ -1,11 +1,9 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.IItemDb;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import com.earth2me.essentials.api.IItemDb;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -20,8 +18,10 @@ public class ItemDb implements IConf, IItemDb
|
||||
file = new ManagedFile("items.csv", ess);
|
||||
}
|
||||
private final transient Map<String, Integer> items = new HashMap<String, Integer>();
|
||||
private final transient Map<ItemData, List<String>> names = new HashMap<ItemData, List<String>>();
|
||||
private final transient Map<String, Short> durabilities = new HashMap<String, Short>();
|
||||
private final transient ManagedFile file;
|
||||
private final transient Pattern splitPattern = Pattern.compile("[:+',;.]");
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
@@ -35,6 +35,7 @@ public class ItemDb implements IConf, IItemDb
|
||||
|
||||
durabilities.clear();
|
||||
items.clear();
|
||||
names.clear();
|
||||
|
||||
for (String line : lines)
|
||||
{
|
||||
@@ -51,9 +52,25 @@ public class ItemDb implements IConf, IItemDb
|
||||
}
|
||||
|
||||
final int numeric = Integer.parseInt(parts[1]);
|
||||
final short data = parts.length > 2 && !parts[2].equals("0") ? Short.parseShort(parts[2]) : 0;
|
||||
String itemName = parts[0].toLowerCase(Locale.ENGLISH);
|
||||
|
||||
durabilities.put(parts[0].toLowerCase(Locale.ENGLISH), parts.length > 2 && !parts[2].equals("0") ? Short.parseShort(parts[2]) : 0);
|
||||
items.put(parts[0].toLowerCase(Locale.ENGLISH), numeric);
|
||||
durabilities.put(itemName, data);
|
||||
items.put(itemName, numeric);
|
||||
|
||||
ItemData itemData = new ItemData(numeric, data);
|
||||
if (names.containsKey(itemData))
|
||||
{
|
||||
List<String> nameList = names.get(itemData);
|
||||
nameList.add(itemName);
|
||||
Collections.sort(nameList, new LengthCompare());
|
||||
}
|
||||
else
|
||||
{
|
||||
List<String> nameList = new ArrayList<String>();
|
||||
nameList.add(itemName);
|
||||
names.put(itemData, nameList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,19 +86,20 @@ public class ItemDb implements IConf, IItemDb
|
||||
int itemid = 0;
|
||||
String itemname = null;
|
||||
short metaData = 0;
|
||||
String[] parts = splitPattern.split(id);;
|
||||
if (id.matches("^\\d+[:+',;.]\\d+$"))
|
||||
{
|
||||
itemid = Integer.parseInt(id.split("[:+',;.]")[0]);
|
||||
metaData = Short.parseShort(id.split("[:+',;.]")[1]);
|
||||
itemid = Integer.parseInt(parts[0]);
|
||||
metaData = Short.parseShort(parts[1]);
|
||||
}
|
||||
else if (id.matches("^\\d+$"))
|
||||
else if (Util.isInt(id))
|
||||
{
|
||||
itemid = Integer.parseInt(id);
|
||||
}
|
||||
else if (id.matches("^[^:+',;.]+[:+',;.]\\d+$"))
|
||||
{
|
||||
itemname = id.split("[:+',;.]")[0].toLowerCase(Locale.ENGLISH);
|
||||
metaData = Short.parseShort(id.split("[:+',;.]")[1]);
|
||||
itemname = parts[0].toLowerCase(Locale.ENGLISH);
|
||||
metaData = Short.parseShort(parts[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -119,4 +137,85 @@ public class ItemDb implements IConf, IItemDb
|
||||
retval.setDurability(metaData);
|
||||
return retval;
|
||||
}
|
||||
|
||||
public String names(ItemStack item)
|
||||
{
|
||||
ItemData itemData = new ItemData(item.getTypeId(), item.getDurability());
|
||||
List<String> nameList = names.get(itemData);
|
||||
if (nameList == null)
|
||||
{
|
||||
itemData = new ItemData(item.getTypeId(), (short)0);
|
||||
nameList = names.get(itemData);
|
||||
if (nameList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (nameList.size() > 15)
|
||||
{
|
||||
nameList = nameList.subList(0, 14);
|
||||
}
|
||||
return Util.joinList(", ", nameList);
|
||||
}
|
||||
|
||||
|
||||
class ItemData
|
||||
{
|
||||
final private int itemNo;
|
||||
final private short itemData;
|
||||
|
||||
ItemData(final int itemNo, final short itemData)
|
||||
{
|
||||
this.itemNo = itemNo;
|
||||
this.itemData = itemData;
|
||||
}
|
||||
|
||||
public int getItemNo()
|
||||
{
|
||||
return itemNo;
|
||||
}
|
||||
|
||||
public short getItemData()
|
||||
{
|
||||
return itemData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return (31 * itemNo) ^ itemData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (o == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!(o instanceof ItemData))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ItemData pairo = (ItemData)o;
|
||||
return this.itemNo == pairo.getItemNo()
|
||||
&& this.itemData == pairo.getItemData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class LengthCompare implements java.util.Comparator<String>
|
||||
{
|
||||
public LengthCompare()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(String s1, String s2)
|
||||
{
|
||||
return s1.length() - s2.length();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -44,6 +44,10 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
final PluginManager pluginManager = ess.getServer().getPluginManager();
|
||||
final JailListener blockListener = new JailListener();
|
||||
pluginManager.registerEvents(blockListener, ess);
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Registering Jail listener");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,16 +59,24 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
@Override
|
||||
public void finishRead()
|
||||
{
|
||||
if (enabled == false && getCount() > 0)
|
||||
{
|
||||
registerListeners();
|
||||
}
|
||||
checkRegister();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishWrite()
|
||||
{
|
||||
if (enabled == false)
|
||||
checkRegister();
|
||||
}
|
||||
|
||||
public void resetListener()
|
||||
{
|
||||
enabled = false;
|
||||
checkRegister();
|
||||
}
|
||||
|
||||
private void checkRegister()
|
||||
{
|
||||
if (enabled == false && getCount() > 0)
|
||||
{
|
||||
registerListeners();
|
||||
}
|
||||
|
@@ -6,9 +6,7 @@ import com.earth2me.essentials.commands.NoChargeException;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@@ -23,7 +21,7 @@ public class Kit
|
||||
final StringBuilder list = new StringBuilder();
|
||||
for (String kiteItem : kits.getKeys(false))
|
||||
{
|
||||
if (user == null || user.isAuthorized("essentials.kit." + kiteItem.toLowerCase(Locale.ENGLISH)))
|
||||
if (user == null || user.isAuthorized("essentials.kits." + kiteItem.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
list.append(" ").append(capitalCase(kiteItem));
|
||||
}
|
||||
@@ -37,12 +35,17 @@ public class Kit
|
||||
|
||||
}
|
||||
|
||||
public static void checkTime(final User user, final String kitName, final Map<String, Object> els) throws NoChargeException
|
||||
public static void checkTime(final User user, final String kitName, final Map<String, Object> els) throws Exception
|
||||
{
|
||||
if (user.isAuthorized("essentials.kit.exemptdelay"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Calendar time = new GregorianCalendar();
|
||||
|
||||
// Take the current time, and remove the delay from it.
|
||||
final double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0L;
|
||||
final double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0.0d;
|
||||
final Calendar earliestTime = new GregorianCalendar();
|
||||
earliestTime.add(Calendar.SECOND, -(int)delay);
|
||||
earliestTime.add(Calendar.MILLISECOND, -(int)((delay * 1000.0) % 1000.0));
|
||||
@@ -50,9 +53,9 @@ public class Kit
|
||||
final long earliestLong = earliestTime.getTimeInMillis();
|
||||
|
||||
// When was the last kit used?
|
||||
final Long lastTime = user.getKitTimestamp(kitName);
|
||||
final long lastTime = user.getKitTimestamp(kitName);
|
||||
|
||||
if (lastTime == null || lastTime < earliestLong)
|
||||
if (lastTime < earliestLong || lastTime == 0L)
|
||||
{
|
||||
user.setKitTimestamp(kitName, time.getTimeInMillis());
|
||||
}
|
||||
@@ -62,6 +65,11 @@ public class Kit
|
||||
// If this happens, let's give the user the benifit of the doubt.
|
||||
user.setKitTimestamp(kitName, time.getTimeInMillis());
|
||||
}
|
||||
else if (earliestLong < 0L)
|
||||
{
|
||||
user.sendMessage(_("kitOnce"));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
else
|
||||
{
|
||||
time.setTimeInMillis(lastTime);
|
||||
@@ -95,57 +103,34 @@ public class Kit
|
||||
try
|
||||
{
|
||||
boolean spew = false;
|
||||
final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
|
||||
for (String d : items)
|
||||
{
|
||||
final String[] parts = d.split(" ");
|
||||
final String[] item = parts[0].split("[:+',;.]", 2);
|
||||
final int id = Material.getMaterial(Integer.parseInt(item[0])).getId();
|
||||
final short data = item.length > 1 ? Short.parseShort(item[1]) : 0;
|
||||
final int amount = parts.length > 1 ? Integer.parseInt(parts[1]) : 1;
|
||||
if (d.startsWith(ess.getSettings().getCurrencySymbol()))
|
||||
{
|
||||
Double value = Double.parseDouble(d.substring(ess.getSettings().getCurrencySymbol().length()).trim());
|
||||
Trade t = new Trade(value, ess);
|
||||
t.pay(user);
|
||||
continue;
|
||||
}
|
||||
|
||||
final String[] parts = d.split(" ");
|
||||
final ItemStack parseStack = ess.getItemDb().get(parts[0], parts.length > 1 ? Integer.parseInt(parts[1]) : 1);
|
||||
final MetaItemStack metaStack = new MetaItemStack(parseStack);
|
||||
|
||||
final ItemStack stack = new ItemStack(id, amount, data);
|
||||
if (parts.length > 2)
|
||||
{
|
||||
for (int i = 2; i < parts.length; i++)
|
||||
{
|
||||
final String[] split = parts[i].split("[:+',;.]", 2);
|
||||
if (split.length < 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final Enchantment enchantment = Enchantments.getByName(split[0]);
|
||||
if (enchantment == null)
|
||||
{
|
||||
throw new Exception("Enchantment not found: " + split[0]);
|
||||
}
|
||||
int level;
|
||||
if (split.length > 1)
|
||||
{
|
||||
level = Integer.parseInt(split[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
level = enchantment.getMaxLevel();
|
||||
}
|
||||
try
|
||||
{
|
||||
stack.addEnchantment(enchantment, level);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Enchantment " + enchantment.getName() + ": " + ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
metaStack.parseStringMeta(user, allowUnsafe, parts, 2, ess);
|
||||
}
|
||||
|
||||
final Map<Integer, ItemStack> overfilled;
|
||||
if (user.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
|
||||
overfilled = InventoryWorkaround.addOversizedItems(user.getInventory(), ess.getSettings().getOversizedStackSize(), metaStack.getItemStack());
|
||||
}
|
||||
else
|
||||
{
|
||||
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, 0, stack);
|
||||
overfilled = InventoryWorkaround.addItems(user.getInventory(), metaStack.getItemStack());
|
||||
}
|
||||
for (ItemStack itemStack : overfilled.values())
|
||||
{
|
||||
|
361
Essentials/src/com/earth2me/essentials/MetaItemStack.java
Normal file
361
Essentials/src/com/earth2me/essentials/MetaItemStack.java
Normal file
@@ -0,0 +1,361 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.textreader.*;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.*;
|
||||
|
||||
|
||||
public class MetaItemStack
|
||||
{
|
||||
private final transient Pattern splitPattern = Pattern.compile("[:+',;.]");
|
||||
private final ItemStack stack;
|
||||
private final static Map<String, DyeColor> colorMap = new HashMap<String, DyeColor>();
|
||||
private final static Map<String, FireworkEffect.Type> fireworkShape = new HashMap<String, FireworkEffect.Type>();
|
||||
private FireworkEffect.Builder builder = FireworkEffect.builder();
|
||||
private boolean validFirework = false;
|
||||
|
||||
static
|
||||
{
|
||||
for (DyeColor color : DyeColor.values())
|
||||
{
|
||||
colorMap.put(color.name(), color);
|
||||
}
|
||||
for (FireworkEffect.Type type : FireworkEffect.Type.values())
|
||||
{
|
||||
fireworkShape.put(type.name(), type);
|
||||
}
|
||||
}
|
||||
|
||||
public MetaItemStack(final ItemStack stack)
|
||||
{
|
||||
this.stack = stack.clone();
|
||||
}
|
||||
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
|
||||
public boolean isValidFirework()
|
||||
{
|
||||
return validFirework;
|
||||
}
|
||||
|
||||
public FireworkEffect.Builder getFireworkBuilder()
|
||||
{
|
||||
return builder;
|
||||
}
|
||||
|
||||
public void parseStringMeta(final CommandSender user, final boolean allowUnsafe, String[] string, int fromArg, final IEssentials ess) throws Exception
|
||||
{
|
||||
|
||||
for (int i = fromArg; i < string.length; i++)
|
||||
{
|
||||
addStringMeta(user, allowUnsafe, string[i], ess);
|
||||
}
|
||||
if (validFirework)
|
||||
{
|
||||
FireworkEffect effect = builder.build();
|
||||
FireworkMeta fmeta = (FireworkMeta)stack.getItemMeta();
|
||||
fmeta.addEffect(effect);
|
||||
stack.setItemMeta(fmeta);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: TL this
|
||||
private void addStringMeta(final CommandSender user, final boolean allowUnsafe, final String string, final IEssentials ess) throws Exception
|
||||
{
|
||||
final String[] split = splitPattern.split(string, 2);
|
||||
if (split.length < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (split.length > 1 && split[0].equalsIgnoreCase("name"))
|
||||
{
|
||||
final String displayName = Util.replaceFormat(split[1].replace('_', ' '));
|
||||
final ItemMeta meta = stack.getItemMeta();
|
||||
meta.setDisplayName(displayName);
|
||||
stack.setItemMeta(meta);
|
||||
}
|
||||
else if (split.length > 1 && (split[0].equalsIgnoreCase("lore") || split[0].equalsIgnoreCase("desc")))
|
||||
{
|
||||
final List<String> lore = new ArrayList<String>();
|
||||
for (String line : split[1].split("\\|"))
|
||||
{
|
||||
lore.add(Util.replaceFormat(line.replace('_', ' ')));
|
||||
}
|
||||
final ItemMeta meta = stack.getItemMeta();
|
||||
meta.setLore(lore);
|
||||
stack.setItemMeta(meta);
|
||||
}
|
||||
else if (split.length > 1 && (split[0].equalsIgnoreCase("player") || split[0].equalsIgnoreCase("owner")) && stack.getType() == Material.SKULL_ITEM)
|
||||
{
|
||||
if (stack.getDurability() == 3)
|
||||
{
|
||||
final String owner = split[1];
|
||||
final SkullMeta meta = (SkullMeta)stack.getItemMeta();
|
||||
boolean result = meta.setOwner(owner);
|
||||
stack.setItemMeta(meta);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("You can only set the owner of player skulls (397:3)");
|
||||
}
|
||||
}
|
||||
else if (split.length > 1 && split[0].equalsIgnoreCase("book") && stack.getType() == Material.WRITTEN_BOOK)
|
||||
{
|
||||
final BookMeta meta = (BookMeta)stack.getItemMeta();
|
||||
final IText input = new BookInput("book", true, ess);
|
||||
final BookPager pager = new BookPager(input);
|
||||
|
||||
List<String> pages = pager.getPages(split[1]);
|
||||
meta.setPages(pages);
|
||||
|
||||
stack.setItemMeta(meta);
|
||||
}
|
||||
else if (split.length > 1 && split[0].equalsIgnoreCase("author") && stack.getType() == Material.WRITTEN_BOOK)
|
||||
{
|
||||
final String author = split[1];
|
||||
final BookMeta meta = (BookMeta)stack.getItemMeta();
|
||||
meta.setAuthor(author);
|
||||
stack.setItemMeta(meta);
|
||||
}
|
||||
else if (split.length > 1 && split[0].equalsIgnoreCase("title") && stack.getType() == Material.WRITTEN_BOOK)
|
||||
{
|
||||
final String title = Util.replaceFormat(split[1].replace('_', ' '));
|
||||
final BookMeta meta = (BookMeta)stack.getItemMeta();
|
||||
meta.setTitle(title);
|
||||
stack.setItemMeta(meta);
|
||||
}
|
||||
else if (split.length > 1 && split[0].equalsIgnoreCase("power") && stack.getType() == Material.FIREWORK)
|
||||
{
|
||||
final int power = Util.isInt(split[1]) ? Integer.parseInt(split[1]) : 0;
|
||||
final FireworkMeta meta = (FireworkMeta)stack.getItemMeta();
|
||||
meta.setPower(power > 3 ? 4 : power);
|
||||
stack.setItemMeta(meta);
|
||||
}
|
||||
else if (stack.getType() == Material.FIREWORK) //WARNING - Meta for fireworks will be ignored after this point.
|
||||
{
|
||||
addFireworkMeta(user, false, string, ess);
|
||||
}
|
||||
else if (split.length > 1 && (split[0].equalsIgnoreCase("color") || split[0].equalsIgnoreCase("colour"))
|
||||
&& (stack.getType() == Material.LEATHER_BOOTS
|
||||
|| stack.getType() == Material.LEATHER_CHESTPLATE
|
||||
|| stack.getType() == Material.LEATHER_HELMET
|
||||
|| stack.getType() == Material.LEATHER_LEGGINGS))
|
||||
{
|
||||
final String[] color = split[1].split("(\\||,)");
|
||||
if (color.length == 3)
|
||||
{
|
||||
final int red = Util.isInt(color[0]) ? Integer.parseInt(color[0]) : 0;
|
||||
final int green = Util.isInt(color[1]) ? Integer.parseInt(color[1]) : 0;
|
||||
final int blue = Util.isInt(color[2]) ? Integer.parseInt(color[2]) : 0;
|
||||
final LeatherArmorMeta meta = (LeatherArmorMeta)stack.getItemMeta();
|
||||
meta.setColor(Color.fromRGB(red, green, blue));
|
||||
stack.setItemMeta(meta);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Leather Color Syntax: color:<red>,<green>,<blue> eg: color:255,0,0");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
parseEnchantmentStrings(user, allowUnsafe, split);
|
||||
}
|
||||
}
|
||||
|
||||
public void addFireworkMeta(final CommandSender user, final boolean allowShortName, final String string, final IEssentials ess) throws Exception
|
||||
{
|
||||
if (stack.getType() == Material.FIREWORK)
|
||||
{
|
||||
final String[] split = splitPattern.split(string, 2);
|
||||
|
||||
if (split.length < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (split[0].equalsIgnoreCase("color") || split[0].equalsIgnoreCase("colour") || (allowShortName && split[0].equalsIgnoreCase("c")))
|
||||
{
|
||||
if (validFirework)
|
||||
{
|
||||
FireworkEffect effect = builder.build();
|
||||
FireworkMeta fmeta = (FireworkMeta)stack.getItemMeta();
|
||||
fmeta.addEffect(effect);
|
||||
stack.setItemMeta(fmeta);
|
||||
builder = FireworkEffect.builder();
|
||||
}
|
||||
|
||||
List<Color> primaryColors = new ArrayList<Color>();
|
||||
String[] colors = split[1].split(",");
|
||||
for (String color : colors)
|
||||
{
|
||||
if (colorMap.containsKey(color.toUpperCase()))
|
||||
{
|
||||
validFirework = true;
|
||||
primaryColors.add(colorMap.get(color.toUpperCase()).getFireworkColor());
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(_("fireworkSyntax"));
|
||||
throw new Exception(_("invalidFireworkFormat", split[1], split[0]));
|
||||
|
||||
}
|
||||
}
|
||||
builder.withColor(primaryColors);
|
||||
}
|
||||
else if (split[0].equalsIgnoreCase("shape") || split[0].equalsIgnoreCase("type") || (allowShortName && (split[0].equalsIgnoreCase("s") || split[0].equalsIgnoreCase("t"))))
|
||||
{
|
||||
FireworkEffect.Type finalEffect = null;
|
||||
split[1] = (split[1].equalsIgnoreCase("large") ? "BALL_LARGE" : split[1]);
|
||||
if (fireworkShape.containsKey(split[1].toUpperCase()))
|
||||
{
|
||||
finalEffect = fireworkShape.get(split[1].toUpperCase());
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(_("fireworkSyntax"));
|
||||
throw new Exception(_("invalidFireworkFormat", split[1], split[0]));
|
||||
}
|
||||
if (finalEffect != null)
|
||||
{
|
||||
builder.with(finalEffect);
|
||||
}
|
||||
}
|
||||
else if (split[0].equalsIgnoreCase("fade") || (allowShortName && split[0].equalsIgnoreCase("f")))
|
||||
{
|
||||
List<Color> fadeColors = new ArrayList<Color>();
|
||||
String[] colors = split[1].split(",");
|
||||
for (String color : colors)
|
||||
{
|
||||
if (colorMap.containsKey(color.toUpperCase()))
|
||||
{
|
||||
fadeColors.add(colorMap.get(color.toUpperCase()).getFireworkColor());
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(_("fireworkSyntax"));
|
||||
throw new Exception(_("invalidFireworkFormat", split[1], split[0]));
|
||||
}
|
||||
}
|
||||
if (!fadeColors.isEmpty())
|
||||
{
|
||||
builder.withFade(fadeColors);
|
||||
}
|
||||
}
|
||||
else if (split[0].equalsIgnoreCase("effect") || (allowShortName && split[0].equalsIgnoreCase("e")))
|
||||
{
|
||||
String[] effects = split[1].split(",");
|
||||
for (String effect : effects)
|
||||
{
|
||||
if (effect.equalsIgnoreCase("twinkle"))
|
||||
{
|
||||
builder.flicker(true);
|
||||
}
|
||||
else if (effect.equalsIgnoreCase("trail"))
|
||||
{
|
||||
builder.trail(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(_("fireworkSyntax"));
|
||||
throw new Exception(_("invalidFireworkFormat", split[1], split[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void parseEnchantmentStrings(final CommandSender user, final boolean allowUnsafe, final String[] split) throws Exception
|
||||
{
|
||||
Enchantment enchantment = getEnchantment(null, split[0]);
|
||||
|
||||
int level = -1;
|
||||
if (split.length > 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
level = Integer.parseInt(split[1]);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
level = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (level < 0 || (!allowUnsafe && level > enchantment.getMaxLevel()))
|
||||
{
|
||||
level = enchantment.getMaxLevel();
|
||||
}
|
||||
addEnchantment(user, allowUnsafe, enchantment, level);
|
||||
}
|
||||
|
||||
public void addEnchantment(final CommandSender user, final boolean allowUnsafe, final Enchantment enchantment, final int level) throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
if (stack.getType().equals(Material.ENCHANTED_BOOK))
|
||||
{
|
||||
EnchantmentStorageMeta meta = (EnchantmentStorageMeta)stack.getItemMeta();
|
||||
if (level == 0)
|
||||
{
|
||||
meta.removeStoredEnchant(enchantment);
|
||||
}
|
||||
else
|
||||
{
|
||||
meta.addStoredEnchant(enchantment, level, allowUnsafe);
|
||||
}
|
||||
stack.setItemMeta(meta);
|
||||
}
|
||||
else // all other material types besides ENCHANTED_BOOK
|
||||
{
|
||||
if (level == 0)
|
||||
{
|
||||
stack.removeEnchantment(enchantment);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (allowUnsafe)
|
||||
{
|
||||
stack.addUnsafeEnchantment(enchantment, level);
|
||||
}
|
||||
else
|
||||
{
|
||||
stack.addEnchantment(enchantment, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Enchantment " + enchantment.getName() + ": " + ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Properly TL this
|
||||
public Enchantment getEnchantment(final User user, final String name) throws Exception
|
||||
{
|
||||
final Enchantment enchantment = Enchantments.getByName(name);
|
||||
if (enchantment == null)
|
||||
{
|
||||
throw new Exception(_("enchantmentNotFound") + ": " + name);
|
||||
}
|
||||
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
|
||||
if (user != null && !user.isAuthorized("essentials.enchant." + enchantmentName))
|
||||
{
|
||||
throw new Exception(_("enchantmentPerm", enchantmentName));
|
||||
}
|
||||
return enchantment;
|
||||
}
|
||||
}
|
@@ -1,20 +1,19 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
// Suffixes can be appended on the end of a mob name to make it plural
|
||||
// Entities without a suffix, will default to 's'
|
||||
public enum Mob
|
||||
{
|
||||
CHICKEN("Chicken", Enemies.FRIENDLY, EntityType.CHICKEN),
|
||||
@@ -41,8 +40,14 @@ public enum Mob
|
||||
MAGMACUBE("MagmaCube", Enemies.ENEMY, EntityType.MAGMA_CUBE),
|
||||
SNOWMAN("Snowman", Enemies.FRIENDLY, "", EntityType.SNOWMAN),
|
||||
OCELOT("Ocelot", Enemies.NEUTRAL, EntityType.OCELOT),
|
||||
IRONGOLEM("IronGolem", Enemies.NEUTRAL, EntityType.IRON_GOLEM);
|
||||
|
||||
IRONGOLEM("IronGolem", Enemies.NEUTRAL, EntityType.IRON_GOLEM),
|
||||
WITHER("Wither", Enemies.ENEMY, EntityType.WITHER),
|
||||
BAT("Bat", Enemies.FRIENDLY, EntityType.BAT),
|
||||
WITCH("Witch", Enemies.ENEMY, EntityType.WITCH),
|
||||
BOAT("Boat", Enemies.NEUTRAL, EntityType.BOAT),
|
||||
MINECART("Minecart", Enemies.NEUTRAL, EntityType.MINECART),
|
||||
ENDERCRYSTAL("EnderCrystal", Enemies.NEUTRAL, EntityType.ENDER_CRYSTAL),
|
||||
EXPERIENCEORB("ExperienceOrb", Enemies.NEUTRAL, EntityType.EXPERIENCE_ORB);
|
||||
public static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
private Mob(String n, Enemies en, String s, EntityType type)
|
||||
@@ -72,14 +77,20 @@ public enum Mob
|
||||
hashMap.put(mob.name.toLowerCase(Locale.ENGLISH), mob);
|
||||
}
|
||||
}
|
||||
|
||||
public static Set<String> getMobList() {
|
||||
|
||||
public static Set<String> getMobList()
|
||||
{
|
||||
return Collections.unmodifiableSet(hashMap.keySet());
|
||||
}
|
||||
|
||||
public LivingEntity spawn(final Player player, final Server server, final Location loc) throws MobException
|
||||
public Entity spawn(final Player player, final Server server, final Location loc) throws MobException
|
||||
{
|
||||
final LivingEntity entity = player.getWorld().spawn(loc, (Class<? extends LivingEntity>)this.bukkitType.getEntityClass());
|
||||
return spawn(player.getWorld(), server, loc);
|
||||
}
|
||||
|
||||
public Entity spawn(final World world, final Server server, final Location loc) throws MobException
|
||||
{
|
||||
final Entity entity = world.spawn(loc, (Class<? extends Entity>)this.bukkitType.getEntityClass());
|
||||
if (entity == null)
|
||||
{
|
||||
logger.log(Level.WARNING, _("unableToSpawnMob"));
|
||||
|
@@ -11,11 +11,8 @@ import org.bukkit.conversations.ConversationAbandonedEvent;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.*;
|
||||
import org.bukkit.inventory.InventoryView.Property;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.map.MapView;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.permissions.Permission;
|
||||
@@ -841,6 +838,12 @@ public class OfflinePlayer implements Player
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBedSpawnLocation(Location lctn, boolean force)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playEffect(EntityEffect ee)
|
||||
{
|
||||
@@ -1068,5 +1071,101 @@ public class OfflinePlayer implements Player
|
||||
public boolean isValid()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlySpeed(float value) throws IllegalArgumentException
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWalkSpeed(float value) throws IllegalArgumentException
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFlySpeed()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWalkSpeed()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getEnderChest()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(Location arg0, Sound arg1, float arg2, float arg3)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveExpLevels(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getRemoveWhenFarAway()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRemoveWhenFarAway(boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityEquipment getEquipment()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCanPickupItems(boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getCanPickupItems()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation(Location lctn)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTexturePack(String string)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxHealth(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetMaxHealth()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.MemoryConfiguration;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -54,19 +55,21 @@ public class Settings implements ISettings
|
||||
@Override
|
||||
public int getHomeLimit(final User user)
|
||||
{
|
||||
final Set<String> homeList = getMultipleHomes();
|
||||
if (homeList == null)
|
||||
int limit = 1;
|
||||
if (user.isAuthorized("essentials.sethome.multiple"))
|
||||
{
|
||||
//TODO: Replace this code to remove backwards compat, after settings are automatically updated
|
||||
// return getHomeLimit("default");
|
||||
return config.getInt("multiple-homes", 5);
|
||||
limit = getHomeLimit("default");
|
||||
}
|
||||
int limit = getHomeLimit("default");
|
||||
for (String set : homeList)
|
||||
|
||||
final Set<String> homeList = getMultipleHomes();
|
||||
if (homeList != null)
|
||||
{
|
||||
if (user.isAuthorized("essentials.sethome.multiple." + set) && (limit < getHomeLimit(set)))
|
||||
for (String set : homeList)
|
||||
{
|
||||
limit = getHomeLimit(set);
|
||||
if (user.isAuthorized("essentials.sethome.multiple." + set) && (limit < getHomeLimit(set)))
|
||||
{
|
||||
limit = getHomeLimit(set);
|
||||
}
|
||||
}
|
||||
}
|
||||
return limit;
|
||||
@@ -144,26 +147,6 @@ public class Settings implements ISettings
|
||||
return disCommands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandRestricted(IEssentialsCommand cmd)
|
||||
{
|
||||
return isCommandRestricted(cmd.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandRestricted(String label)
|
||||
{
|
||||
for (String c : config.getStringList("restricted-commands"))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(label))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return config.getBoolean("restrict-" + label.toLowerCase(Locale.ENGLISH), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerCommand(String label)
|
||||
{
|
||||
@@ -191,6 +174,7 @@ public class Settings implements ISettings
|
||||
}
|
||||
return config.getBoolean("override-" + name.toLowerCase(Locale.ENGLISH), false);
|
||||
}
|
||||
private ConfigurationSection commandCosts;
|
||||
|
||||
@Override
|
||||
public double getCommandCost(IEssentialsCommand cmd)
|
||||
@@ -198,15 +182,85 @@ public class Settings implements ISettings
|
||||
return getCommandCost(cmd.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCommandCost(String label)
|
||||
public ConfigurationSection _getCommandCosts()
|
||||
{
|
||||
double cost = config.getDouble("command-costs." + label, 0.0);
|
||||
if (cost == 0.0)
|
||||
if (config.isConfigurationSection("command-costs"))
|
||||
{
|
||||
cost = config.getDouble("cost-" + label, 0.0);
|
||||
final ConfigurationSection section = config.getConfigurationSection("command-costs");
|
||||
final ConfigurationSection newSection = new MemoryConfiguration();
|
||||
for (String command : section.getKeys(false))
|
||||
{
|
||||
PluginCommand cmd = ess.getServer().getPluginCommand(command);
|
||||
if (command.charAt(0) == '/')
|
||||
{
|
||||
ess.getLogger().warning("Invalid command cost. '" + command + "' should not start with '/'.");
|
||||
}
|
||||
if (section.isDouble(command))
|
||||
{
|
||||
newSection.set(command.toLowerCase(Locale.ENGLISH), section.getDouble(command));
|
||||
}
|
||||
else if (section.isInt(command))
|
||||
{
|
||||
newSection.set(command.toLowerCase(Locale.ENGLISH), (double)section.getInt(command));
|
||||
}
|
||||
else if (section.isString(command))
|
||||
{
|
||||
String costString = section.getString(command);
|
||||
try
|
||||
{
|
||||
double cost = Double.parseDouble(costString.trim().replace(getCurrencySymbol(), "").replaceAll("\\W", ""));
|
||||
newSection.set(command.toLowerCase(Locale.ENGLISH), cost);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
ess.getLogger().warning("Invalid command cost for: " + command + " (" + costString + ")");
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ess.getLogger().warning("Invalid command cost for: " + command);
|
||||
}
|
||||
}
|
||||
return newSection;
|
||||
}
|
||||
return cost;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCommandCost(String name)
|
||||
{
|
||||
name = name.replace('.', '_').replace('/', '_');
|
||||
if (commandCosts != null)
|
||||
{
|
||||
return commandCosts.getDouble(name, 0.0);
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
private Set<String> socialSpyCommands = new HashSet<String>();
|
||||
|
||||
public Set<String> _getSocialSpyCommands()
|
||||
{
|
||||
Set<String> socialspyCommands = new HashSet<String>();
|
||||
|
||||
if (config.isConfigurationSection("socialspy-commands"))
|
||||
{
|
||||
for (String c : config.getStringList("socialspy-commands"))
|
||||
{
|
||||
socialspyCommands.add(c.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
socialspyCommands.addAll(Arrays.asList("msg", "r", "mail", "m", "whisper", "emsg", "t", "tell", "er", "reply", "ereply", "email", "action", "describe", "eme", "eaction", "edescribe", "etell", "ewhisper", "pm"));
|
||||
}
|
||||
|
||||
return socialspyCommands;
|
||||
}
|
||||
|
||||
public Set<String> getSocialSpyCommands()
|
||||
{
|
||||
return socialSpyCommands;
|
||||
}
|
||||
private String nicknamePrefix = "~";
|
||||
|
||||
@@ -262,7 +316,7 @@ public class Settings implements ISettings
|
||||
public Map<String, Object> getKit(String name)
|
||||
{
|
||||
name = name.replace('.', '_').replace('/', '_');
|
||||
if (config.isConfigurationSection("kits"))
|
||||
if (getKits() != null)
|
||||
{
|
||||
final ConfigurationSection kits = getKits();
|
||||
if (kits.isConfigurationSection(name))
|
||||
@@ -286,7 +340,7 @@ public class Settings implements ISettings
|
||||
|
||||
if (colorName == null)
|
||||
{
|
||||
return ChatColor.RED;
|
||||
return ChatColor.DARK_RED;
|
||||
}
|
||||
if ("none".equalsIgnoreCase(colorName) || colorName.isEmpty())
|
||||
{
|
||||
@@ -362,6 +416,7 @@ public class Settings implements ISettings
|
||||
format = format.replace("{WORLDNAME}", "{1}");
|
||||
format = format.replace("{SHORTWORLDNAME}", "{2}");
|
||||
format = format.replaceAll("\\{(\\D*?)\\}", "\\[$1\\]");
|
||||
format = "§r".concat(format);
|
||||
mFormat = new MessageFormat(format);
|
||||
chatFormats.put(group, mFormat);
|
||||
}
|
||||
@@ -413,7 +468,8 @@ public class Settings implements ISettings
|
||||
teleportInvulnerability = _isTeleportInvulnerability();
|
||||
disableItemPickupWhileAfk = _getDisableItemPickupWhileAfk();
|
||||
registerBackInListener = _registerBackInListener();
|
||||
cancelAfkOnMove = _cancelAfkOnMove();
|
||||
cancelAfkOnInteract = _cancelAfkOnInteract();
|
||||
cancelAfkOnMove = _cancelAfkOnMove() && cancelAfkOnInteract;
|
||||
getFreezeAfkPlayers = _getFreezeAfkPlayers();
|
||||
itemSpawnBl = _getItemSpawnBlacklist();
|
||||
loginAttackDelay = _getLoginAttackDelay();
|
||||
@@ -431,6 +487,10 @@ public class Settings implements ISettings
|
||||
disablePrefix = _disablePrefix();
|
||||
disableSuffix = _disableSuffix();
|
||||
chatRadius = _getChatRadius();
|
||||
commandCosts = _getCommandCosts();
|
||||
socialSpyCommands = _getSocialSpyCommands();
|
||||
warnOnBuildDisallow = _warnOnBuildDisallow();
|
||||
mailsPerMinute = _getMailsPerMinute();
|
||||
}
|
||||
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
|
||||
|
||||
@@ -505,17 +565,17 @@ public class Settings implements ISettings
|
||||
}
|
||||
return newSigns;
|
||||
}
|
||||
private boolean warnOnBuildDisallow;
|
||||
|
||||
@Override
|
||||
public boolean spawnIfNoHome()
|
||||
private boolean _warnOnBuildDisallow()
|
||||
{
|
||||
return config.getBoolean("spawn-if-no-home", false);
|
||||
return config.getBoolean("protect.disable.warn-on-build-disallow", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean warnOnBuildDisallow()
|
||||
{
|
||||
return config.getBoolean("protect.disable.warn-on-build-disallow", false);
|
||||
return warnOnBuildDisallow;
|
||||
}
|
||||
private boolean debug = false;
|
||||
private boolean configDebug = false;
|
||||
@@ -549,10 +609,12 @@ public class Settings implements ISettings
|
||||
return config.getString("locale", "");
|
||||
}
|
||||
|
||||
//This method should always only return one character due to the implementation of the calling methods
|
||||
//If you need to use a string currency, for example "coins", use the translation key 'currency'.
|
||||
@Override
|
||||
public String getCurrencySymbol()
|
||||
{
|
||||
return config.getString("currency-symbol", "$").substring(0, 1).replaceAll("[0-9]", "$");
|
||||
return config.getString("currency-symbol", "$").concat("$").substring(0, 1).replaceAll("[0-9]", "$");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -687,6 +749,7 @@ public class Settings implements ISettings
|
||||
}
|
||||
private boolean prefixsuffixconfigured = false;
|
||||
private boolean addprefixsuffix = false;
|
||||
private boolean essentialsChatActive = false;
|
||||
|
||||
private boolean _addPrefixSuffix()
|
||||
{
|
||||
@@ -698,10 +761,16 @@ public class Settings implements ISettings
|
||||
return config.hasProperty("add-prefix-suffix");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEssentialsChatActive(boolean essentialsChatActive)
|
||||
{
|
||||
this.essentialsChatActive = essentialsChatActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPrefixSuffix()
|
||||
{
|
||||
return prefixsuffixconfigured ? addprefixsuffix : ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat");
|
||||
return prefixsuffixconfigured ? addprefixsuffix : essentialsChatActive;
|
||||
}
|
||||
private boolean disablePrefix = false;
|
||||
|
||||
@@ -763,6 +832,18 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getBoolean("cancel-afk-on-move", true);
|
||||
}
|
||||
private boolean cancelAfkOnInteract;
|
||||
|
||||
@Override
|
||||
public boolean cancelAfkOnInteract()
|
||||
{
|
||||
return cancelAfkOnInteract;
|
||||
}
|
||||
|
||||
private boolean _cancelAfkOnInteract()
|
||||
{
|
||||
return config.getBoolean("cancel-afk-on-interact", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areDeathMessagesEnabled()
|
||||
@@ -789,6 +870,12 @@ public class Settings implements ISettings
|
||||
return config.getBoolean("repair-enchanted", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowUnsafeEnchantments()
|
||||
{
|
||||
return config.getBoolean("unsafe-enchantments", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorldTeleportPermissions()
|
||||
{
|
||||
@@ -855,7 +942,7 @@ public class Settings implements ISettings
|
||||
@Override
|
||||
public long getTpaAcceptCancellation()
|
||||
{
|
||||
return config.getLong("tpa-accept-cancellation", 0);
|
||||
return config.getLong("tpa-accept-cancellation", 120);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -912,4 +999,38 @@ public class Settings implements ISettings
|
||||
{
|
||||
return signUsePerSecond;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxFlySpeed()
|
||||
{
|
||||
double maxSpeed = config.getDouble("max-fly-speed", 1.0);
|
||||
return maxSpeed > 1.0 ? 1.0 : Math.abs(maxSpeed);
|
||||
}
|
||||
|
||||
//This option does not exist in the config.yml because it wasn't yet implemented in bukkit
|
||||
//The code was commented out in the /speed command
|
||||
@Override
|
||||
public double getMaxWalkSpeed()
|
||||
{
|
||||
double maxSpeed = config.getDouble("max-walk-speed", 0.8);
|
||||
return maxSpeed > 1.0 ? 1.0 : Math.abs(maxSpeed);
|
||||
}
|
||||
private int mailsPerMinute;
|
||||
|
||||
private int _getMailsPerMinute()
|
||||
{
|
||||
return config.getInt("mails-per-minute", 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMailsPerMinute()
|
||||
{
|
||||
return mailsPerMinute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxTempban()
|
||||
{
|
||||
return config.getLong("max-tempban-time", -1);
|
||||
}
|
||||
}
|
||||
|
295
Essentials/src/com/earth2me/essentials/SpawnMob.java
Normal file
295
Essentials/src/com/earth2me/essentials/SpawnMob.java
Normal file
@@ -0,0 +1,295 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Mob.MobException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
import org.bukkit.material.Colorable;
|
||||
|
||||
|
||||
public class SpawnMob
|
||||
{
|
||||
public static String mobList(final User user)
|
||||
{
|
||||
final Set<String> mobList = Mob.getMobList();
|
||||
final Set<String> availableList = new HashSet<String>();
|
||||
for (String mob : mobList)
|
||||
{
|
||||
if (user.isAuthorized("essentials.spawnmob." + mob.toLowerCase()))
|
||||
{
|
||||
availableList.add(mob);
|
||||
}
|
||||
}
|
||||
if (availableList.isEmpty())
|
||||
{
|
||||
availableList.add(_("none"));
|
||||
}
|
||||
return Util.joinList(availableList);
|
||||
}
|
||||
|
||||
public static String[] mobData(final String mobString)
|
||||
{
|
||||
String[] returnString = new String[4];
|
||||
|
||||
final String[] parts = mobString.split(",");
|
||||
String[] mobParts = parts[0].split(":");
|
||||
|
||||
returnString[0] = mobParts[0];
|
||||
if (mobParts.length == 2)
|
||||
{
|
||||
returnString[1] = mobParts[1];
|
||||
}
|
||||
|
||||
if (parts.length > 1)
|
||||
{
|
||||
String[] mountParts = parts[1].split(":");
|
||||
returnString[2] = mountParts[0];
|
||||
if (mountParts.length == 2)
|
||||
{
|
||||
returnString[3] = mountParts[1];
|
||||
}
|
||||
}
|
||||
|
||||
return returnString;
|
||||
}
|
||||
|
||||
// This method spawns a mob where the user is looking, owned by user
|
||||
public static void spawnmob(final IEssentials ess, final Server server, final User user, final String[] Data, int mobCount) throws Exception
|
||||
{
|
||||
final Block block = Util.getTarget(user).getBlock();
|
||||
if (block == null)
|
||||
{
|
||||
throw new Exception(_("unableToSpawnMob"));
|
||||
}
|
||||
spawnmob(ess, server, user, user, block.getLocation(), Data, mobCount);
|
||||
}
|
||||
|
||||
// This method spawns a mob at loc, owned by noone
|
||||
public static void spawnmob(final IEssentials ess, final Server server, final CommandSender sender, final Location loc, final String[] Data, int mobCount) throws Exception
|
||||
{
|
||||
spawnmob(ess, server, sender, null, loc, Data, mobCount);
|
||||
}
|
||||
|
||||
// This method spawns a mob at target, owned by target
|
||||
public static void spawnmob(final IEssentials ess, final Server server, final CommandSender sender, final User target, final String[] Data, int mobCount) throws Exception
|
||||
{
|
||||
spawnmob(ess, server, sender, target, target.getLocation(), Data, mobCount);
|
||||
}
|
||||
|
||||
// This method spawns a mob at loc, owned by target
|
||||
public static void spawnmob(final IEssentials ess, final Server server, final CommandSender sender, final User target, final Location loc, final String[] Data, int mobCount) throws Exception
|
||||
{
|
||||
final Location sloc = Util.getSafeDestination(loc);
|
||||
final String mobType = Data[0];
|
||||
final String mobData = Data[1];
|
||||
final String mountType = Data[2];
|
||||
final String mountData = Data[3];
|
||||
|
||||
Mob mob = Mob.fromName(mobType);
|
||||
Mob mobMount = null;
|
||||
|
||||
checkSpawnable(ess, sender, mob);
|
||||
|
||||
if (mountType != null)
|
||||
{
|
||||
mobMount = Mob.fromName(mountType);
|
||||
checkSpawnable(ess, sender, mobMount);
|
||||
}
|
||||
|
||||
int serverLimit = ess.getSettings().getSpawnMobLimit();
|
||||
if (mobCount > serverLimit)
|
||||
{
|
||||
mobCount = serverLimit;
|
||||
sender.sendMessage(_("mobSpawnLimit"));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < mobCount; i++)
|
||||
{
|
||||
spawnMob(ess, server, sender, target, sloc, mob, mobData, mobMount, mountData);
|
||||
}
|
||||
sender.sendMessage(mobCount + " " + mob.name.toLowerCase(Locale.ENGLISH) + mob.suffix + " " + _("spawned"));
|
||||
}
|
||||
catch (MobException e1)
|
||||
{
|
||||
throw new Exception(_("unableToSpawnMob"), e1);
|
||||
}
|
||||
catch (NumberFormatException e2)
|
||||
{
|
||||
throw new Exception(_("numberRequired"), e2);
|
||||
}
|
||||
catch (NullPointerException np)
|
||||
{
|
||||
throw new Exception(_("soloMob"), np);
|
||||
}
|
||||
}
|
||||
|
||||
private static void spawnMob(final IEssentials ess, final Server server, final CommandSender sender, final User target, final Location sloc, Mob mob, String mobData, Mob mobMount, String mountData) throws Exception
|
||||
{
|
||||
Entity spawnedMob = mob.spawn(sloc.getWorld(), server, sloc);
|
||||
Entity spawnedMount = null;
|
||||
|
||||
if (mobMount != null)
|
||||
{
|
||||
spawnedMount = mobMount.spawn(sloc.getWorld(), server, sloc);
|
||||
spawnedMob.setPassenger(spawnedMount);
|
||||
}
|
||||
if (mobData != null)
|
||||
{
|
||||
changeMobData(mob.getType(), spawnedMob, mobData, target);
|
||||
}
|
||||
if (spawnedMount != null && mountData != null)
|
||||
{
|
||||
changeMobData(mobMount.getType(), spawnedMount, mountData, target);
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkSpawnable(IEssentials ess, CommandSender sender, Mob mob) throws Exception
|
||||
{
|
||||
if (mob == null)
|
||||
{
|
||||
throw new Exception(_("invalidMob"));
|
||||
}
|
||||
|
||||
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new Exception(_("disabledToSpawnMob"));
|
||||
}
|
||||
|
||||
if (sender instanceof User && !((User)sender).isAuthorized("essentials.spawnmob." + mob.name.toLowerCase()))
|
||||
{
|
||||
throw new Exception(_("noPermToSpawnMob"));
|
||||
}
|
||||
}
|
||||
|
||||
private static void changeMobData(final EntityType type, final Entity spawned, String data, final User target) throws Exception
|
||||
{
|
||||
data = data.toLowerCase(Locale.ENGLISH);
|
||||
|
||||
if (spawned instanceof Slime)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Slime)spawned).setSize(Integer.parseInt(data));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Exception(_("slimeMalformedSize"), e);
|
||||
}
|
||||
}
|
||||
|
||||
if ((spawned instanceof Ageable) && data.contains("baby"))
|
||||
{
|
||||
((Ageable)spawned).setBaby();
|
||||
data = data.replace("baby", "");
|
||||
}
|
||||
|
||||
if (spawned instanceof Colorable)
|
||||
{
|
||||
final String color = data.toUpperCase(Locale.ENGLISH);
|
||||
try
|
||||
{
|
||||
if (color.equals("RANDOM"))
|
||||
{
|
||||
final Random rand = new Random();
|
||||
((Colorable)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
|
||||
}
|
||||
else if (color.length() > 1)
|
||||
{
|
||||
((Colorable)spawned).setColor(DyeColor.valueOf(color));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Exception(_("sheepMalformedColor"), e);
|
||||
}
|
||||
}
|
||||
|
||||
if (spawned instanceof Tameable && data.contains("tamed") && target != null)
|
||||
{
|
||||
final Tameable tameable = ((Tameable)spawned);
|
||||
tameable.setTamed(true);
|
||||
tameable.setOwner(target.getBase());
|
||||
data = data.replace("tamed", "");
|
||||
}
|
||||
|
||||
if (type == EntityType.WOLF)
|
||||
{
|
||||
if (data.contains("angry"))
|
||||
{
|
||||
((Wolf)spawned).setAngry(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (type == EntityType.CREEPER && data.contains("powered"))
|
||||
{
|
||||
((Creeper)spawned).setPowered(true);
|
||||
}
|
||||
|
||||
if (type == EntityType.OCELOT)
|
||||
{
|
||||
if (data.contains("siamese") || data.contains("white"))
|
||||
{
|
||||
((Ocelot)spawned).setCatType(Ocelot.Type.SIAMESE_CAT);
|
||||
}
|
||||
else if (data.contains("red") || data.contains("orange") || data.contains("tabby"))
|
||||
{
|
||||
((Ocelot)spawned).setCatType(Ocelot.Type.RED_CAT);
|
||||
}
|
||||
else if (data.contains("black") || data.contains("tuxedo"))
|
||||
{
|
||||
((Ocelot)spawned).setCatType(Ocelot.Type.BLACK_CAT);
|
||||
}
|
||||
}
|
||||
|
||||
if (type == EntityType.VILLAGER)
|
||||
{
|
||||
for (Villager.Profession prof : Villager.Profession.values())
|
||||
{
|
||||
if (data.contains(prof.toString().toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
((Villager)spawned).setProfession(prof);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (spawned instanceof Zombie)
|
||||
{
|
||||
if (data.contains("villager"))
|
||||
{
|
||||
((Zombie)spawned).setVillager(true);
|
||||
}
|
||||
if (data.contains("baby"))
|
||||
{
|
||||
((Zombie)spawned).setBaby(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (type == EntityType.SKELETON)
|
||||
{
|
||||
if (data.contains("wither"))
|
||||
{
|
||||
((Skeleton)spawned).setSkeletonType(SkeletonType.WITHER);
|
||||
}
|
||||
}
|
||||
|
||||
if (type == EntityType.EXPERIENCE_ORB)
|
||||
{
|
||||
if (Util.isInt(data))
|
||||
{
|
||||
((ExperienceOrb)spawned).setExperience(Integer.parseInt(data));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -24,13 +24,13 @@ public class TNTExplodeListener implements Listener, Runnable
|
||||
if (!enabled)
|
||||
{
|
||||
enabled = true;
|
||||
timer = ess.scheduleSyncDelayedTask(this, 1000);
|
||||
timer = ess.scheduleSyncDelayedTask(this, 200);
|
||||
return;
|
||||
}
|
||||
if (timer != -1)
|
||||
{
|
||||
ess.getScheduler().cancelTask(timer);
|
||||
timer = ess.scheduleSyncDelayedTask(this, 1000);
|
||||
timer = ess.scheduleSyncDelayedTask(this, 200);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,12 +1,12 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.ITeleport;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.ITeleport;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
@@ -15,38 +15,40 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
public class Teleport implements Runnable, ITeleport
|
||||
{
|
||||
private static final double MOVE_CONSTANT = 0.3;
|
||||
|
||||
|
||||
private static class Target
|
||||
|
||||
|
||||
private class Target
|
||||
{
|
||||
private final Location location;
|
||||
private final Entity entity;
|
||||
|
||||
public Target(Location location)
|
||||
private final String name;
|
||||
|
||||
Target(Location location)
|
||||
{
|
||||
this.location = location;
|
||||
this.entity = null;
|
||||
this.name = null;
|
||||
}
|
||||
|
||||
public Target(Entity entity)
|
||||
|
||||
Target(Player entity)
|
||||
{
|
||||
this.entity = entity;
|
||||
this.name = entity.getName();
|
||||
this.location = null;
|
||||
}
|
||||
|
||||
|
||||
public Location getLocation()
|
||||
{
|
||||
if (this.entity != null)
|
||||
if (this.name != null)
|
||||
{
|
||||
return this.entity.getLocation();
|
||||
|
||||
return ess.getServer().getPlayerExact(name).getLocation();
|
||||
}
|
||||
return location;
|
||||
}
|
||||
}
|
||||
private IUser user;
|
||||
private IUser teleportUser;
|
||||
private int teleTimer = -1;
|
||||
private long started; // time this task was initiated
|
||||
private long delay; // how long to delay the teleport
|
||||
private long tpdelay; // how long to delay the teleport
|
||||
private int health;
|
||||
// note that I initially stored a clone of the location for reference, but...
|
||||
// when comparing locations, I got incorrect mismatches (rounding errors, looked like)
|
||||
@@ -55,55 +57,76 @@ public class Teleport implements Runnable, ITeleport
|
||||
private long initY;
|
||||
private long initZ;
|
||||
private Target teleportTarget;
|
||||
private boolean respawn;
|
||||
private Trade chargeFor;
|
||||
private final IEssentials ess;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private TeleportCause cause;
|
||||
|
||||
|
||||
private void initTimer(long delay, Target target, Trade chargeFor, TeleportCause cause)
|
||||
{
|
||||
initTimer(delay, user, target, chargeFor, cause, false);
|
||||
}
|
||||
|
||||
private void initTimer(long delay, IUser teleportUser, Target target, Trade chargeFor, TeleportCause cause, boolean respawn)
|
||||
{
|
||||
this.started = System.currentTimeMillis();
|
||||
this.delay = delay;
|
||||
this.health = user.getHealth();
|
||||
this.initX = Math.round(user.getLocation().getX() * MOVE_CONSTANT);
|
||||
this.initY = Math.round(user.getLocation().getY() * MOVE_CONSTANT);
|
||||
this.initZ = Math.round(user.getLocation().getZ() * MOVE_CONSTANT);
|
||||
this.tpdelay = delay;
|
||||
this.health = teleportUser.getHealth();
|
||||
this.initX = Math.round(teleportUser.getLocation().getX() * MOVE_CONSTANT);
|
||||
this.initY = Math.round(teleportUser.getLocation().getY() * MOVE_CONSTANT);
|
||||
this.initZ = Math.round(teleportUser.getLocation().getZ() * MOVE_CONSTANT);
|
||||
this.teleportUser = teleportUser;
|
||||
this.teleportTarget = target;
|
||||
this.chargeFor = chargeFor;
|
||||
this.cause = cause;
|
||||
this.respawn = respawn;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
|
||||
|
||||
if (user == null || !user.isOnline() || user.getLocation() == null)
|
||||
{
|
||||
cancel();
|
||||
cancel(false);
|
||||
return;
|
||||
}
|
||||
if (Math.round(user.getLocation().getX() * MOVE_CONSTANT) != initX
|
||||
|| Math.round(user.getLocation().getY() * MOVE_CONSTANT) != initY
|
||||
|| Math.round(user.getLocation().getZ() * MOVE_CONSTANT) != initZ
|
||||
|| user.getHealth() < health)
|
||||
{ // user moved, cancel teleport
|
||||
if (teleportUser == null || !teleportUser.isOnline() || teleportUser.getLocation() == null)
|
||||
{
|
||||
cancel(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!user.isAuthorized("essentials.teleport.timer.move")
|
||||
&& (Math.round(teleportUser.getLocation().getX() * MOVE_CONSTANT) != initX
|
||||
|| Math.round(teleportUser.getLocation().getY() * MOVE_CONSTANT) != initY
|
||||
|| Math.round(teleportUser.getLocation().getZ() * MOVE_CONSTANT) != initZ
|
||||
|| teleportUser.getHealth() < health))
|
||||
{
|
||||
// user moved, cancel teleport
|
||||
cancel(true);
|
||||
return;
|
||||
}
|
||||
|
||||
health = user.getHealth(); // in case user healed, then later gets injured
|
||||
|
||||
health = teleportUser.getHealth(); // in case user healed, then later gets injured
|
||||
long now = System.currentTimeMillis();
|
||||
if (now > started + delay)
|
||||
if (now > started + tpdelay)
|
||||
{
|
||||
try
|
||||
{
|
||||
cooldown(false);
|
||||
user.sendMessage(_("teleportationCommencing"));
|
||||
teleportUser.sendMessage(_("teleportationCommencing"));
|
||||
try
|
||||
{
|
||||
|
||||
now(teleportTarget, cause);
|
||||
if (respawn)
|
||||
{
|
||||
teleportUser.getTeleport().respawn(cause);
|
||||
}
|
||||
else
|
||||
{
|
||||
teleportUser.getTeleport().now(teleportTarget, cause);
|
||||
}
|
||||
cancel(false);
|
||||
if (chargeFor != null)
|
||||
{
|
||||
chargeFor.charge(user);
|
||||
@@ -117,32 +140,20 @@ public class Teleport implements Runnable, ITeleport
|
||||
catch (Exception ex)
|
||||
{
|
||||
user.sendMessage(_("cooldownWithMessage", ex.getMessage()));
|
||||
if (user != teleportUser)
|
||||
{
|
||||
teleportUser.sendMessage(_("cooldownWithMessage", ex.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Teleport(IUser user, IEssentials ess)
|
||||
{
|
||||
this.user = user;
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public void respawn(final Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
final Player player = user.getBase();
|
||||
final Location bed = player.getBedSpawnLocation();
|
||||
final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, bed == null ? player.getWorld().getSpawnLocation() : bed, bed != null);
|
||||
ess.getServer().getPluginManager().callEvent(pre);
|
||||
teleport(new Target(pre.getRespawnLocation()), chargeFor, cause);
|
||||
}
|
||||
|
||||
public void warp(String warp, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
Location loc = ess.getWarps().getWarp(warp);
|
||||
teleport(new Target(loc), chargeFor, cause);
|
||||
user.sendMessage(_("warpingTo", warp));
|
||||
}
|
||||
|
||||
|
||||
public void cooldown(boolean check) throws Exception
|
||||
{
|
||||
final Calendar time = new GregorianCalendar();
|
||||
@@ -158,7 +169,7 @@ public class Teleport implements Runnable, ITeleport
|
||||
|
||||
// When was the last teleport used?
|
||||
final Long lastTime = user.getLastTeleportTimestamp();
|
||||
|
||||
|
||||
if (lastTime > time.getTimeInMillis())
|
||||
{
|
||||
// This is to make sure time didn't get messed up on last kit use.
|
||||
@@ -181,6 +192,7 @@ public class Teleport implements Runnable, ITeleport
|
||||
}
|
||||
}
|
||||
|
||||
//If we need to cancel a pending teleport call this method
|
||||
public void cancel(boolean notifyUser)
|
||||
{
|
||||
if (teleTimer == -1)
|
||||
@@ -193,6 +205,10 @@ public class Teleport implements Runnable, ITeleport
|
||||
if (notifyUser)
|
||||
{
|
||||
user.sendMessage(_("pendingTeleportCancelled"));
|
||||
if (teleportUser != user)
|
||||
{
|
||||
teleportUser.sendMessage(_("pendingTeleportCancelled"));
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
@@ -201,30 +217,54 @@ public class Teleport implements Runnable, ITeleport
|
||||
}
|
||||
}
|
||||
|
||||
public void cancel()
|
||||
//The now function is used when you want to skip tp delay when teleporting someone to a location or player.
|
||||
public void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception
|
||||
{
|
||||
if (cooldown)
|
||||
{
|
||||
cooldown(false);
|
||||
}
|
||||
now(new Target(loc), cause);
|
||||
}
|
||||
|
||||
public void now(Player entity, boolean cooldown, TeleportCause cause) throws Exception
|
||||
{
|
||||
if (cooldown)
|
||||
{
|
||||
cooldown(false);
|
||||
}
|
||||
now(new Target(entity), cause);
|
||||
}
|
||||
|
||||
private void now(Target target, TeleportCause cause) throws Exception
|
||||
{
|
||||
cancel(false);
|
||||
user.setLastLocation();
|
||||
user.getBase().teleport(Util.getSafeDestination(target.getLocation()), cause);
|
||||
}
|
||||
|
||||
//The teleport function is used when you want to normally teleport someone to a location or player.
|
||||
//This method is nolonger used internally and will be removed.
|
||||
@Deprecated
|
||||
public void teleport(Location loc, Trade chargeFor) throws Exception
|
||||
{
|
||||
teleport(new Target(loc), chargeFor, TeleportCause.PLUGIN);
|
||||
teleport(loc, chargeFor, TeleportCause.PLUGIN);
|
||||
}
|
||||
|
||||
|
||||
public void teleport(Location loc, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
teleport(new Target(loc), chargeFor, cause);
|
||||
}
|
||||
|
||||
public void teleport(Entity entity, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
|
||||
public void teleport(Player entity, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
teleport(new Target(entity), chargeFor, cause);
|
||||
}
|
||||
|
||||
|
||||
private void teleport(Target target, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
|
||||
|
||||
if (chargeFor != null)
|
||||
{
|
||||
chargeFor.isAffordableFor(user);
|
||||
@@ -240,59 +280,117 @@ public class Teleport implements Runnable, ITeleport
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
cancel(false);
|
||||
warnUser(user, delay);
|
||||
initTimer((long)(delay * 1000.0), target, chargeFor, cause);
|
||||
|
||||
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
|
||||
}
|
||||
|
||||
cancel();
|
||||
//The teleportToMe function is a wrapper used to handle teleporting players to them, like /tphere
|
||||
public void teleportToMe(User otherUser, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
Target target = new Target(user);
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
|
||||
if (chargeFor != null)
|
||||
{
|
||||
chargeFor.isAffordableFor(user);
|
||||
}
|
||||
cooldown(true);
|
||||
if (delay <= 0 || user.isAuthorized("essentials.teleport.timer.bypass"))
|
||||
{
|
||||
cooldown(false);
|
||||
otherUser.getTeleport().now(target, cause);
|
||||
if (chargeFor != null)
|
||||
{
|
||||
chargeFor.charge(user);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
cancel(false);
|
||||
warnUser(otherUser, delay);
|
||||
initTimer((long)(delay * 1000.0), otherUser, target, chargeFor, cause, false);
|
||||
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
|
||||
}
|
||||
|
||||
private void warnUser(final IUser user, final double delay)
|
||||
{
|
||||
Calendar c = new GregorianCalendar();
|
||||
c.add(Calendar.SECOND, (int)delay);
|
||||
c.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
|
||||
user.sendMessage(_("dontMoveMessage", Util.formatDateDiff(c.getTimeInMillis())));
|
||||
initTimer((long)(delay * 1000.0), target, chargeFor, cause);
|
||||
}
|
||||
|
||||
//The respawn function is a wrapper used to handle tp fallback, on /jail and /home
|
||||
public void respawn(final Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
if (chargeFor != null)
|
||||
{
|
||||
chargeFor.isAffordableFor(user);
|
||||
}
|
||||
cooldown(true);
|
||||
if (delay <= 0 || user.isAuthorized("essentials.teleport.timer.bypass"))
|
||||
{
|
||||
cooldown(false);
|
||||
respawn(cause);
|
||||
if (chargeFor != null)
|
||||
{
|
||||
chargeFor.charge(user);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
cancel(false);
|
||||
warnUser(user, delay);
|
||||
initTimer((long)(delay * 1000.0), user, null, chargeFor, cause, true);
|
||||
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
|
||||
}
|
||||
|
||||
private void now(Target target, TeleportCause cause) throws Exception
|
||||
|
||||
public void respawn(TeleportCause cause) throws Exception
|
||||
{
|
||||
cancel();
|
||||
user.setLastLocation();
|
||||
user.getBase().teleport(Util.getSafeDestination(target.getLocation()), cause);
|
||||
}
|
||||
|
||||
public void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception
|
||||
{
|
||||
if (cooldown)
|
||||
final Player player = user.getBase();
|
||||
Location bed = player.getBedSpawnLocation();
|
||||
if (bed != null)
|
||||
{
|
||||
cooldown(false);
|
||||
now(new Target(bed), cause);
|
||||
}
|
||||
now(new Target(loc), cause);
|
||||
}
|
||||
|
||||
public void now(Location loc, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
cooldown(false);
|
||||
chargeFor.charge(user);
|
||||
now(new Target(loc), cause);
|
||||
}
|
||||
|
||||
public void now(Entity entity, boolean cooldown, TeleportCause cause) throws Exception
|
||||
{
|
||||
if (cooldown)
|
||||
else
|
||||
{
|
||||
cooldown(false);
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().info("Could not find bed spawn, forcing respawn event.");
|
||||
}
|
||||
final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, player.getWorld().getSpawnLocation(), false);
|
||||
ess.getServer().getPluginManager().callEvent(pre);
|
||||
now(new Target(pre.getRespawnLocation()), cause);
|
||||
}
|
||||
now(new Target(entity), cause);
|
||||
}
|
||||
|
||||
//The warp function is a wrapper used to teleport a player to a /warp
|
||||
public void warp(String warp, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
Location loc = ess.getWarps().getWarp(warp);
|
||||
user.sendMessage(_("warpingTo", warp));
|
||||
teleport(new Target(loc), chargeFor, cause);
|
||||
}
|
||||
|
||||
//The back function is a wrapper used to teleport a player /back to their previous location.
|
||||
public void back(Trade chargeFor) throws Exception
|
||||
{
|
||||
teleport(new Target(user.getLastLocation()), chargeFor, TeleportCause.COMMAND);
|
||||
}
|
||||
|
||||
//This function is used to throw a user back after a jail sentence
|
||||
public void back() throws Exception
|
||||
{
|
||||
now(new Target(user.getLastLocation()), TeleportCause.COMMAND);
|
||||
}
|
||||
|
||||
//This function handles teleporting to /home
|
||||
public void home(Location loc, Trade chargeFor) throws Exception
|
||||
{
|
||||
teleport(new Target(loc), chargeFor, TeleportCause.COMMAND);
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import com.earth2me.essentials.craftbukkit.SetExpFix;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
@@ -20,7 +20,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
public class Trade
|
||||
{
|
||||
private final transient String command;
|
||||
private final transient String fallbackCommand;
|
||||
private final transient Trade fallbackTrade;
|
||||
private final transient Double money;
|
||||
private final transient ItemStack itemStack;
|
||||
private final transient Integer exp;
|
||||
@@ -31,7 +31,7 @@ public class Trade
|
||||
this(command, null, null, null, null, ess);
|
||||
}
|
||||
|
||||
public Trade(final String command, final String fallback, final IEssentials ess)
|
||||
public Trade(final String command, final Trade fallback, final IEssentials ess)
|
||||
{
|
||||
this(command, fallback, null, null, null, ess);
|
||||
}
|
||||
@@ -51,10 +51,10 @@ public class Trade
|
||||
this(null, null, null, null, exp, ess);
|
||||
}
|
||||
|
||||
private Trade(final String command, final String fallback, final Double money, final ItemStack item, final Integer exp, final IEssentials ess)
|
||||
private Trade(final String command, final Trade fallback, final Double money, final ItemStack item, final Integer exp, final IEssentials ess)
|
||||
{
|
||||
this.command = command;
|
||||
this.fallbackCommand = fallback;
|
||||
this.fallbackTrade = fallback;
|
||||
this.money = money;
|
||||
this.itemStack = item;
|
||||
this.exp = exp;
|
||||
@@ -63,6 +63,12 @@ public class Trade
|
||||
|
||||
public void isAffordableFor(final IUser user) throws ChargeException
|
||||
{
|
||||
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "checking if " + user.getName() + " can afford charge.");
|
||||
}
|
||||
|
||||
if (getMoney() != null
|
||||
&& getMoney() > 0
|
||||
&& !user.canAfford(getMoney()))
|
||||
@@ -71,7 +77,7 @@ public class Trade
|
||||
}
|
||||
|
||||
if (getItemStack() != null
|
||||
&& !InventoryWorkaround.containsItem(user.getInventory(), true, true, itemStack))
|
||||
&& !user.getInventory().containsAtLeast(itemStack, itemStack.getAmount()))
|
||||
{
|
||||
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
|
||||
}
|
||||
@@ -107,7 +113,7 @@ public class Trade
|
||||
{
|
||||
if (dropItems)
|
||||
{
|
||||
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItem(user.getInventory(), true, getItemStack());
|
||||
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItems(user.getInventory(), getItemStack());
|
||||
final Location loc = user.getLocation();
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
@@ -131,7 +137,7 @@ public class Trade
|
||||
}
|
||||
else
|
||||
{
|
||||
success = InventoryWorkaround.addAllItems(user.getInventory(), true, getItemStack());
|
||||
success = InventoryWorkaround.addAllItems(user.getInventory(), getItemStack());
|
||||
}
|
||||
user.updateInventory();
|
||||
}
|
||||
@@ -144,9 +150,14 @@ public class Trade
|
||||
|
||||
public void charge(final IUser user) throws ChargeException
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "charging user " + user.getName());
|
||||
}
|
||||
|
||||
if (getMoney() != null)
|
||||
{
|
||||
if (!user.canAfford(getMoney()) && getMoney() > 0)
|
||||
if (!user.canAfford(getMoney()) && getMoney() > 0.0d)
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
@@ -154,17 +165,17 @@ public class Trade
|
||||
}
|
||||
if (getItemStack() != null)
|
||||
{
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, true, itemStack))
|
||||
if (!user.getInventory().containsAtLeast(itemStack, itemStack.getAmount()))
|
||||
{
|
||||
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
|
||||
}
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, true, getItemStack());
|
||||
user.getInventory().removeItem(getItemStack());
|
||||
user.updateInventory();
|
||||
}
|
||||
if (command != null)
|
||||
{
|
||||
final double cost = getCommandCost(user);
|
||||
if (!user.canAfford(cost) && cost > 0)
|
||||
if (!user.canAfford(cost) && cost > 0.0d)
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
@@ -198,16 +209,24 @@ public class Trade
|
||||
|
||||
public Double getCommandCost(final IUser user)
|
||||
{
|
||||
double cost = 0d;
|
||||
if (command != null && !command.isEmpty()
|
||||
&& !user.isAuthorized("essentials.nocommandcost.all")
|
||||
&& !user.isAuthorized("essentials.nocommandcost." + command))
|
||||
double cost = 0.0d;
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
|
||||
if (cost == 0.0 && fallbackCommand != null && !fallbackCommand.isEmpty())
|
||||
if (cost == 0.0d && fallbackTrade != null)
|
||||
{
|
||||
cost = ess.getSettings().getCommandCost(fallbackCommand.charAt(0) == '/' ? fallbackCommand.substring(1) : fallbackCommand);
|
||||
cost = fallbackTrade.getCommandCost(user);
|
||||
}
|
||||
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "calculated command (" + command + ") cost for " + user.getName() + " as " + cost);
|
||||
}
|
||||
}
|
||||
if (cost != 0.0d && (user.isAuthorized("essentials.nocommandcost.all")
|
||||
|| user.isAuthorized("essentials.nocommandcost." + command)))
|
||||
{
|
||||
return 0.0d;
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
@@ -215,6 +234,9 @@ public class Trade
|
||||
|
||||
public static void log(String type, String subtype, String event, String sender, Trade charge, String receiver, Trade pay, Location loc, IEssentials ess)
|
||||
{
|
||||
//isEcoLogUpdateEnabled() - This refers to log entries with no location, ie API updates #EasterEgg
|
||||
//isEcoLogEnabled() - This refers to log entries with with location, ie /pay /sell and eco signs.
|
||||
|
||||
if ((loc == null && !ess.getSettings().isEcoLogUpdateEnabled())
|
||||
|| (loc != null && !ess.getSettings().isEcoLogEnabled()))
|
||||
{
|
||||
|
@@ -11,6 +11,9 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
|
||||
public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
@@ -25,8 +28,11 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
private transient long lastThrottledAction;
|
||||
private transient long lastActivity = System.currentTimeMillis();
|
||||
private boolean hidden = false;
|
||||
private boolean rightClickJump = false;
|
||||
private transient Location afkPosition = null;
|
||||
private boolean invSee = false;
|
||||
private boolean recipeSee = false;
|
||||
private boolean enderSee = false;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
User(final Player base, final IEssentials ess)
|
||||
@@ -60,32 +66,37 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
@Override
|
||||
public boolean isAuthorized(final String node)
|
||||
{
|
||||
final boolean result = isAuthorizedCheck(node);
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "checking if " + base.getName() + " has " + node);
|
||||
ess.getLogger().log(Level.INFO, "checking if " + base.getName() + " has " + node + " - " + result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isAuthorizedCheck(final String node)
|
||||
{
|
||||
|
||||
if (base instanceof OfflinePlayer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isOp())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isJailed())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return ess.getPermissionsHandler().hasPermission(base, node);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ess.getLogger().log(Level.SEVERE, "Permission System Error: " + ess.getPermissionsHandler().getName() + " returned: " + ex.getMessage());
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.SEVERE, "Permission System Error: " + ess.getPermissionsHandler().getName() + " returned: " + ex.getMessage(), ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
ess.getLogger().log(Level.SEVERE, "Permission System Error: " + ess.getPermissionsHandler().getName() + " returned: " + ex.getMessage());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -116,7 +127,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
|
||||
public void giveMoney(final double value, final CommandSender initiator)
|
||||
{
|
||||
if (value == 0)
|
||||
if (value == 0.0d)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -130,7 +141,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
|
||||
public void payUser(final User reciever, final double value) throws Exception
|
||||
{
|
||||
if (value == 0)
|
||||
if (value == 0.0d)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -155,7 +166,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
|
||||
public void takeMoney(final double value, final CommandSender initiator)
|
||||
{
|
||||
if (value == 0)
|
||||
if (value == 0.0d)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -175,6 +186,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
|
||||
public boolean canAfford(final double cost, final boolean permcheck)
|
||||
{
|
||||
if (cost <= 0.0d)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
final double mon = getMoney();
|
||||
if (!permcheck || isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
@@ -233,21 +248,17 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return getHome(getHomes().get(0));
|
||||
}
|
||||
|
||||
public void setHome()
|
||||
{
|
||||
setHome("home", getLocation());
|
||||
}
|
||||
|
||||
public void setHome(final String name)
|
||||
{
|
||||
setHome(name, getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastLocation()
|
||||
{
|
||||
setLastLocation(getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogoutLocation()
|
||||
{
|
||||
setLogoutLocation(getLocation());
|
||||
}
|
||||
|
||||
public void requestTeleport(final User player, final boolean here)
|
||||
{
|
||||
@@ -289,7 +300,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
if (opPrefix != null && opPrefix.toString().length() > 0)
|
||||
{
|
||||
prefix.insert(0, opPrefix.toString());
|
||||
suffix = "§f";
|
||||
suffix = "§r";
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -299,17 +310,18 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
|
||||
if (ess.getSettings().addPrefixSuffix())
|
||||
{
|
||||
//These two extra toggles are not documented, because they are mostly redundant #EasterEgg
|
||||
if (!ess.getSettings().disablePrefix())
|
||||
{
|
||||
final String ptext = ess.getPermissionsHandler().getPrefix(base).replace('&', '§');
|
||||
prefix.insert(0, ptext);
|
||||
suffix = "§f";
|
||||
suffix = "§r";
|
||||
}
|
||||
if (!ess.getSettings().disableSuffix())
|
||||
{
|
||||
final String stext = ess.getPermissionsHandler().getSuffix(base).replace('&', '§');
|
||||
suffix = stext + "§f";
|
||||
suffix = suffix.replace("§f§f", "§f");
|
||||
suffix = stext + "§r";
|
||||
suffix = suffix.replace("§f§f", "§f").replace("§f§r", "§r").replace("§r§r", "§r");
|
||||
}
|
||||
}
|
||||
final String strPrefix = prefix.toString();
|
||||
@@ -484,6 +496,13 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
getTeleport().respawn(null, TeleportCause.PLUGIN);
|
||||
}
|
||||
catch (Exception ex1)
|
||||
{
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -517,13 +536,17 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
|
||||
public void updateActivity(final boolean broadcast)
|
||||
{
|
||||
if (isAfk())
|
||||
if (isAfk() && ess.getSettings().cancelAfkOnInteract())
|
||||
{
|
||||
setAfk(false);
|
||||
if (broadcast && !isHidden())
|
||||
{
|
||||
setDisplayNick();
|
||||
ess.broadcastMessage(this, _("userIsNotAway", getDisplayName()));
|
||||
final String msg = _("userIsNotAway", getDisplayName());
|
||||
if (!msg.isEmpty())
|
||||
{
|
||||
ess.broadcastMessage(this, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
lastActivity = System.currentTimeMillis();
|
||||
@@ -550,13 +573,17 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
}
|
||||
}
|
||||
final long autoafk = ess.getSettings().getAutoAfk();
|
||||
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis() && isAuthorized("essentials.afk"))
|
||||
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis() && isAuthorized("essentials.afk.auto"))
|
||||
{
|
||||
setAfk(true);
|
||||
if (!isHidden())
|
||||
{
|
||||
setDisplayNick();
|
||||
ess.broadcastMessage(this, _("userIsAway", getDisplayName()));
|
||||
final String msg = _("userIsAway", getDisplayName());
|
||||
if (!msg.isEmpty())
|
||||
{
|
||||
ess.broadcastMessage(this, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -612,6 +639,16 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
{
|
||||
invSee = set;
|
||||
}
|
||||
|
||||
public boolean isEnderSee()
|
||||
{
|
||||
return enderSee;
|
||||
}
|
||||
|
||||
public void setEnderSee(final boolean set)
|
||||
{
|
||||
enderSee = set;
|
||||
}
|
||||
private transient long teleportInvulnerabilityTimestamp = 0;
|
||||
|
||||
public void enableInvulnerabilityAfterTeleport()
|
||||
@@ -656,6 +693,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
}
|
||||
setHidden(true);
|
||||
ess.getVanishedPlayers().add(getName());
|
||||
if (isAuthorized("essentials.vanish.effect"))
|
||||
{
|
||||
this.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -665,6 +706,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
}
|
||||
setHidden(false);
|
||||
ess.getVanishedPlayers().remove(getName());
|
||||
if (isAuthorized("essentials.vanish.effect"))
|
||||
{
|
||||
this.removePotionEffect(PotionEffectType.INVISIBILITY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -694,4 +739,30 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
{
|
||||
lastThrottledAction = System.currentTimeMillis();;
|
||||
}
|
||||
|
||||
public boolean isFlyClickJump()
|
||||
{
|
||||
return rightClickJump;
|
||||
}
|
||||
|
||||
public void setRightClickJump(boolean rightClickJump)
|
||||
{
|
||||
this.rightClickJump = rightClickJump;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgnoreExempt()
|
||||
{
|
||||
return this.isAuthorized("essentials.chat.ignoreexempt");
|
||||
}
|
||||
|
||||
public boolean isRecipeSee()
|
||||
{
|
||||
return recipeSee;
|
||||
}
|
||||
|
||||
public void setRecipeSee(boolean recipeSee)
|
||||
{
|
||||
this.recipeSee = recipeSee;
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import static com.earth2me.essentials.I18n._;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -11,13 +12,14 @@ import org.bukkit.inventory.ItemStack;
|
||||
public abstract class UserData extends PlayerExtension implements IConf
|
||||
{
|
||||
protected final transient IEssentials ess;
|
||||
private final EssentialsConf config;
|
||||
private EssentialsConf config;
|
||||
private final File folder;
|
||||
|
||||
protected UserData(Player base, IEssentials ess)
|
||||
{
|
||||
super(base);
|
||||
this.ess = ess;
|
||||
File folder = new File(ess.getDataFolder(), "userdata");
|
||||
folder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!folder.exists())
|
||||
{
|
||||
folder.mkdirs();
|
||||
@@ -26,6 +28,13 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
public final void reset()
|
||||
{
|
||||
config.getFile().delete();
|
||||
config = new EssentialsConf(new File(folder, Util.sanitizeFileName(base.getName()) + ".yml"));
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void reloadConfig()
|
||||
{
|
||||
@@ -39,23 +48,24 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
lastHealTimestamp = _getLastHealTimestamp();
|
||||
jail = _getJail();
|
||||
mails = _getMails();
|
||||
teleportEnabled = getTeleportEnabled();
|
||||
ignoredPlayers = getIgnoredPlayers();
|
||||
teleportEnabled = _getTeleportEnabled();
|
||||
godmode = _getGodModeEnabled();
|
||||
muted = getMuted();
|
||||
muted = _getMuted();
|
||||
muteTimeout = _getMuteTimeout();
|
||||
jailed = getJailed();
|
||||
jailed = _getJailed();
|
||||
jailTimeout = _getJailTimeout();
|
||||
lastLogin = _getLastLogin();
|
||||
lastLogout = _getLastLogout();
|
||||
lastLoginAddress = _getLastLoginAddress();
|
||||
afk = getAfk();
|
||||
afk = _getAfk();
|
||||
geolocation = _getGeoLocation();
|
||||
isSocialSpyEnabled = _isSocialSpyEnabled();
|
||||
isNPC = _isNPC();
|
||||
arePowerToolsEnabled = _arePowerToolsEnabled();
|
||||
kitTimestamps = _getKitTimestamps();
|
||||
nickname = _getNickname();
|
||||
setIgnoredPlayers(_getIgnoredPlayers());
|
||||
logoutLocation = _getLogoutLocation();
|
||||
}
|
||||
private double money;
|
||||
|
||||
@@ -99,26 +109,25 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
public Location getHome(String name) throws Exception
|
||||
private String getHomeName(String search)
|
||||
{
|
||||
Location loc = config.getLocation("homes." + name, getServer());
|
||||
if (loc == null)
|
||||
if (Util.isInt(search))
|
||||
{
|
||||
try
|
||||
{
|
||||
loc = config.getLocation("homes." + getHomes().get(Integer.parseInt(name) - 1), getServer());
|
||||
search = getHomes().get(Integer.parseInt(search) - 1);
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return loc;
|
||||
return search;
|
||||
}
|
||||
|
||||
public Location getHome(String name) throws Exception
|
||||
{
|
||||
String search = getHomeName(name);
|
||||
return config.getLocation("homes." + search, getServer());
|
||||
}
|
||||
|
||||
public Location getHome(final Location world)
|
||||
@@ -152,7 +161,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
public void setHome(String name, Location loc)
|
||||
{
|
||||
//Invalid names will corrupt the yaml
|
||||
name = Util.sanitizeFileName(name);
|
||||
name = Util.safeString(name);
|
||||
homes.put(name, loc);
|
||||
config.setProperty("homes." + name, loc);
|
||||
config.save();
|
||||
@@ -160,20 +169,20 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
public void delHome(String name) throws Exception
|
||||
{
|
||||
String search = name;
|
||||
String search = getHomeName(name);
|
||||
if (!homes.containsKey(search))
|
||||
{
|
||||
search = Util.sanitizeFileName(name);
|
||||
search = Util.safeString(search);
|
||||
}
|
||||
if (homes.containsKey(search))
|
||||
{
|
||||
homes.remove(name);
|
||||
config.removeProperty("homes." + name);
|
||||
homes.remove(search);
|
||||
config.removeProperty("homes." + search);
|
||||
config.save();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("invalidHome", name));
|
||||
throw new Exception(_("invalidHome", search));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,6 +319,37 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("lastlocation", loc);
|
||||
config.save();
|
||||
}
|
||||
|
||||
private Location logoutLocation;
|
||||
|
||||
private Location _getLogoutLocation()
|
||||
{
|
||||
try
|
||||
{
|
||||
return config.getLocation("logoutlocation", getServer());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Location getLogoutLocation()
|
||||
{
|
||||
return logoutLocation;
|
||||
}
|
||||
|
||||
public void setLogoutLocation(Location loc)
|
||||
{
|
||||
if (loc == null || loc.getWorld() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
logoutLocation = loc;
|
||||
config.setProperty("logoutlocation", loc);
|
||||
config.save();
|
||||
}
|
||||
|
||||
private long lastTeleportTimestamp;
|
||||
|
||||
private long _getLastTeleportTimestamp()
|
||||
@@ -406,7 +446,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
}
|
||||
private boolean teleportEnabled;
|
||||
|
||||
private boolean getTeleportEnabled()
|
||||
private boolean _getTeleportEnabled()
|
||||
{
|
||||
return config.getBoolean("teleportenabled", true);
|
||||
}
|
||||
@@ -438,7 +478,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
}
|
||||
private List<String> ignoredPlayers;
|
||||
|
||||
public List<String> getIgnoredPlayers()
|
||||
public List<String> _getIgnoredPlayers()
|
||||
{
|
||||
return Collections.synchronizedList(config.getStringList("ignore"));
|
||||
}
|
||||
@@ -471,7 +511,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
public boolean isIgnoredPlayer(IUser user)
|
||||
{
|
||||
return (ignoredPlayers.contains(user.getName().toLowerCase(Locale.ENGLISH)) && !user.isAuthorized("essentials.chat.ignoreexempt"));
|
||||
return (ignoredPlayers.contains(user.getName().toLowerCase(Locale.ENGLISH)) && !user.isIgnoreExempt());
|
||||
}
|
||||
|
||||
public void setIgnoredPlayer(IUser user, boolean set)
|
||||
@@ -506,10 +546,15 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
}
|
||||
private boolean muted;
|
||||
|
||||
public boolean getMuted()
|
||||
public boolean _getMuted()
|
||||
{
|
||||
return config.getBoolean("muted", false);
|
||||
}
|
||||
|
||||
public boolean getMuted()
|
||||
{
|
||||
return muted;
|
||||
}
|
||||
|
||||
public boolean isMuted()
|
||||
{
|
||||
@@ -542,7 +587,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
}
|
||||
private boolean jailed;
|
||||
|
||||
private boolean getJailed()
|
||||
private boolean _getJailed()
|
||||
{
|
||||
return config.getBoolean("jailed", false);
|
||||
}
|
||||
@@ -626,7 +671,10 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
public void setLastLogin(long time)
|
||||
{
|
||||
_setLastLogin(time);
|
||||
_setLastLoginAddress(base.getAddress().getAddress().getHostAddress());
|
||||
if (base.getAddress() != null && base.getAddress().getAddress() != null)
|
||||
{
|
||||
_setLastLoginAddress(base.getAddress().getAddress().getHostAddress());
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
private long lastLogout;
|
||||
@@ -666,7 +714,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
}
|
||||
private boolean afk;
|
||||
|
||||
private boolean getAfk()
|
||||
private boolean _getAfk()
|
||||
{
|
||||
return config.getBoolean("afk", false);
|
||||
}
|
||||
@@ -777,22 +825,39 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
{
|
||||
return config.getBoolean("powertoolsenabled", true);
|
||||
}
|
||||
private Map<String, Object> kitTimestamps;
|
||||
|
||||
private Map<String, Object> _getKitTimestamps()
|
||||
private Map<String, Long> kitTimestamps;
|
||||
|
||||
private Map<String, Long> _getKitTimestamps()
|
||||
{
|
||||
|
||||
|
||||
if (config.isConfigurationSection("timestamps.kits"))
|
||||
{
|
||||
return config.getConfigurationSection("timestamps.kits").getValues(false);
|
||||
final ConfigurationSection section = config.getConfigurationSection("timestamps.kits");
|
||||
final Map<String, Long> timestamps = new HashMap<String, Long>();
|
||||
for (String command : section.getKeys(false))
|
||||
{
|
||||
if (section.isLong(command))
|
||||
{
|
||||
timestamps.put(command.toLowerCase(Locale.ENGLISH), section.getLong(command));
|
||||
}
|
||||
else if (section.isInt(command))
|
||||
{
|
||||
timestamps.put(command.toLowerCase(Locale.ENGLISH), (long)section.getInt(command));
|
||||
}
|
||||
}
|
||||
return timestamps;
|
||||
}
|
||||
return new HashMap<String, Object>();
|
||||
return new HashMap<String, Long>();
|
||||
}
|
||||
|
||||
public Long getKitTimestamp(final String name)
|
||||
|
||||
public long getKitTimestamp(String name)
|
||||
{
|
||||
final Number num = (Number)kitTimestamps.get(name.toLowerCase(Locale.ENGLISH));
|
||||
return num == null ? null : num.longValue();
|
||||
name = name.replace('.', '_').replace('/', '_');
|
||||
if (kitTimestamps != null && kitTimestamps.containsKey(name))
|
||||
{
|
||||
return kitTimestamps.get(name);
|
||||
}
|
||||
return 0l;
|
||||
}
|
||||
|
||||
public void setKitTimestamp(final String name, final long time)
|
||||
|
@@ -27,7 +27,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
|
||||
|
||||
private void loadAllUsersAsync(final IEssentials ess)
|
||||
{
|
||||
ess.scheduleAsyncDelayedTask(new Runnable()
|
||||
ess.runTaskAsynchronously(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
|
@@ -24,12 +24,19 @@ public class Util
|
||||
private final static Pattern INVALIDFILECHARS = Pattern.compile("[^a-z0-9]");
|
||||
private final static Pattern INVALIDCHARS = Pattern.compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");
|
||||
|
||||
//Used to clean file names before saving to disk
|
||||
public static String sanitizeFileName(final String name)
|
||||
{
|
||||
final String newName = INVALIDFILECHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_");
|
||||
return newName;
|
||||
return safeString(name);
|
||||
}
|
||||
|
||||
//Used to clean strings/names before saving as filenames/permissions
|
||||
public static String safeString(final String string)
|
||||
{
|
||||
return INVALIDFILECHARS.matcher(string.toLowerCase(Locale.ENGLISH)).replaceAll("_");
|
||||
}
|
||||
|
||||
//Less restrictive string sanitizing, when not used as perm or filename
|
||||
public static String sanitizeString(final String string)
|
||||
{
|
||||
return INVALIDCHARS.matcher(string).replaceAll("");
|
||||
@@ -288,6 +295,7 @@ public class Util
|
||||
public final static int RADIUS = 3;
|
||||
public final static Vector3D[] VOLUME;
|
||||
|
||||
|
||||
public static class Vector3D
|
||||
{
|
||||
public Vector3D(int x, int y, int z)
|
||||
@@ -397,6 +405,15 @@ public class Util
|
||||
}
|
||||
|
||||
public static boolean isBlockUnsafe(final World world, final int x, final int y, final int z)
|
||||
{
|
||||
if (isBlockDamaging(world, x, y, z))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return isBlockAboveAir(world, x, y, z);
|
||||
}
|
||||
|
||||
public static boolean isBlockDamaging(final World world, final int x, final int y, final int z)
|
||||
{
|
||||
final Block below = world.getBlockAt(x, y - 1, z);
|
||||
if (below.getType() == Material.LAVA || below.getType() == Material.STATIONARY_LAVA)
|
||||
@@ -419,7 +436,7 @@ public class Util
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return isBlockAboveAir(world, x, y, z);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ItemStack convertBlockToItem(final Block block)
|
||||
@@ -587,7 +604,8 @@ public class Util
|
||||
return input.substring(pos, pos + 2);
|
||||
}
|
||||
private static transient final Pattern URL_PATTERN = Pattern.compile("((?:(?:https?)://)?[\\w-_\\.]{2,})\\.([a-z]{2,3}(?:/\\S+)?)");
|
||||
private static transient final Pattern VANILLA_PATTERN = Pattern.compile("\u00A7+[0-9A-FK-ORa-fk-or]");
|
||||
private static transient final Pattern VANILLA_PATTERN = Pattern.compile("\u00A7+[0-9A-FK-ORa-fk-or]?");
|
||||
private static transient final Pattern LOGCOLOR_PATTERN = Pattern.compile("\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]");
|
||||
private static transient final Pattern REPLACE_PATTERN = Pattern.compile("&([0-9a-fk-or])");
|
||||
private static transient final Pattern VANILLA_COLOR_PATTERN = Pattern.compile("\u00A7+[0-9A-Fa-f]");
|
||||
private static transient final Pattern VANILLA_MAGIC_PATTERN = Pattern.compile("\u00A7+[Kk]");
|
||||
@@ -596,6 +614,7 @@ public class Util
|
||||
private static transient final Pattern REPLACE_MAGIC_PATTERN = Pattern.compile("&(k)");
|
||||
private static transient final Pattern REPLACE_FORMAT_PATTERN = Pattern.compile("&([l-or])");
|
||||
|
||||
//This method is used to simply strip the native minecraft colour codes
|
||||
public static String stripFormat(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
@@ -605,6 +624,16 @@ public class Util
|
||||
return VANILLA_PATTERN.matcher(input).replaceAll("");
|
||||
}
|
||||
|
||||
public static String stripLogColorFormat(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return LOGCOLOR_PATTERN.matcher(input).replaceAll("");
|
||||
}
|
||||
|
||||
//This method is used to simply replace the ess colour codes with minecraft ones, ie &c
|
||||
public static String replaceFormat(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
@@ -614,20 +643,7 @@ public class Util
|
||||
return REPLACE_PATTERN.matcher(input).replaceAll("\u00a7$1");
|
||||
}
|
||||
|
||||
public static String blockURL(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String text = URL_PATTERN.matcher(input).replaceAll("$1 $2");
|
||||
while (URL_PATTERN.matcher(text).find())
|
||||
{
|
||||
text = URL_PATTERN.matcher(text).replaceAll("$1 $2");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
//This is the general permission sensitive message format function, does not touch urls.
|
||||
public static String formatString(final IUser user, final String permBase, final String input)
|
||||
{
|
||||
if (input == null)
|
||||
@@ -662,6 +678,7 @@ public class Util
|
||||
return message;
|
||||
}
|
||||
|
||||
//This is the general permission sensitive message format function, checks for urls.
|
||||
public static String formatMessage(final IUser user, final String permBase, final String input)
|
||||
{
|
||||
if (input == null)
|
||||
@@ -675,6 +692,20 @@ public class Util
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
private static String blockURL(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String text = URL_PATTERN.matcher(input).replaceAll("$1 $2");
|
||||
while (URL_PATTERN.matcher(text).find())
|
||||
{
|
||||
text = URL_PATTERN.matcher(text).replaceAll("$1 $2");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
private static String stripColor(final String input, final Pattern pattern)
|
||||
{
|
||||
|
@@ -3,6 +3,7 @@ package com.earth2me.essentials;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.commands.WarpNotFoundException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -70,7 +71,14 @@ public class Warps implements IConf
|
||||
}
|
||||
conf.setProperty(null, loc);
|
||||
conf.setProperty("name", name);
|
||||
conf.save();
|
||||
try
|
||||
{
|
||||
conf.saveWithError();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
throw new IOException(_("invalidWarpName"));
|
||||
}
|
||||
}
|
||||
|
||||
public void delWarp(String name) throws Exception
|
||||
|
@@ -8,7 +8,6 @@ import com.earth2me.essentials.Util;
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
/**
|
||||
@@ -72,17 +71,7 @@ public final class Economy
|
||||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
}
|
||||
User user;
|
||||
Player player = ess.getServer().getPlayer(name);
|
||||
if (player != null)
|
||||
{
|
||||
user = ess.getUser(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
user = ess.getOfflineUser(name);
|
||||
}
|
||||
return user;
|
||||
return ess.getUser(name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,10 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.util.Map;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
|
||||
|
||||
public interface IAlternativeCommandsHandler
|
||||
{
|
||||
Map<String, String> disabledCommands();
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.perm.IPermissionsHandler;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public interface IEssentials extends Plugin, IReload
|
||||
{
|
||||
void addReloadListener(IReload listener);
|
||||
|
||||
IUser getUser(Object base);
|
||||
|
||||
int broadcastMessage(IUser sender, String message);
|
||||
|
||||
II18n getI18n();
|
||||
|
||||
ISettings getSettings();
|
||||
|
||||
IJails getJail();
|
||||
|
||||
IWarps getWarps();
|
||||
|
||||
IWorth getWorth();
|
||||
|
||||
IItemDb getItemDb();
|
||||
|
||||
IUserMap getUserMap();
|
||||
|
||||
IEssentialsEconomy getEconomy();
|
||||
|
||||
World getWorld(String name);
|
||||
|
||||
Methods getPaymentMethod();
|
||||
|
||||
int scheduleAsyncDelayedTask(Runnable run);
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run);
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run, long delay);
|
||||
|
||||
int scheduleSyncRepeatingTask(Runnable run, long delay, long period);
|
||||
|
||||
IPermissionsHandler getPermissionsHandler();
|
||||
|
||||
IAlternativeCommandsHandler getAlternativeCommandsHandler();
|
||||
|
||||
void showCommandError(CommandSender sender, String commandLabel, Throwable exception);
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
|
||||
public interface IEssentialsEconomy
|
||||
{
|
||||
double getMoney(String name) throws UserDoesNotExistException;
|
||||
|
||||
void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
void add(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
void subtract(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
void divide(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
void multiply(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
boolean hasEnough(String name, double amount) throws UserDoesNotExistException;
|
||||
|
||||
boolean hasMore(String name, double amount) throws UserDoesNotExistException;
|
||||
|
||||
boolean hasLess(String name, double amount) throws UserDoesNotExistException;
|
||||
|
||||
boolean isNegative(String name) throws UserDoesNotExistException;
|
||||
|
||||
String format(double amount);
|
||||
|
||||
boolean playerExists(String name);
|
||||
|
||||
boolean isNPC(String name) throws UserDoesNotExistException;
|
||||
|
||||
boolean createNPC(String name);
|
||||
|
||||
void removeNPC(String name) throws UserDoesNotExistException;
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.settings.Settings;
|
||||
import com.earth2me.essentials.storage.IStorageObjectHolder;
|
||||
|
||||
|
||||
public interface ISettings extends IStorageObjectHolder<Settings>
|
||||
{
|
||||
|
||||
}
|
@@ -1,43 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public interface IUser extends Player, IReload
|
||||
{
|
||||
long getLastTeleportTimestamp();
|
||||
|
||||
boolean isAuthorized(String node);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
|
||||
|
||||
void setLastTeleportTimestamp(long time);
|
||||
|
||||
Location getLastLocation();
|
||||
|
||||
Player getBase();
|
||||
|
||||
double getMoney();
|
||||
|
||||
void takeMoney(double value);
|
||||
|
||||
void giveMoney(double value);
|
||||
|
||||
String getGroup();
|
||||
|
||||
void setLastLocation();
|
||||
|
||||
Location getHome(String name) throws Exception;
|
||||
|
||||
Location getHome(Location loc) throws Exception;
|
||||
|
||||
boolean isHidden();
|
||||
|
||||
ITeleport getTeleport();
|
||||
|
||||
void setJail(String jail);
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public interface IUserMap
|
||||
{
|
||||
boolean userExists(final String name);
|
||||
|
||||
IUser getUser(final String name);
|
||||
|
||||
void removeUser(final String name);
|
||||
|
||||
Set<String> getAllUniqueUsers();
|
||||
|
||||
int getUniqueUsers();
|
||||
|
||||
File getUserFile(final String name);
|
||||
}
|
@@ -1,16 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.util.Collection;
|
||||
import org.bukkit.Location;
|
||||
|
||||
|
||||
public interface IWarps extends IReload
|
||||
{
|
||||
Location getWarp(String warp) throws Exception;
|
||||
|
||||
Collection<String> getWarps();
|
||||
|
||||
void removeWarp(String name) throws Exception;
|
||||
|
||||
void setWarp(String name, Location loc) throws Exception;
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public interface IWorth extends IReload
|
||||
{
|
||||
double getPrice(ItemStack itemStack);
|
||||
|
||||
void setPrice(ItemStack itemStack, double price);
|
||||
}
|
@@ -32,12 +32,13 @@ public class Commandafk extends EssentialsCommand
|
||||
private void toggleAfk(User user)
|
||||
{
|
||||
user.setDisplayNick();
|
||||
String msg = "";
|
||||
if (!user.toggleAfk())
|
||||
{
|
||||
//user.sendMessage(_("markedAsNotAway"));
|
||||
if (!user.isHidden())
|
||||
{
|
||||
ess.broadcastMessage(user, _("userIsNotAway", user.getDisplayName()));
|
||||
msg = _("userIsNotAway", user.getDisplayName());
|
||||
}
|
||||
user.updateActivity(false);
|
||||
}
|
||||
@@ -46,8 +47,12 @@ public class Commandafk extends EssentialsCommand
|
||||
//user.sendMessage(_("markedAsAway"));
|
||||
if (!user.isHidden())
|
||||
{
|
||||
ess.broadcastMessage(user, _("userIsAway", user.getDisplayName()));
|
||||
msg = _("userIsAway", user.getDisplayName());
|
||||
}
|
||||
}
|
||||
if (!msg.isEmpty())
|
||||
{
|
||||
ess.broadcastMessage(user, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
||||
|
||||
// This command has a in theme message that only shows if you supply a parameter #EasterEgg
|
||||
public class Commandantioch extends EssentialsCommand
|
||||
{
|
||||
public Commandantioch()
|
||||
|
@@ -17,9 +17,9 @@ public class Commandback extends EssentialsCommand
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (user.getWorld() != user.getLastLocation().getWorld() && ess.getSettings().isWorldTeleportPermissions()
|
||||
&& !user.isAuthorized("essentials.world." + user.getLastLocation().getWorld().getName()))
|
||||
&& !user.isAuthorized("essentials.worlds." + user.getLastLocation().getWorld().getName()))
|
||||
{
|
||||
throw new Exception(_("noPerm", "essentials.world." + user.getLastLocation().getWorld().getName()));
|
||||
throw new Exception(_("noPerm", "essentials.worlds." + user.getLastLocation().getWorld().getName()));
|
||||
}
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
|
@@ -27,6 +27,7 @@ public class Commandbalance extends EssentialsCommand
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
//TODO: Remove 'other' perm
|
||||
final double bal = (args.length < 1
|
||||
|| !(user.isAuthorized("essentials.balance.others")
|
||||
|| user.isAuthorized("essentials.balance.other"))
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.textreader.ArrayListInput;
|
||||
import com.earth2me.essentials.textreader.TextPager;
|
||||
@@ -12,7 +12,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
//TODO: Remove op and replace with perm
|
||||
public class Commandbalancetop extends EssentialsCommand
|
||||
{
|
||||
public Commandbalancetop()
|
||||
@@ -63,7 +63,7 @@ public class Commandbalancetop extends EssentialsCommand
|
||||
{
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
ess.scheduleAsyncDelayedTask(new Viewer(sender, page, force));
|
||||
ess.runTaskAsynchronously(new Viewer(sender, page, force));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -71,7 +71,7 @@ public class Commandbalancetop extends EssentialsCommand
|
||||
{
|
||||
sender.sendMessage(_("orderBalances", ess.getUserMap().getUniqueUsers()));
|
||||
}
|
||||
ess.scheduleAsyncDelayedTask(new Viewer(sender, page, force));
|
||||
ess.runTaskAsynchronously(new Viewer(sender, page, force));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class Commandbalancetop extends EssentialsCommand
|
||||
cal.setTimeInMillis(cacheage);
|
||||
final DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
sender.sendMessage(_("balanceTop", format.format(cal.getTime())));
|
||||
new TextPager(cache).showPage(Integer.toString(page), "", "balancetop", sender);
|
||||
new TextPager(cache).showPage(Integer.toString(page), null, "balancetop", sender);
|
||||
}
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ public class Commandbalancetop extends EssentialsCommand
|
||||
{
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
ess.scheduleAsyncDelayedTask(viewer);
|
||||
ess.runTaskAsynchronously(viewer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ public class Commandbalancetop extends EssentialsCommand
|
||||
{
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
ess.scheduleAsyncDelayedTask(new Calculator(new Viewer(sender, page, force), force));
|
||||
ess.runTaskAsynchronously(new Calculator(new Viewer(sender, page, force), force));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,10 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Console;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.OfflinePlayer;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -18,11 +21,21 @@ public class Commandban extends EssentialsCommand
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
boolean nomatch = false;
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
final User user = getPlayer(server, args, 0, true);
|
||||
User user;
|
||||
try
|
||||
{
|
||||
user = getPlayer(server, args, 0, true);
|
||||
}
|
||||
catch (NoSuchFieldException e)
|
||||
{
|
||||
nomatch = true;
|
||||
user = ess.getUser(new OfflinePlayer(args[0], ess));
|
||||
}
|
||||
if (!user.isOnline())
|
||||
{
|
||||
if (sender instanceof Player
|
||||
@@ -34,32 +47,39 @@ public class Commandban extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user.isAuthorized("essentials.ban.exempt"))
|
||||
if (user.isAuthorized("essentials.ban.exempt") && sender instanceof Player)
|
||||
{
|
||||
sender.sendMessage(_("banExempt"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
String banReason;
|
||||
if (args.length > 1)
|
||||
{
|
||||
banReason = _("banFormat", getFinalArg(args, 1), senderName);
|
||||
banReason = Util.replaceFormat(getFinalArg(args, 1).replace("\\n", "\n").replace("|", "\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
banReason = _("banFormat", _("defaultBanReason"), senderName);
|
||||
banReason = _("defaultBanReason");
|
||||
}
|
||||
|
||||
user.setBanReason(banReason);
|
||||
|
||||
user.setBanReason(_("banFormat", banReason, senderName));
|
||||
user.setBanned(true);
|
||||
user.kickPlayer(banReason);
|
||||
user.setBanTimeout(0);
|
||||
user.kickPlayer(_("banFormat", banReason, senderName));
|
||||
|
||||
server.getLogger().log(Level.INFO, _("playerBanned", senderName, user.getName(), banReason));
|
||||
|
||||
if (nomatch) {
|
||||
sender.sendMessage(_("userUnknown", args[0]));
|
||||
}
|
||||
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final User player = ess.getUser(onlinePlayer);
|
||||
if (player.isAuthorized("essentials.ban.notify"))
|
||||
if (onlinePlayer == sender || player.isAuthorized("essentials.ban.notify"))
|
||||
{
|
||||
onlinePlayer.sendMessage(_("playerBanned", senderName, user.getName(), banReason));
|
||||
}
|
||||
|
@@ -0,0 +1,92 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
|
||||
|
||||
public class Commandbook extends EssentialsCommand
|
||||
{
|
||||
public Commandbook()
|
||||
{
|
||||
super("book");
|
||||
}
|
||||
|
||||
//TODO: Translate this
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final ItemStack item = user.getItemInHand();
|
||||
final String player = user.getName();
|
||||
if (item.getType() == Material.WRITTEN_BOOK)
|
||||
{
|
||||
BookMeta bmeta = (BookMeta)item.getItemMeta();
|
||||
|
||||
if (args.length > 1 && args[0].equalsIgnoreCase("author"))
|
||||
{
|
||||
if (user.isAuthorized("essentals.book.author"))
|
||||
{
|
||||
bmeta.setAuthor(args[1]);
|
||||
item.setItemMeta(bmeta);
|
||||
user.sendMessage(_("bookAuthorSet", getFinalArg(args, 1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("denyChangeAuthor"));
|
||||
}
|
||||
}
|
||||
else if (args.length > 1 && args[0].equalsIgnoreCase("title"))
|
||||
{
|
||||
if (user.isAuthorized("essentials.book.title") && (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others")))
|
||||
{
|
||||
bmeta.setTitle(args[1]);
|
||||
item.setItemMeta(bmeta);
|
||||
user.sendMessage(_("bookTitleSet", getFinalArg(args, 1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("denyChangeTitle"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others"))
|
||||
{
|
||||
ItemStack newItem = new ItemStack(Material.BOOK_AND_QUILL, item.getAmount());
|
||||
newItem.setItemMeta(bmeta);
|
||||
user.setItemInHand(newItem);
|
||||
user.sendMessage(_("editBookContents"));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("denyBookEdit"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (item.getType() == Material.BOOK_AND_QUILL)
|
||||
{
|
||||
BookMeta bmeta = (BookMeta)item.getItemMeta();
|
||||
if (!user.isAuthorized("essentals.book.author"))
|
||||
{
|
||||
bmeta.setAuthor(player);
|
||||
}
|
||||
ItemStack newItem = new ItemStack(Material.WRITTEN_BOOK, item.getAmount());
|
||||
newItem.setItemMeta(bmeta);
|
||||
user.setItemInHand(newItem);
|
||||
user.sendMessage(_("bookLocked"));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("holdBook"));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isAuthor(BookMeta bmeta, String player)
|
||||
{
|
||||
String author = bmeta.getAuthor();
|
||||
return author != null && author.equalsIgnoreCase(player);
|
||||
}
|
||||
}
|
@@ -2,13 +2,10 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Commandbreak extends EssentialsCommand
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -13,6 +14,17 @@ public class Commandbroadcast extends EssentialsCommand
|
||||
super("broadcast");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
ess.broadcastMessage(null, _("broadcast", Util.replaceFormat(getFinalArg(args, 0)), user.getDisplayName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
@@ -21,6 +33,6 @@ public class Commandbroadcast extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
ess.broadcastMessage(null, _("broadcast", Util.replaceFormat(getFinalArg(args, 0))));
|
||||
ess.broadcastMessage(null, _("broadcast", Util.replaceFormat(getFinalArg(args, 0)), sender.getName()));
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,12 @@ public class Commandburn extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
//TODO: TL this
|
||||
if (args[0].trim().length() < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException("You need to specify a player to burn.");
|
||||
}
|
||||
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
{
|
||||
|
@@ -2,10 +2,12 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.List;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Commandclearinventory extends EssentialsCommand
|
||||
@@ -21,78 +23,134 @@ public class Commandclearinventory extends EssentialsCommand
|
||||
{
|
||||
if (args.length > 0 && user.isAuthorized("essentials.clearinventory.others"))
|
||||
{
|
||||
//TODO: Fix fringe user match case.
|
||||
if (args[0].length() >= 3)
|
||||
if (args[0].contentEquals("*") && user.isAuthorized("essentials.clearinventory.all"))
|
||||
{
|
||||
List<Player> online = server.matchPlayer(args[0]);
|
||||
|
||||
if (!online.isEmpty())
|
||||
{
|
||||
for (Player p : online)
|
||||
{
|
||||
p.getInventory().clear();
|
||||
user.sendMessage(_("inventoryClearedOthers", p.getDisplayName()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new Exception(_("playerNotFound"));
|
||||
cleanInventoryAll(server, user, args);
|
||||
}
|
||||
else if (args[0].trim().length() < 2)
|
||||
{
|
||||
cleanInventorySelf(server, user, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
Player p = server.getPlayer(args[0]);
|
||||
if (p != null)
|
||||
{
|
||||
p.getInventory().clear();
|
||||
user.sendMessage(_("inventoryClearedOthers", p.getDisplayName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
cleanInventoryOthers(server, user, args);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
user.getInventory().clear();
|
||||
user.sendMessage(_("inventoryCleared"));
|
||||
cleanInventorySelf(server, user, args);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
if (args.length > 0)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
if (args[0].length() >= 3)
|
||||
{
|
||||
List<Player> online = server.matchPlayer(args[0]);
|
||||
|
||||
if (!online.isEmpty())
|
||||
if (args[0].contentEquals("*"))
|
||||
{
|
||||
for (Player p : online)
|
||||
{
|
||||
p.getInventory().clear();
|
||||
sender.sendMessage(_("inventoryClearedOthers", p.getDisplayName()));
|
||||
}
|
||||
return;
|
||||
cleanInventoryAll(server, sender, args);
|
||||
}
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Player u = server.getPlayer(args[0]);
|
||||
if (u != null)
|
||||
{
|
||||
u.getInventory().clear();
|
||||
sender.sendMessage(_("inventoryClearedOthers", u.getDisplayName()));
|
||||
}
|
||||
else
|
||||
else if (args[0].trim().length() < 2)
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
else
|
||||
{
|
||||
cleanInventoryOthers(server, sender, args);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanInventoryAll(Server server, CommandSender sender, String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 1)
|
||||
{
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
clearInventory(onlinePlayer, args[1]);
|
||||
}
|
||||
sender.sendMessage("Cleared everyone's inventory");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanInventoryOthers(Server server, CommandSender user, String[] args) throws Exception
|
||||
{
|
||||
List<Player> online = server.matchPlayer(args[0]);
|
||||
|
||||
if (!online.isEmpty())
|
||||
{
|
||||
for (Player p : online)
|
||||
{
|
||||
if (args.length > 1)
|
||||
{
|
||||
clearInventory(p, args[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
p.getInventory().clear();
|
||||
}
|
||||
user.sendMessage(_("inventoryClearedOthers", p.getDisplayName()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanInventorySelf(Server server, User user, String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0)
|
||||
{
|
||||
clearInventory(user, args[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.getInventory().clear();
|
||||
}
|
||||
user.sendMessage(_("inventoryCleared"));
|
||||
}
|
||||
|
||||
private void clearInventory(Player player, String arg) throws Exception
|
||||
{
|
||||
if (arg.equalsIgnoreCase("*"))
|
||||
{
|
||||
player.getInventory().clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
final String[] split = arg.split(":");
|
||||
final ItemStack item = ess.getItemDb().get(split[0]);
|
||||
final int type = item.getTypeId();
|
||||
|
||||
if (split.length > 1 && Util.isInt(split[1]))
|
||||
{
|
||||
player.getInventory().clear(type, Integer.parseInt(split[1]));
|
||||
}
|
||||
else if (split.length > 1 && split[1].equalsIgnoreCase("*"))
|
||||
{
|
||||
player.getInventory().clear(type, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Util.isInt(split[0]))
|
||||
{
|
||||
player.getInventory().clear(type, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.getInventory().clear(type, item.getDurability());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -50,10 +50,10 @@ public class Commanddelhome extends EssentialsCommand
|
||||
{
|
||||
name = expandedArg[0];
|
||||
}
|
||||
//TODO: Think up a nice error message
|
||||
/*
|
||||
* if (name.equalsIgnoreCase("bed")) { throw new Exception("You cannot remove the vanilla home point"); }
|
||||
*/
|
||||
|
||||
|
||||
if (name.equalsIgnoreCase("bed")) { throw new Exception(_("invalidHomeName")); }
|
||||
|
||||
user.delHome(name.toLowerCase(Locale.ENGLISH));
|
||||
sender.sendMessage(_("deleteHome", name));
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -18,6 +19,9 @@ public class Commandeco extends EssentialsCommand
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
Double broadcast = null;
|
||||
Double broadcastAll = null;
|
||||
final double startingBalance = (double)ess.getSettings().getStartingBalance();
|
||||
if (args.length < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
@@ -34,6 +38,8 @@ public class Commandeco extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException(ex);
|
||||
}
|
||||
|
||||
final double minBalance = ess.getSettings().getMinMoney();
|
||||
|
||||
if (args[1].contentEquals("**"))
|
||||
{
|
||||
for (String sUser : ess.getUserMap().getAllUniqueUsers())
|
||||
@@ -49,11 +55,25 @@ public class Commandeco extends EssentialsCommand
|
||||
if (player.canAfford(amount, false))
|
||||
{
|
||||
player.takeMoney(amount);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player.getMoney() > 0)
|
||||
{
|
||||
player.setMoney(0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RESET:
|
||||
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
||||
player.setMoney(startingBalance);
|
||||
broadcastAll = startingBalance;
|
||||
break;
|
||||
|
||||
case SET:
|
||||
boolean underMinimum = (player.getMoney() - amount) < minBalance;
|
||||
player.setMoney(underMinimum ? minBalance : amount);
|
||||
broadcastAll = underMinimum ? minBalance : amount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -70,15 +90,28 @@ public class Commandeco extends EssentialsCommand
|
||||
break;
|
||||
|
||||
case TAKE:
|
||||
if (!player.canAfford(amount, false))
|
||||
if (player.canAfford(amount))
|
||||
{
|
||||
throw new Exception(_("notEnoughMoney"));
|
||||
player.takeMoney(amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player.getMoney() > 0)
|
||||
{
|
||||
player.setMoney(0);
|
||||
}
|
||||
}
|
||||
player.takeMoney(amount);
|
||||
break;
|
||||
|
||||
case RESET:
|
||||
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
||||
player.setMoney(startingBalance);
|
||||
broadcast = startingBalance;
|
||||
break;
|
||||
|
||||
case SET:
|
||||
boolean underMinimum = (player.getMoney() - amount) < minBalance;
|
||||
player.setMoney(underMinimum ? minBalance : amount);
|
||||
broadcast = underMinimum ? minBalance : amount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -93,23 +126,38 @@ public class Commandeco extends EssentialsCommand
|
||||
break;
|
||||
|
||||
case TAKE:
|
||||
if (!player.canAfford(amount, false))
|
||||
if (!player.canAfford(amount))
|
||||
{
|
||||
throw new Exception(_("notEnoughMoney"));
|
||||
|
||||
}
|
||||
player.takeMoney(amount, sender);
|
||||
break;
|
||||
|
||||
case RESET:
|
||||
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
||||
player.setMoney(startingBalance);
|
||||
break;
|
||||
|
||||
case SET:
|
||||
boolean underMinimum = (player.getMoney() - amount) < minBalance;
|
||||
player.setMoney(underMinimum ? minBalance : amount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (broadcast != null)
|
||||
{
|
||||
server.broadcastMessage(_("resetBal", Util.formatAsCurrency(broadcast)));
|
||||
}
|
||||
if (broadcastAll != null)
|
||||
{
|
||||
server.broadcastMessage(_("resetBalAll", Util.formatAsCurrency(broadcastAll)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private enum EcoCommands
|
||||
{
|
||||
GIVE, TAKE, RESET
|
||||
GIVE, TAKE, RESET, SET
|
||||
}
|
||||
}
|
||||
|
@@ -2,9 +2,13 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Enchantments;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.MetaItemStack;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.*;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -32,7 +36,7 @@ public class Commandenchant extends EssentialsCommand
|
||||
for (Map.Entry<String, Enchantment> entry : Enchantments.entrySet())
|
||||
{
|
||||
final String enchantmentName = entry.getValue().getName().toLowerCase(Locale.ENGLISH);
|
||||
if (enchantmentslist.contains(enchantmentName) || user.isAuthorized("essentials.enchant." + enchantmentName))
|
||||
if (enchantmentslist.contains(enchantmentName) || (user.isAuthorized("essentials.enchant." + enchantmentName) && entry.getValue().canEnchantItem(stack)))
|
||||
{
|
||||
enchantmentslist.add(entry.getKey());
|
||||
//enchantmentslist.add(enchantmentName);
|
||||
@@ -40,6 +44,7 @@ public class Commandenchant extends EssentialsCommand
|
||||
}
|
||||
throw new NotEnoughArgumentsException(_("enchantments", Util.joinList(enchantmentslist.toArray())));
|
||||
}
|
||||
|
||||
int level = -1;
|
||||
if (args.length > 1)
|
||||
{
|
||||
@@ -52,20 +57,14 @@ public class Commandenchant extends EssentialsCommand
|
||||
level = -1;
|
||||
}
|
||||
}
|
||||
final Enchantment enchantment = getEnchantment(args[0], user);
|
||||
if (level < 0 || level > enchantment.getMaxLevel())
|
||||
{
|
||||
level = enchantment.getMaxLevel();
|
||||
}
|
||||
if (level == 0)
|
||||
{
|
||||
stack.removeEnchantment(enchantment);
|
||||
}
|
||||
else
|
||||
{
|
||||
stack.addEnchantment(enchantment, level);
|
||||
}
|
||||
user.getInventory().setItemInHand(stack);
|
||||
|
||||
final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments() && user.isAuthorized("essentials.enchant.allowunsafe");
|
||||
|
||||
final MetaItemStack metaStack = new MetaItemStack(stack);
|
||||
final Enchantment enchantment = metaStack.getEnchantment(user, args[0]);
|
||||
metaStack.addEnchantment(user, allowUnsafe, enchantment, level);
|
||||
user.getInventory().setItemInHand(metaStack.getItemStack());
|
||||
|
||||
user.updateInventory();
|
||||
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
|
||||
if (level == 0)
|
||||
@@ -77,20 +76,4 @@ public class Commandenchant extends EssentialsCommand
|
||||
user.sendMessage(_("enchantmentApplied", enchantmentName.replace('_', ' ')));
|
||||
}
|
||||
}
|
||||
|
||||
public static Enchantment getEnchantment(final String name, final User user) throws Exception
|
||||
{
|
||||
|
||||
final Enchantment enchantment = Enchantments.getByName(name);
|
||||
if (enchantment == null)
|
||||
{
|
||||
throw new Exception(_("enchantmentNotFound"));
|
||||
}
|
||||
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
|
||||
if (user != null && !user.isAuthorized("essentials.enchant." + enchantmentName))
|
||||
{
|
||||
throw new Exception(_("enchantmentPerm", enchantmentName));
|
||||
}
|
||||
return enchantment;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,30 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
|
||||
|
||||
public class Commandenderchest extends EssentialsCommand
|
||||
{
|
||||
public Commandenderchest()
|
||||
{
|
||||
super("enderchest");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && user.isAuthorized("essentials.enderchest.others"))
|
||||
{
|
||||
final User invUser = getPlayer(server, args, 0);
|
||||
user.openInventory(invUser.getEnderChest());
|
||||
user.setEnderSee(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.openInventory(user.getEnderChest());
|
||||
user.setEnderSee(false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -1,13 +1,11 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.metrics.Metrics;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
@@ -16,7 +14,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
// This command has 4 undocumented behaviours #EasterEgg
|
||||
public class Commandessentials extends EssentialsCommand
|
||||
{
|
||||
public Commandessentials()
|
||||
@@ -44,6 +42,10 @@ public class Commandessentials extends EssentialsCommand
|
||||
{
|
||||
run_moo(server, sender, commandLabel, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("reset"))
|
||||
{
|
||||
run_reset(server, sender, commandLabel, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("opt-out"))
|
||||
{
|
||||
run_optout(server, sender, commandLabel, args);
|
||||
@@ -53,6 +55,7 @@ public class Commandessentials extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
//If you do not supply an argument this command will list 'overridden' commands.
|
||||
private void run_disabled(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
sender.sendMessage("Essentials " + ess.getDescription().getVersion());
|
||||
@@ -72,6 +75,17 @@ public class Commandessentials extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
private void run_reset(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException("/<command> reset <player>");
|
||||
}
|
||||
final User user = getPlayer(server, args, 1, true);
|
||||
user.reset();
|
||||
sender.sendMessage("Reset Essentials userdata for player: " + user.getDisplayName());
|
||||
}
|
||||
|
||||
private void run_debug(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
ess.getSettings().setDebug(!ess.getSettings().isDebug());
|
||||
|
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.craftbukkit.SetExpFix;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Server;
|
||||
@@ -45,21 +46,40 @@ public class Commandexp extends EssentialsCommand
|
||||
setExp(user, user, args[1], true);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (args[0].equalsIgnoreCase("show"))
|
||||
{
|
||||
String match = args[0].trim();
|
||||
if (args.length == 2)
|
||||
if (args.length >= 2 && user.isAuthorized("essentials.exp.others"))
|
||||
{
|
||||
match = args[1].trim();
|
||||
}
|
||||
if (match.equalsIgnoreCase("show") || !user.isAuthorized("essentials.exp.others"))
|
||||
{
|
||||
showExp(user, user);
|
||||
String match = args[1].trim();
|
||||
showMatch(server, user, match);
|
||||
}
|
||||
else
|
||||
{
|
||||
showExp(user, user);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (args.length >= 1 && Util.isInt(args[0].toLowerCase(Locale.ENGLISH).replace("l", "")) && user.isAuthorized("essentials.exp.give"))
|
||||
{
|
||||
if (args.length >= 2 && user.isAuthorized("essentials.exp.give.others"))
|
||||
{
|
||||
expMatch(server, user, args[1], args[0], true);
|
||||
}
|
||||
else
|
||||
{
|
||||
setExp(user, user, args[0], true);
|
||||
}
|
||||
}
|
||||
else if (args.length >= 1 && user.isAuthorized("essentials.exp.others"))
|
||||
{
|
||||
String match = args[0].trim();
|
||||
showMatch(server, user, match);
|
||||
}
|
||||
else
|
||||
{
|
||||
showExp(user, user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,9 +101,14 @@ public class Commandexp extends EssentialsCommand
|
||||
else
|
||||
{
|
||||
String match = args[0].trim();
|
||||
if (args.length == 2)
|
||||
if (args.length >= 2 && Util.isInt(args[0].toLowerCase(Locale.ENGLISH).replace("l", "")))
|
||||
{
|
||||
match = args[1].trim();
|
||||
expMatch(server, sender, match, args[0], true);
|
||||
}
|
||||
else if (args.length == 1)
|
||||
{
|
||||
match = args[0].trim();
|
||||
}
|
||||
showMatch(server, sender, match);
|
||||
}
|
||||
@@ -104,13 +129,13 @@ public class Commandexp extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
private void expMatch(final Server server, final CommandSender sender, final String match, String amount, final boolean toggle) throws NotEnoughArgumentsException
|
||||
private void expMatch(final Server server, final CommandSender sender, final String match, String amount, final boolean give) throws NotEnoughArgumentsException
|
||||
{
|
||||
boolean foundUser = false;
|
||||
for (Player matchPlayer : server.matchPlayer(match))
|
||||
{
|
||||
final User target = ess.getUser(matchPlayer);
|
||||
setExp(sender, target, amount, toggle);
|
||||
setExp(sender, target, amount, give);
|
||||
foundUser = true;
|
||||
}
|
||||
if (!foundUser)
|
||||
@@ -121,17 +146,17 @@ public class Commandexp extends EssentialsCommand
|
||||
|
||||
private void showExp(final CommandSender sender, final User target)
|
||||
{
|
||||
final int totalExp = SetExpFix.getTotalExperience(target);
|
||||
sender.sendMessage(_("exp", target.getDisplayName(), SetExpFix.getTotalExperience(target), target.getLevel(), SetExpFix.getExpUntilNextLevel(target)));
|
||||
}
|
||||
|
||||
private void setExp(final CommandSender sender, final User target, String strAmount, final boolean give)
|
||||
//TODO: Limit who can give negative exp?
|
||||
private void setExp(final CommandSender sender, final User target, String strAmount, final boolean give) throws NotEnoughArgumentsException
|
||||
{
|
||||
Long amount;
|
||||
long amount;
|
||||
strAmount = strAmount.toLowerCase(Locale.ENGLISH);
|
||||
if (strAmount.startsWith("l"))
|
||||
if (strAmount.contains("l"))
|
||||
{
|
||||
strAmount = strAmount.substring(1);
|
||||
strAmount = strAmount.replaceAll("l", "");
|
||||
int neededLevel = Integer.parseInt(strAmount);
|
||||
if (give)
|
||||
{
|
||||
@@ -140,8 +165,13 @@ public class Commandexp extends EssentialsCommand
|
||||
amount = (long)SetExpFix.getExpToLevel(neededLevel);
|
||||
SetExpFix.setTotalExperience(target, 0);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
amount = Long.parseLong(strAmount);
|
||||
if (amount > Integer.MAX_VALUE || amount < Integer.MIN_VALUE)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
}
|
||||
|
||||
if (give)
|
||||
@@ -152,7 +182,11 @@ public class Commandexp extends EssentialsCommand
|
||||
{
|
||||
amount = (long)Integer.MAX_VALUE;
|
||||
}
|
||||
SetExpFix.setTotalExperience(target, amount.intValue());
|
||||
if (amount < 0l)
|
||||
{
|
||||
amount = 0l;
|
||||
}
|
||||
SetExpFix.setTotalExperience(target, (int)amount);
|
||||
sender.sendMessage(_("expSet", target.getDisplayName(), amount));
|
||||
}
|
||||
}
|
||||
|
@@ -2,8 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.SmallFireball;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
|
||||
@@ -18,12 +17,43 @@ public class Commandfireball extends EssentialsCommand
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
boolean small = false;
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("small"))
|
||||
Class<? extends Entity> type = Fireball.class;
|
||||
Projectile projectile;
|
||||
int speed = 2;
|
||||
if (args.length > 0)
|
||||
{
|
||||
small = true;
|
||||
if (args[0].equalsIgnoreCase("small"))
|
||||
{
|
||||
type = SmallFireball.class;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("arrow"))
|
||||
{
|
||||
type = Arrow.class;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("skull"))
|
||||
{
|
||||
type = WitherSkull.class;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("egg"))
|
||||
{
|
||||
type = Egg.class;
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("snowball"))
|
||||
{
|
||||
type = Snowball.class;
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("expbottle"))
|
||||
{
|
||||
type = ThrownExpBottle.class;
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("large"))
|
||||
{
|
||||
type = LargeFireball.class;
|
||||
}
|
||||
}
|
||||
final Vector direction = user.getEyeLocation().getDirection().multiply(2);
|
||||
Fireball fireball = user.getWorld().spawn(user.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), small ? SmallFireball.class : Fireball.class);
|
||||
fireball.setShooter(user.getBase());
|
||||
final Vector direction = user.getEyeLocation().getDirection().multiply(speed);
|
||||
projectile = (Projectile)user.getWorld().spawn(user.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), type);
|
||||
projectile.setShooter(user.getBase());
|
||||
projectile.setVelocity(direction);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,156 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.MetaItemStack;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Firework;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.FireworkMeta;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
//This command has quite a complicated syntax, in theory it has 4 seperate syntaxes which are all variable:
|
||||
//
|
||||
//1: /firework clear - This clears all of the effects on a firework stack
|
||||
//
|
||||
//2: /firework power <int> - This changes the base power of a firework
|
||||
//
|
||||
//3: /firework fire - This 'fires' a copy of the firework held.
|
||||
//3: /firework fire <int> - This 'fires' a number of copies of the firework held.
|
||||
//3: /firework fire <other> - This 'fires' a copy of the firework held, in the direction you are looking, #easteregg
|
||||
//
|
||||
//4: /firework [meta] - This will add an effect to the firework stack held
|
||||
//4: /firework color:<color> - The minimum you need to set an effect is 'color'
|
||||
//4: Full Syntax: color:<color[,color,..]> [fade:<color[,color,..]>] [shape:<shape>] [effect:<effect[,effect]>]
|
||||
//4: Possible Shapes: star, ball, large, creeper, burst
|
||||
//4: Possible Effects trail, twinkle
|
||||
|
||||
public class Commandfirework extends EssentialsCommand
|
||||
{
|
||||
private final transient Pattern splitPattern = Pattern.compile("[:+',;.]");
|
||||
private final static Map<String, DyeColor> colorMap = new HashMap<String, DyeColor>();
|
||||
private final static Map<String, FireworkEffect.Type> fireworkShape = new HashMap<String, FireworkEffect.Type>();
|
||||
|
||||
static
|
||||
{
|
||||
for (DyeColor color : DyeColor.values())
|
||||
{
|
||||
colorMap.put(color.name(), color);
|
||||
}
|
||||
for (FireworkEffect.Type type : FireworkEffect.Type.values())
|
||||
{
|
||||
fireworkShape.put(type.name(), type);
|
||||
}
|
||||
}
|
||||
|
||||
public Commandfirework()
|
||||
{
|
||||
super("firework");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final ItemStack stack = user.getItemInHand();
|
||||
if (stack.getType() == Material.FIREWORK)
|
||||
{
|
||||
if (args.length > 0)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("clear"))
|
||||
{
|
||||
FireworkMeta fmeta = (FireworkMeta)stack.getItemMeta();
|
||||
fmeta.clearEffects();
|
||||
stack.setItemMeta(fmeta);
|
||||
user.sendMessage(_("fireworkEffectsCleared"));
|
||||
}
|
||||
else if (args.length > 1 && (args[0].equalsIgnoreCase("power") || (args[0].equalsIgnoreCase("p"))))
|
||||
{
|
||||
FireworkMeta fmeta = (FireworkMeta)stack.getItemMeta();
|
||||
try
|
||||
{
|
||||
int power = Integer.parseInt(args[1]);
|
||||
fmeta.setPower(power > 3 ? 4 : power);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new Exception(_("invalidFireworkFormat", args[1], args[0]));
|
||||
}
|
||||
stack.setItemMeta(fmeta);
|
||||
}
|
||||
else if ((args[0].equalsIgnoreCase("fire") || (args[0].equalsIgnoreCase("p")))
|
||||
&& user.isAuthorized("essentials.firework.fire"))
|
||||
{
|
||||
int amount = 1;
|
||||
boolean direction = false;
|
||||
if (Util.isInt(args[1]))
|
||||
{
|
||||
final int serverLimit = ess.getSettings().getSpawnMobLimit();
|
||||
amount = Integer.parseInt(args[1]);
|
||||
if (amount > serverLimit)
|
||||
{
|
||||
amount = serverLimit;
|
||||
user.sendMessage(_("mobSpawnLimit"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
direction = true;
|
||||
}
|
||||
for (int i = 0; i < amount; i++)
|
||||
{
|
||||
Firework firework = (Firework)user.getWorld().spawnEntity(user.getLocation(), EntityType.FIREWORK);
|
||||
FireworkMeta fmeta = (FireworkMeta)stack.getItemMeta();
|
||||
if (direction)
|
||||
{
|
||||
final Vector vector = user.getEyeLocation().getDirection().multiply(0.070);
|
||||
if (fmeta.getPower() > 1)
|
||||
{
|
||||
fmeta.setPower(1);
|
||||
}
|
||||
firework.setVelocity(vector);
|
||||
}
|
||||
firework.setFireworkMeta(fmeta);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final MetaItemStack mStack = new MetaItemStack(stack);
|
||||
for (String arg : args)
|
||||
{
|
||||
final String[] split = splitPattern.split(arg, 2);
|
||||
mStack.addFireworkMeta(user, true, arg, ess);
|
||||
}
|
||||
|
||||
if (mStack.isValidFirework())
|
||||
{
|
||||
FireworkMeta fmeta = (FireworkMeta)mStack.getItemStack().getItemMeta();
|
||||
FireworkEffect effect = mStack.getFireworkBuilder().build();
|
||||
fmeta.addEffect(effect);
|
||||
stack.setItemMeta(fmeta);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(_("fireworkSyntax"));
|
||||
throw new Exception(_("fireworkColor"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("holdFirework"));
|
||||
}
|
||||
}
|
||||
}
|
@@ -28,15 +28,34 @@ public class Commandfly extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && args[0].trim().length() > 2 && user.isAuthorized("essentials.fly.others"))
|
||||
if (args.length == 1)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("on") || args[0].startsWith("ena") || args[0].equalsIgnoreCase("1"))
|
||||
{
|
||||
user.setAllowFlight(true);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("off") || args[0].startsWith("dis") || args[0].equalsIgnoreCase("0"))
|
||||
{
|
||||
user.setAllowFlight(false);
|
||||
}
|
||||
else if (user.isAuthorized("essentials.fly.others"))
|
||||
{
|
||||
flyOtherPlayers(server, user, args);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (args.length == 2 && user.isAuthorized("essentials.fly.others"))
|
||||
{
|
||||
flyOtherPlayers(server, user, args);
|
||||
return;
|
||||
}
|
||||
user.setAllowFlight(!user.getAllowFlight());
|
||||
if (!user.getAllowFlight())
|
||||
else
|
||||
{
|
||||
user.setFlying(false);
|
||||
user.setAllowFlight(!user.getAllowFlight());
|
||||
if (!user.getAllowFlight())
|
||||
{
|
||||
user.setFlying(false);
|
||||
}
|
||||
}
|
||||
user.sendMessage(_("flyMode", _(user.getAllowFlight() ? "enabled" : "disabled"), user.getDisplayName()));
|
||||
}
|
||||
|
@@ -19,57 +19,116 @@ public class Commandgamemode extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
GameMode gameMode;
|
||||
if (args.length == 0)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
gamemodeOtherPlayers(server, sender, args);
|
||||
else if (args.length == 1)
|
||||
{
|
||||
gameMode = matchGameMode(commandLabel);
|
||||
gamemodeOtherPlayers(server, sender, gameMode, args[0]);
|
||||
}
|
||||
else if (args.length == 2)
|
||||
{
|
||||
gameMode = matchGameMode(args[0].toLowerCase(Locale.ENGLISH));
|
||||
gamemodeOtherPlayers(server, sender, gameMode, args[1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
GameMode gameMode;
|
||||
if (args.length == 0)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
gameMode = matchGameMode(commandLabel);
|
||||
}
|
||||
|
||||
if (args.length > 1 && args[1].trim().length() > 2 && user.isAuthorized("essentials.gamemode.others"))
|
||||
else if (args.length > 1 && args[1].trim().length() > 2 && user.isAuthorized("essentials.gamemode.others"))
|
||||
{
|
||||
gamemodeOtherPlayers(server, user, args);
|
||||
gameMode = matchGameMode(args[0].toLowerCase(Locale.ENGLISH));
|
||||
gamemodeOtherPlayers(server, user, gameMode, args[1]);
|
||||
return;
|
||||
}
|
||||
performSetMode(args[0].toLowerCase(Locale.ENGLISH), user);
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
gameMode = matchGameMode(args[0].toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
catch (NotEnoughArgumentsException e)
|
||||
{
|
||||
if (user.isAuthorized("essentials.gamemode.others"))
|
||||
{
|
||||
gameMode = matchGameMode(commandLabel);
|
||||
gamemodeOtherPlayers(server, user, gameMode, args[0]);
|
||||
return;
|
||||
}
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
}
|
||||
if (gameMode == null)
|
||||
{
|
||||
gameMode = user.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : user.getGameMode() == GameMode.CREATIVE ? GameMode.ADVENTURE : GameMode.SURVIVAL;
|
||||
}
|
||||
user.setGameMode(gameMode);
|
||||
user.sendMessage(_("gameMode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName()));
|
||||
}
|
||||
|
||||
private void gamemodeOtherPlayers(final Server server, final CommandSender sender, final String[] args)
|
||||
private void gamemodeOtherPlayers(final Server server, final CommandSender sender, final GameMode gameMode, final String player) throws NotEnoughArgumentsException
|
||||
{
|
||||
for (Player matchPlayer : server.matchPlayer(args[1]))
|
||||
//TODO: TL this
|
||||
if (player.trim().length() < 2 || gameMode == null)
|
||||
{
|
||||
final User player = ess.getUser(matchPlayer);
|
||||
if (player.isHidden())
|
||||
throw new NotEnoughArgumentsException("You need to specify a valid player/mode.");
|
||||
}
|
||||
|
||||
boolean foundUser = false;
|
||||
for (Player matchPlayer : server.matchPlayer(player))
|
||||
{
|
||||
final User user = ess.getUser(matchPlayer);
|
||||
if (user.isHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
performSetMode(args[0].toLowerCase(Locale.ENGLISH), player);
|
||||
sender.sendMessage(_("gameMode", _(player.getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName()));
|
||||
user.setGameMode(gameMode);
|
||||
sender.sendMessage(_("gameMode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName()));
|
||||
foundUser = true;
|
||||
}
|
||||
if (!foundUser)
|
||||
{
|
||||
throw new NotEnoughArgumentsException(_("playerNotFound"));
|
||||
}
|
||||
}
|
||||
|
||||
private void performSetMode(String mode, Player player)
|
||||
private GameMode matchGameMode(String modeString) throws NotEnoughArgumentsException
|
||||
{
|
||||
if (mode.contains("survi") || mode.equalsIgnoreCase("0") || mode.equalsIgnoreCase("s"))
|
||||
GameMode mode = null;
|
||||
if (modeString.equalsIgnoreCase("gmc") || modeString.equalsIgnoreCase("egmc")
|
||||
|| modeString.contains("creat") || modeString.equalsIgnoreCase("1") || modeString.equalsIgnoreCase("c"))
|
||||
{
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
mode = GameMode.CREATIVE;
|
||||
}
|
||||
else if (mode.contains("creat") || mode.equalsIgnoreCase("1") || mode.equalsIgnoreCase("c"))
|
||||
else if (modeString.equalsIgnoreCase("gms") || modeString.equalsIgnoreCase("egms")
|
||||
|| modeString.contains("survi") || modeString.equalsIgnoreCase("0") || modeString.equalsIgnoreCase("s"))
|
||||
{
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
mode = GameMode.SURVIVAL;
|
||||
}
|
||||
else if (mode.contains("advent") || mode.equalsIgnoreCase("2") || mode.equalsIgnoreCase("a"))
|
||||
else if (modeString.equalsIgnoreCase("gma") || modeString.equalsIgnoreCase("egma")
|
||||
|| modeString.contains("advent") || modeString.equalsIgnoreCase("2") || modeString.equalsIgnoreCase("a"))
|
||||
{
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
mode = GameMode.ADVENTURE;
|
||||
}
|
||||
else if (modeString.equalsIgnoreCase("gmt") || modeString.equalsIgnoreCase("egmt")
|
||||
|| modeString.contains("toggle") || modeString.contains("cycle") || modeString.equalsIgnoreCase("t"))
|
||||
{
|
||||
mode = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
}
|
@@ -1,6 +1,9 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.List;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
@@ -31,12 +34,15 @@ public class Commandgc extends EssentialsCommand
|
||||
{
|
||||
color = ChatColor.RED;
|
||||
}
|
||||
|
||||
sender.sendMessage(_("uptime", Util.formatDateDiff(ManagementFactory.getRuntimeMXBean().getStartTime())));
|
||||
sender.sendMessage(_("tps", "" + color + tps));
|
||||
sender.sendMessage(_("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(_("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(_("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
|
||||
|
||||
for (World w : server.getWorlds())
|
||||
List<World> worlds = server.getWorlds();
|
||||
for (World w : worlds)
|
||||
{
|
||||
String worldType = "World";
|
||||
switch (w.getEnvironment())
|
||||
@@ -49,10 +55,7 @@ public class Commandgc extends EssentialsCommand
|
||||
break;
|
||||
}
|
||||
|
||||
sender.sendMessage(
|
||||
worldType + " \"" + w.getName() + "\": "
|
||||
+ w.getLoadedChunks().length + _("gcchunks")
|
||||
+ w.getEntities().size() + _("gcentities"));
|
||||
sender.sendMessage(_("gcWorld", worldType, w.getName(), w.getLoadedChunks().length, w.getEntities().size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
@@ -40,18 +41,17 @@ public class Commandgetpos extends EssentialsCommand
|
||||
outputPosition(sender, user.getLocation(), null);
|
||||
}
|
||||
|
||||
//TODO: Translate
|
||||
private void outputPosition(final CommandSender sender, final Location coords, final Location distance)
|
||||
{
|
||||
sender.sendMessage("§7World: " + coords.getWorld().getName());
|
||||
sender.sendMessage("§7X: " + coords.getBlockX() + " (+East <-> -West)");
|
||||
sender.sendMessage("§7Y: " + coords.getBlockY() + " (+Up <-> -Down)");
|
||||
sender.sendMessage("§7Z: " + coords.getBlockZ() + " (+South <-> -North)");
|
||||
sender.sendMessage("§7Yaw: " + (coords.getYaw() + 180 + 360) % 360 + " (Rotation)");
|
||||
sender.sendMessage("§7Pitch: " + coords.getPitch() + " (Head angle)");
|
||||
sender.sendMessage(_("currentWorld", coords.getWorld().getName()));
|
||||
sender.sendMessage(_("posX", coords.getBlockX()));
|
||||
sender.sendMessage(_("posY", coords.getBlockY()));
|
||||
sender.sendMessage(_("posZ", coords.getBlockZ()));
|
||||
sender.sendMessage(_("posYaw", (coords.getYaw() + 180 + 360) % 360));
|
||||
sender.sendMessage(_("posPitch", coords.getPitch()));
|
||||
if (distance != null && coords.getWorld().equals(distance.getWorld()))
|
||||
{
|
||||
sender.sendMessage("§7Distance: " + coords.distance(distance));
|
||||
sender.sendMessage(_("distance", coords.distance(distance)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,14 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import com.earth2me.essentials.MetaItemStack;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -29,7 +28,7 @@ public class Commandgive extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
final ItemStack stack = ess.getItemDb().get(args[1]);
|
||||
ItemStack stack = ess.getItemDb().get(args[1]);
|
||||
|
||||
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
if (sender instanceof Player
|
||||
@@ -45,45 +44,43 @@ public class Commandgive extends EssentialsCommand
|
||||
|
||||
final User giveTo = getPlayer(server, args, 0);
|
||||
|
||||
if (args.length > 3 && Util.isInt(args[2]) && Util.isInt(args[3]))
|
||||
{
|
||||
stack.setAmount(Integer.parseInt(args[2]));
|
||||
stack.setDurability(Short.parseShort(args[3]));
|
||||
}
|
||||
else if (args.length > 2 && Integer.parseInt(args[2]) > 0)
|
||||
try
|
||||
{
|
||||
stack.setAmount(Integer.parseInt(args[2]));
|
||||
if (args.length > 3 && Util.isInt(args[2]) && Util.isInt(args[3]))
|
||||
{
|
||||
stack.setAmount(Integer.parseInt(args[2]));
|
||||
stack.setDurability(Short.parseShort(args[3]));
|
||||
}
|
||||
else if (args.length > 2 && Integer.parseInt(args[2]) > 0)
|
||||
{
|
||||
stack.setAmount(Integer.parseInt(args[2]));
|
||||
}
|
||||
else if (ess.getSettings().getDefaultStackSize() > 0)
|
||||
{
|
||||
stack.setAmount(ess.getSettings().getDefaultStackSize());
|
||||
}
|
||||
else if (ess.getSettings().getOversizedStackSize() > 0 && giveTo.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
stack.setAmount(ess.getSettings().getOversizedStackSize());
|
||||
}
|
||||
}
|
||||
else if (ess.getSettings().getDefaultStackSize() > 0)
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
stack.setAmount(ess.getSettings().getDefaultStackSize());
|
||||
}
|
||||
else if (ess.getSettings().getOversizedStackSize() > 0 && giveTo.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
stack.setAmount(ess.getSettings().getOversizedStackSize());
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
if (args.length > 3)
|
||||
{
|
||||
for (int i = Util.isInt(args[3]) ? 4 : 3; i < args.length; i++)
|
||||
MetaItemStack metaStack = new MetaItemStack(stack);
|
||||
boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
|
||||
if (allowUnsafe && sender instanceof Player && !ess.getUser(sender).isAuthorized("essentials.enchant.allowunsafe"))
|
||||
{
|
||||
final String[] split = args[i].split("[:+',;.]", 2);
|
||||
if (split.length < 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final Enchantment enchantment = Commandenchant.getEnchantment(split[0], sender instanceof Player ? ess.getUser(sender) : null);
|
||||
int level;
|
||||
if (split.length > 1)
|
||||
{
|
||||
level = Integer.parseInt(split[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
level = enchantment.getMaxLevel();
|
||||
}
|
||||
stack.addEnchantment(enchantment, level);
|
||||
allowUnsafe = false;
|
||||
}
|
||||
|
||||
metaStack.parseStringMeta(sender, allowUnsafe, args, Util.isInt(args[3]) ? 4 : 3, ess);
|
||||
|
||||
stack = metaStack.getItemStack();
|
||||
}
|
||||
|
||||
if (stack.getType() == Material.AIR)
|
||||
@@ -91,16 +88,15 @@ public class Commandgive extends EssentialsCommand
|
||||
throw new Exception(_("cantSpawnItem", "Air"));
|
||||
}
|
||||
|
||||
//TODO: TL this.
|
||||
final String itemName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
|
||||
sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + ".");
|
||||
sender.sendMessage(_("giveSpawn", stack.getAmount(), itemName, giveTo.getDisplayName()));
|
||||
if (giveTo.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
InventoryWorkaround.addItem(giveTo.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
|
||||
InventoryWorkaround.addOversizedItems(giveTo.getInventory(), ess.getSettings().getOversizedStackSize(), stack);
|
||||
}
|
||||
else
|
||||
{
|
||||
InventoryWorkaround.addItem(giveTo.getInventory(), true, stack);
|
||||
InventoryWorkaround.addItems(giveTo.getInventory(), stack);
|
||||
}
|
||||
giveTo.updateInventory();
|
||||
}
|
||||
|
@@ -33,10 +33,20 @@ public class Commandgod extends EssentialsCommand
|
||||
godOtherPlayers(server, user, args);
|
||||
return;
|
||||
}
|
||||
user.setGodModeEnabled(!user.isGodModeEnabled());
|
||||
godPlayer(user, !user.isGodModeEnabled());
|
||||
user.sendMessage(_("godMode", (user.isGodModeEnabled() ? _("enabled") : _("disabled"))));
|
||||
}
|
||||
|
||||
private void godPlayer(User player, boolean enabled)
|
||||
{
|
||||
player.setGodModeEnabled(enabled);
|
||||
if (enabled)
|
||||
{
|
||||
player.setHealth(player.getMaxHealth());
|
||||
player.setFoodLevel(20);
|
||||
}
|
||||
}
|
||||
|
||||
private void godOtherPlayers(final Server server, final CommandSender sender, final String[] args)
|
||||
{
|
||||
for (Player matchPlayer : server.matchPlayer(args[0]))
|
||||
@@ -47,28 +57,24 @@ public class Commandgod extends EssentialsCommand
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean enabled;
|
||||
if (args.length > 1)
|
||||
{
|
||||
if (args[1].contains("on") || args[1].contains("ena") || args[1].equalsIgnoreCase("1"))
|
||||
{
|
||||
player.setGodModeEnabled(true);
|
||||
enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setGodModeEnabled(false);
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setGodModeEnabled(!player.isGodModeEnabled());
|
||||
}
|
||||
|
||||
final boolean enabled = player.isGodModeEnabled();
|
||||
if (enabled)
|
||||
{
|
||||
player.setFoodLevel(20);
|
||||
enabled = !player.isGodModeEnabled();
|
||||
}
|
||||
|
||||
godPlayer(player, enabled);
|
||||
player.sendMessage(_("godMode", (enabled ? _("enabled") : _("disabled"))));
|
||||
sender.sendMessage(_("godMode", _(enabled ? "godEnabledFor" : "godDisabledFor", matchPlayer.getDisplayName())));
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ public class Commandhat extends EssentialsCommand
|
||||
{
|
||||
final ItemStack air = new ItemStack(Material.AIR);
|
||||
inv.setHelmet(air);
|
||||
InventoryWorkaround.addItem(user.getInventory(), true, head);
|
||||
InventoryWorkaround.addItems(user.getInventory(), head);
|
||||
user.sendMessage(_("hatRemoved"));
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import java.util.List;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
|
||||
public class Commandheal extends EssentialsCommand
|
||||
@@ -33,9 +34,7 @@ public class Commandheal extends EssentialsCommand
|
||||
{
|
||||
user.healCooldown();
|
||||
}
|
||||
user.setHealth(20);
|
||||
user.setFoodLevel(20);
|
||||
user.sendMessage(_("heal"));
|
||||
healPlayer(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,10 +62,20 @@ public class Commandheal extends EssentialsCommand
|
||||
{
|
||||
continue;
|
||||
}
|
||||
p.setHealth(20);
|
||||
p.setFoodLevel(20);
|
||||
p.sendMessage(_("heal"));
|
||||
healPlayer(p);
|
||||
sender.sendMessage(_("healOther", p.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
||||
private void healPlayer(final Player player)
|
||||
{
|
||||
player.setHealth(player.getMaxHealth());
|
||||
player.setFoodLevel(20);
|
||||
player.setFireTicks(0);
|
||||
player.sendMessage(_("heal"));
|
||||
for (PotionEffect effect : player.getActivePotionEffects())
|
||||
{
|
||||
player.removePotionEffect(effect.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@ public class Commandhome extends EssentialsCommand
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
User player = user;
|
||||
String homeName = "";
|
||||
String[] nameParts;
|
||||
@@ -45,10 +44,10 @@ public class Commandhome extends EssentialsCommand
|
||||
}
|
||||
try
|
||||
{
|
||||
if ("bed".equalsIgnoreCase(homeName))
|
||||
if ("bed".equalsIgnoreCase(homeName) && user.isAuthorized("essentials.home.bed"))
|
||||
{
|
||||
final Location bed = player.getBedSpawnLocation();
|
||||
if (bed != null && bed.getBlock().getType() == Material.BED_BLOCK)
|
||||
if (bed != null)
|
||||
{
|
||||
user.getTeleport().teleport(bed, charge, TeleportCause.COMMAND);
|
||||
throw new NoChargeException();
|
||||
@@ -59,24 +58,14 @@ public class Commandhome extends EssentialsCommand
|
||||
catch (NotEnoughArgumentsException e)
|
||||
{
|
||||
Location bed = player.getBedSpawnLocation();
|
||||
if (bed != null && bed.getBlock().getType() != Material.BED_BLOCK)
|
||||
{
|
||||
bed = null;
|
||||
}
|
||||
final List<String> homes = player.getHomes();
|
||||
if (homes.isEmpty() && player.equals(user))
|
||||
{
|
||||
if (bed != null)
|
||||
{
|
||||
user.getTeleport().teleport(bed, charge, TeleportCause.COMMAND);
|
||||
throw new NoChargeException();
|
||||
}
|
||||
user.getTeleport().respawn(charge, TeleportCause.COMMAND);
|
||||
|
||||
}
|
||||
else if (homes.isEmpty())
|
||||
{
|
||||
throw new Exception(player == user ? _("noHomeSet") : _("noHomeSetPlayer"));
|
||||
throw new Exception(_("noHomeSetPlayer"));
|
||||
}
|
||||
else if (homes.size() == 1 && player.equals(user))
|
||||
{
|
||||
@@ -84,9 +73,9 @@ public class Commandhome extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bed != null)
|
||||
if (bed != null && user.isAuthorized("essentials.home.bed"))
|
||||
{
|
||||
homes.add("bed");
|
||||
homes.add(_("bed"));
|
||||
}
|
||||
user.sendMessage(_("homes", Util.joinList(homes)));
|
||||
}
|
||||
@@ -102,9 +91,9 @@ public class Commandhome extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
if (user.getWorld() != loc.getWorld() && ess.getSettings().isWorldHomePermissions()
|
||||
&& !user.isAuthorized("essentials.world." + loc.getWorld().getName()))
|
||||
&& !user.isAuthorized("essentials.worlds." + loc.getWorld().getName()))
|
||||
{
|
||||
throw new Exception(_("noPerm", "essentials.world." + loc.getWorld().getName()));
|
||||
throw new Exception(_("noPerm", "essentials.worlds." + loc.getWorld().getName()));
|
||||
}
|
||||
user.getTeleport().home(loc, charge);
|
||||
}
|
||||
|
@@ -1,10 +1,8 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.Arrays;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
|
||||
public class Commandinvsee extends EssentialsCommand
|
||||
@@ -13,6 +11,8 @@ public class Commandinvsee extends EssentialsCommand
|
||||
{
|
||||
super("invsee");
|
||||
}
|
||||
|
||||
//This method has a hidden param, which if given will display the equip slots. #easteregg
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
@@ -21,8 +21,20 @@ public class Commandinvsee extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
final User invUser = getPlayer(server, args, 0);
|
||||
|
||||
final User invUser = getPlayer(server, args, 0);
|
||||
Inventory inv;
|
||||
|
||||
if (args.length > 1 && user.isAuthorized("essentials.invsee.equip"))
|
||||
{
|
||||
inv = server.createInventory(invUser, 9, "Equipped");
|
||||
inv.setContents(invUser.getInventory().getArmorContents());
|
||||
}
|
||||
else
|
||||
{
|
||||
inv = invUser.getInventory();
|
||||
}
|
||||
user.openInventory(inv);
|
||||
user.setInvSee(true);
|
||||
user.openInventory(invUser.getInventory());
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,12 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.MetaItemStack;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Commanditem extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
final ItemStack stack = ess.getItemDb().get(args[0]);
|
||||
ItemStack stack = ess.getItemDb().get(args[0]);
|
||||
|
||||
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
if (ess.getSettings().permissionBasedItemSpawn()
|
||||
@@ -50,33 +50,21 @@ public class Commanditem extends EssentialsCommand
|
||||
{
|
||||
stack.setAmount(ess.getSettings().getOversizedStackSize());
|
||||
}
|
||||
if (args.length > 2)
|
||||
{
|
||||
for (int i = 2; i < args.length; i++)
|
||||
{
|
||||
final String[] split = args[i].split("[:+',;.]", 2);
|
||||
if (split.length < 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final Enchantment enchantment = Commandenchant.getEnchantment(split[0], user);
|
||||
int level;
|
||||
if (split.length > 1)
|
||||
{
|
||||
level = Integer.parseInt(split[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
level = enchantment.getMaxLevel();
|
||||
}
|
||||
stack.addEnchantment(enchantment, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
if (args.length > 2)
|
||||
{
|
||||
MetaItemStack metaStack = new MetaItemStack(stack);
|
||||
final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments() && user.isAuthorized("essentials.enchant.allowunsafe");
|
||||
|
||||
metaStack.parseStringMeta(user, allowUnsafe, args, 2, ess);
|
||||
|
||||
stack = metaStack.getItemStack();
|
||||
}
|
||||
|
||||
|
||||
if (stack.getType() == Material.AIR)
|
||||
{
|
||||
@@ -87,11 +75,11 @@ public class Commanditem extends EssentialsCommand
|
||||
user.sendMessage(_("itemSpawn", stack.getAmount(), displayName));
|
||||
if (user.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
|
||||
InventoryWorkaround.addOversizedItems(user.getInventory(), ess.getSettings().getOversizedStackSize(), stack);
|
||||
}
|
||||
else
|
||||
{
|
||||
InventoryWorkaround.addItem(user.getInventory(), true, stack);
|
||||
InventoryWorkaround.addItems(user.getInventory(), stack);
|
||||
}
|
||||
user.updateInventory();
|
||||
}
|
||||
|
@@ -19,10 +19,12 @@ public class Commanditemdb extends EssentialsCommand
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
ItemStack itemStack = null;
|
||||
boolean itemHeld = false;
|
||||
if (args.length < 1)
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
itemHeld = true;
|
||||
itemStack = ((Player)sender).getItemInHand();
|
||||
}
|
||||
if (itemStack == null)
|
||||
@@ -34,9 +36,9 @@ public class Commanditemdb extends EssentialsCommand
|
||||
{
|
||||
itemStack = ess.getItemDb().get(args[0]);
|
||||
}
|
||||
sender.sendMessage(itemStack.getType().toString() + "- " + itemStack.getTypeId() + ":" + Integer.toString(itemStack.getDurability()));
|
||||
|
||||
if (itemStack.getType() != Material.AIR)
|
||||
sender.sendMessage(_("itemType", itemStack.getType().toString(), itemStack.getTypeId() + ":" + Integer.toString(itemStack.getDurability())));
|
||||
|
||||
if (itemHeld && itemStack.getType() != Material.AIR)
|
||||
{
|
||||
int maxuses = itemStack.getType().getMaxDurability();
|
||||
int durability = ((maxuses + 1) - itemStack.getDurability());
|
||||
@@ -44,6 +46,11 @@ public class Commanditemdb extends EssentialsCommand
|
||||
{
|
||||
sender.sendMessage(_("durability", Integer.toString(durability)));
|
||||
}
|
||||
}
|
||||
}
|
||||
final String itemNameList = ess.getItemDb().names(itemStack);
|
||||
if (itemNameList != null)
|
||||
{
|
||||
sender.sendMessage(_("itemNames", ess.getItemDb().names(itemStack)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
|
||||
// This method contains an undocumented sub command #EasterEgg
|
||||
public class Commandjump extends EssentialsCommand
|
||||
{
|
||||
public Commandjump()
|
||||
@@ -19,6 +19,21 @@ public class Commandjump extends EssentialsCommand
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && args[0].contains("lock") && user.isAuthorized("essentials.jump.lock"))
|
||||
{
|
||||
if (user.isFlyClickJump())
|
||||
{
|
||||
user.setRightClickJump(false);
|
||||
user.sendMessage("Flying wizard mode disabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
user.setRightClickJump(true);
|
||||
user.sendMessage("Enabling flying wizard mode");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Location loc;
|
||||
final Location cloc = user.getLocation();
|
||||
|
||||
|
@@ -3,6 +3,8 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.Console;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -23,21 +25,34 @@ public class Commandkick extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
final User user = getPlayer(server, args, 0);
|
||||
if (sender instanceof Player && user.isAuthorized("essentials.kick.exempt"))
|
||||
final User target = getPlayer(server, args, 0, true);
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
throw new Exception(_("kickExempt"));
|
||||
User user = ess.getUser(sender);
|
||||
if (target.isHidden() && !user.isAuthorized("essentials.list.hidden"))
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
if (target.isAuthorized("essentials.kick.exempt"))
|
||||
{
|
||||
throw new Exception(_("kickExempt"));
|
||||
}
|
||||
}
|
||||
final String kickReason = args.length > 1 ? getFinalArg(args, 1) : _("kickDefault");
|
||||
user.kickPlayer(kickReason);
|
||||
|
||||
String kickReason = args.length > 1 ? getFinalArg(args, 1) : _("kickDefault");
|
||||
kickReason = Util.replaceFormat(kickReason.replace("\\n", "\n").replace("|", "\n"));
|
||||
|
||||
target.kickPlayer(kickReason);
|
||||
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
|
||||
server.getLogger().log(Level.INFO, _("playerKicked", senderName, target.getName(), kickReason));
|
||||
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
User player = ess.getUser(onlinePlayer);
|
||||
if (player.isAuthorized("essentials.kick.notify"))
|
||||
{
|
||||
onlinePlayer.sendMessage(_("playerKicked", senderName, user.getName(), kickReason));
|
||||
onlinePlayer.sendMessage(_("playerKicked", senderName, target.getName(), kickReason));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -16,6 +17,9 @@ public class Commandkickall extends EssentialsCommand
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
String kickReason = args.length > 0 ? getFinalArg(args, 0) : _("kickDefault");
|
||||
kickReason = Util.replaceFormat(kickReason.replace("\\n", "\n").replace("|", "\n"));
|
||||
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
if (sender instanceof Player && onlinePlayer.getName().equalsIgnoreCase(((Player)sender).getName()))
|
||||
@@ -24,7 +28,7 @@ public class Commandkickall extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
onlinePlayer.kickPlayer(args.length > 0 ? getFinalArg(args, 0) : _("kickDefault"));
|
||||
onlinePlayer.kickPlayer(kickReason);
|
||||
}
|
||||
}
|
||||
sender.sendMessage(_("kickedAll"));
|
||||
|
@@ -22,16 +22,28 @@ public class Commandkill extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
//TODO: TL this
|
||||
if (args[0].trim().length() < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException("You need to specify a player to kill.");
|
||||
}
|
||||
|
||||
for (Player matchPlayer : server.matchPlayer(args[0]))
|
||||
{
|
||||
final EntityDamageEvent ede = new EntityDamageEvent(matchPlayer, sender instanceof Player && ((Player)sender).getName().equals(matchPlayer.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, Short.MAX_VALUE);
|
||||
server.getPluginManager().callEvent(ede);
|
||||
if (ede.isCancelled() && !sender.hasPermission("essentials.kill.force"))
|
||||
if (ede.isCancelled() && sender instanceof Player && !ess.getUser(sender).isAuthorized("essentials.kill.force"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
matchPlayer.damage(Short.MAX_VALUE);
|
||||
|
||||
if (matchPlayer.getHealth() > 0)
|
||||
{
|
||||
matchPlayer.setHealth(0);
|
||||
}
|
||||
|
||||
sender.sendMessage(_("kill", matchPlayer.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
@@ -1,28 +1,16 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Mob;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.Collections;
|
||||
import com.earth2me.essentials.Mob;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.ComplexLivingEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Flying;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.NPC;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.entity.Snowman;
|
||||
import org.bukkit.entity.WaterMob;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Commandkillall extends EssentialsCommand
|
||||
@@ -122,7 +110,7 @@ public class Commandkillall extends EssentialsCommand
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(entity instanceof Ocelot)
|
||||
if (entity instanceof Ocelot)
|
||||
{
|
||||
if (((Ocelot)entity).isTamed())
|
||||
{
|
||||
@@ -133,7 +121,7 @@ public class Commandkillall extends EssentialsCommand
|
||||
{
|
||||
if (entity instanceof Animals || entity instanceof NPC || entity instanceof Snowman || entity instanceof WaterMob)
|
||||
{
|
||||
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
|
||||
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, new ArrayList<ItemStack>(0));
|
||||
ess.getServer().getPluginManager().callEvent(event);
|
||||
entity.remove();
|
||||
numKills++;
|
||||
@@ -143,7 +131,7 @@ public class Commandkillall extends EssentialsCommand
|
||||
{
|
||||
if (entity instanceof Monster || entity instanceof ComplexLivingEntity || entity instanceof Flying || entity instanceof Slime)
|
||||
{
|
||||
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
|
||||
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, new ArrayList<ItemStack>(0));
|
||||
ess.getServer().getPluginManager().callEvent(event);
|
||||
entity.remove();
|
||||
numKills++;
|
||||
@@ -151,14 +139,14 @@ public class Commandkillall extends EssentialsCommand
|
||||
}
|
||||
else if (all)
|
||||
{
|
||||
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
|
||||
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, new ArrayList<ItemStack>(0));
|
||||
ess.getServer().getPluginManager().callEvent(event);
|
||||
entity.remove();
|
||||
numKills++;
|
||||
}
|
||||
else if (entityClass != null && entityClass.isAssignableFrom(entity.getClass()))
|
||||
{
|
||||
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
|
||||
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, new ArrayList<ItemStack>(0));
|
||||
ess.getServer().getPluginManager().callEvent(event);
|
||||
entity.remove();
|
||||
numKills++;
|
||||
|
@@ -1,8 +1,13 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.*;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.*;
|
||||
import com.earth2me.essentials.Kit;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -26,12 +31,12 @@ public class Commandkit extends EssentialsCommand
|
||||
else if (args.length > 1 && user.isAuthorized("essentials.kit.others"))
|
||||
{
|
||||
final User userTo = getPlayer(server, args, 1, true);
|
||||
final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH));
|
||||
final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH)).trim();
|
||||
giveKit(userTo, user, kitName);
|
||||
}
|
||||
else
|
||||
{
|
||||
final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH));
|
||||
final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH)).trim();
|
||||
giveKit(user, user, kitName);
|
||||
}
|
||||
}
|
||||
@@ -59,12 +64,17 @@ public class Commandkit extends EssentialsCommand
|
||||
}
|
||||
|
||||
private void giveKit(User userTo, User userFrom, String kitName) throws Exception
|
||||
{
|
||||
{
|
||||
if (kitName.isEmpty())
|
||||
{
|
||||
throw new Exception(_("kitError2"));
|
||||
}
|
||||
|
||||
final Map<String, Object> kit = ess.getSettings().getKit(kitName);
|
||||
|
||||
if (!userFrom.isAuthorized("essentials.kit." + kitName))
|
||||
if (!userFrom.isAuthorized("essentials.kits." + kitName))
|
||||
{
|
||||
throw new Exception(_("noKitPermission", "essentials.kit." + kitName));
|
||||
throw new Exception(_("noKitPermission", "essentials.kits." + kitName));
|
||||
}
|
||||
|
||||
final List<String> items = Kit.getItems(userTo, kit);
|
||||
|
@@ -7,7 +7,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
|
||||
|
||||
// This command is not documented on the wiki #EasterEgg
|
||||
public class Commandkittycannon extends EssentialsCommand
|
||||
{
|
||||
private static Random random = new Random();
|
||||
|
@@ -6,17 +6,19 @@ import com.earth2me.essentials.Util;
|
||||
import java.util.List;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandmail extends EssentialsCommand
|
||||
{
|
||||
private static int mailsPerMinute = 0;
|
||||
private static long timestamp = 0;
|
||||
|
||||
public Commandmail()
|
||||
{
|
||||
super("mail");
|
||||
}
|
||||
|
||||
//TODO: Tidy this up
|
||||
//TODO: Tidy this up / TL these errors.
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
@@ -42,24 +44,29 @@ public class Commandmail extends EssentialsCommand
|
||||
throw new Exception(_("noPerm", "essentials.mail.send"));
|
||||
}
|
||||
|
||||
Player player = server.getPlayer(args[1]);
|
||||
User u;
|
||||
if (player != null)
|
||||
{
|
||||
u = ess.getUser(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
u = ess.getOfflineUser(args[1]);
|
||||
}
|
||||
User u = ess.getUser(args[1]);
|
||||
if (u == null)
|
||||
{
|
||||
throw new Exception(_("playerNeverOnServer", args[1]));
|
||||
}
|
||||
if (!u.isIgnoredPlayer(user))
|
||||
{
|
||||
final String mail = Util.sanitizeString(Util.stripFormat(getFinalArg(args, 2)));
|
||||
u.addMail(user.getName() + ": " + mail);
|
||||
final String mail = user.getName() + ": " + Util.sanitizeString(Util.stripFormat(getFinalArg(args, 2)));
|
||||
if (mail.length() > 1000)
|
||||
{
|
||||
throw new Exception("Mail message too long. Try to keep it below 1000");
|
||||
}
|
||||
if (Math.abs(System.currentTimeMillis() - timestamp) > 60000)
|
||||
{
|
||||
timestamp = System.currentTimeMillis();
|
||||
mailsPerMinute = 0;
|
||||
}
|
||||
mailsPerMinute++;
|
||||
if (mailsPerMinute > ess.getSettings().getMailsPerMinute())
|
||||
{
|
||||
throw new Exception("Too many mails have been send within the last minute. Maximum: " + ess.getSettings().getMailsPerMinute());
|
||||
}
|
||||
u.addMail(mail);
|
||||
}
|
||||
user.sendMessage(_("mailSent"));
|
||||
return;
|
||||
@@ -70,7 +77,7 @@ public class Commandmail extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(_("noPerm", "essentials.mail.sendall"));
|
||||
}
|
||||
ess.scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + Util.stripFormat(getFinalArg(args, 1))));
|
||||
ess.runTaskAsynchronously(new SendAll(user.getName() + ": " + Util.stripFormat(getFinalArg(args, 1))));
|
||||
user.sendMessage(_("mailSent"));
|
||||
return;
|
||||
}
|
||||
@@ -96,16 +103,7 @@ public class Commandmail extends EssentialsCommand
|
||||
}
|
||||
else if (args.length >= 3 && "send".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
Player player = server.getPlayer(args[1]);
|
||||
User u;
|
||||
if (player != null)
|
||||
{
|
||||
u = ess.getUser(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
u = ess.getOfflineUser(args[1]);
|
||||
}
|
||||
User u = ess.getUser(args[1]);
|
||||
if (u == null)
|
||||
{
|
||||
throw new Exception(_("playerNeverOnServer", args[1]));
|
||||
@@ -116,21 +114,14 @@ public class Commandmail extends EssentialsCommand
|
||||
}
|
||||
else if (args.length >= 1 && "sendall".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
ess.scheduleAsyncDelayedTask(new SendAll("Server: " + getFinalArg(args, 2)));
|
||||
ess.runTaskAsynchronously(new SendAll("Server: " + getFinalArg(args, 2)));
|
||||
sender.sendMessage(_("mailSent"));
|
||||
return;
|
||||
}
|
||||
else if (args.length >= 2)
|
||||
{
|
||||
//allow sending from console without "send" argument, since it's the only thing the console can do
|
||||
Player player = server.getPlayer(args[0]);
|
||||
User u;
|
||||
if (player != null)
|
||||
{
|
||||
u = ess.getUser(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
u = ess.getOfflineUser(args[0]);
|
||||
}
|
||||
User u = ess.getUser(args[0]);
|
||||
if (u == null)
|
||||
{
|
||||
throw new Exception(_("playerNeverOnServer", args[0]));
|
||||
|
@@ -25,7 +25,7 @@ public class Commandmore extends EssentialsCommand
|
||||
if (stack.getAmount() >= ((user.isAuthorized("essentials.oversizedstacks"))
|
||||
? ess.getSettings().getOversizedStackSize() : stack.getMaxStackSize()))
|
||||
{
|
||||
throw new NoChargeException();
|
||||
throw new Exception(_("fullStack"));
|
||||
}
|
||||
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
if (ess.getSettings().permissionBasedItemSpawn()
|
||||
|
@@ -17,15 +17,15 @@ public class Commandmsg extends EssentialsCommand
|
||||
{
|
||||
super("msg");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2 || args[0].trim().length() < 3 || args[1].trim().isEmpty())
|
||||
if (args.length < 2 || args[0].trim().length() < 2 || args[1].trim().isEmpty())
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
|
||||
String message = getFinalArg(args, 1);
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
@@ -40,12 +40,12 @@ public class Commandmsg extends EssentialsCommand
|
||||
{
|
||||
message = Util.replaceFormat(message);
|
||||
}
|
||||
|
||||
|
||||
final String translatedMe = _("me");
|
||||
|
||||
|
||||
final IReplyTo replyTo = sender instanceof Player ? ess.getUser((Player)sender) : Console.getConsoleReplyTo();
|
||||
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
|
||||
|
||||
if (args[0].equalsIgnoreCase(Console.NAME))
|
||||
{
|
||||
sender.sendMessage(_("msgFormat", translatedMe, Console.NAME, message));
|
||||
@@ -55,14 +55,14 @@ public class Commandmsg extends EssentialsCommand
|
||||
Console.getConsoleReplyTo().setReplyTo(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final List<Player> matchedPlayers = server.matchPlayer(args[0]);
|
||||
|
||||
|
||||
if (matchedPlayers.isEmpty())
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
|
||||
|
||||
int i = 0;
|
||||
for (Player matchedPlayer : matchedPlayers)
|
||||
{
|
||||
@@ -76,17 +76,28 @@ public class Commandmsg extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
|
||||
|
||||
for (Player matchedPlayer : matchedPlayers)
|
||||
{
|
||||
sender.sendMessage(_("msgFormat", translatedMe, matchedPlayer.getDisplayName(), message));
|
||||
{
|
||||
final User matchedUser = ess.getUser(matchedPlayer);
|
||||
if (sender instanceof Player && (matchedUser.isIgnoredPlayer(ess.getUser(sender)) || matchedUser.isHidden()))
|
||||
|
||||
if (sender instanceof Player && matchedUser.isHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (matchedUser.isAfk())
|
||||
{
|
||||
sender.sendMessage(_("userAFK", matchedPlayer.getDisplayName()));
|
||||
}
|
||||
|
||||
sender.sendMessage(_("msgFormat", translatedMe, matchedPlayer.getDisplayName(), message));
|
||||
if (sender instanceof Player && matchedUser.isIgnoredPlayer(ess.getUser(sender)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
matchedPlayer.sendMessage(_("msgFormat", senderName, translatedMe, message));
|
||||
replyTo.setReplyTo(ess.getUser(matchedPlayer));
|
||||
replyTo.setReplyTo(matchedUser);
|
||||
ess.getUser(matchedPlayer).setReplyTo(sender);
|
||||
}
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@ import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandmute extends EssentialsCommand
|
||||
@@ -41,17 +42,31 @@ public class Commandmute extends EssentialsCommand
|
||||
}
|
||||
player.setMuteTimeout(muteTimestamp);
|
||||
final boolean muted = player.getMuted();
|
||||
sender.sendMessage(
|
||||
muted
|
||||
? (muteTimestamp > 0
|
||||
? _("mutedPlayerFor", player.getDisplayName(), Util.formatDateDiff(muteTimestamp))
|
||||
: _("mutedPlayer", player.getDisplayName()))
|
||||
: _("unmutedPlayer", player.getDisplayName()));
|
||||
player.sendMessage(
|
||||
muted
|
||||
? (muteTimestamp > 0
|
||||
? _("playerMutedFor", Util.formatDateDiff(muteTimestamp))
|
||||
: _("playerMuted"))
|
||||
: _("playerUnmuted"));
|
||||
if (muted)
|
||||
{
|
||||
if (muteTimestamp > 0)
|
||||
{
|
||||
sender.sendMessage(_("mutedPlayerFor", player.getDisplayName(), Util.formatDateDiff(muteTimestamp)));
|
||||
player.sendMessage(_("playerMutedFor", Util.formatDateDiff(muteTimestamp)));
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(_("mutedPlayer", player.getDisplayName()));
|
||||
player.sendMessage(_("playerMuted"));
|
||||
}
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final User user = ess.getUser(onlinePlayer);
|
||||
if (onlinePlayer != sender && user.isAuthorized("essentials.mute.notify"))
|
||||
{
|
||||
onlinePlayer.sendMessage(_("muteNotify", sender.getName(), player.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(_("unmutedPlayer", player.getDisplayName()));
|
||||
player.sendMessage(_("playerUnmuted"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -22,7 +22,8 @@ public class Commandpay extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
if (args[0].trim().length() < 3)
|
||||
//TODO: TL this.
|
||||
if (args[0].trim().length() < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException("You need to specify a player to pay.");
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
// This command can be used to echo messages to the users screen, mostly useless but also an #EasterEgg
|
||||
public class Commandping extends EssentialsCommand
|
||||
{
|
||||
public Commandping()
|
||||
|
@@ -24,6 +24,7 @@ public class Commandrealname extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
final String whois = args[0].toLowerCase(Locale.ENGLISH);
|
||||
boolean foundUser = false;
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final User u = ess.getUser(onlinePlayer);
|
||||
@@ -33,13 +34,15 @@ public class Commandrealname extends EssentialsCommand
|
||||
}
|
||||
u.setDisplayNick();
|
||||
final String displayName = Util.stripFormat(u.getDisplayName()).toLowerCase(Locale.ENGLISH);
|
||||
if (!whois.equals(displayName)
|
||||
&& !displayName.equals(Util.stripFormat(ess.getSettings().getNicknamePrefix()) + whois)
|
||||
&& !whois.equalsIgnoreCase(u.getName()))
|
||||
if (displayName.contains(whois))
|
||||
{
|
||||
continue;
|
||||
foundUser = true;
|
||||
sender.sendMessage(u.getDisplayName() + " " + _("is") + " " + u.getName());
|
||||
}
|
||||
sender.sendMessage(u.getDisplayName() + " " + _("is") + " " + u.getName());
|
||||
}
|
||||
if (!foundUser)
|
||||
{
|
||||
throw new NoSuchFieldException(_("playerNotFound"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
196
Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java
Executable file
196
Essentials/src/com/earth2me/essentials/commands/Commandrecipe.java
Executable file
@@ -0,0 +1,196 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.FurnaceRecipe;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.ShapelessRecipe;
|
||||
|
||||
|
||||
public class Commandrecipe extends EssentialsCommand
|
||||
{
|
||||
public Commandrecipe()
|
||||
{
|
||||
super("recipe");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
final ItemStack itemType = ess.getItemDb().get(args[0]);
|
||||
int recipeNo = 0;
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
if (Util.isInt(args[1]))
|
||||
{
|
||||
recipeNo = Integer.parseInt(args[1]) - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("invalidNumber"));
|
||||
}
|
||||
}
|
||||
|
||||
final List<Recipe> recipesOfType = ess.getServer().getRecipesFor(itemType);
|
||||
if (recipesOfType.size() < 1)
|
||||
{
|
||||
throw new Exception(_("recipeNone", getMaterialName(itemType)));
|
||||
}
|
||||
|
||||
if (recipeNo < 0 || recipeNo >= recipesOfType.size())
|
||||
{
|
||||
throw new Exception(_("recipeBadIndex"));
|
||||
}
|
||||
|
||||
final Recipe selectedRecipe = recipesOfType.get(recipeNo);
|
||||
sender.sendMessage(_("recipe", getMaterialName(itemType), recipeNo + 1, recipesOfType.size()));
|
||||
|
||||
if (selectedRecipe instanceof FurnaceRecipe)
|
||||
{
|
||||
furnaceRecipe(sender, (FurnaceRecipe)selectedRecipe);
|
||||
}
|
||||
else if (selectedRecipe instanceof ShapedRecipe)
|
||||
{
|
||||
shapedRecipe(sender, (ShapedRecipe)selectedRecipe);
|
||||
}
|
||||
else if (selectedRecipe instanceof ShapelessRecipe)
|
||||
{
|
||||
shapelessRecipe(sender, (ShapelessRecipe)selectedRecipe);
|
||||
}
|
||||
|
||||
if (recipesOfType.size() > 1 && args.length == 1)
|
||||
{
|
||||
sender.sendMessage(_("recipeMore", commandLabel, args[0], getMaterialName(itemType)));
|
||||
}
|
||||
}
|
||||
|
||||
public void furnaceRecipe(final CommandSender sender, final FurnaceRecipe recipe)
|
||||
{
|
||||
sender.sendMessage(_("recipeFurnace", getMaterialName(recipe.getInput())));
|
||||
}
|
||||
|
||||
public void shapedRecipe(final CommandSender sender, final ShapedRecipe recipe)
|
||||
{
|
||||
final Map<Character, ItemStack> recipeMap = recipe.getIngredientMap();
|
||||
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
final User user = ess.getUser(sender);
|
||||
user.setRecipeSee(true);
|
||||
final InventoryView view = user.openWorkbench(null, true);
|
||||
final String[] recipeShape = recipe.getShape();
|
||||
final Map<Character, ItemStack> ingredientMap = recipe.getIngredientMap();
|
||||
for (int j = 0; j < recipeShape.length; j++)
|
||||
{
|
||||
for (int k = 0; k < recipeShape[j].length(); k++)
|
||||
{
|
||||
final ItemStack item = ingredientMap.get(recipeShape[j].toCharArray()[k]);
|
||||
if(item == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
item.setAmount(0);
|
||||
view.getTopInventory().setItem(j * 3 + k + 1, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final HashMap<Material, String> colorMap = new HashMap<Material, String>();
|
||||
int i = 1;
|
||||
for (Character c : "abcdefghi".toCharArray())
|
||||
{
|
||||
ItemStack item = recipeMap.get(c);
|
||||
if (!colorMap.containsKey(item == null ? null : item.getType()))
|
||||
{
|
||||
colorMap.put(item == null ? null : item.getType(), String.valueOf(i++));
|
||||
}
|
||||
}
|
||||
final Material[][] materials = new Material[3][3];
|
||||
for (int j = 0; j < recipe.getShape().length; j++)
|
||||
{
|
||||
for (int k = 0; k < recipe.getShape()[j].length(); k++)
|
||||
{
|
||||
ItemStack item = recipe.getIngredientMap().get(recipe.getShape()[j].toCharArray()[k]);
|
||||
materials[j][k] = item == null ? null : item.getType();
|
||||
}
|
||||
}
|
||||
sender.sendMessage(_("recipeGrid", colorMap.get(materials[0][0]), colorMap.get(materials[0][1]), colorMap.get(materials[0][2])));
|
||||
sender.sendMessage(_("recipeGrid", colorMap.get(materials[1][0]), colorMap.get(materials[1][1]), colorMap.get(materials[1][2])));
|
||||
sender.sendMessage(_("recipeGrid", colorMap.get(materials[2][0]), colorMap.get(materials[2][1]), colorMap.get(materials[2][2])));
|
||||
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (Material items : colorMap.keySet().toArray(new Material[colorMap.size()]))
|
||||
{
|
||||
s.append(_("recipeGridItem", colorMap.get(items), getMaterialName(items)));
|
||||
}
|
||||
sender.sendMessage(_("recipeWhere", s.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public void shapelessRecipe(final CommandSender sender, final ShapelessRecipe recipe)
|
||||
{
|
||||
final List<ItemStack> ingredients = recipe.getIngredientList();
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
final User user = ess.getUser(sender);
|
||||
user.setRecipeSee(true);
|
||||
final InventoryView view = user.openWorkbench(null, true);
|
||||
for (int i = 0; i < ingredients.size(); i++)
|
||||
{
|
||||
view.setItem(i + 1, ingredients.get(i));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (int i = 0; i < ingredients.size(); i++)
|
||||
{
|
||||
s.append(getMaterialName(ingredients.get(i)));
|
||||
if (i != ingredients.size() - 1)
|
||||
{
|
||||
s.append(",");
|
||||
}
|
||||
s.append(" ");
|
||||
}
|
||||
sender.sendMessage(_("recipeShapeless", s.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public String getMaterialName(final ItemStack stack)
|
||||
{
|
||||
if (stack == null)
|
||||
{
|
||||
return _("recipeNothing");
|
||||
}
|
||||
return getMaterialName(stack.getType());
|
||||
}
|
||||
|
||||
public String getMaterialName(final Material type)
|
||||
{
|
||||
if (type == null)
|
||||
{
|
||||
return _("recipeNothing");
|
||||
}
|
||||
return type.toString().replace("_", " ").toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
}
|
@@ -28,7 +28,7 @@ public class Commandrepair extends EssentialsCommand
|
||||
if (args[0].equalsIgnoreCase("hand"))
|
||||
{
|
||||
final ItemStack item = user.getItemInHand();
|
||||
if (item == null)
|
||||
if (item == null || item.getType().isBlock() || item.getDurability() == 0)
|
||||
{
|
||||
throw new Exception(_("repairInvalidType"));
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public class Commandrepair extends EssentialsCommand
|
||||
}
|
||||
|
||||
final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH);
|
||||
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess);
|
||||
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-" + item.getTypeId(), new Trade("repair-item", ess), ess), ess);
|
||||
|
||||
charge.isAffordableFor(user);
|
||||
|
||||
@@ -100,12 +100,12 @@ public class Commandrepair extends EssentialsCommand
|
||||
{
|
||||
for (ItemStack item : items)
|
||||
{
|
||||
if (item == null)
|
||||
if (item == null || item.getType().isBlock() || item.getDurability() == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH);
|
||||
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), "repair-item", ess);
|
||||
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-" + item.getTypeId(), new Trade("repair-item", ess), ess), ess);
|
||||
try
|
||||
{
|
||||
charge.isAffordableFor(user);
|
||||
|
@@ -35,12 +35,28 @@ public class Commandseen extends EssentialsCommand
|
||||
}
|
||||
try
|
||||
{
|
||||
User player = getPlayer(server, args, 0);
|
||||
player.setDisplayNick();
|
||||
sender.sendMessage(_("seenOnline", player.getDisplayName(), Util.formatDateDiff(player.getLastLogin())));
|
||||
User user = getPlayer(server, args, 0);
|
||||
user.setDisplayNick();
|
||||
sender.sendMessage(_("seenOnline", user.getDisplayName(), Util.formatDateDiff(user.getLastLogin())));
|
||||
if (user.isAfk())
|
||||
{
|
||||
sender.sendMessage(_("whoisAFK", _("true")));
|
||||
}
|
||||
if (user.isJailed())
|
||||
{
|
||||
sender.sendMessage(_("whoisJail", (user.getJailTimeout() > 0
|
||||
? Util.formatDateDiff(user.getJailTimeout())
|
||||
: _("true"))));
|
||||
}
|
||||
if (user.isMuted())
|
||||
{
|
||||
sender.sendMessage(_("whoisMuted", (user.getMuteTimeout() > 0
|
||||
? Util.formatDateDiff(user.getMuteTimeout())
|
||||
: _("true"))));
|
||||
}
|
||||
if (extra)
|
||||
{
|
||||
sender.sendMessage(_("whoisIPAddress", player.getAddress().getAddress().toString()));
|
||||
sender.sendMessage(_("whoisIPAddress", user.getAddress().getAddress().toString()));
|
||||
}
|
||||
}
|
||||
catch (NoSuchFieldException e)
|
||||
@@ -59,8 +75,9 @@ public class Commandseen extends EssentialsCommand
|
||||
if (extra)
|
||||
{
|
||||
sender.sendMessage(_("whoisIPAddress", player.getLastLoginAddress()));
|
||||
final Location loc = player.getLastLocation();
|
||||
if (loc != null) {
|
||||
final Location loc = player.getLogoutLocation();
|
||||
if (loc != null)
|
||||
{
|
||||
sender.sendMessage(_("whoisLocation", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
@@ -22,6 +21,8 @@ public class Commandsell extends EssentialsCommand
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
double totalWorth = 0.0;
|
||||
String type = "";
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
@@ -41,12 +42,16 @@ public class Commandsell extends EssentialsCommand
|
||||
}
|
||||
try
|
||||
{
|
||||
sellItem(user, stack, args, true);
|
||||
totalWorth += sellItem(user, stack, args, true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
if (totalWorth > 0)
|
||||
{
|
||||
user.sendMessage(_("totalWorthAll", type, Util.displayCurrency(totalWorth, ess)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("blocks"))
|
||||
@@ -59,12 +64,16 @@ public class Commandsell extends EssentialsCommand
|
||||
}
|
||||
try
|
||||
{
|
||||
sellItem(user, stack, args, true);
|
||||
totalWorth += sellItem(user, stack, args, true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
if (totalWorth > 0)
|
||||
{
|
||||
user.sendMessage(_("totalWorthBlocks", type, Util.displayCurrency(totalWorth, ess)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (is == null)
|
||||
@@ -74,7 +83,7 @@ public class Commandsell extends EssentialsCommand
|
||||
sellItem(user, is, args, false);
|
||||
}
|
||||
|
||||
private void sellItem(User user, ItemStack is, String[] args, boolean isBulkSell) throws Exception
|
||||
private double sellItem(User user, ItemStack is, String[] args, boolean isBulkSell) throws Exception
|
||||
{
|
||||
if (is == null || is.getType() == Material.AIR)
|
||||
{
|
||||
@@ -107,19 +116,7 @@ public class Commandsell extends EssentialsCommand
|
||||
int max = 0;
|
||||
for (ItemStack s : user.getInventory().getContents())
|
||||
{
|
||||
if (s == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (s.getTypeId() != is.getTypeId())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (s.getDurability() != is.getDurability())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!s.getEnchantments().equals(is.getEnchantments()))
|
||||
if (s == null || !s.isSimilar(is))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -149,19 +146,23 @@ public class Commandsell extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
return worth * amount;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Prices for Enchantments
|
||||
final ItemStack ris = is.clone();
|
||||
ris.setAmount(amount);
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, true, ris);
|
||||
if (!user.getInventory().containsAtLeast(ris, amount)) {
|
||||
// This should never happen.
|
||||
throw new IllegalStateException("Trying to remove more items than are available.");
|
||||
}
|
||||
user.getInventory().removeItem(ris);
|
||||
user.updateInventory();
|
||||
Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(worth * amount, ess), user.getLocation(), ess);
|
||||
user.giveMoney(worth * amount);
|
||||
user.sendMessage(_("itemSold", Util.displayCurrency(worth * amount, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth, ess)));
|
||||
logger.log(Level.INFO, _("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth * amount, ess), amount, Util.displayCurrency(worth, ess)));
|
||||
|
||||
return worth * amount;
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,9 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
|
||||
|
||||
@@ -16,6 +18,10 @@ public class Commandsethome extends EssentialsCommand
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
User usersHome = user;
|
||||
String name = "home";
|
||||
final Location location = user.getLocation();
|
||||
|
||||
if (args.length > 0)
|
||||
{
|
||||
//Allowing both formats /sethome khobbits house | /sethome khobbits:house
|
||||
@@ -27,59 +33,52 @@ public class Commandsethome extends EssentialsCommand
|
||||
|
||||
if (args.length < 2)
|
||||
{
|
||||
if (user.isAuthorized("essentials.sethome.multiple"))
|
||||
{
|
||||
if ("bed".equals(args[0].toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getHomeLimit(user))
|
||||
|| (user.getHomes().contains(args[0].toLowerCase(Locale.ENGLISH))))
|
||||
{
|
||||
user.setHome(args[0].toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("maxHomes", ess.getSettings().getHomeLimit(user)));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("maxHomes", 1));
|
||||
}
|
||||
name = args[0].toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user.isAuthorized("essentials.sethome.others"))
|
||||
{
|
||||
User usersHome = ess.getUser(ess.getServer().getPlayer(args[0]));
|
||||
usersHome = ess.getUser(args[0]);
|
||||
if (usersHome == null)
|
||||
{
|
||||
usersHome = ess.getOfflineUser(args[0]);
|
||||
throw new NoSuchFieldException(_("playerNotFound"));
|
||||
}
|
||||
if (usersHome == null)
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
String name = args[1].toLowerCase(Locale.ENGLISH);
|
||||
if (!user.isAuthorized("essentials.sethome.multiple"))
|
||||
{
|
||||
name = "home";
|
||||
}
|
||||
if ("bed".equals(name.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
usersHome.setHome(name, user.getLocation());
|
||||
name = args[1].toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (checkHomeLimit(user, usersHome, name))
|
||||
{
|
||||
user.setHome();
|
||||
name = "home";
|
||||
}
|
||||
if ("bed".equals(name) || Util.isInt(name))
|
||||
{
|
||||
throw new NoSuchFieldException(_("invalidHomeName"));
|
||||
}
|
||||
usersHome.setHome(name, location);
|
||||
user.sendMessage(_("homeSet", user.getLocation().getWorld().getName(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ()));
|
||||
|
||||
}
|
||||
|
||||
private boolean checkHomeLimit(final User user, final User usersHome, String name) throws Exception
|
||||
{
|
||||
if (!user.isAuthorized("essentials.sethome.multiple.unlimited"))
|
||||
{
|
||||
int limit = ess.getSettings().getHomeLimit(user);
|
||||
if (usersHome.getHomes().size() == limit && usersHome.getHomes().contains(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (usersHome.getHomes().size() >= limit)
|
||||
{
|
||||
throw new Exception(_("maxHomes", ess.getSettings().getHomeLimit(user)));
|
||||
}
|
||||
if (limit == 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -22,9 +22,10 @@ public class Commandsetwarp extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
if (args[0].matches("[0-9]+")) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
|
||||
if (Util.isInt(args[0]))
|
||||
{
|
||||
throw new NoSuchFieldException(_("invalidWarpName"));
|
||||
}
|
||||
|
||||
final Location loc = user.getLocation();
|
||||
@@ -39,7 +40,7 @@ public class Commandsetwarp extends EssentialsCommand
|
||||
{
|
||||
}
|
||||
|
||||
if (warpLoc == null || user.isAuthorized("essentials.warp.overwrite." + Util.sanitizeFileName(args[0])))
|
||||
if (warpLoc == null || user.isAuthorized("essentials.warp.overwrite." + Util.safeString(args[0])))
|
||||
{
|
||||
warps.setWarp(args[0], loc);
|
||||
}
|
||||
|
@@ -1,13 +1,15 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.*;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Mob;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
|
||||
public class Commandspawner extends EssentialsCommand
|
||||
@@ -32,6 +34,7 @@ public class Commandspawner extends EssentialsCommand
|
||||
}
|
||||
|
||||
String name = args[0];
|
||||
int delay = 0;
|
||||
|
||||
Mob mob = null;
|
||||
mob = Mob.fromName(name);
|
||||
@@ -47,11 +50,20 @@ public class Commandspawner extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(_("noPermToSpawnMob"));
|
||||
}
|
||||
if (args.length > 1)
|
||||
{
|
||||
if (Util.isInt(args[1]))
|
||||
{
|
||||
delay = Integer.parseInt(args[1]);
|
||||
}
|
||||
}
|
||||
final Trade charge = new Trade("spawner-" + mob.name.toLowerCase(Locale.ENGLISH), ess);
|
||||
charge.isAffordableFor(user);
|
||||
try
|
||||
{
|
||||
((CreatureSpawner)target.getBlock().getState()).setSpawnedType(mob.getType());
|
||||
CreatureSpawner spawner = (CreatureSpawner)target.getBlock().getState();
|
||||
spawner.setSpawnedType(mob.getType());
|
||||
spawner.setDelay(delay);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user