mirror of
https://github.com/EssentialsX/Essentials.git
synced 2026-11-05 09:10:17 -05:00
Compare commits
688
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8bb50189bc | ||
|
|
eb665a059a | ||
|
|
f2407bcc31 | ||
|
|
a8cfbe1eab | ||
|
|
03b73072d9 | ||
|
|
48049f3870 | ||
|
|
d2c553652f | ||
|
|
3dc29be083 | ||
|
|
ee00fb77d0 | ||
|
|
d890418944 | ||
|
|
8e0560ae1a | ||
|
|
82e5447526 | ||
|
|
8b23f8608d | ||
|
|
0dd5134f5a | ||
|
|
a39a904c8a | ||
|
|
1d38b72835 | ||
|
|
efcab71969 | ||
|
|
41e11a738d | ||
|
|
62e1710607 | ||
|
|
c681befdf2 | ||
|
|
2db256678e | ||
|
|
a2ca381bbd | ||
|
|
32f5a31ea5 | ||
|
|
87dc671a0d | ||
|
|
621f9b4f48 | ||
|
|
3858e1cdd6 | ||
|
|
ff7cc5aec9 | ||
|
|
d18a47a643 | ||
|
|
497a08940e | ||
|
|
bd8fe521cd | ||
|
|
59c93901d3 | ||
|
|
3177f25eb6 | ||
|
|
b0fe189156 | ||
|
|
8103e822ed | ||
|
|
c597653ce2 | ||
|
|
d9ceb727ef | ||
|
|
2844af0039 | ||
|
|
066f3fd726 | ||
|
|
e9c0bb2133 | ||
|
|
f0acf733a5 | ||
|
|
33c6fc1f1f | ||
|
|
91b504cc66 | ||
|
|
6ea57bcd2f | ||
|
|
c92c066a3a | ||
|
|
caff3c115b | ||
|
|
517961b26a | ||
|
|
85f63d0afe | ||
|
|
ecc56351ec | ||
|
|
9b04705ec9 | ||
|
|
e786653364 | ||
|
|
e5613d43cc | ||
|
|
ce8f05cd94 | ||
|
|
e52a9c1f6b | ||
|
|
de744fe9e2 | ||
|
|
a0031d1d45 | ||
|
|
d60dd01f0f | ||
|
|
ad3bc2ad98 | ||
|
|
cf69a6d72c | ||
|
|
1a65a31a7e | ||
|
|
9c998eac2f | ||
|
|
2bdc00dc14 | ||
|
|
83e8dac6a0 | ||
|
|
3879d582d3 | ||
|
|
1fd5222d40 | ||
|
|
fe15bab05f | ||
|
|
f2dd51cf57 | ||
|
|
ac1f2badc7 | ||
|
|
d3f6e82474 | ||
|
|
676f941bb8 | ||
|
|
bd74bd1286 | ||
|
|
5831cde90e | ||
|
|
b2394048fa | ||
|
|
4811e46dd6 | ||
|
|
8d266a3440 | ||
|
|
f680fb1b76 | ||
|
|
a845f351f8 | ||
|
|
997a409b5a | ||
|
|
a6673c5157 | ||
|
|
5ef7135fc8 | ||
|
|
4c698762c3 | ||
|
|
82e389be8f | ||
|
|
1df79bc9f4 | ||
|
|
ab590af927 | ||
|
|
002e4a2772 | ||
|
|
0e9b971280 | ||
|
|
73b5fe971f | ||
|
|
6398626559 | ||
|
|
828f97c9a8 | ||
|
|
d6d4752383 | ||
|
|
d2bf35dac2 | ||
|
|
8d6e3e7c18 | ||
|
|
0b057d8e29 | ||
|
|
4c6cc5ced0 | ||
|
|
b828222176 | ||
|
|
bbab993ef1 | ||
|
|
b110ce79cc | ||
|
|
ab530f35d0 | ||
|
|
0654a76ccc | ||
|
|
e8fbdef38b | ||
|
|
96c4dd2ab9 | ||
|
|
998d097d7d | ||
|
|
df3b9a7ef9 | ||
|
|
fd6f768cca | ||
|
|
aa085de3e7 | ||
|
|
2e1c880502 | ||
|
|
e3756623a1 | ||
|
|
8f28073b29 | ||
|
|
e2024ca2b6 | ||
|
|
80491513a2 | ||
|
|
f67e13122d | ||
|
|
16e19a7775 | ||
|
|
a220b267d4 | ||
|
|
1153a0eee4 | ||
|
|
7d8b0c102c | ||
|
|
4abbbcb82b | ||
|
|
248e4e2ae2 | ||
|
|
fb211d722c | ||
|
|
1b3698283e | ||
|
|
cccddc3311 | ||
|
|
70a3a5919e | ||
|
|
fc7a3e091d | ||
|
|
f6b4daebb5 | ||
|
|
688d37ee60 | ||
|
|
382bd24046 | ||
|
|
e0d913dbaf | ||
|
|
bb1cad1bc1 | ||
|
|
d7af679243 | ||
|
|
c8f6ea7f8e | ||
|
|
d3dd4980a4 | ||
|
|
b140f606b4 | ||
|
|
057c9cb3f5 | ||
|
|
3dcf8bc8fc | ||
|
|
ecc1a0acea | ||
|
|
afb951461c | ||
|
|
e9a14b204f | ||
|
|
1cbdbc40a5 | ||
|
|
5d4aa95fc3 | ||
|
|
17e11adf9a | ||
|
|
3454db3e2b | ||
|
|
7039d613ee | ||
|
|
12e3eb1a23 | ||
|
|
a60f040f7e | ||
|
|
22c277f9ab | ||
|
|
fa423b3dd2 | ||
|
|
0c37e091c0 | ||
|
|
3dd3fa4519 | ||
|
|
b559809bfa | ||
|
|
59e45592cf | ||
|
|
1fb57cb678 | ||
|
|
fba4dd2d9a | ||
|
|
3ec0dbd404 | ||
|
|
5a5dc933ad | ||
|
|
6427a93d14 | ||
|
|
610a713997 | ||
|
|
347be03b25 | ||
|
|
322ecdb9fc | ||
|
|
033babd586 | ||
|
|
d3302dea00 | ||
|
|
8249a961f6 | ||
|
|
41344ce1b0 | ||
|
|
65be2dba99 | ||
|
|
087e600d6d | ||
|
|
f18c3c7e1d | ||
|
|
394a786044 | ||
|
|
14030deb16 | ||
|
|
0543a8f8ba | ||
|
|
34987d6e07 | ||
|
|
631583aef0 | ||
|
|
8998168ec2 | ||
|
|
00050d08d4 | ||
|
|
aa47499656 | ||
|
|
bc93bc6ae7 | ||
|
|
dfd283d998 | ||
|
|
016dd10060 | ||
|
|
8281908306 | ||
|
|
01861e5a64 | ||
|
|
3d913f9fcc | ||
|
|
6c738294d1 | ||
|
|
30f0f78efc | ||
|
|
8cc249c2d3 | ||
|
|
6946488e0d | ||
|
|
53a73998a2 | ||
|
|
f12a14d7f7 | ||
|
|
089c2210bd | ||
|
|
1a2fc307fd | ||
|
|
38aa85dd0c | ||
|
|
c374f474ed | ||
|
|
2a1b19a8a8 | ||
|
|
325889c466 | ||
|
|
216cc7f681 | ||
|
|
7df5098bf6 | ||
|
|
27adc21446 | ||
|
|
5de354af86 | ||
|
|
bb32ec9567 | ||
|
|
6ee7017603 | ||
|
|
9dc54340f8 | ||
|
|
0592c1fe11 | ||
|
|
90419cdbf5 | ||
|
|
91393e3180 | ||
|
|
dfdf49ac35 | ||
|
|
d2a3240905 | ||
|
|
1138e32292 | ||
|
|
256c963370 | ||
|
|
d818f705ad | ||
|
|
1ac033a60e | ||
|
|
af248a1d2e | ||
|
|
c0d21b6044 | ||
|
|
e10675dfdc | ||
|
|
7b8c2a4575 | ||
|
|
812a357361 | ||
|
|
ac20207ea1 | ||
|
|
43d7fb367b | ||
|
|
040e2bee86 | ||
|
|
6f88e7bb98 | ||
|
|
45f88016fc | ||
|
|
5a1ea77019 | ||
|
|
83fc7de01a | ||
|
|
d14f278ecf | ||
|
|
69b76b810c | ||
|
|
2c787e07ec | ||
|
|
3e9b27e3ef | ||
|
|
4bc3d5efad | ||
|
|
9791dcc0bc | ||
|
|
84068c18b1 | ||
|
|
a32b55e28f | ||
|
|
8d1262fc91 | ||
|
|
a2f727bebc | ||
|
|
7f1ba0d6ae | ||
|
|
2b48045a8f | ||
|
|
7e5b79aa14 | ||
|
|
a53d8ddef1 | ||
|
|
2690696712 | ||
|
|
086343ee48 | ||
|
|
c79ac59bc0 | ||
|
|
a1ad512a80 | ||
|
|
6a9865cd67 | ||
|
|
5d95d1fca6 | ||
|
|
2541efb682 | ||
|
|
8ff405f2fe | ||
|
|
376d206d2b | ||
|
|
6295127589 | ||
|
|
1c381fc203 | ||
|
|
b93d289176 | ||
|
|
a2fa666fd5 | ||
|
|
76eb00575b | ||
|
|
81d7be4f77 | ||
|
|
b776362be7 | ||
|
|
65df249510 | ||
|
|
6fa2b14d65 | ||
|
|
6ec674d0a3 | ||
|
|
93883cfc12 | ||
|
|
2e565f8881 | ||
|
|
b851cd10f2 | ||
|
|
576b48c08c | ||
|
|
5ca9927987 | ||
|
|
a753f322df | ||
|
|
300ee9c729 | ||
|
|
1fbed62c1d | ||
|
|
a21d80ecd8 | ||
|
|
1e7bf9a46c | ||
|
|
19595c5847 | ||
|
|
47c8217511 | ||
|
|
db50d455df | ||
|
|
ec5746dbe6 | ||
|
|
05ba5c00e6 | ||
|
|
bb2b504d7a | ||
|
|
5bb86309f6 | ||
|
|
abbeb0a212 | ||
|
|
d9d781a33a | ||
|
|
327c15c5be | ||
|
|
858e2a8b89 | ||
|
|
33d37a2f96 | ||
|
|
a8f6014a42 | ||
|
|
a117080b32 | ||
|
|
f75390bd3f | ||
|
|
b07ba21659 | ||
|
|
a109134b92 | ||
|
|
69d3921a6a | ||
|
|
ca3369938d | ||
|
|
fbd9ee9453 | ||
|
|
8185b05b5d | ||
|
|
b9fc6a0b2b | ||
|
|
62ebf3db41 | ||
|
|
a90b16be36 | ||
|
|
d07ecde47d | ||
|
|
5db35458e8 | ||
|
|
cf4752dad6 | ||
|
|
a085503c84 | ||
|
|
9a893f65fe | ||
|
|
cc273e919c | ||
|
|
65702ea0bf | ||
|
|
614b7b84f7 | ||
|
|
a04e0533d6 | ||
|
|
b85a5e9e0d | ||
|
|
bb6b2c9374 | ||
|
|
df47aad478 | ||
|
|
9eb73cf854 | ||
|
|
12777af61a | ||
|
|
acb50786c4 | ||
|
|
33f48eae0d | ||
|
|
7b18343e75 | ||
|
|
9bb2ef9cbe | ||
|
|
beb34a7651 | ||
|
|
0ac26265e2 | ||
|
|
d6dc6d1d39 | ||
|
|
0ab8a2760d | ||
|
|
8bb4067f06 | ||
|
|
fe1820134b | ||
|
|
7d7c686e6a | ||
|
|
0b681c3654 | ||
|
|
23eeb82ac4 | ||
|
|
edd6adc78f | ||
|
|
c9028623ac | ||
|
|
dd5bcb8762 | ||
|
|
bc1c252dca | ||
|
|
19ba6e5195 | ||
|
|
864e608582 | ||
|
|
b84785cc82 | ||
|
|
832910d480 | ||
|
|
164541794e | ||
|
|
13da2b2924 | ||
|
|
84ac520353 | ||
|
|
7aea9e71e8 | ||
|
|
5613975314 | ||
|
|
dc0ca35017 | ||
|
|
662d30ae45 | ||
|
|
4099755b9b | ||
|
|
57bee443b1 | ||
|
|
0f3c0e82f2 | ||
|
|
0e21d3287e | ||
|
|
3cedfeef2c | ||
|
|
a20f2b71da | ||
|
|
b2e3290038 | ||
|
|
979592c8ba | ||
|
|
7001798874 | ||
|
|
40a2bccf2d | ||
|
|
ee13d33b66 | ||
|
|
fdb46f60fd | ||
|
|
5027198010 | ||
|
|
90a5a4a470 | ||
|
|
85cab9533e | ||
|
|
304b13ca5e | ||
|
|
6a1c53dd01 | ||
|
|
d7b2ac97aa | ||
|
|
7b7289db4c | ||
|
|
ba2b827d7c | ||
|
|
621618e41f | ||
|
|
54559172c6 | ||
|
|
6ccb60813a | ||
|
|
2067bb8f0d | ||
|
|
b34119901e | ||
|
|
4f31d2779d | ||
|
|
ed29f29622 | ||
|
|
b8e41df0f6 | ||
|
|
602517473d | ||
|
|
cee0823db4 | ||
|
|
b317aef8c9 | ||
|
|
8b41219fcc | ||
|
|
61fa43a769 | ||
|
|
fdbc6fa94f | ||
|
|
28dd14d38c | ||
|
|
0ffe24903a | ||
|
|
f6e6e0042a | ||
|
|
e550a7cc44 | ||
|
|
9efc0840e3 | ||
|
|
82165a2af6 | ||
|
|
815b700eac | ||
|
|
fcda9f9d3b | ||
|
|
aa663c0c98 | ||
|
|
bda2f5e615 | ||
|
|
377f967dab | ||
|
|
63a4fe32c1 | ||
|
|
06dc9c25af | ||
|
|
feb1c53004 | ||
|
|
2530a5018f | ||
|
|
4bb1185bd5 | ||
|
|
d5c8d0c1bf | ||
|
|
8828fb0868 | ||
|
|
cc29ebbbc9 | ||
|
|
1c44a25a4a | ||
|
|
0483635a5c | ||
|
|
cf21ecee2e | ||
|
|
3b59dd0b02 | ||
|
|
5467e502a5 | ||
|
|
e805d1047f | ||
|
|
dc99efb0a7 | ||
|
|
6a156ede68 | ||
|
|
4a963b22f1 | ||
|
|
6af9ec266b | ||
|
|
150a0e0ddd | ||
|
|
d388290427 | ||
|
|
c8ba06f0ee | ||
|
|
a65390ed98 | ||
|
|
6b85b306ef | ||
|
|
faa7e0e7a9 | ||
|
|
fdbb6510ef | ||
|
|
aa3606007a | ||
|
|
d0bf1905a9 | ||
|
|
548666b79b | ||
|
|
6dbb5bc605 | ||
|
|
15687c20d0 | ||
|
|
81cc5b1f28 | ||
|
|
7aea8a3fce | ||
|
|
db5974970d | ||
|
|
d2bc7e01a2 | ||
|
|
3d232e13d9 | ||
|
|
83b71eef5e | ||
|
|
13e5f22c25 | ||
|
|
b88d0f88a1 | ||
|
|
d727cad2db | ||
|
|
fd1256b449 | ||
|
|
c3235b3694 | ||
|
|
c1c3005454 | ||
|
|
a3c71e4617 | ||
|
|
5aa2bc1706 | ||
|
|
277c623a77 | ||
|
|
e37db99c56 | ||
|
|
be83383fd5 | ||
|
|
033151a170 | ||
|
|
ba2539db67 | ||
|
|
e3a470e264 | ||
|
|
21d0661d79 | ||
|
|
1556801834 | ||
|
|
e0dc003464 | ||
|
|
81f0ad4d92 | ||
|
|
1ce6be5944 | ||
|
|
cc31fbed8e | ||
|
|
29a15dfe18 | ||
|
|
2f00865847 | ||
|
|
462fe18b15 | ||
|
|
31326d530f | ||
|
|
9f3eb461a9 | ||
|
|
48230f615d | ||
|
|
34b0deba29 | ||
|
|
088f50ce8a | ||
|
|
d9a93d8dff | ||
|
|
5ad12b52f8 | ||
|
|
747776344b | ||
|
|
f979a79081 | ||
|
|
e6685abe4d | ||
|
|
f867f675b9 | ||
|
|
d9bfabd652 | ||
|
|
d9b88a83d1 | ||
|
|
a8fdce257b | ||
|
|
c3a8958046 | ||
|
|
d0345e45b6 | ||
|
|
5ab3422b29 | ||
|
|
66c4a24852 | ||
|
|
db27a8c627 | ||
|
|
78c376af79 | ||
|
|
b749cd4e42 | ||
|
|
a0554f566d | ||
|
|
1696d7ae71 | ||
|
|
ad8ad8b574 | ||
|
|
3c28dabfad | ||
|
|
a38fe6acd4 | ||
|
|
f104c2e8f6 | ||
|
|
4dc92a144e | ||
|
|
1a7b198353 | ||
|
|
25c9557c59 | ||
|
|
963fd7cf01 | ||
|
|
d7080950b0 | ||
|
|
9c51f6e177 | ||
|
|
39352da929 | ||
|
|
ad65e66a7c | ||
|
|
132ddc323f | ||
|
|
411e96bb18 | ||
|
|
705f9c267c | ||
|
|
d2db6348d9 | ||
|
|
ae7275c7ad | ||
|
|
cecb9867d9 | ||
|
|
7e65038ae7 | ||
|
|
37d77f3e89 | ||
|
|
f4ef5a2094 | ||
|
|
af364b4bb4 | ||
|
|
cd4c58cfcb | ||
|
|
3898970bba | ||
|
|
fb8f89e6dc | ||
|
|
1b0b0b1b57 | ||
|
|
4c89ef5638 | ||
|
|
5478a47e25 | ||
|
|
48affa91b0 | ||
|
|
fa2f97760b | ||
|
|
557ca86ab2 | ||
|
|
b32d28be37 | ||
|
|
b9b5db8ccd | ||
|
|
7ec1ca651f | ||
|
|
8245adfd08 | ||
|
|
beea6879b1 | ||
|
|
e4ba0245be | ||
|
|
aefbf921fe | ||
|
|
8a1fb88ecd | ||
|
|
962b6848c4 | ||
|
|
2086b8c978 | ||
|
|
343291b210 | ||
|
|
7ed57bc291 | ||
|
|
367e9840cc | ||
|
|
ea590c2ed1 | ||
|
|
cb5ab32be6 | ||
|
|
244674124b | ||
|
|
39770cd46d | ||
|
|
f58fa10686 | ||
|
|
da8d5454d4 | ||
|
|
71c11d05fd | ||
|
|
dab37c7b5b | ||
|
|
ce14779d2b | ||
|
|
a447bc7e66 | ||
|
|
4d3e8332a8 | ||
|
|
367fcdd029 | ||
|
|
3b838cc23d | ||
|
|
f2d9b10e87 | ||
|
|
fc2c67ceda | ||
|
|
d02380edba | ||
|
|
3a1d0032c6 | ||
|
|
ef37306701 | ||
|
|
34568ea8fc | ||
|
|
56a2398d9b | ||
|
|
db03b3c09e | ||
|
|
b272374072 | ||
|
|
8afde1ccc0 | ||
|
|
674128b3f7 | ||
|
|
c2936186f8 | ||
|
|
5006c68af2 | ||
|
|
526df76ca9 | ||
|
|
e92aeee91b | ||
|
|
f2107047da | ||
|
|
f280985dd6 | ||
|
|
f610dd9c72 | ||
|
|
7e4cbd7b26 | ||
|
|
ffd1154ca3 | ||
|
|
7f4ba16388 | ||
|
|
66dafdca0d | ||
|
|
3a8b888e7c | ||
|
|
ed1aa2f9dc | ||
|
|
4eb94e7fac | ||
|
|
16b101b958 | ||
|
|
ff8564787a | ||
|
|
6616d9a62f | ||
|
|
ae053dea58 | ||
|
|
335c9f37ab | ||
|
|
914a44007d | ||
|
|
bbd10b90c0 | ||
|
|
d93120257b | ||
|
|
e763b362d9 | ||
|
|
5ae0ab745f | ||
|
|
e5eb1ca0cb | ||
|
|
ecaecc5e62 | ||
|
|
e596f85953 | ||
|
|
aef2ca3e5d | ||
|
|
bd7a50ad07 | ||
|
|
5346b112a4 | ||
|
|
d95d7745ad | ||
|
|
6c9a57d4b3 | ||
|
|
60235d0da4 | ||
|
|
995f18bb0f | ||
|
|
a720bf33ce | ||
|
|
ea2649db5e | ||
|
|
0f87670991 | ||
|
|
b53fc9cadc | ||
|
|
4b35e1b729 | ||
|
|
016defd043 | ||
|
|
2aa88d05cf | ||
|
|
c530030e5d | ||
|
|
48e0073b31 | ||
|
|
ce6d5596aa | ||
|
|
40e106db13 | ||
|
|
3dc0659f66 | ||
|
|
8f32d66e03 | ||
|
|
1c11ab0957 | ||
|
|
fafd9b20a9 | ||
|
|
a6d60dbc94 | ||
|
|
fa5d6fbfae | ||
|
|
88ded926f4 | ||
|
|
3b9a07e560 | ||
|
|
512a1b9183 | ||
|
|
e652ed2981 | ||
|
|
28db891aa5 | ||
|
|
b63ae9b771 | ||
|
|
fb834bf104 | ||
|
|
953ce38d63 | ||
|
|
ca29f18850 | ||
|
|
503b4fee55 | ||
|
|
b7cb11cd95 | ||
|
|
cfa8b8e2f4 | ||
|
|
70621e3eff | ||
|
|
0731580cc9 | ||
|
|
8bb3a76366 | ||
|
|
209a9a2f95 | ||
|
|
d50d8bfee0 | ||
|
|
b0e606568f | ||
|
|
22ea5b0f8b | ||
|
|
6676efe029 | ||
|
|
6b360da8d8 | ||
|
|
198b205d83 | ||
|
|
b9e56d100c | ||
|
|
0a924bf226 | ||
|
|
2ea5e6c03b | ||
|
|
efaed85188 | ||
|
|
c378d98b0f | ||
|
|
9d6727daf2 | ||
|
|
c6aa5f1e68 | ||
|
|
a16ced78a5 | ||
|
|
cdea68443a | ||
|
|
e24c053b95 | ||
|
|
798d4458d4 | ||
|
|
a228708138 | ||
|
|
5d8f5cecee | ||
|
|
34f650e270 | ||
|
|
49bdf5719e | ||
|
|
fd2d2456b9 | ||
|
|
adc7502115 | ||
|
|
631c7f30b6 | ||
|
|
46cba7a9a7 | ||
|
|
246383804a | ||
|
|
32bbe877aa | ||
|
|
0eee5acac7 | ||
|
|
7d112a957c | ||
|
|
76c06ce17a | ||
|
|
350a951e8b | ||
|
|
6cc742b139 | ||
|
|
ebc56c0e15 | ||
|
|
f0c503dd13 | ||
|
|
bfa8b26661 | ||
|
|
772bf4c7d0 | ||
|
|
edefb21142 | ||
|
|
01f69b3f2b | ||
|
|
26c9b34744 | ||
|
|
dfad01d558 | ||
|
|
b974410dd9 | ||
|
|
d01e2e0a3b | ||
|
|
5a544fd251 | ||
|
|
f5fac6f9f5 | ||
|
|
5d925aa338 | ||
|
|
8136179e55 | ||
|
|
dea44d7cbc | ||
|
|
e0597f2df1 | ||
|
|
99268b9d9e | ||
|
|
bcf81d9f0a | ||
|
|
775c8d34dd | ||
|
|
75973f69a5 | ||
|
|
f04b7133eb | ||
|
|
b1446154bf | ||
|
|
640f51564a | ||
|
|
5c258c03dc | ||
|
|
bc8aa0c77a | ||
|
|
cc18f95bc9 | ||
|
|
9e5c64ae9c | ||
|
|
7bbb62ce50 | ||
|
|
d8a81923b1 | ||
|
|
1321f8de5d | ||
|
|
4bfc8e1459 | ||
|
|
4f16c8b5a7 | ||
|
|
a45e620946 | ||
|
|
d877880171 | ||
|
|
a91aeb1a76 | ||
|
|
b7791caa75 | ||
|
|
6c862e72b5 | ||
|
|
710088fb13 | ||
|
|
198607d425 | ||
|
|
4bbc2aa8d5 | ||
|
|
c038751c0b | ||
|
|
f1b544a96f | ||
|
|
9a4ef7cd20 | ||
|
|
bc3d8d5ece | ||
|
|
1751baeed6 | ||
|
|
7b825cc8d5 | ||
|
|
a005436510 | ||
|
|
541fc51780 | ||
|
|
aef2dd35d6 | ||
|
|
e94a01b149 | ||
|
|
1a572bca2e | ||
|
|
5a47d18a9b | ||
|
|
991a5cb24c | ||
|
|
e8e97e86a0 | ||
|
|
f6cedda1e2 | ||
|
|
3dab3d8df8 | ||
|
|
3e359b5b48 | ||
|
|
09e17a4d6c | ||
|
|
651b89d97b | ||
|
|
0ff89abeee | ||
|
|
8ba3e3c2f9 | ||
|
|
e53ce03d36 | ||
|
|
aeb3b0f37c | ||
|
|
2d038579ba | ||
|
|
ba86a338c2 | ||
|
|
1bcc2e6e50 | ||
|
|
797dde94e1 | ||
|
|
b83bb1faa3 |
No files matched your search
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="lib/bukkit-0.0.1-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="lib/craftbukkit-0.0.1-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="lib/Permissions3.jar"/>
|
||||
</classpath>
|
||||
+11
-1
@@ -22,4 +22,14 @@
|
||||
/EssentialsXMPP/dist/
|
||||
/EssentialsXMPP/build/
|
||||
/EssentialsProtect/dist/
|
||||
/EssentialsProtect/build/
|
||||
/EssentialsProtect/build/
|
||||
/EssentialsPermissionsCommands/nbproject/private/
|
||||
/EssentialsPermissionsCommands/build/
|
||||
/EssentialsPermissionsCommands/dist/
|
||||
/Essentials/nbproject/private/
|
||||
/Essentials/dist/
|
||||
/Essentials/build/
|
||||
/YamlAnnotations/
|
||||
/EssentialsUpdate/nbproject/private/
|
||||
/EssentialsRelease/
|
||||
/EssentialsUpdate/
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Essentials</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -650,6 +650,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.EssentialsXMPP}" name="call.subproject"/>
|
||||
<param location="${project.EssentialsXMPP}/build.xml" name="call.script"/>
|
||||
<param name="call.target" value="jar"/>
|
||||
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
|
||||
</antcall>
|
||||
</target>
|
||||
<target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
|
||||
<target depends="init" name="-check-automatic-build">
|
||||
@@ -917,11 +924,12 @@ is divided into following sections:
|
||||
<classpath>
|
||||
<path path="${javac.classpath}"/>
|
||||
</classpath>
|
||||
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
|
||||
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
|
||||
<filename name="**/*.java"/>
|
||||
</fileset>
|
||||
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
|
||||
<include name="**/*.java"/>
|
||||
<exclude name="*.java"/>
|
||||
</fileset>
|
||||
</javadoc>
|
||||
<copy todir="${dist.javadoc.dir}">
|
||||
@@ -1135,6 +1143,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.EssentialsXMPP}" name="call.subproject"/>
|
||||
<param location="${project.EssentialsXMPP}/build.xml" name="call.script"/>
|
||||
<param name="call.target" value="clean"/>
|
||||
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
|
||||
</antcall>
|
||||
</target>
|
||||
<target depends="init" name="-do-clean">
|
||||
<delete dir="${build.dir}"/>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
build.xml.data.CRC32=c4188209
|
||||
build.xml.data.CRC32=51b33957
|
||||
build.xml.script.CRC32=7a797370
|
||||
build.xml.stylesheet.CRC32=28e38971@1.43.1.45
|
||||
build.xml.stylesheet.CRC32=28e38971@1.44.1.45
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=c4188209
|
||||
nbproject/build-impl.xml.script.CRC32=73a4865f
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45
|
||||
nbproject/build-impl.xml.data.CRC32=51b33957
|
||||
nbproject/build-impl.xml.script.CRC32=66b89647
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45
|
||||
@@ -3,7 +3,42 @@ annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.run.all.processors=true
|
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||
application.title=BuildAll
|
||||
application.vendor=Paul
|
||||
application.vendor=
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAnnotationArgs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineArrayInit=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAssignment=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineBinaryOp=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineCallArgs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineDisjunctiveCatchTypes=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineFor=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineImplements=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineMethodParams=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineParenthesized=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTernaryOp=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineThrows=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTryResources=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesAfterClassHeader=0
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesBeforeClass=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width=4
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indentCasesFromSwitch=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeCatchOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeElseOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeFinallyOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeWhileOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceAfterTypeCast=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab=4
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size=4
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java,**/*.form
|
||||
# This directory is removed when the project is cleaned:
|
||||
@@ -27,22 +62,23 @@ dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
includes=**
|
||||
jar.compress=false
|
||||
jar.compress=true
|
||||
javac.classpath=\
|
||||
${reference.Essentials.jar}:\
|
||||
${reference.EssentialsChat.jar}:\
|
||||
${reference.EssentialsGroupBridge.jar}:\
|
||||
${reference.EssentialsGroupManager.jar}:\
|
||||
${reference.EssentialsProtect.jar}:\
|
||||
${reference.EssentialsSpawn.jar}:\
|
||||
${reference.EssentialsGeoIP.jar}
|
||||
${reference.EssentialsGeoIP.jar}:\
|
||||
${reference.EssentialsGroupBridge.jar}:\
|
||||
${reference.EssentialsXMPP.jar}:\
|
||||
${reference.EssentialsGroupManager.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.processorpath=\
|
||||
${javac.classpath}
|
||||
javac.source=1.5
|
||||
javac.target=1.5
|
||||
javac.source=1.6
|
||||
javac.target=1.6
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}:\
|
||||
@@ -71,6 +107,7 @@ project.EssentialsGroupBridge=../EssentialsGroupBridge
|
||||
project.EssentialsGroupManager=../EssentialsGroupManager
|
||||
project.EssentialsProtect=../EssentialsProtect
|
||||
project.EssentialsSpawn=../EssentialsSpawn
|
||||
project.EssentialsXMPP=../EssentialsXMPP
|
||||
reference.Essentials.jar=${project.Essentials}/dist/Essentials.jar
|
||||
reference.EssentialsChat.jar=${project.EssentialsChat}/dist/EssentialsChat.jar
|
||||
reference.EssentialsGeoIP.jar=${project.EssentialsGeoIP}/dist/EssentialsGeoIP.jar
|
||||
@@ -78,6 +115,7 @@ reference.EssentialsGroupBridge.jar=${project.EssentialsGroupBridge}/dist/Essent
|
||||
reference.EssentialsGroupManager.jar=${project.EssentialsGroupManager}/dist/EssentialsGroupManager.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
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
|
||||
@@ -71,6 +71,14 @@
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
<reference>
|
||||
<foreign-project>EssentialsXMPP</foreign-project>
|
||||
<artifact-type>jar</artifact-type>
|
||||
<script>build.xml</script>
|
||||
<target>jar</target>
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
</references>
|
||||
</configuration>
|
||||
</project>
|
||||
@@ -1,7 +0,0 @@
|
||||
# NetBeans cruft
|
||||
/build
|
||||
/dist
|
||||
/nbproject/private
|
||||
|
||||
# Mac cruft
|
||||
.DS_Store
|
||||
+84
-84
@@ -1,84 +1,84 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- You may freely edit this file. See commented blocks below for -->
|
||||
<!-- some examples of how to customize the build. -->
|
||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||
<!-- the Compile on Save feature is turned off for the project. -->
|
||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||
<!-- in the project's Project Properties dialog box.-->
|
||||
<project name="Essentials" default="default" basedir=".">
|
||||
|
||||
<description>Builds, tests, and runs the project Essentials.</description>
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
<!--
|
||||
|
||||
There exist several targets which are by default empty and which can be
|
||||
used for execution of your tasks. These targets are usually executed
|
||||
before and after some main targets. They are:
|
||||
|
||||
-pre-init: called before initialization of project properties
|
||||
-post-init: called after initialization of project properties
|
||||
-pre-compile: called before javac compilation
|
||||
-post-compile: called after javac compilation
|
||||
-pre-compile-single: called before javac compilation of single file
|
||||
-post-compile-single: called after javac compilation of single file
|
||||
-pre-compile-test: called before javac compilation of JUnit tests
|
||||
-post-compile-test: called after javac compilation of JUnit tests
|
||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||
-pre-jar: called before JAR building
|
||||
-post-jar: called after JAR building
|
||||
-post-clean: called after cleaning build products
|
||||
|
||||
(Targets beginning with '-' are not intended to be called on their own.)
|
||||
|
||||
Example of inserting an obfuscator after compilation could look like this:
|
||||
|
||||
<target name="-post-compile">
|
||||
<obfuscate>
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
</obfuscate>
|
||||
</target>
|
||||
|
||||
For list of available properties check the imported
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
|
||||
Another way to customize the build is by overriding existing main targets.
|
||||
The targets of interest are:
|
||||
|
||||
-init-macrodef-javac: defines macro for javac compilation
|
||||
-init-macrodef-junit: defines macro for junit execution
|
||||
-init-macrodef-debug: defines macro for class debugging
|
||||
-init-macrodef-java: defines macro for class execution
|
||||
-do-jar-with-manifest: JAR building (if you are using a manifest)
|
||||
-do-jar-without-manifest: JAR building (if you are not using a manifest)
|
||||
run: execution of project
|
||||
-javadoc-build: Javadoc generation
|
||||
test-report: JUnit report generation
|
||||
|
||||
An example of overriding the target for project execution could look like this:
|
||||
|
||||
<target name="run" depends="Essentials-impl.jar">
|
||||
<exec dir="bin" executable="launcher.exe">
|
||||
<arg file="${dist.jar}"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
Notice that the overridden target depends on the jar target and not only on
|
||||
the compile target as the regular run target does. Again, for a list of available
|
||||
properties which you can use, check the target you are overriding in the
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
-->
|
||||
<!--target name="-post-jar">
|
||||
<jar jarfile="${dist.dir}/Essentials.jar">
|
||||
<zipfileset src="${dist.jar}" excludes="META-INF/*" />
|
||||
<zipfileset src="${dist.dir}/lib/Register.jar" excludes="META-INF/*" />
|
||||
<manifest>
|
||||
<attribute name="Classpath" value="Essentials.jar"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target-->
|
||||
</project>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- You may freely edit this file. See commented blocks below for -->
|
||||
<!-- some examples of how to customize the build. -->
|
||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||
<!-- the Compile on Save feature is turned off for the project. -->
|
||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||
<!-- in the project's Project Properties dialog box.-->
|
||||
<project name="Essentials" default="default" basedir=".">
|
||||
|
||||
<description>Builds, tests, and runs the project Essentials.</description>
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
<!--
|
||||
|
||||
There exist several targets which are by default empty and which can be
|
||||
used for execution of your tasks. These targets are usually executed
|
||||
before and after some main targets. They are:
|
||||
|
||||
-pre-init: called before initialization of project properties
|
||||
-post-init: called after initialization of project properties
|
||||
-pre-compile: called before javac compilation
|
||||
-post-compile: called after javac compilation
|
||||
-pre-compile-single: called before javac compilation of single file
|
||||
-post-compile-single: called after javac compilation of single file
|
||||
-pre-compile-test: called before javac compilation of JUnit tests
|
||||
-post-compile-test: called after javac compilation of JUnit tests
|
||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||
-pre-jar: called before JAR building
|
||||
-post-jar: called after JAR building
|
||||
-post-clean: called after cleaning build products
|
||||
|
||||
(Targets beginning with '-' are not intended to be called on their own.)
|
||||
|
||||
Example of inserting an obfuscator after compilation could look like this:
|
||||
|
||||
<target name="-post-compile">
|
||||
<obfuscate>
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
</obfuscate>
|
||||
</target>
|
||||
|
||||
For list of available properties check the imported
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
|
||||
Another way to customize the build is by overriding existing main targets.
|
||||
The targets of interest are:
|
||||
|
||||
-init-macrodef-javac: defines macro for javac compilation
|
||||
-init-macrodef-junit: defines macro for junit execution
|
||||
-init-macrodef-debug: defines macro for class debugging
|
||||
-init-macrodef-java: defines macro for class execution
|
||||
-do-jar-with-manifest: JAR building (if you are using a manifest)
|
||||
-do-jar-without-manifest: JAR building (if you are not using a manifest)
|
||||
run: execution of project
|
||||
-javadoc-build: Javadoc generation
|
||||
test-report: JUnit report generation
|
||||
|
||||
An example of overriding the target for project execution could look like this:
|
||||
|
||||
<target name="run" depends="Essentials-impl.jar">
|
||||
<exec dir="bin" executable="launcher.exe">
|
||||
<arg file="${dist.jar}"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
Notice that the overridden target depends on the jar target and not only on
|
||||
the compile target as the regular run target does. Again, for a list of available
|
||||
properties which you can use, check the target you are overriding in the
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
-->
|
||||
<!--target name="-post-jar">
|
||||
<jar jarfile="${dist.dir}/Essentials.jar">
|
||||
<zipfileset src="${dist.jar}" excludes="META-INF/*" />
|
||||
<zipfileset src="${dist.dir}/lib/Register.jar" excludes="META-INF/*" />
|
||||
<manifest>
|
||||
<attribute name="Classpath" value="Essentials.jar"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target-->
|
||||
</project>
|
||||
@@ -868,11 +868,12 @@ is divided into following sections:
|
||||
<classpath>
|
||||
<path path="${javac.classpath}"/>
|
||||
</classpath>
|
||||
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
|
||||
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
|
||||
<filename name="**/*.java"/>
|
||||
</fileset>
|
||||
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
|
||||
<include name="**/*.java"/>
|
||||
<exclude name="*.java"/>
|
||||
</fileset>
|
||||
</javadoc>
|
||||
<copy todir="${dist.javadoc.dir}">
|
||||
|
||||
@@ -4,8 +4,8 @@ build.xml.stylesheet.CRC32=28e38971@1.38.2.45
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=4b596d89
|
||||
nbproject/build-impl.xml.script.CRC32=4926001b
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45
|
||||
nbproject/build-impl.xml.script.CRC32=dbc81ee1
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45
|
||||
nbproject/profiler-build-impl.xml.data.CRC32=ab78ce15
|
||||
nbproject/profiler-build-impl.xml.script.CRC32=abda56ed
|
||||
nbproject/profiler-build-impl.xml.stylesheet.CRC32=f10cf54c@1.11.1
|
||||
@@ -1 +1,2 @@
|
||||
DoNotUseThreads
|
||||
SignatureDeclareThrowsException
|
||||
@@ -3,7 +3,42 @@ annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.run.all.processors=true
|
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||
application.title=Essentials
|
||||
application.vendor=Paul
|
||||
application.vendor=
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAnnotationArgs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineArrayInit=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAssignment=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineBinaryOp=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineCallArgs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineDisjunctiveCatchTypes=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineFor=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineImplements=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineMethodParams=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineParenthesized=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTernaryOp=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineThrows=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTryResources=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesAfterClassHeader=0
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesBeforeClass=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width=4
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indentCasesFromSwitch=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeCatchOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeElseOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeFinallyOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeWhileOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceAfterTypeCast=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab=4
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size=4
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java,**/*.form
|
||||
# This directory is removed when the project is cleaned:
|
||||
@@ -26,27 +61,39 @@ dist.jar=${dist.dir}/Essentials.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.BOSEconomy.jar=../lib/BOSEconomy.jar
|
||||
file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar
|
||||
file.reference.bPermissions.jar=../lib/bPermissions.jar
|
||||
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar
|
||||
file.reference.iCo4.jar=../lib/iCo4.jar
|
||||
file.reference.iCo5.jar=../lib/iCo5.jar
|
||||
file.reference.iCo6.jar=../lib/iCo6.jar
|
||||
file.reference.junit-4.5.jar=..\\lib\\junit_4\\junit-4.5.jar
|
||||
file.reference.Permissions.jar=..\\lib\\Permissions.jar
|
||||
file.reference.MultiCurrency.jar=../lib/MultiCurrency.jar
|
||||
file.reference.Permissions3.jar=../lib/Permissions3.jar
|
||||
file.reference.PermissionsBukkit-1.2.jar=../lib/PermissionsBukkit-1.2.jar
|
||||
file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar
|
||||
includes=**
|
||||
jar.compress=false
|
||||
jar.archive.disabled=${jnlp.enabled}
|
||||
jar.compress=true
|
||||
jar.index=${jnlp.enabled}
|
||||
javac.classpath=\
|
||||
${file.reference.Permissions.jar}:\
|
||||
${file.reference.Permissions3.jar}:\
|
||||
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
|
||||
${file.reference.BOSEconomy.jar}:\
|
||||
${file.reference.iCo4.jar}:\
|
||||
${file.reference.iCo5.jar}
|
||||
${file.reference.iCo5.jar}:\
|
||||
${file.reference.iCo6.jar}:\
|
||||
${file.reference.MultiCurrency.jar}:\
|
||||
${file.reference.BOSEconomy7.jar}:\
|
||||
${file.reference.PermissionsEx.jar}:\
|
||||
${file.reference.bPermissions.jar}:\
|
||||
${file.reference.PermissionsBukkit-1.2.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.processorpath=\
|
||||
${javac.classpath}
|
||||
javac.source=1.5
|
||||
javac.target=1.5
|
||||
javac.source=1.6
|
||||
javac.target=1.6
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}:\
|
||||
@@ -64,8 +111,17 @@ javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
jnlp.codebase.type=no.codebase
|
||||
jnlp.descriptor=application
|
||||
jnlp.enabled=false
|
||||
jnlp.mixed.code=default
|
||||
jnlp.offline-allowed=false
|
||||
jnlp.signed=false
|
||||
jnlp.signing=
|
||||
jnlp.signing.alias=
|
||||
jnlp.signing.keystore=
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
mkdist.disabled=false
|
||||
mkdist.disabled=true
|
||||
platform.active=default_platform
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
|
||||
@@ -1,35 +1,45 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
|
||||
public class Backup implements Runnable {
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private final CraftServer server;
|
||||
private final IEssentials ess;
|
||||
private boolean running = false;
|
||||
private int taskId = -1;
|
||||
private boolean active = false;
|
||||
|
||||
public Backup(IEssentials ess) {
|
||||
public class Backup implements Runnable
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient final CraftServer server;
|
||||
private transient final IEssentials ess;
|
||||
private transient boolean running = false;
|
||||
private transient int taskId = -1;
|
||||
private transient boolean active = false;
|
||||
|
||||
public Backup(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
server = (CraftServer)ess.getServer();
|
||||
if (server.getOnlinePlayers().length > 0) {
|
||||
if (server.getOnlinePlayers().length > 0)
|
||||
{
|
||||
startTask();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void onPlayerJoin() {
|
||||
void onPlayerJoin()
|
||||
{
|
||||
startTask();
|
||||
}
|
||||
|
||||
private void startTask() {
|
||||
if (!running) {
|
||||
long interval = ess.getSettings().getBackupInterval()*1200; // minutes -> ticks
|
||||
if (interval < 1200) {
|
||||
|
||||
private void startTask()
|
||||
{
|
||||
if (!running)
|
||||
{
|
||||
final long interval = ess.getSettings().getBackupInterval() * 1200; // minutes -> ticks
|
||||
if (interval < 1200)
|
||||
{
|
||||
return;
|
||||
}
|
||||
taskId = ess.scheduleSyncRepeatingTask(this, interval, interval);
|
||||
@@ -37,48 +47,84 @@ public class Backup implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if (active) return;
|
||||
active = true;
|
||||
final String command = ess.getSettings().getBackupCommand();
|
||||
if (command == null || "".equals(command)) {
|
||||
public void run()
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
logger.log(Level.INFO, Util.i18n("backupStarted"));
|
||||
active = true;
|
||||
final String command = ess.getSettings().getBackupCommand();
|
||||
if (command == null || "".equals(command))
|
||||
{
|
||||
return;
|
||||
}
|
||||
LOGGER.log(Level.INFO, Util.i18n("backupStarted"));
|
||||
final CommandSender cs = server.getServer().console;
|
||||
server.dispatchCommand(cs, "save-all");
|
||||
server.dispatchCommand(cs, "save-off");
|
||||
|
||||
|
||||
ess.scheduleAsyncDelayedTask(
|
||||
new Runnable() {
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
Process child = Runtime.getRuntime().exec(command);
|
||||
child.waitFor();
|
||||
} catch (InterruptedException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
} catch (IOException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
} finally {
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable() {
|
||||
|
||||
public void run() {
|
||||
server.dispatchCommand(cs, "save-on");
|
||||
if (server.getOnlinePlayers().length == 0) {
|
||||
running = false;
|
||||
if (taskId != -1) {
|
||||
server.getScheduler().cancelTask(taskId);
|
||||
new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
final ProcessBuilder childBuilder = new ProcessBuilder(command);
|
||||
childBuilder.redirectErrorStream(true);
|
||||
childBuilder.directory(ess.getDataFolder().getParentFile().getParentFile());
|
||||
final Process child = childBuilder.start();
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(child.getInputStream()));
|
||||
try
|
||||
{
|
||||
child.waitFor();
|
||||
String line;
|
||||
do
|
||||
{
|
||||
line = reader.readLine();
|
||||
if (line != null)
|
||||
{
|
||||
LOGGER.log(Level.INFO, line);
|
||||
}
|
||||
}
|
||||
while (line != null);
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
active = false;
|
||||
logger.log(Level.INFO, Util.i18n("backupFinished"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
catch (InterruptedException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
server.dispatchCommand(cs, "save-on");
|
||||
if (server.getOnlinePlayers().length == 0)
|
||||
{
|
||||
running = false;
|
||||
if (taskId != -1)
|
||||
{
|
||||
server.getScheduler().cancelTask(taskId);
|
||||
}
|
||||
}
|
||||
active = false;
|
||||
LOGGER.log(Level.INFO, Util.i18n("backupFinished"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Charge
|
||||
{
|
||||
private final String command;
|
||||
private final Double costs;
|
||||
private final ItemStack items;
|
||||
private final IEssentials ess;
|
||||
|
||||
public Charge(String command, IEssentials ess)
|
||||
{
|
||||
this(command, null, null, ess);
|
||||
}
|
||||
|
||||
public Charge(double money, IEssentials ess)
|
||||
{
|
||||
this(null, money, null, ess);
|
||||
}
|
||||
|
||||
public Charge(ItemStack items, IEssentials ess)
|
||||
{
|
||||
this(null, null, items, ess);
|
||||
}
|
||||
|
||||
private Charge(String command, Double money, ItemStack item, IEssentials ess)
|
||||
{
|
||||
this.command = command;
|
||||
this.costs = money;
|
||||
this.items = item;
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public void isAffordableFor(IUser user) throws Exception
|
||||
{
|
||||
double mon = user.getMoney();
|
||||
if (costs != null)
|
||||
{
|
||||
if (mon < costs && !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
}
|
||||
if (items != null)
|
||||
{
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, items))
|
||||
{
|
||||
throw new Exception(Util.format("missingItems", items.getAmount(), items.getType().toString().toLowerCase().replace("_", " ")));
|
||||
}
|
||||
}
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
if (user.isAuthorized("essentials.nocommandcost.all")
|
||||
|| user.isAuthorized("essentials.nocommandcost." + command))
|
||||
{
|
||||
return;
|
||||
}
|
||||
double cost = ess.getSettings().getCommandCost(command.startsWith("/") ? command.substring(1) : command);
|
||||
if (mon < cost && !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void charge(IUser user) throws Exception
|
||||
{
|
||||
double mon = user.getMoney();
|
||||
if (costs != null)
|
||||
{
|
||||
if (mon < costs && !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(costs);
|
||||
}
|
||||
if (items != null)
|
||||
{
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, items))
|
||||
{
|
||||
throw new Exception(Util.format("missingItems", items.getAmount(), items.getType().toString().toLowerCase().replace("_", " ")));
|
||||
}
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, items);
|
||||
user.updateInventory();
|
||||
}
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
if (user.isAuthorized("essentials.nocommandcost.all")
|
||||
|| user.isAuthorized("essentials.nocommandcost." + command))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
double cost = ess.getSettings().getCommandCost(command.startsWith("/") ? command.substring(1) : command);
|
||||
if (mon < cost && !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(cost);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
|
||||
public class ChargeException extends Exception
|
||||
{
|
||||
public ChargeException(final String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ChargeException(final String message, final Throwable throwable)
|
||||
{
|
||||
super(message, throwable);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.Commandtime;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* This utility class is used for converting between the ingame
|
||||
* time in ticks to ingame time as a friendly string.
|
||||
* Note that the time is INGAME.
|
||||
*
|
||||
* http://www.minecraftwiki.net/wiki/Day/night_cycle
|
||||
*
|
||||
* @author Olof Larsson
|
||||
*/
|
||||
public final class DescParseTickFormat
|
||||
{
|
||||
// ============================================
|
||||
// First some information vars. TODO: Should this be in a config file?
|
||||
// --------------------------------------------
|
||||
public static final Map<String, Integer> nameToTicks = new LinkedHashMap<String, Integer>();
|
||||
public static final Set<String> resetAliases = new HashSet<String>();
|
||||
public static final int ticksAtMidnight = 18000;
|
||||
public static final int ticksPerDay = 24000;
|
||||
public static final int ticksPerHour = 1000;
|
||||
public static final double ticksPerMinute = 1000d / 60d;
|
||||
public static final double ticksPerSecond = 1000d / 60d / 60d;
|
||||
private static final SimpleDateFormat SDFTwentyFour = new SimpleDateFormat("HH:mm", Locale.ENGLISH);
|
||||
private static final SimpleDateFormat SDFTwelve = new SimpleDateFormat("h:mmaa", Locale.ENGLISH);
|
||||
|
||||
static
|
||||
{
|
||||
SDFTwentyFour.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
SDFTwelve.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
|
||||
nameToTicks.put("sunrise", 23000);
|
||||
nameToTicks.put("dawn", 23000);
|
||||
|
||||
nameToTicks.put("daystart", 0);
|
||||
nameToTicks.put("day", 0);
|
||||
|
||||
nameToTicks.put("morning", 1000);
|
||||
|
||||
nameToTicks.put("midday", 6000);
|
||||
nameToTicks.put("noon", 6000);
|
||||
|
||||
nameToTicks.put("afternoon", 9000);
|
||||
|
||||
nameToTicks.put("sunset", 12000);
|
||||
nameToTicks.put("dusk", 12000);
|
||||
nameToTicks.put("sundown", 12000);
|
||||
nameToTicks.put("nightfall", 12000);
|
||||
|
||||
nameToTicks.put("nightstart", 14000);
|
||||
nameToTicks.put("night", 14000);
|
||||
|
||||
nameToTicks.put("midnight", 18000);
|
||||
|
||||
resetAliases.add("reset");
|
||||
resetAliases.add("normal");
|
||||
resetAliases.add("default");
|
||||
}
|
||||
|
||||
private DescParseTickFormat()
|
||||
{
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// PARSE. From describing String to int
|
||||
// --------------------------------------------
|
||||
public static long parse(String desc) throws NumberFormatException
|
||||
{
|
||||
// Only look at alphanumeric and lowercase and : for 24:00
|
||||
desc = desc.toLowerCase().replaceAll("[^A-Za-z0-9:]", "");
|
||||
|
||||
// Detect ticks format
|
||||
try
|
||||
{
|
||||
return parseTicks(desc);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
// Detect 24-hour format
|
||||
try
|
||||
{
|
||||
return parse24(desc);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
// Detect 12-hour format
|
||||
try
|
||||
{
|
||||
return parse12(desc);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
// Detect aliases
|
||||
try
|
||||
{
|
||||
return parseAlias(desc);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
// Well we failed to understand...
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
public static long parseTicks(String desc) throws NumberFormatException
|
||||
{
|
||||
if (!desc.matches("^[0-9]+ti?c?k?s?$"))
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
desc = desc.replaceAll("[^0-9]", "");
|
||||
|
||||
return Long.parseLong(desc) % 24000;
|
||||
}
|
||||
|
||||
public static long parse24(String desc) throws NumberFormatException
|
||||
{
|
||||
if (!desc.matches("^[0-9]{2}[^0-9]?[0-9]{2}$"))
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
desc = desc.toLowerCase().replaceAll("[^0-9]", "");
|
||||
|
||||
if (desc.length() != 4)
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
final int hours = Integer.parseInt(desc.substring(0, 2));
|
||||
final int minutes = Integer.parseInt(desc.substring(2, 4));
|
||||
|
||||
return hoursMinutesToTicks(hours, minutes);
|
||||
}
|
||||
|
||||
public static long parse12(String desc) throws NumberFormatException
|
||||
{
|
||||
if (!desc.matches("^[0-9]{1,2}([^0-9]?[0-9]{2})?(pm|am)$"))
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
int hours = 0;
|
||||
int minutes = 0;
|
||||
|
||||
desc = desc.toLowerCase().replaceAll("[^0-9]", "");
|
||||
|
||||
if (desc.length() > 4)
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
if (desc.length() == 4)
|
||||
{
|
||||
hours += Integer.parseInt(desc.substring(0, 2));
|
||||
minutes += Integer.parseInt(desc.substring(2, 4));
|
||||
}
|
||||
else if (desc.length() == 3)
|
||||
{
|
||||
hours += Integer.parseInt(desc.substring(0, 1));
|
||||
minutes += Integer.parseInt(desc.substring(1, 3));
|
||||
}
|
||||
else if (desc.length() == 2)
|
||||
{
|
||||
hours += Integer.parseInt(desc.substring(0, 2));
|
||||
}
|
||||
else if (desc.length() == 1)
|
||||
{
|
||||
hours += Integer.parseInt(desc.substring(0, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
if (desc.endsWith("pm") && hours != 12)
|
||||
{
|
||||
hours += 12;
|
||||
}
|
||||
|
||||
if (desc.endsWith("am") && hours == 12)
|
||||
{
|
||||
hours -= 12;
|
||||
}
|
||||
|
||||
return hoursMinutesToTicks(hours, minutes);
|
||||
}
|
||||
|
||||
public static long hoursMinutesToTicks(final int hours, final int minutes)
|
||||
{
|
||||
long ret = ticksAtMidnight;
|
||||
ret += (hours) * ticksPerHour;
|
||||
|
||||
ret += (minutes / 60.0) * ticksPerHour;
|
||||
|
||||
ret %= ticksPerDay;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static long parseAlias(final String desc) throws NumberFormatException
|
||||
{
|
||||
final Integer ret = nameToTicks.get(desc);
|
||||
if (ret == null)
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static boolean meansReset(final String desc)
|
||||
{
|
||||
return resetAliases.contains(desc);
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// FORMAT. From int to describing String
|
||||
// --------------------------------------------
|
||||
public static String format(final long ticks)
|
||||
{
|
||||
return Util.format("timeFormat", format24(ticks), format12(ticks), formatTicks(ticks));
|
||||
}
|
||||
|
||||
public static String formatTicks(final long ticks)
|
||||
{
|
||||
return (ticks % ticksPerDay) + "ticks";
|
||||
}
|
||||
|
||||
public static String format24(final long ticks)
|
||||
{
|
||||
synchronized (SDFTwentyFour)
|
||||
{
|
||||
return formatDateFormat(ticks, SDFTwentyFour);
|
||||
}
|
||||
}
|
||||
|
||||
public static String format12(final long ticks)
|
||||
{
|
||||
synchronized (SDFTwelve)
|
||||
{
|
||||
return formatDateFormat(ticks, SDFTwelve);
|
||||
}
|
||||
}
|
||||
|
||||
public static String formatDateFormat(final long ticks, final SimpleDateFormat format)
|
||||
{
|
||||
final Date date = ticksToDate(ticks);
|
||||
return format.format(date);
|
||||
}
|
||||
|
||||
public static Date ticksToDate(long ticks)
|
||||
{
|
||||
// Assume the server time starts at 0. It would start on a day.
|
||||
// But we will simulate that the server started with 0 at midnight.
|
||||
ticks = ticks - ticksAtMidnight + ticksPerDay;
|
||||
|
||||
// How many ingame days have passed since the server start?
|
||||
final long days = ticks / ticksPerDay;
|
||||
ticks = ticks - days * ticksPerDay;
|
||||
|
||||
// How many hours on the last day?
|
||||
final long hours = ticks / ticksPerHour;
|
||||
ticks = ticks - hours * ticksPerHour;
|
||||
|
||||
// How many minutes on the last day?
|
||||
final long minutes = (long)Math.floor(ticks / ticksPerMinute);
|
||||
final double dticks = ticks - minutes * ticksPerMinute;
|
||||
|
||||
// How many seconds on the last day?
|
||||
final long seconds = (long)Math.floor(dticks / ticksPerSecond);
|
||||
|
||||
// Now we create an english GMT calendar (We wan't no daylight savings)
|
||||
final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.ENGLISH);
|
||||
cal.setLenient(true);
|
||||
|
||||
// And we set the time to 0! And append the time that passed!
|
||||
cal.set(0, Calendar.JANUARY, 1, 0, 0, 0);
|
||||
cal.add(Calendar.DAY_OF_YEAR, (int)days);
|
||||
cal.add(Calendar.HOUR_OF_DAY, (int)hours);
|
||||
cal.add(Calendar.MINUTE, (int)minutes);
|
||||
cal.add(Calendar.SECOND, (int)seconds + 1); // To solve rounding errors.
|
||||
|
||||
return cal.getTime();
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.Economy;
|
||||
import com.earth2me.essentials.commands.EssentialsCommand;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
@@ -25,136 +26,138 @@ import org.bukkit.*;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.commands.NoChargeException;
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import com.earth2me.essentials.perm.PermissionsHandler;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import com.earth2me.essentials.signs.SignBlockListener;
|
||||
import com.earth2me.essentials.signs.SignEntityListener;
|
||||
import com.earth2me.essentials.signs.SignPlayerListener;
|
||||
import java.math.BigInteger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
import org.bukkit.plugin.*;
|
||||
import org.bukkit.plugin.java.*;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
|
||||
public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
public static final String AUTHORS = "Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans and Xeology";
|
||||
public static final int minBukkitBuildVersion = 860;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private Settings settings;
|
||||
private EssentialsPlayerListener playerListener;
|
||||
private EssentialsBlockListener blockListener;
|
||||
private EssentialsEntityListener entityListener;
|
||||
private JailPlayerListener jailPlayerListener;
|
||||
private static Essentials instance = null;
|
||||
private Spawn spawn;
|
||||
private Jail jail;
|
||||
private Warps warps;
|
||||
private Worth worth;
|
||||
private List<IConf> confList;
|
||||
public ArrayList bans = new ArrayList();
|
||||
public ArrayList bannedIps = new ArrayList();
|
||||
private Backup backup;
|
||||
private final Map<String, User> users = new HashMap<String, User>();
|
||||
private EssentialsTimer timer;
|
||||
private EssentialsUpdateTimer updateTimer;
|
||||
private boolean registerFallback = true;
|
||||
private final Methods paymentMethod = new Methods();
|
||||
private final static boolean enableErrorLogging = false;
|
||||
private final EssentialsErrorHandler errorHandler = new EssentialsErrorHandler();
|
||||
public static final int BUKKIT_VERSION = 1060;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient ISettings settings;
|
||||
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);
|
||||
private transient Spawn spawn;
|
||||
private transient Jail jail;
|
||||
private transient Warps warps;
|
||||
private transient Worth worth;
|
||||
private transient List<IConf> confList;
|
||||
private transient Backup backup;
|
||||
private transient ItemDb itemDb;
|
||||
private transient EssentialsUpdateTimer updateTimer;
|
||||
private transient final Methods paymentMethod = new Methods();
|
||||
private transient final static boolean enableErrorLogging = false;
|
||||
private transient final EssentialsErrorHandler errorHandler = new EssentialsErrorHandler();
|
||||
private transient PermissionsHandler permissionsHandler;
|
||||
private transient UserMap userMap;
|
||||
|
||||
public static IEssentials getStatic()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
||||
public Settings getSettings()
|
||||
@Override
|
||||
public ISettings getSettings()
|
||||
{
|
||||
return settings;
|
||||
}
|
||||
|
||||
public void setupForTesting(Server server) throws IOException, InvalidDescriptionException
|
||||
public void setupForTesting(final Server server) throws IOException, InvalidDescriptionException
|
||||
{
|
||||
File dataFolder = File.createTempFile("essentialstest", "");
|
||||
dataFolder.delete();
|
||||
dataFolder.mkdir();
|
||||
logger.log(Level.INFO, Util.i18n("usingTempFolderForTesting"));
|
||||
logger.log(Level.INFO, dataFolder.toString());
|
||||
final File dataFolder = File.createTempFile("essentialstest", "");
|
||||
if (!dataFolder.delete())
|
||||
{
|
||||
throw new IOException();
|
||||
}
|
||||
if (!dataFolder.mkdir())
|
||||
{
|
||||
throw new IOException();
|
||||
}
|
||||
LOGGER.log(Level.INFO, Util.i18n("usingTempFolderForTesting"));
|
||||
LOGGER.log(Level.INFO, dataFolder.toString());
|
||||
this.initialize(null, server, new PluginDescriptionFile(new FileReader(new File("src" + File.separator + "plugin.yml"))), dataFolder, null, null);
|
||||
settings = new Settings(dataFolder);
|
||||
setStatic();
|
||||
}
|
||||
|
||||
public void setStatic()
|
||||
{
|
||||
instance = this;
|
||||
settings = new Settings(this);
|
||||
userMap = new UserMap(this);
|
||||
permissionsHandler = new PermissionsHandler(this, false);
|
||||
Economy.setEss(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
final String[] javaversion = System.getProperty("java.version").split("\\.", 3);
|
||||
if (javaversion == null || javaversion.length < 2 || Integer.parseInt(javaversion[1]) < 6)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, "Java version not supported! Please install Java 1.6. You have " + System.getProperty("java.version"));
|
||||
}
|
||||
if (enableErrorLogging)
|
||||
{
|
||||
logger.addHandler(errorHandler);
|
||||
LOGGER.addHandler(errorHandler);
|
||||
}
|
||||
setStatic();
|
||||
EssentialsUpgrade upgrade = new EssentialsUpgrade(this.getDescription().getVersion(), this);
|
||||
final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
|
||||
upgrade.beforeSettings();
|
||||
confList = new ArrayList<IConf>();
|
||||
settings = new Settings(this.getDataFolder());
|
||||
settings = new Settings(this);
|
||||
confList.add(settings);
|
||||
upgrade.afterSettings();
|
||||
Util.updateLocale(settings.getLocale(), this.getDataFolder());
|
||||
Util.updateLocale(settings.getLocale(), this);
|
||||
userMap = new UserMap(this);
|
||||
confList.add(userMap);
|
||||
spawn = new Spawn(getServer(), this.getDataFolder());
|
||||
confList.add(spawn);
|
||||
warps = new Warps(getServer(), this.getDataFolder());
|
||||
confList.add(warps);
|
||||
worth = new Worth(this.getDataFolder());
|
||||
confList.add(worth);
|
||||
itemDb = new ItemDb(this);
|
||||
confList.add(itemDb);
|
||||
reload();
|
||||
backup = new Backup(this);
|
||||
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
final PluginManager pm = getServer().getPluginManager();
|
||||
for (Plugin plugin : pm.getPlugins())
|
||||
{
|
||||
if (plugin.getDescription().getName().startsWith("Essentials"))
|
||||
if (plugin.getDescription().getName().startsWith("Essentials")
|
||||
&& !plugin.getDescription().getVersion().equals(this.getDescription().getVersion()))
|
||||
{
|
||||
if (!plugin.getDescription().getVersion().equals(this.getDescription().getVersion()))
|
||||
{
|
||||
logger.log(Level.WARNING, Util.format("versionMismatch", plugin.getDescription().getName()));
|
||||
}
|
||||
LOGGER.log(Level.WARNING, Util.format("versionMismatch", plugin.getDescription().getName()));
|
||||
}
|
||||
}
|
||||
Matcher versionMatch = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*").matcher(getServer().getVersion());
|
||||
final Matcher versionMatch = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*").matcher(getServer().getVersion());
|
||||
if (versionMatch.matches())
|
||||
{
|
||||
int versionNumber = Integer.parseInt(versionMatch.group(4));
|
||||
if (versionNumber < minBukkitBuildVersion)
|
||||
final int versionNumber = Integer.parseInt(versionMatch.group(4));
|
||||
if (versionNumber < BUKKIT_VERSION)
|
||||
{
|
||||
logger.log(Level.WARNING, Util.i18n("notRecommendedBukkit"));
|
||||
LOGGER.log(Level.WARNING, Util.i18n("notRecommendedBukkit"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.log(Level.INFO, Util.i18n("bukkitFormatChanged"));
|
||||
LOGGER.log(Level.INFO, Util.i18n("bukkitFormatChanged"));
|
||||
}
|
||||
|
||||
|
||||
ServerListener serverListener = new EssentialsPluginListener(paymentMethod);
|
||||
permissionsHandler = new PermissionsHandler(this, settings.useBukkitPermissions());
|
||||
final EssentialsPluginListener serverListener = new EssentialsPluginListener(this);
|
||||
pm.registerEvent(Type.PLUGIN_ENABLE, serverListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.PLUGIN_DISABLE, serverListener, Priority.Low, this);
|
||||
confList.add(serverListener);
|
||||
|
||||
playerListener = new EssentialsPlayerListener(this);
|
||||
final EssentialsPlayerListener playerListener = new EssentialsPlayerListener(this);
|
||||
pm.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Monitor, this);
|
||||
pm.registerEvent(Type.PLAYER_QUIT, playerListener, Priority.Monitor, this);
|
||||
pm.registerEvent(Type.PLAYER_CHAT, playerListener, Priority.Lowest, this);
|
||||
if (getSettings().getNetherPortalsEnabled())
|
||||
{
|
||||
pm.registerEvent(Type.PLAYER_MOVE, playerListener, Priority.High, this);
|
||||
}
|
||||
pm.registerEvent(Type.PLAYER_COMMAND_PREPROCESS, playerListener, Priority.Lowest, this);
|
||||
pm.registerEvent(Type.PLAYER_MOVE, playerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_LOGIN, playerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_TELEPORT, playerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.High, this);
|
||||
@@ -162,82 +165,91 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
pm.registerEvent(Type.PLAYER_BUCKET_EMPTY, playerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_ANIMATION, playerListener, Priority.High, this);
|
||||
|
||||
blockListener = new EssentialsBlockListener(this);
|
||||
pm.registerEvent(Type.SIGN_CHANGE, blockListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_BREAK, blockListener, Priority.Lowest, this);
|
||||
final EssentialsBlockListener blockListener = new EssentialsBlockListener(this);
|
||||
pm.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Lowest, this);
|
||||
|
||||
entityListener = new EssentialsEntityListener(this);
|
||||
final SignBlockListener signBlockListener = new SignBlockListener(this);
|
||||
pm.registerEvent(Type.SIGN_CHANGE, signBlockListener, Priority.Highest, this);
|
||||
pm.registerEvent(Type.BLOCK_PLACE, signBlockListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_BREAK, signBlockListener, Priority.Highest, this);
|
||||
pm.registerEvent(Type.BLOCK_IGNITE, signBlockListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_BURN, signBlockListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_PISTON_EXTEND, signBlockListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_PISTON_RETRACT, signBlockListener, Priority.Low, this);
|
||||
|
||||
final SignPlayerListener signPlayerListener = new SignPlayerListener(this);
|
||||
pm.registerEvent(Type.PLAYER_INTERACT, signPlayerListener, Priority.Low, this);
|
||||
|
||||
final SignEntityListener signEntityListener = new SignEntityListener(this);
|
||||
pm.registerEvent(Type.ENTITY_EXPLODE, signEntityListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.ENDERMAN_PICKUP, signEntityListener, Priority.Low, this);
|
||||
|
||||
final EssentialsEntityListener entityListener = new EssentialsEntityListener(this);
|
||||
pm.registerEvent(Type.ENTITY_DAMAGE, entityListener, Priority.Lowest, this);
|
||||
pm.registerEvent(Type.ENTITY_COMBUST, entityListener, Priority.Lowest, this);
|
||||
pm.registerEvent(Type.ENTITY_DEATH, entityListener, Priority.Lowest, this);
|
||||
pm.registerEvent(Type.FOOD_LEVEL_CHANGE, entityListener, Priority.Lowest, this);
|
||||
|
||||
jail = new Jail(this);
|
||||
jailPlayerListener = new JailPlayerListener(this);
|
||||
final JailPlayerListener jailPlayerListener = new JailPlayerListener(this);
|
||||
confList.add(jail);
|
||||
pm.registerEvent(Type.BLOCK_BREAK, jail, Priority.High, this);
|
||||
pm.registerEvent(Type.BLOCK_DAMAGE, jail, Priority.High, this);
|
||||
pm.registerEvent(Type.BLOCK_PLACE, jail, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_INTERACT, jailPlayerListener, Priority.High, this);
|
||||
attachEcoListeners();
|
||||
pm.registerEvent(Type.BLOCK_BREAK, jail, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_DAMAGE, jail, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_PLACE, jail, Priority.Low, this);
|
||||
pm.registerEvent(Type.PLAYER_INTERACT, jailPlayerListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.PLAYER_RESPAWN, jailPlayerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_TELEPORT, jailPlayerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_JOIN, jailPlayerListener, Priority.High, this);
|
||||
|
||||
if (settings.isNetherEnabled() && getServer().getWorlds().size() < 2)
|
||||
{
|
||||
logger.log(Level.WARNING, "Old nether is disabled until multiworld support in bukkit is fixed.");
|
||||
getServer().createWorld(settings.getNetherName(), World.Environment.NETHER);
|
||||
}
|
||||
|
||||
timer = new EssentialsTimer(this);
|
||||
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 50);
|
||||
if (enableErrorLogging)
|
||||
pm.registerEvent(Type.ENTITY_EXPLODE, tntListener, Priority.High, this);
|
||||
|
||||
final EssentialsTimer timer = new EssentialsTimer(this);
|
||||
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100);
|
||||
Economy.setEss(this);
|
||||
if (getSettings().isUpdateEnabled())
|
||||
{
|
||||
updateTimer = new EssentialsUpdateTimer(this);
|
||||
getScheduler().scheduleAsyncRepeatingTask(this, updateTimer, 50, 50 * 60 * (this.getDescription().getVersion().startsWith("Dev") ? 60 : 360));
|
||||
getScheduler().scheduleAsyncRepeatingTask(this, updateTimer, 20 * 60 * 10, 20 * 3600 * 6);
|
||||
}
|
||||
logger.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), AUTHORS));
|
||||
LOGGER.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), Util.joinList(this.getDescription().getAuthors())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
instance = null;
|
||||
logger.removeHandler(errorHandler);
|
||||
Trade.closeLog();
|
||||
LOGGER.removeHandler(errorHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload()
|
||||
{
|
||||
loadBanList();
|
||||
Trade.closeLog();
|
||||
|
||||
for (IConf iConf : confList)
|
||||
{
|
||||
iConf.reloadConfig();
|
||||
}
|
||||
|
||||
Util.updateLocale(settings.getLocale(), this.getDataFolder());
|
||||
|
||||
for (User user : users.values())
|
||||
{
|
||||
user.reloadConfig();
|
||||
}
|
||||
Util.updateLocale(settings.getLocale(), this);
|
||||
|
||||
// for motd
|
||||
getConfiguration().load();
|
||||
|
||||
try
|
||||
{
|
||||
ItemDb.load(getDataFolder(), "items.csv");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.WARNING, Util.i18n("itemsCsvNotLoaded"), ex);
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getMotd(CommandSender sender, String def)
|
||||
@Override
|
||||
public String[] getMotd(final CommandSender sender, final String def)
|
||||
{
|
||||
return getLines(sender, "motd", def);
|
||||
}
|
||||
|
||||
public String[] getLines(CommandSender sender, String node, String def)
|
||||
@Override
|
||||
public String[] getLines(final CommandSender sender, final String node, final String def)
|
||||
{
|
||||
List<String> lines = (List<String>)getConfiguration().getProperty(node);
|
||||
if (lines == null)
|
||||
@@ -246,7 +258,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
String[] retval = new String[lines.size()];
|
||||
|
||||
if (lines == null || lines.isEmpty() || lines.get(0) == null)
|
||||
if (lines.isEmpty() || lines.get(0) == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -260,7 +272,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
catch (Throwable ex2)
|
||||
{
|
||||
logger.log(Level.WARNING, Util.format("corruptNodeInConfig", node));
|
||||
LOGGER.log(Level.WARNING, Util.format("corruptNodeInConfig", node));
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
@@ -287,15 +299,28 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
m = m.replace("{IP}", user.getAddress().toString());
|
||||
m = m.replace("{BALANCE}", Double.toString(user.getMoney()));
|
||||
m = m.replace("{MAILS}", Integer.toString(user.getMails().size()));
|
||||
m = m.replace("{WORLD}", user.getLocation().getWorld().getName());
|
||||
}
|
||||
|
||||
m = m.replace("{ONLINE}", Integer.toString(getServer().getOnlinePlayers().length));
|
||||
int playerHidden = 0;
|
||||
for (Player p : getServer().getOnlinePlayers())
|
||||
{
|
||||
if (getUser(p).isHidden())
|
||||
{
|
||||
playerHidden++;
|
||||
}
|
||||
}
|
||||
m = m.replace("{ONLINE}", Integer.toString(getServer().getOnlinePlayers().length - playerHidden));
|
||||
m = m.replace("{UNIQUE}", Integer.toString(userMap.getUniqueUsers()));
|
||||
|
||||
if (m.matches(".*\\{PLAYERLIST\\}.*"))
|
||||
{
|
||||
StringBuilder online = new StringBuilder();
|
||||
for (Player p : getServer().getOnlinePlayers())
|
||||
{
|
||||
if (getUser(p).isHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (online.length() > 0)
|
||||
{
|
||||
online.append(", ");
|
||||
@@ -328,39 +353,15 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
return retval;
|
||||
}
|
||||
|
||||
@SuppressWarnings("LoggerStringConcat")
|
||||
public static void previewCommand(CommandSender sender, Command command, String commandLabel, String[] args)
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender sender, final Command command, final String commandLabel, final String[] args)
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
logger.info(ChatColor.BLUE + "[PLAYER_COMMAND] " + ((Player)sender).getName() + ": /" + commandLabel + " " + EssentialsCommand.getFinalArg(args, 0));
|
||||
}
|
||||
return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command", "essentials.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args)
|
||||
public boolean onCommandEssentials(final CommandSender sender, final Command command, final String commandLabel, final String[] args, final ClassLoader classLoader, final String commandPath, final String permissionPrefix)
|
||||
{
|
||||
return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command");
|
||||
}
|
||||
|
||||
public boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath)
|
||||
{
|
||||
if (("msg".equals(commandLabel.toLowerCase()) || "r".equals(commandLabel.toLowerCase()) || "mail".equals(commandLabel.toLowerCase())) && sender instanceof Player)
|
||||
{
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.append(commandLabel).append(" ");
|
||||
for (String a : args)
|
||||
{
|
||||
str.append(a).append(" ");
|
||||
}
|
||||
for (Player player : getServer().getOnlinePlayers())
|
||||
{
|
||||
if (getUser(player).isSocialSpyEnabled())
|
||||
{
|
||||
player.sendMessage(getUser(sender).getDisplayName() + " : " + str);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Allow plugins to override the command via onCommand
|
||||
if (!getSettings().isCommandOverridden(command.getName()) && !commandLabel.startsWith("e"))
|
||||
{
|
||||
@@ -371,7 +372,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
continue;
|
||||
}
|
||||
|
||||
PluginDescriptionFile desc = p.getDescription();
|
||||
final PluginDescriptionFile desc = p.getDescription();
|
||||
if (desc == null)
|
||||
{
|
||||
continue;
|
||||
@@ -382,24 +383,22 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(desc.getCommands() instanceof Map))
|
||||
final PluginCommand pc = getServer().getPluginCommand(desc.getName() + ":" + commandLabel);
|
||||
if (pc != null)
|
||||
{
|
||||
continue;
|
||||
return pc.execute(sender, commandLabel, args);
|
||||
}
|
||||
|
||||
Map<String, Object> cmds = (Map<String, Object>)desc.getCommands();
|
||||
if (!cmds.containsKey(command.getName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return p.onCommand(sender, command, commandLabel, args);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
previewCommand(sender, command, commandLabel, args);
|
||||
User user = sender instanceof Player ? getUser(sender) : null;
|
||||
User user = null;
|
||||
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
|
||||
if (user != null && !getSettings().isCommandDisabled("mail") && !commandLabel.equals("mail") && user.isAuthorized("essentials.mail"))
|
||||
@@ -426,14 +425,14 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
catch (Exception ex)
|
||||
{
|
||||
sender.sendMessage(Util.format("commandNotLoaded", commandLabel));
|
||||
logger.log(Level.SEVERE, Util.format("commandNotLoaded", commandLabel), ex);
|
||||
LOGGER.log(Level.SEVERE, Util.format("commandNotLoaded", commandLabel), ex);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check authorization
|
||||
if (user != null && !user.isAuthorized(cmd))
|
||||
if (user != null && !user.isAuthorized(cmd, permissionPrefix))
|
||||
{
|
||||
logger.log(Level.WARNING, Util.format("deniedAccessCommand", user.getName()));
|
||||
LOGGER.log(Level.WARNING, Util.format("deniedAccessCommand", user.getName()));
|
||||
user.sendMessage(Util.i18n("noAccessCommand"));
|
||||
return true;
|
||||
}
|
||||
@@ -451,6 +450,10 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (NoChargeException ex)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
catch (NotEnoughArgumentsException ex)
|
||||
{
|
||||
sender.sendMessage(command.getDescription());
|
||||
@@ -459,175 +462,95 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
sender.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
LogRecord lr = new LogRecord(Level.WARNING, Util.format("errorCallingCommand", commandLabel));
|
||||
lr.setThrown(ex);
|
||||
if (getSettings().isDebug())
|
||||
{
|
||||
logger.log(lr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (enableErrorLogging)
|
||||
{
|
||||
errorHandler.publish(lr);
|
||||
errorHandler.flush();
|
||||
}
|
||||
}
|
||||
showError(sender, ex, commandLabel);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("commandFailed", commandLabel), ex);
|
||||
LOGGER.log(Level.SEVERE, Util.format("commandFailed", commandLabel), ex);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void loadBanList()
|
||||
@Override
|
||||
public void showError(final CommandSender sender, final Throwable exception, final String commandLabel)
|
||||
{
|
||||
//I don't like this but it needs to be done until CB fixors
|
||||
File file = new File("banned-players.txt");
|
||||
File ipFile = new File("banned-ips.txt");
|
||||
try
|
||||
sender.sendMessage(Util.format("errorWithMessage", exception.getMessage()));
|
||||
final LogRecord logRecord = new LogRecord(Level.WARNING, Util.format("errorCallingCommand", commandLabel));
|
||||
logRecord.setThrown(exception);
|
||||
if (getSettings().isDebug())
|
||||
{
|
||||
if (!file.exists())
|
||||
{
|
||||
throw new FileNotFoundException(Util.i18n("bannedPlayersFileNotFound"));
|
||||
}
|
||||
|
||||
final BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
|
||||
try
|
||||
{
|
||||
bans.clear();
|
||||
while (bufferedReader.ready())
|
||||
{
|
||||
|
||||
final String line = bufferedReader.readLine().trim().toLowerCase();
|
||||
if (line.length() > 0 && line.charAt(0) == '#')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bans.add(line);
|
||||
|
||||
}
|
||||
}
|
||||
catch (IOException io)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.i18n("bannedPlayersFileError"), io);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
bufferedReader.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.i18n("bannedPlayersFileError"), ex);
|
||||
}
|
||||
}
|
||||
LOGGER.log(logRecord);
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
else
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.i18n("bannedPlayersFileError"), ex);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (!ipFile.exists())
|
||||
if (enableErrorLogging)
|
||||
{
|
||||
throw new FileNotFoundException(Util.i18n("bannedIpsFileNotFound"));
|
||||
errorHandler.publish(logRecord);
|
||||
errorHandler.flush();
|
||||
}
|
||||
|
||||
final BufferedReader bufferedReader = new BufferedReader(new FileReader(ipFile));
|
||||
try
|
||||
{
|
||||
bannedIps.clear();
|
||||
while (bufferedReader.ready())
|
||||
{
|
||||
|
||||
final String line = bufferedReader.readLine().trim().toLowerCase();
|
||||
if (line.length() > 0 && line.charAt(0) == '#')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bannedIps.add(line);
|
||||
|
||||
}
|
||||
}
|
||||
catch (IOException io)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.i18n("bannedIpsFileError"), io);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
bufferedReader.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.i18n("bannedIpsFileError"), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.i18n("bannedIpsFileError"), ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void attachEcoListeners()
|
||||
@Override
|
||||
public BukkitScheduler getScheduler()
|
||||
{
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
EssentialsEcoBlockListener ecoBlockListener = new EssentialsEcoBlockListener(this);
|
||||
EssentialsEcoPlayerListener ecoPlayerListener = new EssentialsEcoPlayerListener(this);
|
||||
pm.registerEvent(Type.PLAYER_INTERACT, ecoPlayerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.BLOCK_BREAK, ecoBlockListener, Priority.High, this);
|
||||
pm.registerEvent(Type.SIGN_CHANGE, ecoBlockListener, Priority.Monitor, this);
|
||||
}
|
||||
|
||||
public CraftScheduler getScheduler()
|
||||
{
|
||||
return (CraftScheduler)this.getServer().getScheduler();
|
||||
return this.getServer().getScheduler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Jail getJail()
|
||||
{
|
||||
return jail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Warps getWarps()
|
||||
{
|
||||
return warps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Worth getWorth()
|
||||
{
|
||||
return worth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Backup getBackup()
|
||||
{
|
||||
return backup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Spawn getSpawn()
|
||||
{
|
||||
return spawn;
|
||||
}
|
||||
|
||||
public User getUser(Object base)
|
||||
@Override
|
||||
public User getUser(final Object base)
|
||||
{
|
||||
if (base instanceof Player)
|
||||
{
|
||||
return getUser((Player)base);
|
||||
}
|
||||
if (base instanceof String)
|
||||
{
|
||||
try
|
||||
{
|
||||
return userMap.getUser((String)base);
|
||||
}
|
||||
catch (NullPointerException ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private <T extends Player> User getUser(T base)
|
||||
private <T extends Player> User getUser(final T base)
|
||||
{
|
||||
if (base == null)
|
||||
{
|
||||
@@ -638,75 +561,70 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
return (User)base;
|
||||
}
|
||||
|
||||
if (users.containsKey(base.getName().toLowerCase()))
|
||||
try
|
||||
{
|
||||
return users.get(base.getName().toLowerCase()).update(base);
|
||||
return userMap.getUser(base.getName()).update(base);
|
||||
}
|
||||
catch (NullPointerException ex)
|
||||
{
|
||||
return new User(base, this);
|
||||
}
|
||||
|
||||
User u = new User(base, this);
|
||||
users.put(u.getName().toLowerCase(), u);
|
||||
return u;
|
||||
}
|
||||
|
||||
public User getOfflineUser(String name)
|
||||
@Override
|
||||
public User getOfflineUser(final String name)
|
||||
{
|
||||
File userFolder = new File(getDataFolder(), "userdata");
|
||||
File userFile = new File(userFolder, Util.sanitizeFileName(name) + ".yml");
|
||||
if (userFile.exists())
|
||||
{ //Users do not get offline changes saved without being reproccessed as Users! ~ Xeology :)
|
||||
return getUser((Player)new OfflinePlayer(name));
|
||||
|
||||
try
|
||||
{
|
||||
return userMap.getUser(name);
|
||||
}
|
||||
catch (NullPointerException ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public World getWorld(String name)
|
||||
@Override
|
||||
public World getWorld(final String name)
|
||||
{
|
||||
if (name.matches("[0-9]+"))
|
||||
{
|
||||
int id = Integer.parseInt(name);
|
||||
if (id < getServer().getWorlds().size())
|
||||
final int worldId = Integer.parseInt(name);
|
||||
if (worldId < getServer().getWorlds().size())
|
||||
{
|
||||
return getServer().getWorlds().get(id);
|
||||
return getServer().getWorlds().get(worldId);
|
||||
}
|
||||
}
|
||||
World w = getServer().getWorld(name);
|
||||
if (w != null)
|
||||
{
|
||||
return w;
|
||||
}
|
||||
return null;
|
||||
return getServer().getWorld(name);
|
||||
}
|
||||
|
||||
public void setRegisterFallback(boolean registerFallback)
|
||||
{
|
||||
this.registerFallback = registerFallback;
|
||||
}
|
||||
|
||||
public boolean isRegisterFallbackEnabled()
|
||||
{
|
||||
return registerFallback;
|
||||
}
|
||||
|
||||
public void addReloadListener(IConf listener)
|
||||
@Override
|
||||
public void addReloadListener(final IConf listener)
|
||||
{
|
||||
confList.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Methods getPaymentMethod()
|
||||
{
|
||||
return paymentMethod;
|
||||
}
|
||||
|
||||
public int broadcastMessage(String name, String message)
|
||||
@Override
|
||||
public int broadcastMessage(final IUser sender, final String message)
|
||||
{
|
||||
Player[] players = getServer().getOnlinePlayers();
|
||||
if (sender == null) {
|
||||
return getServer().broadcastMessage(message);
|
||||
}
|
||||
if (sender.isHidden()) {
|
||||
return 0;
|
||||
}
|
||||
final Player[] players = getServer().getOnlinePlayers();
|
||||
|
||||
for (Player player : players)
|
||||
{
|
||||
User u = getUser(player);
|
||||
if (!u.isIgnoredPlayer(name))
|
||||
final User user = getUser(player);
|
||||
if (!user.isIgnoredPlayer(sender.getName()))
|
||||
{
|
||||
player.sendMessage(message);
|
||||
}
|
||||
@@ -720,28 +638,51 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
return errorHandler.getErrors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleAsyncDelayedTask(final Runnable run)
|
||||
{
|
||||
return this.getScheduler().scheduleAsyncDelayedTask(this, run);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleSyncDelayedTask(final Runnable run)
|
||||
{
|
||||
return this.getScheduler().scheduleSyncDelayedTask(this, run);
|
||||
}
|
||||
|
||||
public int scheduleSyncRepeatingTask(final Runnable run, long delay, long period)
|
||||
@Override
|
||||
public int scheduleSyncDelayedTask(final Runnable run, final long delay)
|
||||
{
|
||||
return this.getScheduler().scheduleSyncDelayedTask(this, run, delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleSyncRepeatingTask(final Runnable run, final long delay, final long period)
|
||||
{
|
||||
return this.getScheduler().scheduleSyncRepeatingTask(this, run, delay, period);
|
||||
}
|
||||
|
||||
public List<String> getBans()
|
||||
@Override
|
||||
public TNTExplodeListener getTNTListener()
|
||||
{
|
||||
return bans;
|
||||
return tntListener;
|
||||
}
|
||||
|
||||
public List<String> getBannedIps()
|
||||
@Override
|
||||
public PermissionsHandler getPermissionsHandler()
|
||||
{
|
||||
return bannedIps;
|
||||
return permissionsHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemDb getItemDb()
|
||||
{
|
||||
return itemDb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserMap getUserMap()
|
||||
{
|
||||
return userMap;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,9 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.craftbukkit.block.CraftSign;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@@ -17,372 +11,99 @@ public class EssentialsBlockListener extends BlockListener
|
||||
{
|
||||
private final IEssentials ess;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
public final static List<Material> protectedBlocks = new ArrayList<Material>(4);
|
||||
|
||||
static
|
||||
{
|
||||
protectedBlocks.add(Material.CHEST);
|
||||
protectedBlocks.add(Material.BURNING_FURNACE);
|
||||
protectedBlocks.add(Material.FURNACE);
|
||||
protectedBlocks.add(Material.DISPENSER);
|
||||
}
|
||||
|
||||
public EssentialsBlockListener(IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
if (ess.getSettings().areSignsDisabled()) return;
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
if (protectedBlocks.contains(event.getBlock().getType()) && !user.isAuthorized("essentials.signs.protection.override"))
|
||||
{
|
||||
if (isBlockProtected(event.getBlock(), user))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
user.sendMessage(Util.format("noDestroyPermission", event.getBlock().getType().toString().toLowerCase()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkProtectionSign(event.getBlock(), user) != NOSIGN &&
|
||||
checkProtectionSign(event.getBlock(), user) != OWNER)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
user.sendMessage(Util.format("noDestroyPermission", event.getBlock().getType().toString().toLowerCase()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSignChange(SignChangeEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
if (ess.getSettings().areSignsDisabled()) return;
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
String username = user.getName().substring(0, user.getName().length() > 14 ? 14 : user.getName().length());
|
||||
|
||||
try
|
||||
{
|
||||
if (event.getLine(0).equalsIgnoreCase("[Protection]"))
|
||||
{
|
||||
Block block = event.getBlock();
|
||||
if (user.isAuthorized("essentials.signs.protection.create") && hasAdjacentChest(block) && !isBlockProtected(block, user))
|
||||
event.setLine(0, "§1[Protection]");
|
||||
else
|
||||
event.setLine(0, "§4[Protection]");
|
||||
event.setLine(3, username);
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Disposal]"))
|
||||
{
|
||||
if (user.isAuthorized("essentials.signs.disposal.create"))
|
||||
event.setLine(0, "§1[Disposal]");
|
||||
else
|
||||
event.setLine(0, "§4[Disposal]");
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Heal]"))
|
||||
{
|
||||
event.setLine(0, "§4[Heal]");
|
||||
if (user.isAuthorized("essentials.signs.heal.create"))
|
||||
{
|
||||
if (!event.getLine(1).isEmpty())
|
||||
{
|
||||
String[] l1 = event.getLine(1).split("[ :-]+", 2);
|
||||
boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
if (q1 < 1 || (!m1 && (int)q1 < 1)) throw new Exception(Util.i18n("moreThanZero"));
|
||||
if (!m1) ItemDb.get(l1[1]);
|
||||
event.setLine(1, (m1 ? Util.formatCurrency(q1) : (int)q1 + " " + l1[1]));
|
||||
}
|
||||
event.setLine(0, "§1[Heal]");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Free]"))
|
||||
{
|
||||
event.setLine(0, "§4[Free]");
|
||||
ItemDb.get(event.getLine(1));
|
||||
if (user.isAuthorized("essentials.signs.free.create"))
|
||||
event.setLine(0, "§1[Free]");
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Mail]"))
|
||||
{
|
||||
if (user.isAuthorized("essentials.signs.mail.create"))
|
||||
event.setLine(0, "§1[Mail]");
|
||||
else
|
||||
event.setLine(0, "§4[Mail]");
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Balance]"))
|
||||
{
|
||||
if (user.isAuthorized("essentials.signs.balance.create"))
|
||||
event.setLine(0, "§1[Balance]");
|
||||
else
|
||||
event.setLine(0, "§4[Balance]");
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Warp]"))
|
||||
{
|
||||
event.setLine(0, "§4[Warp]");
|
||||
if (user.isAuthorized("essentials.signs.warp.create")) {
|
||||
if (!event.getLine(3).isEmpty())
|
||||
{
|
||||
String[] l1 = event.getLine(3).split("[ :-]+", 2);
|
||||
boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
|
||||
if (!m1 && l1.length != 2)
|
||||
{
|
||||
throw new Exception(Util.format("invalidSignLine", 4));
|
||||
}
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
if ((int)q1 < 1) throw new Exception(Util.i18n("moreThanZero"));
|
||||
if (!m1) ItemDb.get(l1[1]);
|
||||
event.setLine(3, (m1 ? Util.formatCurrency(q1) : (int)q1 + " " + l1[1]));
|
||||
}
|
||||
if (event.getLine(1).isEmpty()) {
|
||||
event.setLine(1, "§dWarp name!");
|
||||
return;
|
||||
} else {
|
||||
ess.getWarps().getWarp(event.getLine(1));
|
||||
if (event.getLine(2).equalsIgnoreCase("Everyone")) {
|
||||
event.setLine(2, "§2Everyone");
|
||||
}
|
||||
event.setLine(0, "§1[Warp]");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
Block signBlock = event.getBlockAgainst();
|
||||
if (signBlock.getType() == Material.WALL_SIGN || signBlock.getType() == Material.SIGN_POST)
|
||||
if (event.isCancelled())
|
||||
{
|
||||
Sign sign = new CraftSign(signBlock);
|
||||
if (sign.getLine(0).matches("§1\\[[a-zA-Z]+\\]"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
// Do not rely on getItemInHand();
|
||||
// http://leaky.bukkit.org/issues/663
|
||||
final ItemStack is = new ItemStack(event.getBlockPlaced().getType(), 1, (short)0, event.getBlockPlaced().getData());
|
||||
switch(is.getType()) {
|
||||
case WOODEN_DOOR:
|
||||
is.setType(Material.WOOD_DOOR);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case IRON_DOOR_BLOCK:
|
||||
is.setType(Material.IRON_DOOR);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case SIGN_POST:
|
||||
case WALL_SIGN:
|
||||
is.setType(Material.SIGN);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case CROPS:
|
||||
is.setType(Material.SEEDS);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case CAKE_BLOCK:
|
||||
is.setType(Material.CAKE);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case BED_BLOCK:
|
||||
is.setType(Material.BED);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case REDSTONE_WIRE:
|
||||
is.setType(Material.REDSTONE);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case REDSTONE_TORCH_OFF:
|
||||
case REDSTONE_TORCH_ON:
|
||||
is.setType(Material.REDSTONE_TORCH_ON);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case DIODE_BLOCK_OFF:
|
||||
case DIODE_BLOCK_ON:
|
||||
is.setType(Material.DIODE);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case DOUBLE_STEP:
|
||||
is.setType(Material.STEP);
|
||||
break;
|
||||
case TORCH:
|
||||
case RAILS:
|
||||
case LADDER:
|
||||
case WOOD_STAIRS:
|
||||
case COBBLESTONE_STAIRS:
|
||||
case LEVER:
|
||||
case STONE_BUTTON:
|
||||
case FURNACE:
|
||||
case DISPENSER:
|
||||
case PUMPKIN:
|
||||
case JACK_O_LANTERN:
|
||||
case WOOD_PLATE:
|
||||
case STONE_PLATE:
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
switch (is.getType())
|
||||
{
|
||||
case WOODEN_DOOR:
|
||||
is.setType(Material.WOOD_DOOR);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case IRON_DOOR_BLOCK:
|
||||
is.setType(Material.IRON_DOOR);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case SIGN_POST:
|
||||
case WALL_SIGN:
|
||||
is.setType(Material.SIGN);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case CROPS:
|
||||
is.setType(Material.SEEDS);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case CAKE_BLOCK:
|
||||
is.setType(Material.CAKE);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case BED_BLOCK:
|
||||
is.setType(Material.BED);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case REDSTONE_WIRE:
|
||||
is.setType(Material.REDSTONE);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case REDSTONE_TORCH_OFF:
|
||||
case REDSTONE_TORCH_ON:
|
||||
is.setType(Material.REDSTONE_TORCH_ON);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case DIODE_BLOCK_OFF:
|
||||
case DIODE_BLOCK_ON:
|
||||
is.setType(Material.DIODE);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case DOUBLE_STEP:
|
||||
is.setType(Material.STEP);
|
||||
break;
|
||||
case TORCH:
|
||||
case RAILS:
|
||||
case LADDER:
|
||||
case WOOD_STAIRS:
|
||||
case COBBLESTONE_STAIRS:
|
||||
case LEVER:
|
||||
case STONE_BUTTON:
|
||||
case FURNACE:
|
||||
case DISPENSER:
|
||||
case PUMPKIN:
|
||||
case JACK_O_LANTERN:
|
||||
case WOOD_PLATE:
|
||||
case STONE_PLATE:
|
||||
case PISTON_STICKY_BASE:
|
||||
case PISTON_BASE:
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case FIRE:
|
||||
return;
|
||||
}
|
||||
boolean unlimitedForUser = user.hasUnlimited(is);
|
||||
if (unlimitedForUser) {
|
||||
if (unlimitedForUser)
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable() {
|
||||
|
||||
public void run() {
|
||||
user.getInventory().addItem(is);
|
||||
user.updateInventory();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasAdjacentChest(Block block)
|
||||
{
|
||||
Block[] faces = getAdjacentBlocks(block);
|
||||
for (Block b : faces)
|
||||
{
|
||||
if (protectedBlocks.contains(b.getType()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private static final int NOT_ALLOWED = 0;
|
||||
private static final int ALLOWED = 1;
|
||||
private static final int NOSIGN = 2;
|
||||
private static final int OWNER = 3;
|
||||
|
||||
private int checkProtectionSign(Block block, User user)
|
||||
{
|
||||
String username = user.getName().substring(0, user.getName().length() > 14 ? 14 : user.getName().length());
|
||||
if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)
|
||||
{
|
||||
Sign sign = new CraftSign(block);
|
||||
if (sign.getLine(0).equalsIgnoreCase("§1[Protection]") && !user.isAuthorized("essentials.signs.protection.override"))
|
||||
{
|
||||
for (int i = 1; i <= 2; i++) {
|
||||
String line = sign.getLine(i);
|
||||
if (line.startsWith("(") && line.endsWith(")")) {
|
||||
line = line.substring(1, line.length() - 1);
|
||||
if (user.inGroup(line)) {
|
||||
return ALLOWED;
|
||||
}
|
||||
} else if (line.equalsIgnoreCase(username)) {
|
||||
return ALLOWED;
|
||||
}
|
||||
}
|
||||
if (sign.getLine(3).equalsIgnoreCase(username))
|
||||
{
|
||||
return OWNER;
|
||||
}
|
||||
return NOT_ALLOWED;
|
||||
}
|
||||
}
|
||||
return NOSIGN;
|
||||
}
|
||||
|
||||
private static Block[] getAdjacentBlocks(Block block)
|
||||
{
|
||||
return new Block[]
|
||||
{
|
||||
block.getFace(BlockFace.NORTH),
|
||||
block.getFace(BlockFace.SOUTH),
|
||||
block.getFace(BlockFace.EAST),
|
||||
block.getFace(BlockFace.WEST),
|
||||
block.getFace(BlockFace.DOWN),
|
||||
block.getFace(BlockFace.UP)
|
||||
};
|
||||
}
|
||||
|
||||
public boolean isBlockProtected(Block block, User user)
|
||||
{
|
||||
Block[] faces = getAdjacentBlocks(block);
|
||||
boolean protect = false;
|
||||
for (Block b : faces)
|
||||
{
|
||||
int check = checkProtectionSign(b, user);
|
||||
if (check == NOT_ALLOWED)
|
||||
{
|
||||
protect = true;
|
||||
}
|
||||
if (check == ALLOWED || check == OWNER)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (protectedBlocks.contains(b.getType()))
|
||||
{
|
||||
Block[] faceChest = getAdjacentBlocks(b);
|
||||
|
||||
for (Block a : faceChest)
|
||||
{
|
||||
check = checkProtectionSign(a, user);
|
||||
if (check == NOT_ALLOWED)
|
||||
new Runnable()
|
||||
{
|
||||
protect = true;
|
||||
}
|
||||
if (check == ALLOWED || check == OWNER)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return protect;
|
||||
}
|
||||
|
||||
public static boolean isBlockProtected(Block block)
|
||||
{
|
||||
Block[] faces = getAdjacentBlocks(block);
|
||||
for (Block b : faces)
|
||||
{
|
||||
if (b.getType() == Material.SIGN_POST || b.getType() == Material.WALL_SIGN)
|
||||
{
|
||||
Sign sign = new CraftSign(b);
|
||||
if (sign.getLine(0).equalsIgnoreCase("§1[Protection]"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (protectedBlocks.contains(b.getType()))
|
||||
{
|
||||
Block[] faceChest = getAdjacentBlocks(b);
|
||||
|
||||
for (Block a : faceChest)
|
||||
{
|
||||
if (a.getType() == Material.SIGN_POST || a.getType() == Material.WALL_SIGN)
|
||||
{
|
||||
Sign sign = new CraftSign(a);
|
||||
if (sign.getLine(0).equalsIgnoreCase("§1[Protection]"))
|
||||
public void run()
|
||||
{
|
||||
return true;
|
||||
user.getInventory().addItem(is);
|
||||
user.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -19,12 +21,12 @@ import org.bukkit.util.config.Configuration;
|
||||
|
||||
public class EssentialsConf extends Configuration
|
||||
{
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private File configFile;
|
||||
private String templateName = null;
|
||||
private Class<?> resourceClass = EssentialsConf.class;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient File configFile;
|
||||
private transient String templateName = null;
|
||||
private transient Class<?> resourceClass = EssentialsConf.class;
|
||||
|
||||
public EssentialsConf(File configFile)
|
||||
public EssentialsConf(final File configFile)
|
||||
{
|
||||
super(configFile);
|
||||
this.configFile = configFile;
|
||||
@@ -42,33 +44,79 @@ public class EssentialsConf extends Configuration
|
||||
{
|
||||
if (!configFile.getParentFile().mkdirs())
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
|
||||
LOGGER.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
|
||||
}
|
||||
}
|
||||
// This will delete files where the first character is 0. In most cases they are broken.
|
||||
if (configFile.exists() && configFile.length() != 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
final InputStream input = new FileInputStream(configFile);
|
||||
try
|
||||
{
|
||||
if (input.read() == 0)
|
||||
{
|
||||
input.close();
|
||||
configFile.delete();
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
input.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (!configFile.exists())
|
||||
{
|
||||
if (templateName != null)
|
||||
{
|
||||
logger.log(Level.INFO, Util.format("creatingConfigFromTemplate", configFile.toString()));
|
||||
LOGGER.log(Level.INFO, Util.format("creatingConfigFromTemplate", configFile.toString()));
|
||||
createFromTemplate();
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.log(Level.INFO, Util.format("creatingEmptyConfig", configFile.toString()));
|
||||
LOGGER.log(Level.INFO, Util.format("creatingEmptyConfig", configFile.toString()));
|
||||
if (!configFile.createNewFile())
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
|
||||
LOGGER.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()), ex);
|
||||
LOGGER.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.load();
|
||||
|
||||
try
|
||||
{
|
||||
super.load();
|
||||
}
|
||||
catch (RuntimeException e)
|
||||
{
|
||||
LOGGER.log(Level.INFO, "File: " + configFile.toString());
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (this.root == null)
|
||||
{
|
||||
this.root = new HashMap<String, Object>();
|
||||
@@ -84,7 +132,7 @@ public class EssentialsConf extends Configuration
|
||||
istr = resourceClass.getResourceAsStream(templateName);
|
||||
if (istr == null)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("couldNotFindTemplate", templateName));
|
||||
LOGGER.log(Level.SEVERE, Util.format("couldNotFindTemplate", templateName));
|
||||
return;
|
||||
}
|
||||
ostr = new FileOutputStream(configFile);
|
||||
@@ -99,7 +147,7 @@ public class EssentialsConf extends Configuration
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("failedToWriteConfig", configFile.toString()), ex);
|
||||
LOGGER.log(Level.SEVERE, Util.format("failedToWriteConfig", configFile.toString()), ex);
|
||||
return;
|
||||
}
|
||||
finally
|
||||
@@ -124,12 +172,12 @@ public class EssentialsConf extends Configuration
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("failedToCloseConfig", configFile.toString()), ex);
|
||||
LOGGER.log(Level.SEVERE, Util.format("failedToCloseConfig", configFile.toString()), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTemplateName(String templateName)
|
||||
public void setTemplateName(final String templateName)
|
||||
{
|
||||
this.templateName = templateName;
|
||||
}
|
||||
@@ -139,48 +187,48 @@ public class EssentialsConf extends Configuration
|
||||
return configFile;
|
||||
}
|
||||
|
||||
public void setTemplateName(String templateName, Class<?> resClass)
|
||||
public void setTemplateName(final String templateName, final Class<?> resClass)
|
||||
{
|
||||
this.templateName = templateName;
|
||||
this.resourceClass = resClass;
|
||||
}
|
||||
|
||||
public boolean hasProperty(String path)
|
||||
public boolean hasProperty(final String path)
|
||||
{
|
||||
return getProperty(path) != null;
|
||||
}
|
||||
|
||||
public Location getLocation(String path, Server server)
|
||||
public Location getLocation(final String path, final Server server) throws Exception
|
||||
{
|
||||
String worldName = getString((path != null ? path + "." : "") + "world");
|
||||
final String worldName = getString((path == null ? "" : path + ".") + "world");
|
||||
if (worldName == null || worldName.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
World world = server.getWorld(worldName);
|
||||
final World world = server.getWorld(worldName);
|
||||
if (world == null)
|
||||
{
|
||||
return null;
|
||||
throw new Exception(Util.i18n("invalidWorld"));
|
||||
}
|
||||
return new Location(world,
|
||||
getDouble((path != null ? path + "." : "") + "x", 0),
|
||||
getDouble((path != null ? path + "." : "") + "y", 0),
|
||||
getDouble((path != null ? path + "." : "") + "z", 0),
|
||||
(float)getDouble((path != null ? path + "." : "") + "yaw", 0),
|
||||
(float)getDouble((path != null ? path + "." : "") + "pitch", 0));
|
||||
getDouble((path == null ? "" : path + ".") + "x", 0),
|
||||
getDouble((path == null ? "" : path + ".") + "y", 0),
|
||||
getDouble((path == null ? "" : path + ".") + "z", 0),
|
||||
(float)getDouble((path == null ? "" : path + ".") + "yaw", 0),
|
||||
(float)getDouble((path == null ? "" : path + ".") + "pitch", 0));
|
||||
}
|
||||
|
||||
public void setProperty(String path, Location loc)
|
||||
public void setProperty(final String path, final Location loc)
|
||||
{
|
||||
setProperty((path != null ? path + "." : "") + "world", loc.getWorld().getName());
|
||||
setProperty((path != null ? path + "." : "") + "x", loc.getX());
|
||||
setProperty((path != null ? path + "." : "") + "y", loc.getY());
|
||||
setProperty((path != null ? path + "." : "") + "z", loc.getZ());
|
||||
setProperty((path != null ? path + "." : "") + "yaw", loc.getYaw());
|
||||
setProperty((path != null ? path + "." : "") + "pitch", loc.getPitch());
|
||||
setProperty((path == null ? "" : path + ".") + "world", loc.getWorld().getName());
|
||||
setProperty((path == null ? "" : path + ".") + "x", loc.getX());
|
||||
setProperty((path == null ? "" : path + ".") + "y", loc.getY());
|
||||
setProperty((path == null ? "" : path + ".") + "z", loc.getZ());
|
||||
setProperty((path == null ? "" : path + ".") + "yaw", loc.getYaw());
|
||||
setProperty((path == null ? "" : path + ".") + "pitch", loc.getPitch());
|
||||
}
|
||||
|
||||
public ItemStack getItemStack(String path)
|
||||
public ItemStack getItemStack(final String path)
|
||||
{
|
||||
return new ItemStack(
|
||||
Material.valueOf(getString(path + ".type", "AIR")),
|
||||
@@ -189,9 +237,9 @@ public class EssentialsConf extends Configuration
|
||||
(byte)getInt(path + ".data", 0)*/);
|
||||
}
|
||||
|
||||
public void setProperty(String path, ItemStack stack)
|
||||
public void setProperty(final String path, final ItemStack stack)
|
||||
{
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
final Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("type", stack.getType().toString());
|
||||
map.put("amount", stack.getAmount());
|
||||
map.put("damage", stack.getDurability());
|
||||
@@ -200,40 +248,30 @@ public class EssentialsConf extends Configuration
|
||||
setProperty(path, map);
|
||||
}
|
||||
|
||||
public long getLong(String path, long def)
|
||||
public long getLong(final String path, final long def)
|
||||
{
|
||||
Number num;
|
||||
try
|
||||
{
|
||||
num = (Number)getProperty(path);
|
||||
final Number num = (Number)getProperty(path);
|
||||
return num == null ? def : num.longValue();
|
||||
}
|
||||
catch(ClassCastException ex)
|
||||
catch (ClassCastException ex)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
if (num == null)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
return num.longValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(String path, double def)
|
||||
public double getDouble(final String path, final double def)
|
||||
{
|
||||
Number num;
|
||||
try
|
||||
{
|
||||
num = (Number)getProperty(path);
|
||||
Number num = (Number)getProperty(path);
|
||||
return num == null ? def : num.doubleValue();
|
||||
}
|
||||
catch(ClassCastException ex)
|
||||
catch (ClassCastException ex)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
if (num == null)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
return num.doubleValue();
|
||||
}
|
||||
}
|
||||
@@ -1,250 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.craftbukkit.block.CraftSign;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class EssentialsEcoBlockListener extends BlockListener
|
||||
{
|
||||
private final IEssentials ess;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
public EssentialsEcoBlockListener(Essentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ess.getSettings().areSignsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
String username = user.getName().substring(0, user.getName().length() > 13 ? 13 : user.getName().length());
|
||||
if (event.getBlock().getType() != Material.WALL_SIGN && event.getBlock().getType() != Material.SIGN_POST)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Sign sign = new CraftSign(event.getBlock());
|
||||
|
||||
if (sign.getLine(0).equals("§1[Trade]"))
|
||||
{
|
||||
if (!sign.getLine(3).substring(2).equals(username))
|
||||
{
|
||||
if (!user.isOp())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
String[] l1 = sign.getLines()[1].split("[ :-]+");
|
||||
String[] l2 = sign.getLines()[2].split("[ :-]+");
|
||||
boolean m1 = l1[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
|
||||
boolean m2 = l2[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
double q2 = Double.parseDouble(m2 ? l2[0].substring(1) : l2[0]);
|
||||
double r1 = Double.parseDouble(l1[m1 ? 1 : 2]);
|
||||
double r2 = Double.parseDouble(l2[m2 ? 1 : 2]);
|
||||
if ((!m1 & q1 < 1) || (!m2 & q2 < 1))
|
||||
{
|
||||
throw new Exception(Util.i18n("moreThanZero"));
|
||||
}
|
||||
|
||||
ItemStack i1 = m1 || r1 <= 0 ? null : ItemDb.get(l1[1], (int)r1);
|
||||
ItemStack i2 = m2 || r2 <= 0 ? null : ItemDb.get(l2[1], (int)r2);
|
||||
|
||||
if (m1)
|
||||
{
|
||||
user.giveMoney(r1);
|
||||
}
|
||||
else if (i1 != null)
|
||||
{
|
||||
Map<Integer, ItemStack> leftOver = user.getInventory().addItem(i1);
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
if (m2)
|
||||
{
|
||||
user.giveMoney(r2);
|
||||
}
|
||||
else if (i2 != null)
|
||||
{
|
||||
Map<Integer, ItemStack> leftOver = user.getInventory().addItem(i2);
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
}
|
||||
}
|
||||
user.updateInventory();
|
||||
|
||||
sign.setType(Material.AIR);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSignChange(SignChangeEvent event)
|
||||
{
|
||||
if (ess.getSettings().areSignsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
String username = user.getName().substring(0, user.getName().length() > 13 ? 13 : user.getName().length());
|
||||
|
||||
if ((event.getLine(0).equalsIgnoreCase("[Buy]") || event.getLine(0).equalsIgnoreCase("#1[Buy]")) && user.isAuthorized("essentials.signs.buy.create"))
|
||||
{
|
||||
try
|
||||
{
|
||||
event.setLine(0, "§1[Buy]");
|
||||
event.setLine(1, "" + Math.abs(Integer.parseInt(event.getLine(1))));
|
||||
ItemStack is = ItemDb.get(event.getLine(2));
|
||||
if (is.getTypeId() == 0 || Math.abs(Integer.parseInt(event.getLine(1))) == 0)
|
||||
{
|
||||
throw new Exception("Don't sell air.");
|
||||
}
|
||||
double price = Double.parseDouble(event.getLine(3).replaceAll("[^0-9\\.]", ""));
|
||||
event.setLine(3, Util.formatCurrency(price));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
event.setLine(0, "§4[Buy]");
|
||||
event.setLine(1, "#");
|
||||
event.setLine(2, "Item");
|
||||
event.setLine(3, "$Price");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ((event.getLine(0).equalsIgnoreCase("[Sell]") || event.getLine(0).equalsIgnoreCase("#1[Sell]")) && user.isAuthorized("essentials.signs.sell.create"))
|
||||
{
|
||||
try
|
||||
{
|
||||
event.setLine(0, "§1[Sell]");
|
||||
event.setLine(1, "" + Math.abs(Integer.parseInt(event.getLine(1))));
|
||||
ItemStack is = ItemDb.get(event.getLine(2));
|
||||
if (is.getTypeId() == 0 || Math.abs(Integer.parseInt(event.getLine(1))) == 0)
|
||||
{
|
||||
throw new Exception("Can't buy air.");
|
||||
}
|
||||
double price = Double.parseDouble(event.getLine(3).replaceAll("[^0-9\\.]", ""));
|
||||
event.setLine(3, Util.formatCurrency(price));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
event.setLine(0, "§4[Sell]");
|
||||
event.setLine(1, "#");
|
||||
event.setLine(2, "Item");
|
||||
event.setLine(3, "$Price");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ((event.getLine(0).equalsIgnoreCase("[Trade]") || event.getLine(0).equalsIgnoreCase("#1[Trade]")) && user.isAuthorized("essentials.signs.trade.create"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String[] l1 = event.getLine(1).split("[ :-]+");
|
||||
String[] l2 = event.getLine(2).split("[ :-]+");
|
||||
boolean m1 = l1[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
|
||||
boolean m2 = l2[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
double q2 = Double.parseDouble(m2 ? l2[0].substring(1) : l2[0]);
|
||||
if (m1 ? l1.length != 1 : l1.length != 2)
|
||||
{
|
||||
throw new Exception(Util.format("invalidSignLine", 2));
|
||||
}
|
||||
if (m2 ? l2.length != 2 : l2.length != 3)
|
||||
{
|
||||
throw new Exception(Util.format("invalidSignLine", 3));
|
||||
}
|
||||
double r2 = Double.parseDouble(l2[m2 ? 1 : 2]);
|
||||
r2 = m2 ? r2 : r2 - r2 % q2;
|
||||
if ((!m1 & q1 < 1) || (!m2 & q2 < 1) || r2 < 1)
|
||||
{
|
||||
throw new Exception(Util.i18n("moreThanZero"));
|
||||
}
|
||||
if (!m1)
|
||||
{
|
||||
ItemDb.get(l1[1]);
|
||||
}
|
||||
|
||||
if (m2)
|
||||
{
|
||||
if (user.getMoney() < r2)
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(r2);
|
||||
//user.sendMessage("r2: " + r2 + " q2: " + q2);
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack i2 = ItemDb.get(l2[1], (int)r2);
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, i2))
|
||||
{
|
||||
throw new Exception(Util.format("missingItems", (int)r2, l2[1]));
|
||||
}
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, i2);
|
||||
user.updateInventory();
|
||||
}
|
||||
|
||||
event.setLine(0, "§1[Trade]");
|
||||
event.setLine(1, (m1 ? Util.formatCurrency(q1) : (int)q1 + " " + l1[1]) + ":0");
|
||||
event.setLine(2, (m2 ? Util.formatCurrency(q2) : (int)q2 + " " + l2[1]) + ":" + (m2 ? Util.roundDouble(r2) : "" + (int)r2));
|
||||
event.setLine(3, "§8" + username);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
event.setLine(0, "§4[Trade]");
|
||||
event.setLine(1, "# ItemOr" + ess.getSettings().getCurrencySymbol());
|
||||
event.setLine(2, "# ItemOr" + ess.getSettings().getCurrencySymbol() + ":#");
|
||||
event.setLine(3, "§8" + username);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,211 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.craftbukkit.block.CraftSign;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class EssentialsEcoPlayerListener extends PlayerListener
|
||||
{
|
||||
private final IEssentials ess;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
EssentialsEcoPlayerListener(IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if (ess.getSettings().areSignsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
String username = user.getName().substring(0, user.getName().length() > 13 ? 13 : user.getName().length());
|
||||
if (event.getClickedBlock().getType() != Material.WALL_SIGN && event.getClickedBlock().getType() != Material.SIGN_POST)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Sign sign = new CraftSign(event.getClickedBlock());
|
||||
|
||||
if (sign.getLine(0).equals("§1[Buy]") && user.isAuthorized("essentials.signs.buy.use"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int amount = Integer.parseInt(sign.getLine(1));
|
||||
ItemStack item = ItemDb.get(sign.getLine(2), amount);
|
||||
double cost = Double.parseDouble(sign.getLine(3).substring(1));
|
||||
if (user.getMoney() < cost)
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(cost);
|
||||
Map<Integer, ItemStack> leftOver = user.getInventory().addItem(item);
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
}
|
||||
user.updateInventory();
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (sign.getLine(0).equals("§1[Sell]") && user.isAuthorized("essentials.signs.sell.use"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int amount = Integer.parseInt(sign.getLine(1));
|
||||
ItemStack item = ItemDb.get(sign.getLine(2), amount);
|
||||
double cost = Double.parseDouble(sign.getLine(3).substring(1));
|
||||
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, item))
|
||||
{
|
||||
throw new Exception(Util.format("missingItems", amount, sign.getLine(2)));
|
||||
}
|
||||
user.giveMoney(cost);
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, item);
|
||||
user.updateInventory();
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (sign.getLine(0).equals("§1[Trade]") && user.isAuthorized("essentials.signs.trade.use"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String[] l1 = sign.getLine(1).split("[ :-]+");
|
||||
String[] l2 = sign.getLine(2).split("[ :-]+");
|
||||
boolean m1 = l1[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
|
||||
boolean m2 = l2[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
double q2 = Double.parseDouble(m2 ? l2[0].substring(1) : l2[0]);
|
||||
double r1 = Double.parseDouble(l1[m1 ? 1 : 2]);
|
||||
double r2 = Double.parseDouble(l2[m2 ? 1 : 2]);
|
||||
r1 = m1 ? r1 : r1 - r1 % q1;
|
||||
r2 = m2 ? r2 : r2 - r2 % q2;
|
||||
if ((!m1 & q1 < 1) || (!m2 & q2 < 1))
|
||||
{
|
||||
throw new Exception(Util.i18n("moreThanZero"));
|
||||
}
|
||||
|
||||
ItemStack i1 = m1 || r1 <= 0 ? null : ItemDb.get(l1[1], (int)r1);
|
||||
ItemStack qi1 = m1 ? null : ItemDb.get(l1[1], (int)q1);
|
||||
ItemStack qi2 = m2 ? null : ItemDb.get(l2[1], (int)q2);
|
||||
|
||||
if (username.equals(sign.getLine(3).substring(2)))
|
||||
{
|
||||
if (m1)
|
||||
{
|
||||
user.giveMoney(r1);
|
||||
}
|
||||
else if (i1 != null)
|
||||
{
|
||||
Map<Integer, ItemStack> leftOver = user.getInventory().addItem(i1);
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
}
|
||||
user.updateInventory();
|
||||
}
|
||||
r1 = 0;
|
||||
sign.setLine(1, (m1 ? Util.formatCurrency(q1) : ((int)q1) + " " + l1[1]) + ":0");
|
||||
sign.update();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m1)
|
||||
{
|
||||
if (user.getMoney() < q1)
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, qi1))
|
||||
{
|
||||
throw new Exception(Util.format("missingItems", (int)q1, l1[1]));
|
||||
}
|
||||
}
|
||||
|
||||
if (r2 < q2)
|
||||
{
|
||||
throw new Exception(Util.i18n("tradeSignEmpty"));
|
||||
}
|
||||
|
||||
if (m1)
|
||||
{
|
||||
user.takeMoney(q1);
|
||||
}
|
||||
else
|
||||
{
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, qi1);
|
||||
}
|
||||
|
||||
if (m2)
|
||||
{
|
||||
user.giveMoney(q2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Map<Integer, ItemStack> leftOver = user.getInventory().addItem(qi2);
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
user.updateInventory();
|
||||
|
||||
r1 += q1;
|
||||
r2 -= q2;
|
||||
|
||||
|
||||
sign.setLine(0, "§1[Trade]");
|
||||
sign.setLine(1, (m1 ? Util.formatCurrency(q1) : ((int)q1) + " " + l1[1]) + ":" + (m1 ? Util.roundDouble(r1) : "" + (int)r1));
|
||||
sign.setLine(2, (m2 ? Util.formatCurrency(q2) : ((int)q2) + " " + l2[1]) + ":" + (m2 ? Util.roundDouble(r2) : "" + (int)r2));
|
||||
sign.update();
|
||||
user.sendMessage(Util.i18n("tradeCompleted"));
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import java.util.List;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@@ -35,25 +34,28 @@ public class EssentialsEntityListener extends EntityListener
|
||||
User defender = ess.getUser(eDefend);
|
||||
User attacker = ess.getUser(eAttack);
|
||||
ItemStack is = attacker.getItemInHand();
|
||||
String command = attacker.getPowertool(is);
|
||||
if (command != null && !command.isEmpty())
|
||||
List<String> commandList = attacker.getPowertool(is);
|
||||
if (commandList != null && !commandList.isEmpty())
|
||||
{
|
||||
attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", defender.getName()));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
for (String command : commandList)
|
||||
{
|
||||
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", defender.getName()));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (event instanceof EntityDamageEvent || event instanceof EntityDamageByBlockEvent || event instanceof EntityDamageByProjectileEvent)
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
CraftPlayer player = (CraftPlayer)event.getEntity();
|
||||
player.getHandle().fireTicks = 0;
|
||||
player.setRemainingAir(player.getMaximumAir());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
final Player player = (Player)event.getEntity();
|
||||
player.setFireTicks(0);
|
||||
player.setRemainingAir(player.getMaximumAir());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,4 +81,13 @@ public class EssentialsEntityListener extends EntityListener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
event.setFoodLevel(20);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,22 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.InventoryPlayer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.craftbukkit.block.CraftSign;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
import org.bukkit.event.player.PlayerAnimationType;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerEggThrowEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
@@ -34,57 +32,56 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class EssentialsPlayerListener extends PlayerListener
|
||||
{
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private final Server server;
|
||||
private final IEssentials ess;
|
||||
private final EssentialsBlockListener essBlockListener;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final transient Server server;
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public EssentialsPlayerListener(IEssentials parent)
|
||||
public EssentialsPlayerListener(final IEssentials parent)
|
||||
{
|
||||
this.ess = parent;
|
||||
this.server = parent.getServer();
|
||||
essBlockListener = new EssentialsBlockListener(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event)
|
||||
public void onPlayerRespawn(final PlayerRespawnEvent event)
|
||||
{
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.setDisplayName(user.getNick());
|
||||
updateCompass(user);
|
||||
if (user.isJailed() && user.getJail() != null && !user.getJail().isEmpty()) {
|
||||
try
|
||||
{
|
||||
event.setRespawnLocation(ess.getJail().getJail(user.getJail()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerChat(PlayerChatEvent event)
|
||||
public void onPlayerChat(final PlayerChatEvent event)
|
||||
{
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isMuted())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
logger.info(Util.format("mutedUserSpeaks", user.getName()));
|
||||
user.sendMessage(Util.i18n("playerMuted"));
|
||||
LOGGER.info(Util.format("mutedUserSpeaks", user.getName()));
|
||||
}
|
||||
Iterator<Player> it = event.getRecipients().iterator();
|
||||
final Iterator<Player> it = event.getRecipients().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
User u = ess.getUser(it.next());
|
||||
final User u = ess.getUser(it.next());
|
||||
if (u.isIgnoredPlayer(user.getName()))
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
user.updateActivity(true);
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event)
|
||||
public void onPlayerMove(final PlayerMoveEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
@@ -92,13 +89,30 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
|
||||
if (user.isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
final Location from = event.getFrom();
|
||||
final Location to = event.getTo().clone();
|
||||
to.setX(from.getX());
|
||||
to.setY(from.getBlock().getTypeId() == 0 ? from.getY() - 1 : from.getY());
|
||||
to.setZ(from.getZ());
|
||||
event.setTo(to);
|
||||
return;
|
||||
}
|
||||
|
||||
Location afk = user.getAfkPosition();
|
||||
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9)
|
||||
{
|
||||
user.updateActivity(true);
|
||||
}
|
||||
|
||||
if (!ess.getSettings().getNetherPortalsEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Block block = event.getPlayer().getWorld().getBlockAt(event.getTo().getBlockX(), event.getTo().getBlockY(), event.getTo().getBlockZ());
|
||||
List<World> worlds = server.getWorlds();
|
||||
final List<World> worlds = server.getWorlds();
|
||||
|
||||
if (block.getType() == Material.PORTAL && worlds.size() > 1 && user.isAuthorized("essentials.portal"))
|
||||
{
|
||||
@@ -107,17 +121,19 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
return;
|
||||
}
|
||||
|
||||
Location loc = event.getTo();
|
||||
World nether = server.getWorld(ess.getSettings().getNetherName());
|
||||
if (nether == null) {
|
||||
if (nether == null)
|
||||
{
|
||||
for (World world : worlds)
|
||||
{
|
||||
if (world.getEnvironment() == World.Environment.NETHER) {
|
||||
if (world.getEnvironment() == World.Environment.NETHER)
|
||||
{
|
||||
nether = world;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nether == null) {
|
||||
if (nether == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -128,7 +144,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
{
|
||||
factor = ess.getSettings().getNetherRatio();
|
||||
}
|
||||
else if (user.getWorld().getEnvironment() != world.getEnvironment())
|
||||
else if (user.getWorld().getEnvironment() == World.Environment.NORMAL && world.getEnvironment() == World.Environment.NETHER)
|
||||
{
|
||||
factor = 1.0 / ess.getSettings().getNetherRatio();
|
||||
}
|
||||
@@ -137,6 +153,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
factor = 1.0;
|
||||
}
|
||||
|
||||
Location loc = event.getTo();
|
||||
int x = loc.getBlockX();
|
||||
int y = loc.getBlockY();
|
||||
int z = loc.getBlockZ();
|
||||
@@ -161,14 +178,14 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
if (world.getEnvironment() == World.Environment.NETHER || ess.getSettings().getGenerateExitPortals())
|
||||
{
|
||||
portal = NetherPortal.createPortal(dest);
|
||||
logger.info(Util.format("userCreatedPortal", event.getPlayer().getName()));
|
||||
LOGGER.info(Util.format("userCreatedPortal", event.getPlayer().getName()));
|
||||
user.sendMessage(Util.i18n("generatingPortal"));
|
||||
loc = portal.getSpawn();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.info(Util.format("userUsedPortal", event.getPlayer().getName()));
|
||||
LOGGER.info(Util.format("userUsedPortal", event.getPlayer().getName()));
|
||||
user.sendMessage(Util.i18n("usingPortal"));
|
||||
loc = portal.getSpawn();
|
||||
}
|
||||
@@ -177,7 +194,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
event.setTo(loc);
|
||||
try
|
||||
{
|
||||
user.getTeleport().now(loc, new Charge("portal", ess));
|
||||
user.getTeleport().now(loc, new Trade("portal", ess));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -194,21 +211,25 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
public void onPlayerQuit(final PlayerQuitEvent event)
|
||||
{
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (ess.getSettings().removeGodOnDisconnect() && user.isGodModeEnabled())
|
||||
{
|
||||
user.toggleGodModeEnabled();
|
||||
}
|
||||
if (user.getSavedInventory() != null)
|
||||
{
|
||||
user.getInventory().setContents(user.getSavedInventory());
|
||||
user.setSavedInventory(null);
|
||||
}
|
||||
user.updateActivity(false);
|
||||
user.dispose();
|
||||
if (!ess.getSettings().getReclaimSetting())
|
||||
{
|
||||
return;
|
||||
}
|
||||
user.dispose();
|
||||
Thread thread = new Thread(new Runnable()
|
||||
final Thread thread = new Thread(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
@@ -221,7 +242,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
rt.gc();
|
||||
mem = rt.freeMemory() - mem;
|
||||
mem /= 1024 * 1024;
|
||||
logger.log(Level.INFO, Util.format("freedMemory", mem));
|
||||
LOGGER.log(Level.INFO, Util.format("freedMemory", mem));
|
||||
}
|
||||
catch (InterruptedException ex)
|
||||
{
|
||||
@@ -234,20 +255,20 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
ess.getBackup().onPlayerJoin();
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
|
||||
//we do not know the ip address on playerlogin so we need to do this here.
|
||||
if (user.isIpBanned())
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
String banReason = user.getBanReason();
|
||||
user.kickPlayer(banReason != null && !banReason.isEmpty() ? banReason : Util.i18n("defaultBanReason"));
|
||||
return;
|
||||
user.setDisplayName(user.getNick());
|
||||
}
|
||||
user.updateActivity(false);
|
||||
if (user.isAuthorized("essentials.sleepingignored"))
|
||||
{
|
||||
user.setSleepingIgnored(true);
|
||||
}
|
||||
|
||||
user.setDisplayName(user.getNick());
|
||||
|
||||
if (!ess.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd"))
|
||||
{
|
||||
@@ -263,7 +284,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
|
||||
if (!ess.getSettings().isCommandDisabled("mail") && user.isAuthorized("essentials.mail"))
|
||||
{
|
||||
List<String> mail = user.getMails();
|
||||
final List<String> mail = user.getMails();
|
||||
if (mail.isEmpty())
|
||||
{
|
||||
user.sendMessage(Util.i18n("noNewMail"));
|
||||
@@ -276,19 +297,25 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerLogin(PlayerLoginEvent event)
|
||||
public void onPlayerLogin(final PlayerLoginEvent event)
|
||||
{
|
||||
if (event.getResult() != Result.ALLOWED)
|
||||
if (event.getResult() != Result.ALLOWED && event.getResult() != Result.KICK_FULL && event.getResult() != Result.KICK_BANNED)
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Disconnecting user " + event.getPlayer().toString() + " due to " + event.getResult().toString());
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
user.setNPC(false);
|
||||
|
||||
if (user.isBanned())
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
boolean banExpired = user.checkBanTimeout(currentTime);
|
||||
user.checkMuteTimeout(currentTime);
|
||||
user.checkJailTimeout(currentTime);
|
||||
|
||||
if (banExpired == false && (user.isBanned() || event.getResult() == Result.KICK_BANNED))
|
||||
{
|
||||
String banReason = user.getBanReason();
|
||||
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() ? banReason : Util.i18n("defaultBanReason"));
|
||||
final String banReason = user.getBanReason();
|
||||
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : Util.i18n("defaultBanReason"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -297,12 +324,13 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
event.disallow(Result.KICK_FULL, Util.i18n("serverFull"));
|
||||
return;
|
||||
}
|
||||
event.allow();
|
||||
|
||||
user.setLastLogin(System.currentTimeMillis());
|
||||
updateCompass(user);
|
||||
}
|
||||
|
||||
private void updateCompass(User user)
|
||||
private void updateCompass(final User user)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -320,24 +348,16 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
return;
|
||||
user.setDisplayName(user.getNick());
|
||||
}
|
||||
try
|
||||
{
|
||||
event.setTo(ess.getJail().getJail(user.getJail()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.WARNING, Util.i18n("returnPlayerToJailError"), ex);
|
||||
}
|
||||
user.sendMessage(Util.i18n("jailMessage"));
|
||||
updateCompass(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
@@ -347,29 +367,12 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!ess.getSettings().areSignsDisabled() && EssentialsBlockListener.protectedBlocks.contains(event.getClickedBlock().getType()))
|
||||
{
|
||||
if (!user.isAuthorized("essentials.signs.protection.override"))
|
||||
{
|
||||
if (essBlockListener.isBlockProtected(event.getClickedBlock(), user))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
user.sendMessage(Util.format("noAccessPermission", event.getClickedBlock().getType().toString().toLowerCase()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ess.getSettings().getBedSetsHome() && event.getClickedBlock().getType() == Material.BED_BLOCK)
|
||||
{
|
||||
try
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.setHome();
|
||||
user.sendMessage(Util.i18n("homeSetToBed"));
|
||||
}
|
||||
@@ -377,158 +380,13 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ess.getSettings().areSignsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (event.getClickedBlock().getType() != Material.WALL_SIGN && event.getClickedBlock().getType() != Material.SIGN_POST)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Sign sign = new CraftSign(event.getClickedBlock());
|
||||
|
||||
try
|
||||
{
|
||||
if (sign.getLine(0).equals("§1[Free]") && user.isAuthorized("essentials.signs.free.use"))
|
||||
{
|
||||
ItemStack item = ItemDb.get(sign.getLine(1));
|
||||
CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(user.getHandle()));
|
||||
inv.clear();
|
||||
item.setAmount(9 * 4 * 64);
|
||||
inv.addItem(item);
|
||||
user.showInventory(inv);
|
||||
return;
|
||||
}
|
||||
if (sign.getLine(0).equals("§1[Disposal]") && user.isAuthorized("essentials.signs.disposal.use"))
|
||||
{
|
||||
CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(user.getHandle()));
|
||||
inv.clear();
|
||||
user.showInventory(inv);
|
||||
return;
|
||||
}
|
||||
if (sign.getLine(0).equals("§1[Heal]") && user.isAuthorized("essentials.signs.heal.use"))
|
||||
{
|
||||
if (!sign.getLine(1).isEmpty())
|
||||
{
|
||||
String[] l1 = sign.getLine(1).split("[ :-]+");
|
||||
boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
if (!m1 && (int)q1 < 1)
|
||||
{
|
||||
throw new Exception(Util.i18n("moreThanZero"));
|
||||
}
|
||||
if (m1)
|
||||
{
|
||||
if (user.getMoney() < q1)
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(q1);
|
||||
user.sendMessage(Util.format("moneyTaken", Util.formatCurrency(q1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack i = ItemDb.get(l1[1], (int)q1);
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, i))
|
||||
{
|
||||
throw new Exception(Util.format("missingItems", (int)q1, l1[1]));
|
||||
}
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, i);
|
||||
user.updateInventory();
|
||||
}
|
||||
}
|
||||
user.setHealth(20);
|
||||
user.sendMessage(Util.i18n("youAreHealed"));
|
||||
return;
|
||||
}
|
||||
if (sign.getLine(0).equals("§1[Mail]") && user.isAuthorized("essentials.signs.mail.use") && user.isAuthorized("essentials.mail"))
|
||||
{
|
||||
List<String> mail = user.getMails();
|
||||
if (mail.isEmpty())
|
||||
{
|
||||
user.sendMessage(Util.i18n("noNewMail"));
|
||||
return;
|
||||
}
|
||||
for (String s : mail)
|
||||
{
|
||||
user.sendMessage(s);
|
||||
}
|
||||
user.sendMessage(Util.i18n("markMailAsRead"));
|
||||
return;
|
||||
}
|
||||
if (sign.getLine(0).equals("§1[Balance]") && user.isAuthorized("essentials.signs.balance.use"))
|
||||
{
|
||||
user.sendMessage(Util.format("balance", user.getMoney()));
|
||||
return;
|
||||
}
|
||||
if (sign.getLine(0).equals("§1[Warp]"))
|
||||
{
|
||||
|
||||
if (!sign.getLine(2).isEmpty())
|
||||
{
|
||||
if (sign.getLine(2).equals("§2Everyone"))
|
||||
{
|
||||
Charge charge = chargeUserForWarp(sign, user);
|
||||
user.getTeleport().warp(sign.getLine(1), charge);
|
||||
return;
|
||||
}
|
||||
if (user.inGroup(sign.getLine(2)))
|
||||
{
|
||||
Charge charge = chargeUserForWarp(sign, user);
|
||||
user.getTeleport().warp(sign.getLine(1), charge);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (user.isAuthorized("essentials.signs.warp.use")
|
||||
&& (!ess.getSettings().getPerWarpPermission() || user.isAuthorized("essentials.warp." + sign.getLine(1))))
|
||||
{
|
||||
Charge charge = chargeUserForWarp(sign, user);
|
||||
user.getTeleport().warp(sign.getLine(1), charge);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Charge chargeUserForWarp(Sign sign, User user) throws Exception
|
||||
{
|
||||
if (!sign.getLine(3).isEmpty())
|
||||
{
|
||||
String[] l1 = sign.getLine(3).split("[ :-]+");
|
||||
boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
if (!m1 && (int)q1 < 1)
|
||||
{
|
||||
throw new Exception(Util.i18n("moreThanZero"));
|
||||
}
|
||||
if (m1)
|
||||
{
|
||||
return new Charge(q1, ess);
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack i = ItemDb.get(l1[1], (int)q1);
|
||||
return new Charge(i, ess);
|
||||
}
|
||||
}
|
||||
return new Charge("warpsign", ess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerEggThrow(PlayerEggThrowEvent event)
|
||||
public void onPlayerEggThrow(final PlayerEggThrowEvent event)
|
||||
{
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
ItemStack is = new ItemStack(Material.EGG, 1);
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final ItemStack is = new ItemStack(Material.EGG, 1);
|
||||
if (user.hasUnlimited(is))
|
||||
{
|
||||
user.getInventory().addItem(is);
|
||||
@@ -537,7 +395,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event)
|
||||
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.hasUnlimited(new ItemStack(event.getBucket())))
|
||||
@@ -554,43 +412,75 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerAnimation(PlayerAnimationEvent event)
|
||||
public void onPlayerAnimation(final PlayerAnimationEvent event)
|
||||
{
|
||||
usePowertools(event);
|
||||
}
|
||||
|
||||
private void usePowertools(PlayerAnimationEvent event)
|
||||
private void usePowertools(final PlayerAnimationEvent event)
|
||||
{
|
||||
if (event.getAnimationType() != PlayerAnimationType.ARM_SWING)
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
ItemStack is = user.getItemInHand();
|
||||
if (is == null || is.getType() == Material.AIR)
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final ItemStack is = user.getItemInHand();
|
||||
if (is == null || is.getType() == Material.AIR || !user.arePowerToolsEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
String command = user.getPowertool(is);
|
||||
if (command == null || command.isEmpty())
|
||||
final List<String> commandList = user.getPowertool(is);
|
||||
if (commandList == null || commandList.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (command.matches(".*\\{player\\}.*"))
|
||||
|
||||
// We need to loop through each command and execute
|
||||
for (String command : commandList)
|
||||
{
|
||||
//user.sendMessage("Click a player to use this command");
|
||||
return;
|
||||
}
|
||||
if (command.startsWith("c:"))
|
||||
{
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
if (command.matches(".*\\{player\\}.*"))
|
||||
{
|
||||
p.sendMessage(user.getDisplayName() + ":" + command.substring(2));
|
||||
//user.sendMessage("Click a player to use this command");
|
||||
continue;
|
||||
}
|
||||
else if (command.startsWith("c:"))
|
||||
{
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
p.sendMessage(user.getDisplayName() + ":" + command.substring(2));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
user.getServer().dispatchCommand(event.getPlayer(), command);
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
user.getServer().dispatchCommand(user, command);
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final String cmd = event.getMessage().toLowerCase().split(" ")[0].replace("/", "").toLowerCase();
|
||||
final List<String> commands = Arrays.asList("msg", "r", "mail", "m", "t", "emsg", "tell", "er", "reply", "ereply", "email");
|
||||
if (commands.contains(cmd))
|
||||
{
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
User spyer = ess.getUser(player);
|
||||
if (spyer.isSocialSpyEnabled() && !user.equals(spyer))
|
||||
{
|
||||
player.sendMessage(user.getDisplayName() + " : " + event.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!cmd.equalsIgnoreCase("afk"))
|
||||
{
|
||||
user.updateActivity(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
@@ -8,38 +7,42 @@ import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
|
||||
|
||||
public class EssentialsPluginListener extends ServerListener
|
||||
public class EssentialsPluginListener extends ServerListener implements IConf
|
||||
{
|
||||
private final Methods methods;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private final transient IEssentials ess;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
|
||||
public EssentialsPluginListener(Methods methods)
|
||||
public EssentialsPluginListener(final IEssentials ess)
|
||||
{
|
||||
this.methods = methods;
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onPluginEnable(PluginEnableEvent event)
|
||||
public void onPluginEnable(final PluginEnableEvent event)
|
||||
{
|
||||
if (!methods.hasMethod())
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(ess.getServer().getPluginManager()))
|
||||
{
|
||||
if (methods.setMethod(event.getPlugin()))
|
||||
{
|
||||
logger.log(Level.INFO, "[Essentials] Payment method found (" + methods.getMethod().getName() + " version: " + methods.getMethod().getVersion() + ")");
|
||||
}
|
||||
LOGGER.log(Level.INFO, "[Essentials] Payment method found (" + ess.getPaymentMethod().getMethod().getName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginDisable(PluginDisableEvent event)
|
||||
public void onPluginDisable(final PluginDisableEvent event)
|
||||
{
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
// Check to see if the plugin thats being disabled is the one we are using
|
||||
if (methods != null && methods.hasMethod())
|
||||
if (ess.getPaymentMethod() != null && ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().checkDisabled(event.getPlugin()))
|
||||
{
|
||||
if (methods.checkDisabled(event.getPlugin()))
|
||||
{
|
||||
logger.log(Level.INFO, "[Essentials] Payment method was disabled. No longer accepting payments.");
|
||||
}
|
||||
ess.getPaymentMethod().reset();
|
||||
LOGGER.log(Level.INFO, "[Essentials] Payment method was disabled. No longer accepting payments.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
ess.getPermissionsHandler().setUseSuperperms(ess.getSettings().useBukkitPermissions());
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
}
|
||||
}
|
||||
@@ -1,81 +1,45 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class EssentialsTimer implements Runnable, IConf
|
||||
public class EssentialsTimer implements Runnable
|
||||
{
|
||||
private final IEssentials ess;
|
||||
private final Set<User> allUsers = new HashSet<User>();
|
||||
|
||||
EssentialsTimer(IEssentials ess)
|
||||
private final transient IEssentials ess;
|
||||
private final transient Set<User> onlineUsers = new HashSet<User>();
|
||||
|
||||
EssentialsTimer(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
File userdir = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdir.exists()) {
|
||||
return;
|
||||
}
|
||||
for (String string : userdir.list())
|
||||
{
|
||||
if (!string.endsWith(".yml")) {
|
||||
continue;
|
||||
}
|
||||
String name = string.substring(0, string.length()-4);
|
||||
User u = ess.getUser(new OfflinePlayer(name));
|
||||
allUsers.add(u);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
long currentTime = System.currentTimeMillis();
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
User u = ess.getUser(player);
|
||||
allUsers.add(u);
|
||||
u.setLastActivity(currentTime);
|
||||
final User user = ess.getUser(player);
|
||||
onlineUsers.add(user);
|
||||
user.setLastOnlineActivity(currentTime);
|
||||
user.checkActivity();
|
||||
}
|
||||
|
||||
for (User user: allUsers) {
|
||||
if (user.getBanTimeout() > 0 && user.getBanTimeout() < currentTime) {
|
||||
user.setBanTimeout(0);
|
||||
((CraftServer)ess.getServer()).getHandle().b(user.getName());
|
||||
ess.loadBanList();
|
||||
}
|
||||
if (user.getMuteTimeout() > 0 && user.getMuteTimeout() < currentTime && user.isMuted()) {
|
||||
user.setMuteTimeout(0);
|
||||
user.sendMessage(Util.i18n("canTalkAgain"));
|
||||
user.setMuted(false);
|
||||
}
|
||||
if (user.getJailTimeout() > 0 && user.getJailTimeout() < currentTime && user.isJailed()) {
|
||||
user.setJailTimeout(0);
|
||||
user.setJailed(false);
|
||||
user.sendMessage(Util.i18n("haveBeenReleased"));
|
||||
user.setJail(null);
|
||||
try
|
||||
{
|
||||
user.getTeleport().back();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (user.getLastActivity() < currentTime && user.getLastActivity() > user.getLastLogout()) {
|
||||
user.setLastLogout(user.getLastActivity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadConfig()
|
||||
{
|
||||
for (User user : allUsers)
|
||||
final Iterator<User> iterator = onlineUsers.iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
user.reloadConfig();
|
||||
final User user = iterator.next();
|
||||
if (user.getLastOnlineActivity() < currentTime && user.getLastOnlineActivity() > user.getLastLogout())
|
||||
{
|
||||
user.setLastLogout(user.getLastOnlineActivity());
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
user.checkMuteTimeout(currentTime);
|
||||
user.checkJailTimeout(currentTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,65 +4,81 @@ import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.math.BigInteger;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
class EssentialsUpdateTimer implements Runnable
|
||||
{
|
||||
private URL url;
|
||||
private final Essentials ess;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
public EssentialsUpdateTimer(Essentials ess)
|
||||
private transient URL url;
|
||||
private final transient IEssentials ess;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final transient Pattern pattern = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*");
|
||||
|
||||
public EssentialsUpdateTimer(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
try
|
||||
{
|
||||
url = new URL("http://127.0.0.1:8080/check");
|
||||
url = new URL("http://essentialsupdate.appspot.com/check");
|
||||
}
|
||||
catch (MalformedURLException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, "Invalid url!", ex);
|
||||
LOGGER.log(Level.SEVERE, "Invalid url!", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("v=").append(URLEncoder.encode(ess.getDescription().getVersion(),"UTF-8"));
|
||||
sb.append("&b=").append(URLEncoder.encode(ess.getServer().getVersion(),"UTF-8"));
|
||||
sb.append("&jv=").append(URLEncoder.encode(System.getProperty("java.version"),"UTF-8"));
|
||||
sb.append("&l=").append(URLEncoder.encode(Util.getCurrentLocale().toString(),"UTF-8"));
|
||||
sb.append("&on=").append(URLEncoder.encode(System.getProperty("os.name"),"UTF-8"));
|
||||
sb.append("&ov=").append(URLEncoder.encode(System.getProperty("os.version"),"UTF-8"));
|
||||
for (BigInteger bigInteger : ess.getErrors().keySet())
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
String bukkitVersion = ess.getServer().getVersion();
|
||||
final Matcher versionMatch = pattern.matcher(bukkitVersion);
|
||||
if (versionMatch.matches())
|
||||
{
|
||||
sb.append("&e[]=").append(bigInteger.toString(36));
|
||||
bukkitVersion = versionMatch.group(4);
|
||||
}
|
||||
URLConnection conn = url.openConnection();
|
||||
builder.append("v=").append(URLEncoder.encode(ess.getDescription().getVersion(), "UTF-8"));
|
||||
builder.append("&b=").append(URLEncoder.encode(bukkitVersion, "UTF-8"));
|
||||
final URLConnection conn = url.openConnection();
|
||||
conn.setConnectTimeout(10000);
|
||||
conn.setDoOutput(true);
|
||||
conn.connect();
|
||||
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
|
||||
wr.write(sb.toString());
|
||||
wr.flush();
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String ret = br.readLine();
|
||||
wr.close();
|
||||
br.close();
|
||||
logger.log(Level.INFO, ret);
|
||||
final OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
|
||||
writer.write(builder.toString());
|
||||
writer.flush();
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
final String ret = reader.readLine();
|
||||
writer.close();
|
||||
reader.close();
|
||||
if (!ret.isEmpty() && !ret.equalsIgnoreCase("OK"))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials Update-Check: " + ret);
|
||||
if (ret.startsWith("New Version"))
|
||||
{
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
if (user.isAuthorized("essentials.admin.notices.update"))
|
||||
{
|
||||
user.sendMessage(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, "Failed to open connection", ex);
|
||||
LOGGER.log(Level.SEVERE, "Failed to open connection", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,24 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.security.DigestInputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@@ -16,63 +27,70 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class EssentialsUpgrade
|
||||
{
|
||||
private static boolean alreadyRun = false;
|
||||
private final static Logger logger = Logger.getLogger("Minecraft");
|
||||
private final IEssentials ess;
|
||||
private final static Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final transient IEssentials ess;
|
||||
private final transient EssentialsConf doneFile;
|
||||
|
||||
EssentialsUpgrade(String version, IEssentials essentials)
|
||||
EssentialsUpgrade(final IEssentials essentials)
|
||||
{
|
||||
ess = essentials;
|
||||
if (alreadyRun)
|
||||
if (!ess.getDataFolder().exists())
|
||||
{
|
||||
return;
|
||||
ess.getDataFolder().mkdirs();
|
||||
}
|
||||
alreadyRun = true;
|
||||
doneFile = new EssentialsConf(new File(ess.getDataFolder(), "upgrades-done.yml"));
|
||||
doneFile.load();
|
||||
}
|
||||
|
||||
private void moveWorthValuesToWorthYml()
|
||||
{
|
||||
if (doneFile.getBoolean("moveWorthValuesToWorthYml", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
File configFile = new File(ess.getDataFolder(), "config.yml");
|
||||
final File configFile = new File(ess.getDataFolder(), "config.yml");
|
||||
if (!configFile.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
EssentialsConf conf = new EssentialsConf(configFile);
|
||||
final EssentialsConf conf = new EssentialsConf(configFile);
|
||||
conf.load();
|
||||
Worth w = new Worth(ess.getDataFolder());
|
||||
final Worth worth = new Worth(ess.getDataFolder());
|
||||
boolean found = false;
|
||||
for (Material mat : Material.values())
|
||||
{
|
||||
int id = mat.getId();
|
||||
double value = conf.getDouble("worth-" + id, Double.NaN);
|
||||
final int id = mat.getId();
|
||||
final double value = conf.getDouble("worth-" + id, Double.NaN);
|
||||
if (!Double.isNaN(value))
|
||||
{
|
||||
found = true;
|
||||
w.setPrice(new ItemStack(mat, 1, (short)0, (byte)0), value);
|
||||
worth.setPrice(new ItemStack(mat, 1, (short)0, (byte)0), value);
|
||||
}
|
||||
}
|
||||
if (found)
|
||||
{
|
||||
removeLinesFromConfig(configFile, "\\s*#?\\s*worth-[0-9]+.*", "# Worth values have been moved to worth.yml");
|
||||
}
|
||||
doneFile.setProperty("moveWorthValuesToWorthYml", true);
|
||||
doneFile.save();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.i18n("upgradingFilesError"), e);
|
||||
LOGGER.log(Level.SEVERE, Util.i18n("upgradingFilesError"), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeLinesFromConfig(File file, String regex, String info) throws Exception
|
||||
{
|
||||
boolean needUpdate = false;
|
||||
BufferedReader br = new BufferedReader(new FileReader(file));
|
||||
File tempFile = File.createTempFile("essentialsupgrade", ".tmp.yml", ess.getDataFolder());
|
||||
BufferedWriter bw = new BufferedWriter(new FileWriter(tempFile));
|
||||
final BufferedReader bReader = new BufferedReader(new FileReader(file));
|
||||
final File tempFile = File.createTempFile("essentialsupgrade", ".tmp.yml", ess.getDataFolder());
|
||||
final BufferedWriter bWriter = new BufferedWriter(new FileWriter(tempFile));
|
||||
do
|
||||
{
|
||||
String line = br.readLine();
|
||||
final String line = bReader.readLine();
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
@@ -81,8 +99,8 @@ public class EssentialsUpgrade
|
||||
{
|
||||
if (!needUpdate && info != null)
|
||||
{
|
||||
bw.write(info, 0, info.length());
|
||||
bw.newLine();
|
||||
bWriter.write(info, 0, info.length());
|
||||
bWriter.newLine();
|
||||
}
|
||||
needUpdate = true;
|
||||
}
|
||||
@@ -90,22 +108,22 @@ public class EssentialsUpgrade
|
||||
{
|
||||
if (line.endsWith("\r\n"))
|
||||
{
|
||||
bw.write(line, 0, line.length() - 2);
|
||||
bWriter.write(line, 0, line.length() - 2);
|
||||
}
|
||||
else if (line.endsWith("\r") || line.endsWith("\n"))
|
||||
{
|
||||
bw.write(line, 0, line.length() - 1);
|
||||
bWriter.write(line, 0, line.length() - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
bw.write(line, 0, line.length());
|
||||
bWriter.write(line, 0, line.length());
|
||||
}
|
||||
bw.newLine();
|
||||
bWriter.newLine();
|
||||
}
|
||||
}
|
||||
while (true);
|
||||
br.close();
|
||||
bw.close();
|
||||
bReader.close();
|
||||
bWriter.close();
|
||||
if (needUpdate)
|
||||
{
|
||||
if (!file.renameTo(new File(file.getParentFile(), file.getName().concat("." + System.currentTimeMillis() + ".upgradebackup"))))
|
||||
@@ -116,19 +134,25 @@ public class EssentialsUpgrade
|
||||
{
|
||||
throw new Exception(Util.i18n("configFileRenameError"));
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
tempFile.delete();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateUsersToNewDefaultHome()
|
||||
{
|
||||
File userdataFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (doneFile.getBoolean("updateUsersToNewDefaultHome", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File userdataFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdataFolder.exists() || !userdataFolder.isDirectory())
|
||||
{
|
||||
return;
|
||||
}
|
||||
File[] userFiles = userdataFolder.listFiles();
|
||||
final File[] userFiles = userdataFolder.listFiles();
|
||||
|
||||
for (File file : userFiles)
|
||||
{
|
||||
@@ -136,15 +160,16 @@ public class EssentialsUpgrade
|
||||
{
|
||||
continue;
|
||||
}
|
||||
EssentialsConf config = new EssentialsConf(file);
|
||||
final EssentialsConf config = new EssentialsConf(file);
|
||||
try
|
||||
{
|
||||
config.load();
|
||||
if (config.hasProperty("home") && !config.hasProperty("home.default"))
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object> vals = (List<Object>)config.getProperty("home");
|
||||
if (vals == null) {
|
||||
final List<Object> vals = (List<Object>)config.getProperty("home");
|
||||
if (vals == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
World world = ess.getServer().getWorlds().get(0);
|
||||
@@ -154,7 +179,7 @@ public class EssentialsUpgrade
|
||||
}
|
||||
if (world != null)
|
||||
{
|
||||
Location loc = new Location(
|
||||
final Location loc = new Location(
|
||||
world,
|
||||
((Number)vals.get(0)).doubleValue(),
|
||||
((Number)vals.get(1)).doubleValue(),
|
||||
@@ -162,7 +187,7 @@ public class EssentialsUpgrade
|
||||
((Number)vals.get(3)).floatValue(),
|
||||
((Number)vals.get(4)).floatValue());
|
||||
|
||||
String worldName = world.getName().toLowerCase();
|
||||
final String worldName = world.getName().toLowerCase();
|
||||
if (worldName != null && !worldName.isEmpty())
|
||||
{
|
||||
config.removeProperty("home");
|
||||
@@ -175,30 +200,159 @@ public class EssentialsUpgrade
|
||||
}
|
||||
catch (RuntimeException ex)
|
||||
{
|
||||
logger.log(Level.INFO, "File: "+file.toString());
|
||||
LOGGER.log(Level.INFO, "File: " + file.toString());
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
doneFile.setProperty("updateUsersToNewDefaultHome", true);
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
private void updateUsersPowerToolsFormat()
|
||||
{
|
||||
if (doneFile.getBoolean("updateUsersPowerToolsFormat", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File userdataFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdataFolder.exists() || !userdataFolder.isDirectory())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File[] userFiles = userdataFolder.listFiles();
|
||||
|
||||
for (File file : userFiles)
|
||||
{
|
||||
if (!file.isFile() || !file.getName().endsWith(".yml"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final EssentialsConf config = new EssentialsConf(file);
|
||||
try
|
||||
{
|
||||
config.load();
|
||||
if (config.hasProperty("powertools"))
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
final Map<Integer, Object> powertools = (Map<Integer, Object>)config.getProperty("powertools");
|
||||
if (powertools == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (Map.Entry<Integer, Object> entry : powertools.entrySet())
|
||||
{
|
||||
if (entry.getValue() instanceof String)
|
||||
{
|
||||
List<String> temp = new ArrayList<String>();
|
||||
temp.add((String)entry.getValue());
|
||||
((Map<Integer, Object>)powertools).put(entry.getKey(), temp);
|
||||
}
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
catch (RuntimeException ex)
|
||||
{
|
||||
LOGGER.log(Level.INFO, "File: " + file.toString());
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
doneFile.setProperty("updateUsersPowerToolsFormat", true);
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
private void updateUsersHomesFormat()
|
||||
{
|
||||
if (doneFile.getBoolean("updateUsersHomesFormat", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File userdataFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdataFolder.exists() || !userdataFolder.isDirectory())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File[] userFiles = userdataFolder.listFiles();
|
||||
|
||||
for (File file : userFiles)
|
||||
{
|
||||
if (!file.isFile() || !file.getName().endsWith(".yml"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final EssentialsConf config = new EssentialsConf(file);
|
||||
try
|
||||
{
|
||||
|
||||
config.load();
|
||||
if (config.hasProperty("home") && config.hasProperty("home.default"))
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
final String defworld = (String)config.getProperty("home.default");
|
||||
final Location defloc = getFakeLocation(config, "home.worlds." + defworld);
|
||||
if (defloc != null)
|
||||
{
|
||||
config.setProperty("homes.home", defloc);
|
||||
}
|
||||
|
||||
List<String> worlds = config.getKeys("home.worlds");
|
||||
Location loc;
|
||||
String worldName;
|
||||
|
||||
if (worlds == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (String world : worlds)
|
||||
{
|
||||
if (defworld.equalsIgnoreCase(world))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
loc = getFakeLocation(config, "home.worlds." + world);
|
||||
if (loc == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
worldName = loc.getWorld().getName().toLowerCase();
|
||||
if (worldName != null && !worldName.isEmpty())
|
||||
{
|
||||
config.setProperty("homes." + worldName, loc);
|
||||
}
|
||||
}
|
||||
config.removeProperty("home");
|
||||
config.save();
|
||||
}
|
||||
|
||||
}
|
||||
catch (RuntimeException ex)
|
||||
{
|
||||
LOGGER.log(Level.INFO, "File: " + file.toString());
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
doneFile.setProperty("updateUsersHomesFormat", true);
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
private void moveUsersDataToUserdataFolder()
|
||||
{
|
||||
File usersFile = new File(ess.getDataFolder(), "users.yml");
|
||||
final File usersFile = new File(ess.getDataFolder(), "users.yml");
|
||||
if (!usersFile.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
EssentialsConf usersConfig = new EssentialsConf(usersFile);
|
||||
final EssentialsConf usersConfig = new EssentialsConf(usersFile);
|
||||
usersConfig.load();
|
||||
for (String username : usersConfig.getKeys(null))
|
||||
{
|
||||
User user = new User(new OfflinePlayer(username), ess);
|
||||
String nickname = usersConfig.getString(username + ".nickname");
|
||||
final User user = new User(new OfflinePlayer(username, ess), ess);
|
||||
final String nickname = usersConfig.getString(username + ".nickname");
|
||||
if (nickname != null && !nickname.isEmpty() && !nickname.equals(username))
|
||||
{
|
||||
user.setNickname(nickname);
|
||||
}
|
||||
List<String> mails = usersConfig.getStringList(username + ".mail", null);
|
||||
final List<String> mails = usersConfig.getStringList(username + ".mail", null);
|
||||
if (mails != null && !mails.isEmpty())
|
||||
{
|
||||
user.setMails(mails);
|
||||
@@ -206,8 +360,9 @@ public class EssentialsUpgrade
|
||||
if (!user.hasHome())
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object> vals = (List<Object>)usersConfig.getProperty(username + ".home");
|
||||
if (vals != null) {
|
||||
final List<Object> vals = (List<Object>)usersConfig.getProperty(username + ".home");
|
||||
if (vals != null)
|
||||
{
|
||||
World world = ess.getServer().getWorlds().get(0);
|
||||
if (vals.size() > 5)
|
||||
{
|
||||
@@ -215,12 +370,12 @@ public class EssentialsUpgrade
|
||||
}
|
||||
if (world != null)
|
||||
{
|
||||
user.setHome(new Location(world,
|
||||
((Number)vals.get(0)).doubleValue(),
|
||||
((Number)vals.get(1)).doubleValue(),
|
||||
((Number)vals.get(2)).doubleValue(),
|
||||
((Number)vals.get(3)).floatValue(),
|
||||
((Number)vals.get(4)).floatValue()), true);
|
||||
user.setHome("home", new Location(world,
|
||||
((Number)vals.get(0)).doubleValue(),
|
||||
((Number)vals.get(1)).doubleValue(),
|
||||
((Number)vals.get(2)).doubleValue(),
|
||||
((Number)vals.get(3)).floatValue(),
|
||||
((Number)vals.get(4)).floatValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -230,40 +385,56 @@ public class EssentialsUpgrade
|
||||
|
||||
private void convertWarps()
|
||||
{
|
||||
File warpsFolder = new File(ess.getDataFolder(), "warps");
|
||||
final File warpsFolder = new File(ess.getDataFolder(), "warps");
|
||||
if (!warpsFolder.exists())
|
||||
{
|
||||
warpsFolder.mkdirs();
|
||||
}
|
||||
File[] listOfFiles = warpsFolder.listFiles();
|
||||
final File[] listOfFiles = warpsFolder.listFiles();
|
||||
if (listOfFiles.length >= 1)
|
||||
{
|
||||
for (int i = 0; i < listOfFiles.length; i++)
|
||||
{
|
||||
String filename = listOfFiles[i].getName();
|
||||
final String filename = listOfFiles[i].getName();
|
||||
if (listOfFiles[i].isFile() && filename.endsWith(".dat"))
|
||||
{
|
||||
try
|
||||
{
|
||||
BufferedReader rx = new BufferedReader(new FileReader(listOfFiles[i]));
|
||||
final BufferedReader rx = new BufferedReader(new FileReader(listOfFiles[i]));
|
||||
double x, y, z;
|
||||
float yaw, pitch;
|
||||
String worldName;
|
||||
try
|
||||
{
|
||||
if (!rx.ready()) continue;
|
||||
if (!rx.ready())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
x = Double.parseDouble(rx.readLine().trim());
|
||||
if (!rx.ready()) continue;
|
||||
if (!rx.ready())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
y = Double.parseDouble(rx.readLine().trim());
|
||||
if (!rx.ready()) continue;
|
||||
if (!rx.ready())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
z = Double.parseDouble(rx.readLine().trim());
|
||||
if (!rx.ready()) continue;
|
||||
if (!rx.ready())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
yaw = Float.parseFloat(rx.readLine().trim());
|
||||
if (!rx.ready()) continue;
|
||||
if (!rx.ready())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
pitch = Float.parseFloat(rx.readLine().trim());
|
||||
worldName = rx.readLine();
|
||||
}
|
||||
finally {
|
||||
finally
|
||||
{
|
||||
rx.close();
|
||||
}
|
||||
World w = null;
|
||||
@@ -285,7 +456,7 @@ public class EssentialsUpgrade
|
||||
w = w1;
|
||||
}
|
||||
}
|
||||
Location loc = new Location(w, x, y, z, yaw, pitch);
|
||||
final Location loc = new Location(w, x, y, z, yaw, pitch);
|
||||
ess.getWarps().setWarp(filename.substring(0, filename.length() - 4), loc);
|
||||
if (!listOfFiles[i].renameTo(new File(warpsFolder, filename + ".old")))
|
||||
{
|
||||
@@ -294,52 +465,52 @@ public class EssentialsUpgrade
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
File warpFile = new File(ess.getDataFolder(), "warps.txt");
|
||||
final File warpFile = new File(ess.getDataFolder(), "warps.txt");
|
||||
if (warpFile.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
BufferedReader rx = new BufferedReader(new FileReader(warpFile));
|
||||
try
|
||||
final BufferedReader rx = new BufferedReader(new FileReader(warpFile));
|
||||
try
|
||||
{
|
||||
for (String[] parts = new String[0]; rx.ready(); parts = rx.readLine().split(":"))
|
||||
{
|
||||
if (parts.length < 6)
|
||||
for (String[] parts = new String[0]; rx.ready(); parts = rx.readLine().split(":"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String name = parts[0];
|
||||
double x = Double.parseDouble(parts[1].trim());
|
||||
double y = Double.parseDouble(parts[2].trim());
|
||||
double z = Double.parseDouble(parts[3].trim());
|
||||
float yaw = Float.parseFloat(parts[4].trim());
|
||||
float pitch = Float.parseFloat(parts[5].trim());
|
||||
if (name.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
World w = null;
|
||||
for (World world : ess.getServer().getWorlds())
|
||||
{
|
||||
if (world.getEnvironment() != World.Environment.NETHER)
|
||||
if (parts.length < 6)
|
||||
{
|
||||
w = world;
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
final String name = parts[0];
|
||||
final double x = Double.parseDouble(parts[1].trim());
|
||||
final double y = Double.parseDouble(parts[2].trim());
|
||||
final double z = Double.parseDouble(parts[3].trim());
|
||||
final float yaw = Float.parseFloat(parts[4].trim());
|
||||
final float pitch = Float.parseFloat(parts[5].trim());
|
||||
if (name.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
World w = null;
|
||||
for (World world : ess.getServer().getWorlds())
|
||||
{
|
||||
if (world.getEnvironment() != World.Environment.NETHER)
|
||||
{
|
||||
w = world;
|
||||
break;
|
||||
}
|
||||
}
|
||||
final Location loc = new Location(w, x, y, z, yaw, pitch);
|
||||
ess.getWarps().setWarp(name, loc);
|
||||
if (!warpFile.renameTo(new File(ess.getDataFolder(), "warps.txt.old")))
|
||||
{
|
||||
throw new Exception(Util.format("fileRenameError", "warps.txt"));
|
||||
}
|
||||
}
|
||||
Location loc = new Location(w, x, y, z, yaw, pitch);
|
||||
ess.getWarps().setWarp(name, loc);
|
||||
if (!warpFile.renameTo(new File(ess.getDataFolder(), "warps.txt.old")))
|
||||
{
|
||||
throw new Exception(Util.format("fileRenameError", "warps.txt"));
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -348,52 +519,60 @@ public class EssentialsUpgrade
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sanitizeAllUserFilenames()
|
||||
{
|
||||
File usersFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (doneFile.getBoolean("sanitizeAllUserFilenames", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File usersFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!usersFolder.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
File[] listOfFiles = usersFolder.listFiles();
|
||||
final File[] listOfFiles = usersFolder.listFiles();
|
||||
for (int i = 0; i < listOfFiles.length; i++)
|
||||
{
|
||||
String filename = listOfFiles[i].getName();
|
||||
final String filename = listOfFiles[i].getName();
|
||||
if (!listOfFiles[i].isFile() || !filename.endsWith(".yml"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String sanitizedFilename = Util.sanitizeFileName(filename.substring(0, filename.length() - 4)) + ".yml";
|
||||
final String sanitizedFilename = Util.sanitizeFileName(filename.substring(0, filename.length() - 4)) + ".yml";
|
||||
if (sanitizedFilename.equals(filename))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
File tmpFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename + ".tmp");
|
||||
File newFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename);
|
||||
if (!listOfFiles[i].renameTo(tmpFile)) {
|
||||
logger.log(Level.WARNING, Util.format("userdataMoveError", filename, sanitizedFilename));
|
||||
final File tmpFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename + ".tmp");
|
||||
final File newFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename);
|
||||
if (!listOfFiles[i].renameTo(tmpFile))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, Util.format("userdataMoveError", filename, sanitizedFilename));
|
||||
continue;
|
||||
}
|
||||
if (newFile.exists())
|
||||
{
|
||||
logger.log(Level.WARNING, Util.format("duplicatedUserdata", filename, sanitizedFilename));
|
||||
LOGGER.log(Level.WARNING, Util.format("duplicatedUserdata", filename, sanitizedFilename));
|
||||
continue;
|
||||
}
|
||||
if (!tmpFile.renameTo(newFile)) {
|
||||
logger.log(Level.WARNING, Util.format("userdataMoveBackError", sanitizedFilename, sanitizedFilename));
|
||||
if (!tmpFile.renameTo(newFile))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, Util.format("userdataMoveBackError", sanitizedFilename, sanitizedFilename));
|
||||
}
|
||||
}
|
||||
doneFile.setProperty("sanitizeAllUserFilenames", true);
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
private World getFakeWorld(String name)
|
||||
|
||||
private World getFakeWorld(final String name)
|
||||
{
|
||||
File bukkitDirectory = ess.getDataFolder().getParentFile().getParentFile();
|
||||
File worldDirectory = new File(bukkitDirectory, name);
|
||||
final File bukkitDirectory = ess.getDataFolder().getParentFile().getParentFile();
|
||||
final File worldDirectory = new File(bukkitDirectory, name);
|
||||
if (worldDirectory.exists() && worldDirectory.isDirectory())
|
||||
{
|
||||
return new FakeWorld(worldDirectory.getName(), World.Environment.NORMAL);
|
||||
@@ -401,6 +580,73 @@ public class EssentialsUpgrade
|
||||
return null;
|
||||
}
|
||||
|
||||
public Location getFakeLocation(EssentialsConf config, String path)
|
||||
{
|
||||
String worldName = config.getString((path != null ? path + "." : "") + "world");
|
||||
if (worldName == null || worldName.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
World world = getFakeWorld(worldName);
|
||||
if (world == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Location(world,
|
||||
config.getDouble((path != null ? path + "." : "") + "x", 0),
|
||||
config.getDouble((path != null ? path + "." : "") + "y", 0),
|
||||
config.getDouble((path != null ? path + "." : "") + "z", 0),
|
||||
(float)config.getDouble((path != null ? path + "." : "") + "yaw", 0),
|
||||
(float)config.getDouble((path != null ? path + "." : "") + "pitch", 0));
|
||||
}
|
||||
|
||||
private void deleteOldItemsCsv()
|
||||
{
|
||||
if (doneFile.getBoolean("deleteOldItemsCsv", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File file = new File(ess.getDataFolder(), "items.csv");
|
||||
if (file.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
final Set<BigInteger> oldconfigs = new HashSet<BigInteger>();
|
||||
oldconfigs.add(new BigInteger("66ec40b09ac167079f558d1099e39f10", 16)); // sep 1
|
||||
oldconfigs.add(new BigInteger("34284de1ead43b0bee2aae85e75c041d", 16)); // crlf
|
||||
oldconfigs.add(new BigInteger("c33bc9b8ee003861611bbc2f48eb6f4f", 16)); // jul 24
|
||||
oldconfigs.add(new BigInteger("6ff17925430735129fc2a02f830c1daa", 16)); // crlf
|
||||
|
||||
MessageDigest digest = ManagedFile.getDigest();
|
||||
final BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
|
||||
final DigestInputStream dis = new DigestInputStream(bis, digest);
|
||||
final byte[] buffer = new byte[1024];
|
||||
try
|
||||
{
|
||||
while (dis.read(buffer) != -1)
|
||||
{
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
dis.close();
|
||||
}
|
||||
|
||||
BigInteger hash = new BigInteger(1, digest.digest());
|
||||
if (oldconfigs.contains(hash) && !file.delete())
|
||||
{
|
||||
throw new IOException("Could not delete file " + file.toString());
|
||||
}
|
||||
doneFile.setProperty("deleteOldItemsCsv", true);
|
||||
doneFile.save();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void beforeSettings()
|
||||
{
|
||||
if (!ess.getDataFolder().exists())
|
||||
@@ -416,5 +662,8 @@ public class EssentialsUpgrade
|
||||
updateUsersToNewDefaultHome();
|
||||
moveUsersDataToUserdataFolder();
|
||||
convertWarps();
|
||||
updateUsersPowerToolsFormat();
|
||||
updateUsersHomesFormat();
|
||||
deleteOldItemsCsv();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.BlockChangeDelegate;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
@@ -8,18 +9,15 @@ import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LightningStrike;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.PoweredMinecart;
|
||||
import org.bukkit.entity.StorageMinecart;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -172,26 +170,6 @@ public class FakeWorld implements World
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public Minecart spawnMinecart(Location lctn)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public StorageMinecart spawnStorageMinecart(Location lctn)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public PoweredMinecart spawnPoweredMinecart(Location lctn)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public Boat spawnBoat(Location lctn)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public LivingEntity spawnCreature(Location lctn, CreatureType ct)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
@@ -391,5 +369,72 @@ public class FakeWorld implements World
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public UUID getUID()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public Block getHighestBlockAt(int i, int i1)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public Block getHighestBlockAt(Location lctn)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
|
||||
public Biome getBiome(int i, int i1)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public double getTemperature(int i, int i1)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public double getHumidity(int i, int i1)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unloadChunk(Chunk chunk)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHeight()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getKeepSpawnInMemory()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKeepSpawnInMemory(boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoSave()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoSave(boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,68 +1,65 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.perm.PermissionsHandler;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
public interface IEssentials
|
||||
|
||||
public interface IEssentials extends Plugin
|
||||
{
|
||||
void addReloadListener(IConf listener);
|
||||
|
||||
void reload();
|
||||
|
||||
boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath);
|
||||
|
||||
User getUser(Object base);
|
||||
|
||||
User getOfflineUser(String name);
|
||||
|
||||
World getWorld(String name);
|
||||
|
||||
int broadcastMessage(String name, String message);
|
||||
|
||||
Settings getSettings();
|
||||
|
||||
CraftScheduler getScheduler();
|
||||
|
||||
void reload();
|
||||
|
||||
boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix);
|
||||
|
||||
User getUser(Object base);
|
||||
|
||||
User getOfflineUser(String name);
|
||||
|
||||
World getWorld(String name);
|
||||
|
||||
int broadcastMessage(IUser sender, String message);
|
||||
|
||||
ISettings getSettings();
|
||||
|
||||
BukkitScheduler getScheduler();
|
||||
|
||||
String[] getMotd(CommandSender sender, String def);
|
||||
|
||||
|
||||
String[] getLines(CommandSender sender, String node, String def);
|
||||
|
||||
|
||||
Jail getJail();
|
||||
|
||||
|
||||
Warps getWarps();
|
||||
|
||||
|
||||
Worth getWorth();
|
||||
|
||||
|
||||
Backup getBackup();
|
||||
|
||||
|
||||
Spawn getSpawn();
|
||||
|
||||
void loadBanList();
|
||||
|
||||
public boolean isRegisterFallbackEnabled();
|
||||
|
||||
public Methods getPaymentMethod();
|
||||
|
||||
Server getServer();
|
||||
|
||||
File getDataFolder();
|
||||
|
||||
PluginDescriptionFile getDescription();
|
||||
|
||||
|
||||
Methods getPaymentMethod();
|
||||
|
||||
int scheduleAsyncDelayedTask(Runnable run);
|
||||
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run);
|
||||
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run, long delay);
|
||||
|
||||
int scheduleSyncRepeatingTask(final Runnable run, long delay, long period);
|
||||
|
||||
List<String> getBans();
|
||||
TNTExplodeListener getTNTListener();
|
||||
|
||||
List<String> getBannedIps();
|
||||
PermissionsHandler getPermissionsHandler();
|
||||
|
||||
void showError(final CommandSender sender, final Throwable exception, final String commandLabel);
|
||||
|
||||
ItemDb getItemDb();
|
||||
|
||||
UserMap getUserMap();
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
|
||||
public interface ISettings extends IConf
|
||||
{
|
||||
|
||||
boolean areSignsDisabled();
|
||||
|
||||
String format(String format, IUser user);
|
||||
|
||||
String getAnnounceNewPlayerFormat(IUser user);
|
||||
|
||||
boolean getAnnounceNewPlayers();
|
||||
|
||||
String getBackupCommand();
|
||||
|
||||
long getBackupInterval();
|
||||
|
||||
boolean getBedSetsHome();
|
||||
|
||||
String getChatFormat(String group);
|
||||
|
||||
int getChatRadius();
|
||||
|
||||
double getCommandCost(IEssentialsCommand cmd);
|
||||
|
||||
double getCommandCost(String label);
|
||||
|
||||
String getCurrencySymbol();
|
||||
|
||||
int getDefaultStackSize();
|
||||
|
||||
boolean getGenerateExitPortals();
|
||||
|
||||
double getHealCooldown();
|
||||
|
||||
Object getKit(String name);
|
||||
|
||||
Map<String, Object> getKits();
|
||||
|
||||
String getLocale();
|
||||
|
||||
String getNetherName();
|
||||
|
||||
boolean getNetherPortalsEnabled();
|
||||
|
||||
double getNetherRatio();
|
||||
|
||||
String getNewbieSpawn();
|
||||
|
||||
String getNicknamePrefix();
|
||||
|
||||
ChatColor getOperatorColor() throws Exception;
|
||||
|
||||
boolean getPerWarpPermission();
|
||||
|
||||
boolean getProtectBoolean(final String configName, boolean def);
|
||||
|
||||
int getProtectCreeperMaxHeight();
|
||||
|
||||
List<Integer> getProtectList(final String configName);
|
||||
|
||||
boolean getProtectPreventSpawn(final String creatureName);
|
||||
|
||||
String getProtectString(final String configName);
|
||||
|
||||
boolean getReclaimSetting();
|
||||
|
||||
boolean getRespawnAtHome();
|
||||
|
||||
int getMultipleHomes();
|
||||
|
||||
boolean getSortListByGroups();
|
||||
|
||||
int getSpawnMobLimit();
|
||||
|
||||
int getStartingBalance();
|
||||
|
||||
double getTeleportCooldown();
|
||||
|
||||
double getTeleportDelay();
|
||||
|
||||
boolean hidePermissionlessHelp();
|
||||
|
||||
boolean isCommandDisabled(final IEssentialsCommand cmd);
|
||||
|
||||
boolean isCommandDisabled(String label);
|
||||
|
||||
boolean isCommandOverridden(String name);
|
||||
|
||||
boolean isCommandRestricted(IEssentialsCommand cmd);
|
||||
|
||||
boolean isCommandRestricted(String label);
|
||||
|
||||
boolean isDebug();
|
||||
|
||||
boolean isEcoDisabled();
|
||||
|
||||
boolean isNetherEnabled();
|
||||
|
||||
boolean isTradeInStacks(int id);
|
||||
|
||||
List<Integer> itemSpawnBlacklist();
|
||||
|
||||
boolean permissionBasedItemSpawn();
|
||||
|
||||
boolean showNonEssCommandsInHelp();
|
||||
|
||||
boolean spawnIfNoHome();
|
||||
|
||||
boolean use1to1RatioInNether();
|
||||
|
||||
boolean warnOnBuildDisallow();
|
||||
|
||||
boolean warnOnSmite();
|
||||
|
||||
double getMaxMoney();
|
||||
|
||||
boolean isEcoLogEnabled();
|
||||
|
||||
boolean removeGodOnDisconnect();
|
||||
|
||||
boolean changeDisplayName();
|
||||
|
||||
boolean isPlayerCommand(String string);
|
||||
|
||||
boolean useBukkitPermissions();
|
||||
|
||||
boolean addPrefixSuffix();
|
||||
|
||||
boolean isUpdateEnabled();
|
||||
|
||||
long getAutoAfk();
|
||||
|
||||
long getAutoAfkKick();
|
||||
|
||||
boolean getFreezeAfkPlayers();
|
||||
}
|
||||
@@ -23,6 +23,8 @@ public interface IUser
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
|
||||
|
||||
void setLastTeleportTimestamp(long time);
|
||||
|
||||
Location getLastLocation();
|
||||
@@ -33,6 +35,8 @@ public interface IUser
|
||||
|
||||
void takeMoney(double value);
|
||||
|
||||
void giveMoney(double value);
|
||||
|
||||
PlayerInventory getInventory();
|
||||
|
||||
void updateInventory();
|
||||
@@ -41,11 +45,15 @@ public interface IUser
|
||||
|
||||
void setLastLocation();
|
||||
|
||||
Location getHome(Location location);
|
||||
Location getHome(String name) throws Exception;
|
||||
|
||||
Location getHome(Location loc) throws Exception;
|
||||
|
||||
String getName();
|
||||
|
||||
InetSocketAddress getAddress();
|
||||
|
||||
String getDisplayName();
|
||||
|
||||
boolean isHidden();
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
@@ -17,18 +18,18 @@ public final class InventoryWorkaround
|
||||
private InventoryWorkaround()
|
||||
{
|
||||
}
|
||||
|
||||
public static int first(Inventory ci, ItemStack item, boolean forceDurability, boolean forceAmount)
|
||||
|
||||
public static int first(final Inventory inventory, final ItemStack item, final boolean forceDurability, final boolean forceAmount)
|
||||
{
|
||||
return next(ci, item, 0, forceDurability, forceAmount);
|
||||
return next(inventory, item, 0, forceDurability, forceAmount);
|
||||
}
|
||||
|
||||
public static int next(Inventory ci, ItemStack item, int start, boolean forceDurability, boolean forceAmount)
|
||||
public static int next(final Inventory cinventory, final ItemStack item, final int start, final boolean forceDurability, final boolean forceAmount)
|
||||
{
|
||||
ItemStack[] inventory = ci.getContents();
|
||||
final ItemStack[] inventory = cinventory.getContents();
|
||||
for (int i = start; i < inventory.length; i++)
|
||||
{
|
||||
ItemStack cItem = inventory[i];
|
||||
final ItemStack cItem = inventory[i];
|
||||
if (cItem == null)
|
||||
{
|
||||
continue;
|
||||
@@ -41,15 +42,138 @@ public final class InventoryWorkaround
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static HashMap<Integer, ItemStack> removeItem(Inventory ci, boolean forceDurability, ItemStack... items)
|
||||
public static int firstPartial(final Inventory cinventory, final ItemStack item, final boolean forceDurability)
|
||||
{
|
||||
HashMap<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
||||
if (item == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
final ItemStack[] inventory = cinventory.getContents();
|
||||
for (int i = 0; i < inventory.length; i++)
|
||||
{
|
||||
final ItemStack cItem = inventory[i];
|
||||
if (cItem == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (item.getTypeId() == cItem.getTypeId() && cItem.getAmount() < cItem.getType().getMaxStackSize() && (!forceDurability || cItem.getDurability() == item.getDurability()))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static Map<Integer, ItemStack> addItem(final Inventory cinventory, final boolean forceDurability, final ItemStack... items)
|
||||
{
|
||||
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
||||
|
||||
/* TODO: some optimization
|
||||
* - Create a 'firstPartial' with a 'fromIndex'
|
||||
* - Record the lastPartial per Material
|
||||
* - Cache firstEmpty result
|
||||
*/
|
||||
|
||||
// combine items
|
||||
|
||||
ItemStack[] combined = new ItemStack[items.length];
|
||||
for (int i = 0; i < items.length; i++)
|
||||
{
|
||||
if (items[i] == null || items[i].getAmount() < 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (int j = 0; j < combined.length; j++)
|
||||
{
|
||||
if (combined[j] == null)
|
||||
{
|
||||
combined[j] = new ItemStack(items[i].getType(), items[i].getAmount(), items[i].getDurability());
|
||||
break;
|
||||
}
|
||||
if (combined[j].getTypeId() == items[i].getTypeId() && (!forceDurability || combined[j].getDurability() == items[i].getDurability()))
|
||||
{
|
||||
combined[j].setAmount(combined[j].getAmount() + items[i].getAmount());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < combined.length; i++)
|
||||
{
|
||||
final ItemStack item = combined[i];
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
// Do we already have a stack of it?
|
||||
final int firstPartial = firstPartial(cinventory, item, forceDurability);
|
||||
|
||||
// Drat! no partial stack
|
||||
if (firstPartial == -1)
|
||||
{
|
||||
// Find a free spot!
|
||||
final int firstFree = cinventory.firstEmpty();
|
||||
|
||||
if (firstFree == -1)
|
||||
{
|
||||
// No space at all!
|
||||
leftover.put(i, item);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// More than a single stack!
|
||||
if (item.getAmount() > item.getType().getMaxStackSize())
|
||||
{
|
||||
cinventory.setItem(firstFree, new ItemStack(item.getTypeId(), item.getType().getMaxStackSize(), item.getDurability()));
|
||||
item.setAmount(item.getAmount() - item.getType().getMaxStackSize());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Just store it
|
||||
cinventory.setItem(firstFree, item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// So, apparently it might only partially fit, well lets do just that
|
||||
final ItemStack partialItem = cinventory.getItem(firstPartial);
|
||||
|
||||
final int amount = item.getAmount();
|
||||
final int partialAmount = partialItem.getAmount();
|
||||
final int maxAmount = partialItem.getType().getMaxStackSize();
|
||||
|
||||
// Check if it fully fits
|
||||
if (amount + partialAmount <= maxAmount)
|
||||
{
|
||||
partialItem.setAmount(amount + partialAmount);
|
||||
break;
|
||||
}
|
||||
|
||||
// It fits partially
|
||||
partialItem.setAmount(maxAmount);
|
||||
item.setAmount(amount + partialAmount - maxAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
return leftover;
|
||||
}
|
||||
|
||||
public static Map<Integer, ItemStack> removeItem(final Inventory cinventory, final boolean forceDurability, final ItemStack... items)
|
||||
{
|
||||
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
||||
|
||||
// TODO: optimization
|
||||
|
||||
for (int i = 0; i < items.length; i++)
|
||||
{
|
||||
ItemStack item = items[i];
|
||||
final ItemStack item = items[i];
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
@@ -66,7 +190,7 @@ public final class InventoryWorkaround
|
||||
}
|
||||
|
||||
// get first Item, ignore the amount
|
||||
int first = first(ci, item, forceDurability, false);
|
||||
final int first = first(cinventory, item, forceDurability, false);
|
||||
|
||||
// Drat! we don't have this type in the inventory
|
||||
if (first == -1)
|
||||
@@ -77,20 +201,20 @@ public final class InventoryWorkaround
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack itemStack = ci.getItem(first);
|
||||
int amount = itemStack.getAmount();
|
||||
final ItemStack itemStack = cinventory.getItem(first);
|
||||
final int amount = itemStack.getAmount();
|
||||
|
||||
if (amount <= toDelete)
|
||||
{
|
||||
toDelete -= amount;
|
||||
// clear the slot, all used up
|
||||
ci.clear(first);
|
||||
cinventory.clear(first);
|
||||
}
|
||||
else
|
||||
{
|
||||
// split the stack and store
|
||||
itemStack.setAmount(amount - toDelete);
|
||||
ci.setItem(first, itemStack);
|
||||
cinventory.setItem(first, itemStack);
|
||||
toDelete = 0;
|
||||
}
|
||||
}
|
||||
@@ -99,9 +223,9 @@ public final class InventoryWorkaround
|
||||
return leftover;
|
||||
}
|
||||
|
||||
public static boolean containsItem(Inventory ci, boolean forceDurability, ItemStack... items)
|
||||
public static boolean containsItem(final Inventory cinventory, final boolean forceDurability, final ItemStack... items)
|
||||
{
|
||||
HashMap<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
||||
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
||||
|
||||
// TODO: optimization
|
||||
|
||||
@@ -131,7 +255,7 @@ public final class InventoryWorkaround
|
||||
|
||||
for (int i = 0; i < combined.length; i++)
|
||||
{
|
||||
ItemStack item = combined[i];
|
||||
final ItemStack item = combined[i];
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
@@ -147,7 +271,7 @@ public final class InventoryWorkaround
|
||||
break;
|
||||
}
|
||||
|
||||
int slot = next(ci, item, position, forceDurability, false);
|
||||
final int slot = next(cinventory, item, position, forceDurability, false);
|
||||
|
||||
// Drat! we don't have this type in the inventory
|
||||
if (slot == -1)
|
||||
@@ -157,8 +281,8 @@ public final class InventoryWorkaround
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack itemStack = ci.getItem(slot);
|
||||
int amount = itemStack.getAmount();
|
||||
final ItemStack itemStack = cinventory.getItem(slot);
|
||||
final int amount = itemStack.getAmount();
|
||||
|
||||
if (amount <= mustHave)
|
||||
{
|
||||
@@ -175,17 +299,19 @@ public final class InventoryWorkaround
|
||||
return leftover.isEmpty();
|
||||
}
|
||||
|
||||
public static Item[] dropItem(Location loc, ItemStack itm)
|
||||
public static Item[] dropItem(final Location loc, final ItemStack itm)
|
||||
{
|
||||
int maxStackSize = itm.getType().getMaxStackSize();
|
||||
int stacks = itm.getAmount() / maxStackSize;
|
||||
int leftover = itm.getAmount() % maxStackSize;
|
||||
final int maxStackSize = itm.getType().getMaxStackSize();
|
||||
final int stacks = itm.getAmount() / maxStackSize;
|
||||
final int leftover = itm.getAmount() % maxStackSize;
|
||||
Item[] itemStacks = new Item[stacks + (leftover > 0 ? 1 : 0)];
|
||||
for (int i = 0; i < stacks; i++) {
|
||||
itemStacks[i] = loc.getWorld().dropItem(loc, new ItemStack(itm.getType(), maxStackSize, itm.getDurability()));
|
||||
for (int i = 0; i < stacks; i++)
|
||||
{
|
||||
itemStacks[i] = loc.getWorld().dropItem(loc, new ItemStack(itm.getType(), maxStackSize, itm.getDurability()));
|
||||
}
|
||||
if (leftover > 0) {
|
||||
itemStacks[stacks] = loc.getWorld().dropItem(loc, new ItemStack(itm.getType(), leftover, itm.getDurability()));
|
||||
if (leftover > 0)
|
||||
{
|
||||
itemStacks[stacks] = loc.getWorld().dropItem(loc, new ItemStack(itm.getType(), leftover, itm.getDurability()));
|
||||
}
|
||||
return itemStacks;
|
||||
}
|
||||
|
||||
@@ -1,114 +1,66 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public final class ItemDb
|
||||
public class ItemDb implements IConf
|
||||
{
|
||||
private ItemDb()
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public ItemDb(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
file = new ManagedFile("items.csv", ess);
|
||||
}
|
||||
|
||||
private final static Logger logger = Logger.getLogger("Minecraft");
|
||||
private static Map<String, Integer> items = new HashMap<String, Integer>();
|
||||
private static Map<String, Short> durabilities = new HashMap<String, Short>();
|
||||
private final transient Map<String, Integer> items = new HashMap<String, Integer>();
|
||||
private final transient Map<String, Short> durabilities = new HashMap<String, Short>();
|
||||
private final transient ManagedFile file;
|
||||
|
||||
public static void load(File folder, String fname) throws IOException
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
folder.mkdirs();
|
||||
File file = new File(folder, fname);
|
||||
|
||||
if (!file.exists())
|
||||
{
|
||||
file.createNewFile();
|
||||
InputStream res = ItemDb.class.getResourceAsStream("/items.csv");
|
||||
FileWriter tx = null;
|
||||
try
|
||||
{
|
||||
tx = new FileWriter(file);
|
||||
for (int i = 0; (i = res.read()) > 0;)
|
||||
{
|
||||
tx.write(i);
|
||||
}
|
||||
tx.flush();
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
res.close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
try
|
||||
{
|
||||
if (tx != null)
|
||||
{
|
||||
tx.close();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
final List<String> lines = file.getLines();
|
||||
|
||||
if (lines.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BufferedReader rx = new BufferedReader(new FileReader(file));
|
||||
try
|
||||
{
|
||||
items.clear();
|
||||
durabilities.clear();
|
||||
items.clear();
|
||||
|
||||
for (int i = 0; rx.ready(); i++)
|
||||
for (String line : lines)
|
||||
{
|
||||
line = line.trim().toLowerCase();
|
||||
if (line.length() > 0 && line.charAt(0) == '#')
|
||||
{
|
||||
try
|
||||
{
|
||||
String line = rx.readLine().trim().toLowerCase();
|
||||
if (line.startsWith("#"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String[] parts = line.split("[^a-z0-9]");
|
||||
if (parts.length < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int numeric = Integer.parseInt(parts[1]);
|
||||
|
||||
durabilities.put(parts[0].toLowerCase(), parts.length > 2 && !parts[2].equals("0") ? Short.parseShort(parts[2]) : 0);
|
||||
items.put(parts[0].toLowerCase(), numeric);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.warning(Util.format("parseError", fname, i));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
rx.close();
|
||||
|
||||
final String[] parts = line.split("[^a-z0-9]");
|
||||
if (parts.length < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final int numeric = Integer.parseInt(parts[1]);
|
||||
|
||||
durabilities.put(parts[0].toLowerCase(), parts.length > 2 && !parts[2].equals("0") ? Short.parseShort(parts[2]) : 0);
|
||||
items.put(parts[0].toLowerCase(), numeric);
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack get(String id, int quantity) throws Exception
|
||||
public ItemStack get(final String id, final int quantity) throws Exception
|
||||
{
|
||||
ItemStack retval = get(id.toLowerCase());
|
||||
final ItemStack retval = get(id.toLowerCase());
|
||||
retval.setAmount(quantity);
|
||||
return retval;
|
||||
}
|
||||
|
||||
public static ItemStack get(String id) throws Exception
|
||||
public ItemStack get(final String id) throws Exception
|
||||
{
|
||||
int itemid = 0;
|
||||
String itemname = null;
|
||||
@@ -127,11 +79,11 @@ public final class ItemDb
|
||||
itemname = id.split("[:+',;.]")[0].toLowerCase();
|
||||
metaData = Short.parseShort(id.split("[:+',;.]")[1]);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
itemname = id.toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
if (itemname != null)
|
||||
{
|
||||
if (items.containsKey(itemname))
|
||||
@@ -142,19 +94,24 @@ public final class ItemDb
|
||||
metaData = durabilities.get(itemname);
|
||||
}
|
||||
}
|
||||
else if (Material.getMaterial(itemname) != null)
|
||||
{
|
||||
itemid = Material.getMaterial(itemname).getId();
|
||||
metaData = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(Util.format("unknownItemName", id));
|
||||
}
|
||||
}
|
||||
|
||||
Material mat = Material.getMaterial(itemid);
|
||||
final Material mat = Material.getMaterial(itemid);
|
||||
if (mat == null)
|
||||
{
|
||||
throw new Exception(Util.format("unknownItemId", itemid));
|
||||
}
|
||||
ItemStack retval = new ItemStack(mat);
|
||||
retval.setAmount(Essentials.getStatic().getSettings().getDefaultStackSize());
|
||||
final ItemStack retval = new ItemStack(mat);
|
||||
retval.setAmount(ess.getSettings().getDefaultStackSize());
|
||||
retval.setDurability(metaData);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Jail extends BlockListener implements IConf
|
||||
|
||||
public Location getJail(String jailName) throws Exception
|
||||
{
|
||||
if (config.getProperty(jailName.toLowerCase()) == null)
|
||||
if (jailName == null || config.getProperty(jailName.toLowerCase()) == null)
|
||||
{
|
||||
throw new Exception(Util.i18n("jailNotExist"));
|
||||
}
|
||||
@@ -42,7 +42,10 @@ public class Jail extends BlockListener implements IConf
|
||||
|
||||
public void sendToJail(User user, String jail) throws Exception
|
||||
{
|
||||
user.getTeleport().now(getJail(jail));
|
||||
if (!(user.getBase() instanceof OfflinePlayer))
|
||||
{
|
||||
user.getTeleport().now(getJail(jail));
|
||||
}
|
||||
user.setJail(jail);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
|
||||
public class JailPlayerListener extends PlayerListener
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final IEssentials ess;
|
||||
|
||||
public JailPlayerListener(IEssentials parent)
|
||||
@@ -16,10 +22,63 @@ public class JailPlayerListener extends PlayerListener
|
||||
@Override
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed() && user.getJail() != null && !user.getJail().isEmpty())
|
||||
{
|
||||
try
|
||||
{
|
||||
event.setRespawnLocation(ess.getJail().getJail(user.getJail()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
event.setTo(ess.getJail().getJail(user.getJail()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, Util.i18n("returnPlayerToJailError"), ex);
|
||||
}
|
||||
user.sendMessage(Util.i18n("jailMessage"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
User u = ess.getUser(event.getPlayer());
|
||||
if (u.isJailed())
|
||||
{
|
||||
try
|
||||
{
|
||||
ess.getJail().sendToJail(u, u.getJail());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, Util.i18n("returnPlayerToJailError"), ex);
|
||||
}
|
||||
u.sendMessage(Util.i18n("jailMessage"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.math.BigInteger;
|
||||
import java.security.DigestInputStream;
|
||||
import java.security.DigestOutputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
|
||||
public class ManagedFile
|
||||
{
|
||||
private final static int BUFFERSIZE = 1024 * 8;
|
||||
private final transient File file;
|
||||
|
||||
public ManagedFile(final String filename, final IEssentials ess)
|
||||
{
|
||||
file = new File(ess.getDataFolder(), filename);
|
||||
|
||||
if (file.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (checkForVersion(file, ess.getDescription().getVersion()) && !file.delete())
|
||||
{
|
||||
throw new IOException("Could not delete file " + file.toString());
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (!file.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
copyResourceAscii("/" + filename, file);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Bukkit.getLogger().log(Level.SEVERE, Util.i18n("itemsCsvNotLoaded"), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyResourceAscii(final String resourceName, final File file) throws IOException
|
||||
{
|
||||
final InputStreamReader reader = new InputStreamReader(ManagedFile.class.getResourceAsStream(resourceName));
|
||||
try
|
||||
{
|
||||
final MessageDigest digest = getDigest();
|
||||
final DigestOutputStream digestStream = new DigestOutputStream(new FileOutputStream(file), digest);
|
||||
try
|
||||
{
|
||||
final OutputStreamWriter writer = new OutputStreamWriter(digestStream);
|
||||
try
|
||||
{
|
||||
final char[] buffer = new char[BUFFERSIZE];
|
||||
do
|
||||
{
|
||||
final int length = reader.read(buffer);
|
||||
if (length >= 0)
|
||||
{
|
||||
writer.write(buffer, 0, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (true);
|
||||
writer.write("\n");
|
||||
writer.flush();
|
||||
final BigInteger hashInt = new BigInteger(1, digest.digest());
|
||||
digestStream.on(false);
|
||||
digestStream.write('#');
|
||||
digestStream.write(hashInt.toString(16).getBytes());
|
||||
}
|
||||
finally
|
||||
{
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
digestStream.close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean checkForVersion(final File file, final String version) throws IOException
|
||||
{
|
||||
if (file.length() < 33)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
|
||||
try
|
||||
{
|
||||
final byte[] buffer = new byte[(int)file.length()];
|
||||
int position = 0;
|
||||
do
|
||||
{
|
||||
final int length = bis.read(buffer, position, Math.min((int)file.length() - position, BUFFERSIZE));
|
||||
if (length < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
position += length;
|
||||
}
|
||||
while (position < file.length());
|
||||
final ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
|
||||
if (bais.skip(file.length() - 33) != file.length() - 33)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(bais));
|
||||
try
|
||||
{
|
||||
String hash = reader.readLine();
|
||||
if (hash.matches("#[a-f0-9]{32}"))
|
||||
{
|
||||
hash = hash.substring(1);
|
||||
bais.reset();
|
||||
final String versionline = reader.readLine();
|
||||
if (versionline.matches("#version: .+"))
|
||||
{
|
||||
final String versioncheck = versionline.substring(10);
|
||||
if (!versioncheck.equalsIgnoreCase(version))
|
||||
{
|
||||
bais.reset();
|
||||
final MessageDigest digest = getDigest();
|
||||
final DigestInputStream digestStream = new DigestInputStream(bais, digest);
|
||||
try
|
||||
{
|
||||
final byte[] bytes = new byte[(int)file.length() - 33];
|
||||
digestStream.read(bytes);
|
||||
final BigInteger correct = new BigInteger(hash, 16);
|
||||
final BigInteger test = new BigInteger(1, digest.digest());
|
||||
if (correct.equals(test))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Bukkit.getLogger().warning("File " + file.toString() + " has been modified by user and file version differs, please update the file manually.");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
digestStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
bis.close();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static MessageDigest getDigest() throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
return MessageDigest.getInstance("MD5");
|
||||
}
|
||||
catch (NoSuchAlgorithmException ex)
|
||||
{
|
||||
throw new IOException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getLines()
|
||||
{
|
||||
try
|
||||
{
|
||||
final BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
try
|
||||
{
|
||||
final List<String> lines = new ArrayList<String>();
|
||||
do
|
||||
{
|
||||
final String line = reader.readLine();
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
lines.add(line);
|
||||
}
|
||||
}
|
||||
while (true);
|
||||
return lines;
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,75 +1,58 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.Entity;
|
||||
import net.minecraft.server.WorldServer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public enum Mob
|
||||
{
|
||||
CHICKEN("Chicken", Enemies.FRIENDLY),
|
||||
COW("Cow", Enemies.FRIENDLY),
|
||||
CREEPER("Creeper", Enemies.ENEMY),
|
||||
GHAST("Ghast", Enemies.ENEMY),
|
||||
GIANT("Giant", "GiantZombie", Enemies.ENEMY),
|
||||
PIG("Pig", Enemies.FRIENDLY),
|
||||
PIGZOMB("PigZombie", Enemies.NEUTRAL),
|
||||
SHEEP("Sheep", Enemies.FRIENDLY, ""),
|
||||
SKELETON("Skeleton", Enemies.ENEMY),
|
||||
SLIME("Slime", Enemies.ENEMY),
|
||||
SPIDER("Spider", Enemies.ENEMY),
|
||||
SQUID("Squid", Enemies.FRIENDLY),
|
||||
ZOMBIE("Zombie", Enemies.ENEMY),
|
||||
MONSTER("Monster", Enemies.ENEMY),
|
||||
WOLF("Wolf", Enemies.NEUTRAL);
|
||||
CHICKEN("Chicken", Enemies.FRIENDLY, CreatureType.CHICKEN),
|
||||
COW("Cow", Enemies.FRIENDLY, CreatureType.COW),
|
||||
CREEPER("Creeper", Enemies.ENEMY, CreatureType.CREEPER),
|
||||
GHAST("Ghast", Enemies.ENEMY, CreatureType.GHAST),
|
||||
GIANT("Giant", Enemies.ENEMY, CreatureType.GIANT),
|
||||
PIG("Pig", Enemies.FRIENDLY, CreatureType.PIG),
|
||||
PIGZOMB("PigZombie", Enemies.NEUTRAL, CreatureType.PIG_ZOMBIE),
|
||||
SHEEP("Sheep", Enemies.FRIENDLY, "", CreatureType.SHEEP),
|
||||
SKELETON("Skeleton", Enemies.ENEMY, CreatureType.SKELETON),
|
||||
SLIME("Slime", Enemies.ENEMY, CreatureType.SLIME),
|
||||
SPIDER("Spider", Enemies.ENEMY, CreatureType.SPIDER),
|
||||
SQUID("Squid", Enemies.FRIENDLY, CreatureType.SQUID),
|
||||
ZOMBIE("Zombie", Enemies.ENEMY, CreatureType.ZOMBIE),
|
||||
MONSTER("Monster", Enemies.ENEMY, CreatureType.MONSTER),
|
||||
WOLF("Wolf", Enemies.NEUTRAL, CreatureType.WOLF),
|
||||
CAVESPIDER("CaveSpider", Enemies.ENEMY, CreatureType.CAVE_SPIDER),
|
||||
ENDERMAN("Enderman", Enemies.ENEMY, CreatureType.ENDERMAN),
|
||||
SILVERFISH("Silverfish", Enemies.ENEMY, CreatureType.SILVERFISH);
|
||||
|
||||
public static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
private Mob(String n, Enemies en, String s)
|
||||
private Mob(String n, Enemies en, String s, CreatureType type)
|
||||
{
|
||||
this.s = s;
|
||||
this.suffix = s;
|
||||
this.name = n;
|
||||
this.craftClass = n;
|
||||
this.entityClass = n;
|
||||
this.type = en;
|
||||
this.bukkitType = type;
|
||||
}
|
||||
|
||||
private Mob(String n, Enemies en)
|
||||
private Mob(String n, Enemies en, CreatureType type)
|
||||
{
|
||||
this.name = n;
|
||||
this.craftClass = n;
|
||||
this.entityClass = n;
|
||||
this.type = en;
|
||||
this.bukkitType = type;
|
||||
}
|
||||
|
||||
private Mob(String n, String ec, Enemies en)
|
||||
{
|
||||
this.name = n;
|
||||
this.craftClass = n;
|
||||
this.entityClass = ec;
|
||||
this.type = en;
|
||||
}
|
||||
|
||||
private Mob(String n, String ec, String cc, Enemies en)
|
||||
{
|
||||
this.name = n;
|
||||
this.entityClass = ec;
|
||||
this.craftClass = cc;
|
||||
this.type = en;
|
||||
}
|
||||
public String s = "s";
|
||||
public String name;
|
||||
public Enemies type;
|
||||
private String entityClass;
|
||||
private String craftClass;
|
||||
public String suffix = "s";
|
||||
final public String name;
|
||||
final public Enemies type;
|
||||
final private CreatureType bukkitType;
|
||||
private static final Map<String, Mob> hashMap = new HashMap<String, Mob>();
|
||||
|
||||
static
|
||||
@@ -80,24 +63,16 @@ public enum Mob
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings(
|
||||
public LivingEntity spawn(final Player player, final Server server, final Location loc) throws MobException
|
||||
{
|
||||
"unchecked", "CallToThreadDumpStack"
|
||||
})
|
||||
public CraftEntity spawn(Player player, Server server) throws MobException
|
||||
{
|
||||
try
|
||||
|
||||
final LivingEntity entity = player.getWorld().spawnCreature(loc, this.bukkitType);
|
||||
if (entity == null)
|
||||
{
|
||||
WorldServer world = ((org.bukkit.craftbukkit.CraftWorld)player.getWorld()).getHandle();
|
||||
Constructor<CraftEntity> craft = (Constructor<CraftEntity>)ClassLoader.getSystemClassLoader().loadClass("org.bukkit.craftbukkit.entity.Craft" + craftClass).getConstructors()[0];
|
||||
Constructor<Entity> entity = (Constructor<Entity>)ClassLoader.getSystemClassLoader().loadClass("net.minecraft.server.Entity" + entityClass).getConstructors()[0];
|
||||
return craft.newInstance((CraftServer)server, entity.newInstance(world));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.WARNING, Util.i18n("unableToSpawnMob"), ex);
|
||||
throw new MobException(ex);
|
||||
logger.log(Level.WARNING, Util.i18n("unableToSpawnMob"));
|
||||
throw new MobException();
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,22 +82,20 @@ public enum Mob
|
||||
NEUTRAL("neutral"),
|
||||
ENEMY("enemy");
|
||||
|
||||
private Enemies(String t)
|
||||
private Enemies(final String t)
|
||||
{
|
||||
this.type = t;
|
||||
}
|
||||
protected String type;
|
||||
final protected String type;
|
||||
}
|
||||
|
||||
public CreatureType getType () {
|
||||
return bukkitType;
|
||||
}
|
||||
|
||||
public static class MobException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private MobException(Exception ex)
|
||||
{
|
||||
super(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static Mob fromName(String n)
|
||||
|
||||
@@ -3,9 +3,11 @@ package com.earth2me.essentials;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Achievement;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Instrument;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -23,29 +25,39 @@ import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.map.MapView;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
|
||||
public class OfflinePlayer implements Player
|
||||
{
|
||||
private final String name;
|
||||
final transient IEssentials ess;
|
||||
private Location location = new Location(null, 0, 0, 0, 0, 0);
|
||||
private World world = null;
|
||||
private World world;
|
||||
private UUID uniqueId = UUID.randomUUID();
|
||||
private org.bukkit.OfflinePlayer base;
|
||||
|
||||
public OfflinePlayer(String name)
|
||||
public OfflinePlayer(String name, IEssentials ess)
|
||||
{
|
||||
this.name = name;
|
||||
this.ess = ess;
|
||||
this.world = ess.getServer().getWorlds().get(0);
|
||||
this.base = ess.getServer().getOfflinePlayer(name);
|
||||
}
|
||||
|
||||
public boolean isOnline()
|
||||
{
|
||||
return false;
|
||||
return base.isOnline();
|
||||
}
|
||||
|
||||
public boolean isOp()
|
||||
{
|
||||
return false;
|
||||
return base.isOp();
|
||||
}
|
||||
|
||||
public void sendMessage(String string)
|
||||
@@ -141,7 +153,7 @@ public class OfflinePlayer implements Player
|
||||
{
|
||||
return world;
|
||||
}
|
||||
|
||||
|
||||
public void setLocation(Location loc)
|
||||
{
|
||||
location = loc;
|
||||
@@ -258,7 +270,7 @@ public class OfflinePlayer implements Player
|
||||
|
||||
public Server getServer()
|
||||
{
|
||||
return Essentials.getStatic() == null ? null : Essentials.getStatic().getServer();
|
||||
return ess == null ? null : ess.getServer();
|
||||
}
|
||||
|
||||
public Vector getMomentum()
|
||||
@@ -296,7 +308,8 @@ public class OfflinePlayer implements Player
|
||||
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
|
||||
}
|
||||
|
||||
public void sendRawMessage(String string) {
|
||||
public void sendRawMessage(String string)
|
||||
{
|
||||
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
|
||||
}
|
||||
|
||||
@@ -509,4 +522,196 @@ public class OfflinePlayer implements Player
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public boolean isPermissionSet(String string)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isPermissionSet(Permission prmsn)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasPermission(String string)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasPermission(Permission prmsn)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public PermissionAttachment addAttachment(Plugin plugin)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln, int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public PermissionAttachment addAttachment(Plugin plugin, int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public void removeAttachment(PermissionAttachment pa)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public void recalculatePermissions()
|
||||
{
|
||||
}
|
||||
|
||||
public Set<PermissionAttachmentInfo> getEffectivePermissions()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public void setOp(boolean bln)
|
||||
{
|
||||
base.setOp(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMap(MapView mv)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBanned()
|
||||
{
|
||||
return base.isBanned();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBanned(boolean bln)
|
||||
{
|
||||
base.setBanned(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWhitelisted()
|
||||
{
|
||||
return base.isWhitelisted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWhitelisted(boolean bln)
|
||||
{
|
||||
base.setWhitelisted(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameMode getGameMode()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGameMode(GameMode gm)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getExperience()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExperience(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLevel(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalExperience()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTotalExperience(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExhaustion()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExhaustion(float f)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSaturation()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSaturation(float f)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFoodLevel()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFoodLevel(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getBedSpawnLocation()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSprinting()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSprinting(boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,16 +17,6 @@ public class PlayerExtension extends PlayerWrapper
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public boolean isBanned()
|
||||
{
|
||||
return ess.getBans().contains(getName());
|
||||
}
|
||||
|
||||
public boolean isIpBanned()
|
||||
{
|
||||
return ess.getBannedIps().contains(getAddress().getAddress().toString().replace("/", ""));
|
||||
}
|
||||
|
||||
public float getCorrectedYaw()
|
||||
{
|
||||
float angle = (getLocation().getYaw() - 90.0f) % 360.0f;
|
||||
@@ -53,38 +43,17 @@ public class PlayerExtension extends PlayerWrapper
|
||||
|
||||
public String getGroup()
|
||||
{
|
||||
try
|
||||
{
|
||||
return com.nijikokun.bukkit.Permissions.Permissions.Security.getGroup(getWorld().getName(), getName());
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
return "default";
|
||||
}
|
||||
return ess.getPermissionsHandler().getGroup(base);
|
||||
}
|
||||
|
||||
public boolean inGroup(String group)
|
||||
{
|
||||
try
|
||||
{
|
||||
return com.nijikokun.bukkit.Permissions.Permissions.Security.inGroup(getWorld().getName(), getName(), group);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return ess.getPermissionsHandler().inGroup(base, group);
|
||||
}
|
||||
|
||||
public boolean canBuild()
|
||||
{
|
||||
try
|
||||
{
|
||||
return isOp() || com.nijikokun.bukkit.Permissions.Permissions.Security.canGroupBuild(getWorld().getName(), getGroup());
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return ess.getPermissionsHandler().canBuild(base, getGroup());
|
||||
}
|
||||
|
||||
public EntityPlayer getHandle()
|
||||
|
||||
@@ -7,6 +7,11 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.inventory.*;
|
||||
import org.bukkit.map.MapView;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class PlayerWrapper implements Player
|
||||
@@ -401,20 +406,6 @@ public class PlayerWrapper implements Player
|
||||
return base.eject();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void teleportTo(Location lctn)
|
||||
{
|
||||
base.teleportTo(lctn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void teleportTo(Entity entity)
|
||||
{
|
||||
base.teleportTo(entity);
|
||||
}
|
||||
|
||||
public void saveData()
|
||||
{
|
||||
base.saveData();
|
||||
@@ -560,4 +551,197 @@ public class PlayerWrapper implements Player
|
||||
{
|
||||
base.resetPlayerTime();
|
||||
}
|
||||
|
||||
public boolean isPermissionSet(String string)
|
||||
{
|
||||
return base.isPermissionSet(string);
|
||||
}
|
||||
|
||||
public boolean isPermissionSet(Permission prmsn)
|
||||
{
|
||||
return base.isPermissionSet(prmsn);
|
||||
}
|
||||
|
||||
public boolean hasPermission(String string)
|
||||
{
|
||||
return base.hasPermission(string);
|
||||
}
|
||||
|
||||
public boolean hasPermission(Permission prmsn)
|
||||
{
|
||||
return base.hasPermission(prmsn);
|
||||
}
|
||||
|
||||
public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln)
|
||||
{
|
||||
return base.addAttachment(plugin, string, bln);
|
||||
}
|
||||
|
||||
public PermissionAttachment addAttachment(Plugin plugin)
|
||||
{
|
||||
return base.addAttachment(plugin);
|
||||
}
|
||||
|
||||
public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln, int i)
|
||||
{
|
||||
return base.addAttachment(plugin, string, bln, i);
|
||||
}
|
||||
|
||||
public PermissionAttachment addAttachment(Plugin plugin, int i)
|
||||
{
|
||||
return base.addAttachment(plugin, i);
|
||||
}
|
||||
|
||||
public void removeAttachment(PermissionAttachment pa)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public void recalculatePermissions()
|
||||
{
|
||||
base.recalculatePermissions();
|
||||
}
|
||||
|
||||
public Set<PermissionAttachmentInfo> getEffectivePermissions()
|
||||
{
|
||||
return base.getEffectivePermissions();
|
||||
}
|
||||
|
||||
public void setOp(boolean bln)
|
||||
{
|
||||
base.setOp(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMap(MapView mv)
|
||||
{
|
||||
base.sendMap(mv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBanned()
|
||||
{
|
||||
return base.isBanned();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBanned(boolean bln)
|
||||
{
|
||||
base.setBanned(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWhitelisted()
|
||||
{
|
||||
return base.isWhitelisted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWhitelisted(boolean bln)
|
||||
{
|
||||
base.setWhitelisted(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameMode getGameMode()
|
||||
{
|
||||
return base.getGameMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGameMode(GameMode gm)
|
||||
{
|
||||
base.setGameMode(gm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getExperience()
|
||||
{
|
||||
return base.getExperience();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExperience(int i)
|
||||
{
|
||||
base.setExperience(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel()
|
||||
{
|
||||
return base.getLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLevel(int i)
|
||||
{
|
||||
base.setLevel(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalExperience()
|
||||
{
|
||||
return base.getTotalExperience();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTotalExperience(int i)
|
||||
{
|
||||
base.setTotalExperience(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExhaustion()
|
||||
{
|
||||
return base.getExhaustion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExhaustion(float f)
|
||||
{
|
||||
base.setExhaustion(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSaturation()
|
||||
{
|
||||
return base.getSaturation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSaturation(float f)
|
||||
{
|
||||
base.setSaturation(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFoodLevel()
|
||||
{
|
||||
return base.getFoodLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFoodLevel(int i)
|
||||
{
|
||||
base.setFoodLevel(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getBedSpawnLocation()
|
||||
{
|
||||
return base.getBedSpawnLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSprinting()
|
||||
{
|
||||
return base.isSprinting();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSprinting(boolean bln)
|
||||
{
|
||||
base.setSprinting(bln);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,65 +6,80 @@ import org.bukkit.ChatColor;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Settings implements IConf
|
||||
public class Settings implements ISettings
|
||||
{
|
||||
private final EssentialsConf config;
|
||||
private final transient EssentialsConf config;
|
||||
private final static Logger logger = Logger.getLogger("Minecraft");
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public Settings(File dataFolder)
|
||||
public Settings(IEssentials ess)
|
||||
{
|
||||
config = new EssentialsConf(new File(dataFolder, "config.yml"));
|
||||
this.ess = ess;
|
||||
config = new EssentialsConf(new File(ess.getDataFolder(), "config.yml"));
|
||||
config.setTemplateName("/config.yml");
|
||||
config.load();
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getRespawnAtHome()
|
||||
{
|
||||
return config.getBoolean("respawn-at-home", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMultipleHomes()
|
||||
{
|
||||
return config.getInt("multiple-homes", 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBedSetsHome()
|
||||
{
|
||||
return config.getBoolean("bed-sethome", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChatRadius()
|
||||
{
|
||||
return config.getInt("chat.radius", config.getInt("chat-radius", 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTeleportDelay()
|
||||
{
|
||||
return config.getDouble("teleport-delay", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultStackSize()
|
||||
{
|
||||
return config.getInt("default-stack-size", 64);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartingBalance()
|
||||
{
|
||||
return config.getInt("starting-balance", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getNetherPortalsEnabled()
|
||||
{
|
||||
return isNetherEnabled() && config.getBoolean("nether.portals-enabled", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandDisabled(final IEssentialsCommand cmd)
|
||||
{
|
||||
return isCommandDisabled(cmd.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandDisabled(String label)
|
||||
{
|
||||
for (String c : config.getStringList("disabled-commands", new ArrayList<String>(0)))
|
||||
@@ -75,11 +90,13 @@ public class Settings implements IConf
|
||||
return config.getBoolean("disable-" + label.toLowerCase(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandRestricted(IEssentialsCommand cmd)
|
||||
{
|
||||
return isCommandRestricted(cmd.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandRestricted(String label)
|
||||
{
|
||||
for (String c : config.getStringList("restricted-commands", new ArrayList<String>(0)))
|
||||
@@ -89,7 +106,19 @@ public class Settings implements IConf
|
||||
}
|
||||
return config.getBoolean("restrict-" + label.toLowerCase(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerCommand(String label)
|
||||
{
|
||||
for (String c : config.getStringList("player-commands", new ArrayList<String>(0)))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(label)) continue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandOverridden(String name)
|
||||
{
|
||||
List<String> defaultList = new ArrayList<String>(1);
|
||||
@@ -103,11 +132,13 @@ public class Settings implements IConf
|
||||
return config.getBoolean("override-" + name.toLowerCase(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCommandCost(IEssentialsCommand cmd)
|
||||
{
|
||||
return getCommandCost(cmd.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCommandCost(String label)
|
||||
{
|
||||
double cost = config.getDouble("command-costs." + label, 0.0);
|
||||
@@ -116,26 +147,25 @@ public class Settings implements IConf
|
||||
return cost;
|
||||
}
|
||||
|
||||
public String getCommandPrefix()
|
||||
{
|
||||
return config.getString("command-prefix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNicknamePrefix()
|
||||
{
|
||||
return config.getString("nickname-prefix", "~");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTeleportCooldown()
|
||||
{
|
||||
return config.getDouble("teleport-cooldown", 60);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHealCooldown()
|
||||
{
|
||||
return config.getDouble("heal-cooldown", 60);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKit(String name)
|
||||
{
|
||||
Map<String, Object> kits = (Map<String, Object>)config.getProperty("kits");
|
||||
@@ -148,11 +178,13 @@ public class Settings implements IConf
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getKits()
|
||||
{
|
||||
return (Map<String, Object>)config.getProperty("kits");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatColor getOperatorColor() throws Exception
|
||||
{
|
||||
String colorName = config.getString("ops-name-color", null);
|
||||
@@ -173,257 +205,123 @@ public class Settings implements IConf
|
||||
return ChatColor.getByCode(Integer.parseInt(colorName, 16));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getReclaimSetting()
|
||||
{
|
||||
return config.getBoolean("reclaim-onlogout", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNetherName()
|
||||
{
|
||||
return config.getString("nether.folder", "nether");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNetherEnabled()
|
||||
{
|
||||
return config.getBoolean("nether.enabled", true);
|
||||
return config.getBoolean("nether.enabled", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpawnMobLimit()
|
||||
{
|
||||
return config.getInt("spawnmob-limit", 10);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean showNonEssCommandsInHelp()
|
||||
{
|
||||
return config.getBoolean("non-ess-in-help", true);
|
||||
}
|
||||
|
||||
public Map<String, Boolean> getEpSettings()
|
||||
|
||||
@Override
|
||||
public boolean hidePermissionlessHelp()
|
||||
{
|
||||
Map<String, Boolean> epSettings = new HashMap<String, Boolean>();
|
||||
return config.getBoolean("hide-permissionless-help", true);
|
||||
}
|
||||
|
||||
epSettings.put("protect.protect.signs", config.getBoolean("protect.protect.signs", true));
|
||||
epSettings.put("protect.protect.rails", config.getBoolean("protect.protect.rails", true));
|
||||
epSettings.put("protect.protect.block-below", config.getBoolean("protect.protect.block-below", true));
|
||||
epSettings.put("protect.protect.prevent-block-on-rails", config.getBoolean("protect.protect.prevent-block-on-rails", false));
|
||||
return epSettings;
|
||||
}
|
||||
|
||||
public Map<String, String> getEpDBSettings()
|
||||
{
|
||||
Map<String, String> epSettings = new HashMap<String, String>();
|
||||
epSettings.put("protect.datatype", config.getString("protect.datatype", "sqlite"));
|
||||
epSettings.put("protect.username", config.getString("protect.username", "root"));
|
||||
epSettings.put("protect.password", config.getString("protect.password", "root"));
|
||||
epSettings.put("protect.mysqlDb", config.getString("protect.mysqlDb", "jdbc:mysql://localhost:3306/minecraft"));
|
||||
return epSettings;
|
||||
}
|
||||
|
||||
public List<Integer> getEpAlertOnPlacement()
|
||||
{
|
||||
final List<Integer> epAlertPlace = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString("protect.alert.on-placement", "").split(",")) {
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack is;
|
||||
try {
|
||||
is = ItemDb.get(itemName);
|
||||
epAlertPlace.add(is.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "alert.on-placement"));
|
||||
}
|
||||
}
|
||||
return epAlertPlace;
|
||||
}
|
||||
|
||||
public List<Integer> getEpAlertOnUse()
|
||||
{
|
||||
final List<Integer> epAlertUse = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString("protect.alert.on-use", "").split(",")) {
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack is;
|
||||
try {
|
||||
is = ItemDb.get(itemName);
|
||||
epAlertUse.add(is.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "alert.on-use"));
|
||||
}
|
||||
}
|
||||
return epAlertUse;
|
||||
}
|
||||
|
||||
public List<Integer> getEpAlertOnBreak()
|
||||
{
|
||||
final List<Integer> epAlertPlace = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString("protect.alert.on-break", "").split(",")) {
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack is;
|
||||
try {
|
||||
is = ItemDb.get(itemName);
|
||||
epAlertPlace.add(is.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "alert.on-break"));
|
||||
}
|
||||
}
|
||||
return epAlertPlace;
|
||||
}
|
||||
|
||||
public List<Integer> epBlackListPlacement()
|
||||
{
|
||||
final List<Integer> epBlacklistPlacement = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString("protect.blacklist.placement", "").split(",")) {
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack is;
|
||||
try {
|
||||
is = ItemDb.get(itemName);
|
||||
epBlacklistPlacement.add(is.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "blacklist.placement"));
|
||||
}
|
||||
}
|
||||
return epBlacklistPlacement;
|
||||
}
|
||||
|
||||
public List<Integer> epBlackListUsage()
|
||||
{
|
||||
final List<Integer> epBlackListUsage = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString("protect.blacklist.usage", "").split(",")) {
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack is;
|
||||
try {
|
||||
is = ItemDb.get(itemName);
|
||||
epBlackListUsage.add(is.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "blacklist.usage"));
|
||||
}
|
||||
}
|
||||
return epBlackListUsage;
|
||||
}
|
||||
|
||||
public Map<String, Boolean> getEpGuardSettings()
|
||||
{
|
||||
final Map<String, Boolean> epSettings = new HashMap<String, Boolean>();
|
||||
epSettings.put("protect.prevent.lava-flow", config.getBoolean("protect.prevent.lava-flow", false));
|
||||
epSettings.put("protect.prevent.water-flow", config.getBoolean("protect.prevent.water-flow", false));
|
||||
epSettings.put("protect.prevent.water-bucket-flow", config.getBoolean("protect.prevent.water-bucket-flow", false));
|
||||
epSettings.put("protect.prevent.fire-spread", config.getBoolean("protect.prevent.fire-spread", true));
|
||||
epSettings.put("protect.prevent.flint-fire", config.getBoolean("protect.prevent.flint-fire", false));
|
||||
epSettings.put("protect.prevent.portal-creation", config.getBoolean("protect.prevent.portal-creation", false));
|
||||
epSettings.put("protect.prevent.lava-fire-spread", config.getBoolean("protect.prevent.lava-fire-spread", true));
|
||||
epSettings.put("protect.prevent.tnt-explosion", config.getBoolean("protect.prevent.tnt-explosion", false));
|
||||
epSettings.put("protect.prevent.creeper-explosion", config.getBoolean("protect.prevent.creeper-explosion", false));
|
||||
epSettings.put("protect.prevent.creeper-playerdamage", config.getBoolean("protect.prevent.creeper-playerdamage", false));
|
||||
epSettings.put("protect.prevent.creeper-blockdamage", config.getBoolean("protect.prevent.creeper-blockdamage", false));
|
||||
epSettings.put("protect.prevent.entitytarget", config.getBoolean("protect.prevent.entitytarget", false));
|
||||
for (CreatureType ct : CreatureType.values()) {
|
||||
final String name = ct.toString().toLowerCase();
|
||||
epSettings.put("protect.prevent.spawn."+name, config.getBoolean("protect.prevent.spawn."+name, false));
|
||||
}
|
||||
epSettings.put("protect.prevent.lightning-fire-spread", config.getBoolean("protect.prevent.lightning-fire-spread", true));
|
||||
return epSettings;
|
||||
}
|
||||
|
||||
public Map<String, Boolean> getEpPlayerSettings()
|
||||
{
|
||||
final Map<String, Boolean> epPlayerSettings = new HashMap<String, Boolean>();
|
||||
epPlayerSettings.put("protect.disable.fall", config.getBoolean("protect.disable.fall", false));
|
||||
epPlayerSettings.put("protect.disable.pvp", config.getBoolean("protect.disable.pvp", false));
|
||||
epPlayerSettings.put("protect.disable.drown", config.getBoolean("protect.disable.drown", false));
|
||||
epPlayerSettings.put("protect.disable.suffocate", config.getBoolean("protect.disable.suffocate", false));
|
||||
epPlayerSettings.put("protect.disable.lavadmg", config.getBoolean("protect.disable.lavadmg", false));
|
||||
epPlayerSettings.put("protect.disable.projectiles", config.getBoolean("protect.disable.projectiles", false));
|
||||
epPlayerSettings.put("protect.disable.contactdmg", config.getBoolean("protect.disable.contactdmg", false));
|
||||
epPlayerSettings.put("protect.disable.firedmg", config.getBoolean("protect.disable.firedmg", false));
|
||||
epPlayerSettings.put("protect.disable.build", config.getBoolean("protect.disable.build", false));
|
||||
epPlayerSettings.put("protect.disable.lightning", config.getBoolean("protect.disable.lightning", false));
|
||||
epPlayerSettings.put("protect.disable.weather.lightning", config.getBoolean("protect.disable.weather.lightning", false));
|
||||
epPlayerSettings.put("protect.disable.weather.storm", config.getBoolean("protect.disable.weather.storm", false));
|
||||
epPlayerSettings.put("protect.disable.weather.thunder", config.getBoolean("protect.disable.weather.thunder", false));
|
||||
return epPlayerSettings;
|
||||
|
||||
}
|
||||
|
||||
public int getEpCreeperMaxHeight()
|
||||
@Override
|
||||
public int getProtectCreeperMaxHeight()
|
||||
{
|
||||
return config.getInt("protect.creeper.max-height", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areSignsDisabled()
|
||||
{
|
||||
return config.getBoolean("signs-disabled", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBackupInterval()
|
||||
{
|
||||
return config.getInt("backup.interval", 1440); // 1440 = 24 * 60
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBackupCommand()
|
||||
{
|
||||
return config.getString("backup.command", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChatFormat(String group)
|
||||
{
|
||||
return config.getString("chat.group-formats." + (group == null ? "Default" : group),
|
||||
config.getString("chat.format", "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGenerateExitPortals()
|
||||
{
|
||||
return config.getBoolean("nether.generate-exit-portals", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAnnounceNewPlayers()
|
||||
{
|
||||
return !config.getString("newbies.announce-format", "-").isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAnnounceNewPlayerFormat(IUser user)
|
||||
{
|
||||
return format(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!"), user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(String format, IUser user)
|
||||
{
|
||||
return format.replace('&', '§').replace("§§", "&").replace("{PLAYER}", user.getDisplayName()).replace("{DISPLAYNAME}", user.getDisplayName()).replace("{GROUP}", user.getGroup()).replace("{USERNAME}", user.getName()).replace("{ADDRESS}", user.getAddress().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNewbieSpawn()
|
||||
{
|
||||
return config.getString("newbies.spawnpoint", "default");
|
||||
}
|
||||
@Override
|
||||
public boolean getPerWarpPermission()
|
||||
{
|
||||
return config.getBoolean("per-warp-permission", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getSortListByGroups()
|
||||
{
|
||||
return config.getBoolean("sort-list-by-groups", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
config.load();
|
||||
}
|
||||
|
||||
public ArrayList<Integer> itemSpawnBlacklist()
|
||||
@Override
|
||||
public List<Integer> itemSpawnBlacklist()
|
||||
{
|
||||
ArrayList<Integer> epItemSpwn = new ArrayList<Integer>();
|
||||
final List<Integer> epItemSpwn = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString("item-spawn-blacklist", "").split(",")) {
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
@@ -431,7 +329,7 @@ public class Settings implements IConf
|
||||
}
|
||||
ItemStack is;
|
||||
try {
|
||||
is = ItemDb.get(itemName);
|
||||
is = ess.getItemDb().get(itemName);
|
||||
epItemSpwn.add(is.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "item-spawn-blacklist"));
|
||||
@@ -440,80 +338,169 @@ public class Settings implements IConf
|
||||
return epItemSpwn;
|
||||
}
|
||||
|
||||
public ArrayList<Integer> epBlockBreakingBlacklist()
|
||||
{
|
||||
ArrayList<Integer> epBreakList = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString("protect.blacklist.break", "").split(",")) {
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack is;
|
||||
try {
|
||||
is = ItemDb.get(itemName);
|
||||
epBreakList.add(is.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "blacklist.break"));
|
||||
}
|
||||
}
|
||||
return epBreakList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean spawnIfNoHome()
|
||||
{
|
||||
return config.getBoolean("spawn-if-no-home", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean warnOnBuildDisallow()
|
||||
{
|
||||
return config.getBoolean("protect.disable.warn-on-build-disallow", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean use1to1RatioInNether()
|
||||
{
|
||||
return config.getBoolean("nether.use-1to1-ratio", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNetherRatio()
|
||||
{
|
||||
if (config.getBoolean("nether.use-1to1-ratio", false)) {
|
||||
return 1.0;
|
||||
}
|
||||
return config.getDouble("nether.ratio", 16.0);
|
||||
return config.getDouble("nether.ratio", 8.0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebug()
|
||||
{
|
||||
return config.getBoolean("debug", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean warnOnSmite()
|
||||
{
|
||||
return config.getBoolean("warn-on-smite" ,true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean permissionBasedItemSpawn()
|
||||
{
|
||||
return config.getBoolean("permission-based-item-spawn", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocale()
|
||||
{
|
||||
return config.getString("locale", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrencySymbol()
|
||||
{
|
||||
return config.getString("currency-symbol", "$").substring(0, 1).replaceAll("[0-9]", "$");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTradeInStacks(int id)
|
||||
{
|
||||
return config.getBoolean("trade-in-stacks-" + id, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEcoDisabled()
|
||||
{
|
||||
return config.getBoolean("disable-eco", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getProtectPreventSpawn(final String creatureName)
|
||||
{
|
||||
return config.getBoolean("protect.prevent.spawn."+creatureName, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getProtectList(final String configName)
|
||||
{
|
||||
final List<Integer> list = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString(configName, "").split(",")) {
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack itemStack;
|
||||
try {
|
||||
itemStack = ess.getItemDb().get(itemName);
|
||||
list.add(itemStack.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, configName));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtectString(final String configName)
|
||||
{
|
||||
return config.getString(configName, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getProtectBoolean(final String configName, boolean def)
|
||||
{
|
||||
return config.getBoolean(configName, def);
|
||||
}
|
||||
|
||||
private final static double MAXMONEY = 10000000000000.0;
|
||||
public double getMaxMoney()
|
||||
{
|
||||
double max = config.getDouble("max-money", MAXMONEY);
|
||||
if (Math.abs(max) > MAXMONEY) {
|
||||
max = max < 0 ? -MAXMONEY : MAXMONEY;
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
public boolean isEcoLogEnabled()
|
||||
{
|
||||
return config.getBoolean("economy-log-enabled", false);
|
||||
}
|
||||
|
||||
public boolean removeGodOnDisconnect()
|
||||
{
|
||||
return config.getBoolean("remove-god-on-disconnect", false);
|
||||
}
|
||||
|
||||
public boolean changeDisplayName()
|
||||
{
|
||||
return config.getBoolean("change-displayname", true);
|
||||
}
|
||||
|
||||
public boolean useBukkitPermissions()
|
||||
{
|
||||
return config.getBoolean("use-bukkit-permissions", false);
|
||||
}
|
||||
|
||||
public boolean addPrefixSuffix()
|
||||
{
|
||||
return config.getBoolean("add-prefix-suffix", ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpdateEnabled()
|
||||
{
|
||||
return config.getBoolean("update-check", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAutoAfk()
|
||||
{
|
||||
return config.getLong("auto-afk", 300);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAutoAfkKick()
|
||||
{
|
||||
return config.getLong("auto-afk-kick", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFreezeAfkPlayers()
|
||||
{
|
||||
return config.getBoolean("freeze-afk-players", false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.ChunkPosition;
|
||||
import net.minecraft.server.Packet60Explosion;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
|
||||
|
||||
public class TNTExplodeListener extends EntityListener implements Runnable
|
||||
{
|
||||
private final IEssentials ess;
|
||||
private boolean enabled = false;
|
||||
private int timer = -1;
|
||||
|
||||
public TNTExplodeListener(IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public void enable()
|
||||
{
|
||||
if (!enabled)
|
||||
{
|
||||
enabled = true;
|
||||
timer = ess.scheduleSyncDelayedTask(this, 1000);
|
||||
return;
|
||||
}
|
||||
if (timer != -1) {
|
||||
ess.getScheduler().cancelTask(timer);
|
||||
timer = ess.scheduleSyncDelayedTask(this, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityExplode(final EntityExplodeEvent event)
|
||||
{
|
||||
if (!enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (event.getEntity() instanceof LivingEntity)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final Set<ChunkPosition> set = new HashSet<ChunkPosition>(event.blockList().size());
|
||||
final Player[] players = ess.getServer().getOnlinePlayers();
|
||||
final List<ChunkPosition> blocksUnderPlayers = new ArrayList<ChunkPosition>(players.length);
|
||||
final Location loc = event.getLocation();
|
||||
for (Player player : players)
|
||||
{
|
||||
if (player.getWorld().equals(loc.getWorld()))
|
||||
{
|
||||
blocksUnderPlayers.add(new ChunkPosition(player.getLocation().getBlockX(), player.getLocation().getBlockY() - 1, player.getLocation().getBlockZ()));
|
||||
}
|
||||
}
|
||||
for (Block block : event.blockList())
|
||||
{
|
||||
final ChunkPosition cp = new ChunkPosition(block.getX(), block.getY(), block.getZ());
|
||||
if (!blocksUnderPlayers.contains(cp))
|
||||
{
|
||||
set.add(cp);
|
||||
}
|
||||
}
|
||||
((CraftServer)ess.getServer()).getHandle().sendPacketNearby(loc.getX(), loc.getY(), loc.getZ(), 64.0, ((CraftWorld)loc.getWorld()).getHandle().worldProvider.dimension, new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0F, set));
|
||||
} catch (Throwable ex) {
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,8 +1,8 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -10,6 +10,9 @@ import org.bukkit.entity.Entity;
|
||||
|
||||
public class Teleport implements Runnable
|
||||
{
|
||||
private static final double MOVE_CONSTANT = 0.3;
|
||||
|
||||
|
||||
private static class Target
|
||||
{
|
||||
private final Location location;
|
||||
@@ -48,18 +51,18 @@ public class Teleport implements Runnable
|
||||
private long initY;
|
||||
private long initZ;
|
||||
private Target teleportTarget;
|
||||
private Charge chargeFor;
|
||||
private Trade chargeFor;
|
||||
private final IEssentials ess;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
private void initTimer(long delay, Target target, Charge chargeFor)
|
||||
private void initTimer(long delay, Target target, Trade chargeFor)
|
||||
{
|
||||
this.started = System.currentTimeMillis();
|
||||
this.delay = delay;
|
||||
this.health = user.getHealth();
|
||||
this.initX = Math.round(user.getLocation().getX() * 10000);
|
||||
this.initY = Math.round(user.getLocation().getY() * 10000);
|
||||
this.initZ = Math.round(user.getLocation().getZ() * 10000);
|
||||
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.teleportTarget = target;
|
||||
this.chargeFor = chargeFor;
|
||||
}
|
||||
@@ -72,9 +75,9 @@ public class Teleport implements Runnable
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
if (Math.round(user.getLocation().getX() * 10000) != initX
|
||||
|| Math.round(user.getLocation().getY() * 10000) != initY
|
||||
|| Math.round(user.getLocation().getZ() * 10000) != initZ
|
||||
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
|
||||
cancel(true);
|
||||
@@ -92,7 +95,7 @@ public class Teleport implements Runnable
|
||||
user.sendMessage(Util.i18n("teleportationCommencing"));
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
now(teleportTarget);
|
||||
if (chargeFor != null)
|
||||
{
|
||||
@@ -101,11 +104,7 @@ public class Teleport implements Runnable
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
ess.showError(user.getBase(), ex, "teleport");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -122,12 +121,12 @@ public class Teleport implements Runnable
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public void respawn(Spawn spawn, Charge chargeFor) throws Exception
|
||||
public void respawn(Spawn spawn, Trade chargeFor) throws Exception
|
||||
{
|
||||
teleport(new Target(spawn.getSpawn(user.getGroup())), chargeFor);
|
||||
}
|
||||
|
||||
public void warp(String warp, Charge chargeFor) throws Exception
|
||||
public void warp(String warp, Trade chargeFor) throws Exception
|
||||
{
|
||||
Location loc = ess.getWarps().getWarp(warp);
|
||||
teleport(new Target(loc), chargeFor);
|
||||
@@ -181,17 +180,17 @@ public class Teleport implements Runnable
|
||||
cancel(false);
|
||||
}
|
||||
|
||||
public void teleport(Location loc, Charge chargeFor) throws Exception
|
||||
public void teleport(Location loc, Trade chargeFor) throws Exception
|
||||
{
|
||||
teleport(new Target(loc), chargeFor);
|
||||
}
|
||||
|
||||
public void teleport(Entity entity, Charge chargeFor) throws Exception
|
||||
public void teleport(Entity entity, Trade chargeFor) throws Exception
|
||||
{
|
||||
teleport(new Target(entity), chargeFor);
|
||||
}
|
||||
|
||||
private void teleport(Target target, Charge chargeFor) throws Exception
|
||||
private void teleport(Target target, Trade chargeFor) throws Exception
|
||||
{
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
|
||||
@@ -233,21 +232,24 @@ public class Teleport implements Runnable
|
||||
cooldown(false);
|
||||
now(new Target(loc));
|
||||
}
|
||||
|
||||
public void now(Location loc, Charge chargeFor) throws Exception
|
||||
|
||||
public void now(Location loc, Trade chargeFor) throws Exception
|
||||
{
|
||||
cooldown(false);
|
||||
chargeFor.charge(user);
|
||||
now(new Target(loc));
|
||||
}
|
||||
|
||||
public void now(Entity entity) throws Exception
|
||||
public void now(Entity entity, boolean cooldown) throws Exception
|
||||
{
|
||||
cooldown(false);
|
||||
if (cooldown)
|
||||
{
|
||||
cooldown(false);
|
||||
}
|
||||
now(new Target(entity));
|
||||
}
|
||||
|
||||
public void back(Charge chargeFor) throws Exception
|
||||
public void back(Trade chargeFor) throws Exception
|
||||
{
|
||||
teleport(new Target(user.getLastLocation()), chargeFor);
|
||||
}
|
||||
@@ -257,24 +259,12 @@ public class Teleport implements Runnable
|
||||
back(null);
|
||||
}
|
||||
|
||||
public void home(Charge chargeFor) throws Exception
|
||||
public void home(IUser user, String home, Trade chargeFor) throws Exception
|
||||
{
|
||||
home(user, chargeFor);
|
||||
}
|
||||
|
||||
public void home(IUser user, Charge chargeFor) throws Exception
|
||||
{
|
||||
Location loc = user.getHome(this.user.getLocation());
|
||||
final Location loc = user.getHome(home);
|
||||
if (loc == null)
|
||||
{
|
||||
if (ess.getSettings().spawnIfNoHome())
|
||||
{
|
||||
respawn(ess.getSpawn(), chargeFor);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(user == this.user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer"));
|
||||
}
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
teleport(new Target(loc), chargeFor);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,243 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Trade
|
||||
{
|
||||
private final transient String command;
|
||||
private final transient Double money;
|
||||
private final transient ItemStack itemStack;
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public Trade(final String command, final IEssentials ess)
|
||||
{
|
||||
this(command, null, null, ess);
|
||||
}
|
||||
|
||||
public Trade(final double money, final IEssentials ess)
|
||||
{
|
||||
this(null, money, null, ess);
|
||||
}
|
||||
|
||||
public Trade(final ItemStack items, final IEssentials ess)
|
||||
{
|
||||
this(null, null, items, ess);
|
||||
}
|
||||
|
||||
private Trade(final String command, final Double money, final ItemStack item, final IEssentials ess)
|
||||
{
|
||||
this.command = command;
|
||||
this.money = money;
|
||||
this.itemStack = item;
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public void isAffordableFor(final IUser user) throws ChargeException
|
||||
{
|
||||
final double mon = user.getMoney();
|
||||
if (getMoney() != null
|
||||
&& mon < getMoney()
|
||||
&& getMoney() > 0
|
||||
&& !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new ChargeException(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
|
||||
if (getItemStack() != null
|
||||
&& !InventoryWorkaround.containsItem(user.getInventory(), true, itemStack))
|
||||
{
|
||||
throw new ChargeException(Util.format("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase().replace("_", " ")));
|
||||
}
|
||||
|
||||
if (command != null && !command.isEmpty()
|
||||
&& !user.isAuthorized("essentials.nocommandcost.all")
|
||||
&& !user.isAuthorized("essentials.nocommandcost." + command)
|
||||
&& mon < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
|
||||
&& 0 < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
|
||||
&& !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new ChargeException(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
}
|
||||
|
||||
public void pay(final IUser user)
|
||||
{
|
||||
if (getMoney() != null && getMoney() > 0)
|
||||
{
|
||||
user.giveMoney(getMoney());
|
||||
}
|
||||
if (getItemStack() != null)
|
||||
{
|
||||
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItem(user.getInventory(), true, getItemStack());
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
}
|
||||
user.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
public void charge(final IUser user) throws ChargeException
|
||||
{
|
||||
if (getMoney() != null)
|
||||
{
|
||||
final double mon = user.getMoney();
|
||||
if (mon < getMoney() && getMoney() > 0 && !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new ChargeException(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(getMoney());
|
||||
}
|
||||
if (getItemStack() != null)
|
||||
{
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, itemStack))
|
||||
{
|
||||
throw new ChargeException(Util.format("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase().replace("_", " ")));
|
||||
}
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, getItemStack());
|
||||
user.updateInventory();
|
||||
}
|
||||
if (command != null && !command.isEmpty()
|
||||
&& !user.isAuthorized("essentials.nocommandcost.all")
|
||||
&& !user.isAuthorized("essentials.nocommandcost." + command))
|
||||
{
|
||||
final double mon = user.getMoney();
|
||||
final double cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
|
||||
if (mon < cost && cost > 0 && !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new ChargeException(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(cost);
|
||||
}
|
||||
}
|
||||
|
||||
public Double getMoney()
|
||||
{
|
||||
return money;
|
||||
}
|
||||
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return itemStack;
|
||||
}
|
||||
private static FileWriter fw = null;
|
||||
|
||||
public static void log(String type, String subtype, String event, String sender, Trade charge, String receiver, Trade pay, Location loc, IEssentials ess)
|
||||
{
|
||||
if (!ess.getSettings().isEcoLogEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (fw == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
fw = new FileWriter(new File(ess.getDataFolder(), "trade.log"), true);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(type).append(",").append(subtype).append(",").append(event).append(",\"");
|
||||
sb.append(DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(new Date()));
|
||||
sb.append("\",\"");
|
||||
if (sender != null)
|
||||
{
|
||||
sb.append(sender);
|
||||
}
|
||||
sb.append("\",");
|
||||
if (charge == null)
|
||||
{
|
||||
sb.append("\"\",\"\",\"\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (charge.getItemStack() != null)
|
||||
{
|
||||
sb.append(charge.getItemStack().getAmount()).append(",");
|
||||
sb.append(charge.getItemStack().getType().toString()).append(",");
|
||||
sb.append(charge.getItemStack().getDurability());
|
||||
}
|
||||
if (charge.getMoney() != null)
|
||||
{
|
||||
sb.append(charge.getMoney()).append(",");
|
||||
sb.append("money").append(",");
|
||||
sb.append(ess.getSettings().getCurrencySymbol());
|
||||
}
|
||||
}
|
||||
sb.append(",\"");
|
||||
if (receiver != null)
|
||||
{
|
||||
sb.append(receiver);
|
||||
}
|
||||
sb.append("\",");
|
||||
if (pay == null)
|
||||
{
|
||||
sb.append("\"\",\"\",\"\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pay.getItemStack() != null)
|
||||
{
|
||||
sb.append(pay.getItemStack().getAmount()).append(",");
|
||||
sb.append(pay.getItemStack().getType().toString()).append(",");
|
||||
sb.append(pay.getItemStack().getDurability());
|
||||
}
|
||||
if (pay.getMoney() != null)
|
||||
{
|
||||
sb.append(pay.getMoney()).append(",");
|
||||
sb.append("money").append(",");
|
||||
sb.append(ess.getSettings().getCurrencySymbol());
|
||||
}
|
||||
}
|
||||
if (loc == null)
|
||||
{
|
||||
sb.append(",\"\",\"\",\"\",\"\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append(",\"");
|
||||
sb.append(loc.getWorld().getName()).append("\",");
|
||||
sb.append(loc.getBlockX()).append(",");
|
||||
sb.append(loc.getBlockY()).append(",");
|
||||
sb.append(loc.getBlockZ()).append(",");
|
||||
}
|
||||
sb.append("\n");
|
||||
try
|
||||
{
|
||||
fw.write(sb.toString());
|
||||
fw.flush();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void closeLog()
|
||||
{
|
||||
if (fw != null) {
|
||||
try
|
||||
{
|
||||
fw.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
fw = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,41 +4,59 @@ import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
{
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private boolean justPortaled = false;
|
||||
private CommandSender replyTo = null;
|
||||
private User teleportRequester;
|
||||
private boolean teleportRequestHere;
|
||||
private final Teleport teleport;
|
||||
private long lastActivity;
|
||||
private transient User teleportRequester;
|
||||
private transient boolean teleportRequestHere;
|
||||
private transient final Teleport teleport;
|
||||
private transient long lastOnlineActivity;
|
||||
private transient long lastActivity = System.currentTimeMillis();
|
||||
private boolean hidden = false;
|
||||
private transient boolean godStateBeforeAfk;
|
||||
private transient Location afkPosition;
|
||||
|
||||
User(Player base, IEssentials ess)
|
||||
User(final Player base, final IEssentials ess)
|
||||
{
|
||||
super(base, ess);
|
||||
teleport = new Teleport(this, ess);
|
||||
godStateBeforeAfk = isGodModeEnabled();
|
||||
afkPosition = getLocation();
|
||||
}
|
||||
|
||||
User update(Player base)
|
||||
User update(final Player base)
|
||||
{
|
||||
setBase(base);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isAuthorized(IEssentialsCommand cmd)
|
||||
@Override
|
||||
public boolean isAuthorized(final IEssentialsCommand cmd)
|
||||
{
|
||||
return isAuthorized("essentials." + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
|
||||
return isAuthorized(cmd, "essentials.");
|
||||
}
|
||||
|
||||
public boolean isAuthorized(String node)
|
||||
@Override
|
||||
public boolean isAuthorized(final IEssentialsCommand cmd, final String permissionPrefix)
|
||||
{
|
||||
return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(final String node)
|
||||
{
|
||||
if (base instanceof OfflinePlayer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isOp())
|
||||
{
|
||||
return true;
|
||||
@@ -49,24 +67,16 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return com.nijikokun.bukkit.Permissions.Permissions.Security.permission(base, node);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
String[] cmds = node.split("\\.", 2);
|
||||
return !ess.getSettings().isCommandRestricted(cmds[cmds.length - 1]);
|
||||
}
|
||||
return ess.getPermissionsHandler().hasPermission(base, node);
|
||||
}
|
||||
|
||||
public void healCooldown() throws Exception
|
||||
{
|
||||
Calendar now = new GregorianCalendar();
|
||||
final Calendar now = new GregorianCalendar();
|
||||
if (getLastHealTimestamp() > 0)
|
||||
{
|
||||
double cooldown = ess.getSettings().getHealCooldown();
|
||||
Calendar cooldownTime = new GregorianCalendar();
|
||||
final double cooldown = ess.getSettings().getHealCooldown();
|
||||
final Calendar cooldownTime = new GregorianCalendar();
|
||||
cooldownTime.setTimeInMillis(getLastHealTimestamp());
|
||||
cooldownTime.add(Calendar.SECOND, (int)cooldown);
|
||||
cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
|
||||
@@ -78,54 +88,74 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
setLastHealTimestamp(now.getTimeInMillis());
|
||||
}
|
||||
|
||||
public void giveMoney(double value)
|
||||
@Override
|
||||
public void giveMoney(final double value)
|
||||
{
|
||||
giveMoney(value, null);
|
||||
}
|
||||
|
||||
public void giveMoney(final double value, final CommandSender initiator)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
setMoney(getMoney() + value);
|
||||
sendMessage(Util.format("addedToAccount", Util.formatCurrency(value)));
|
||||
sendMessage(Util.format("addedToAccount", Util.formatCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage(Util.format("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
||||
public void payUser(User reciever, double value) throws Exception
|
||||
public void payUser(final User reciever, final double value) throws Exception
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!canAfford(value))
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
else
|
||||
if (canAfford(value))
|
||||
{
|
||||
setMoney(getMoney() - value);
|
||||
reciever.setMoney(reciever.getMoney() + value);
|
||||
sendMessage(Util.format("moneySentTo", Util.formatCurrency(value), reciever.getDisplayName()));
|
||||
reciever.sendMessage(Util.format("moneyRecievedFrom", Util.formatCurrency(value), getDisplayName()));
|
||||
sendMessage(Util.format("moneySentTo", Util.formatCurrency(value, ess), reciever.getDisplayName()));
|
||||
reciever.sendMessage(Util.format("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
}
|
||||
|
||||
public void takeMoney(double value)
|
||||
@Override
|
||||
public void takeMoney(final double value)
|
||||
{
|
||||
takeMoney(value, null);
|
||||
}
|
||||
|
||||
public void takeMoney(final double value, final CommandSender initiator)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
setMoney(getMoney() - value);
|
||||
sendMessage(Util.format("takenFromAccount", Util.formatCurrency(value)));
|
||||
sendMessage(Util.format("takenFromAccount", Util.formatCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage(Util.format("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canAfford(double cost)
|
||||
public boolean canAfford(final double cost)
|
||||
{
|
||||
double mon = getMoney();
|
||||
final double mon = getMoney();
|
||||
return mon >= cost || isAuthorized("essentials.eco.loan");
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
this.base = new OfflinePlayer(getName());
|
||||
this.base = new OfflinePlayer(getName(), ess);
|
||||
}
|
||||
|
||||
public boolean getJustPortaled()
|
||||
@@ -133,35 +163,38 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return justPortaled;
|
||||
}
|
||||
|
||||
public void setJustPortaled(boolean value)
|
||||
public void setJustPortaled(final boolean value)
|
||||
{
|
||||
justPortaled = value;
|
||||
}
|
||||
|
||||
public void setReplyTo(CommandSender user)
|
||||
@Override
|
||||
public void setReplyTo(final CommandSender user)
|
||||
{
|
||||
replyTo = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSender getReplyTo()
|
||||
{
|
||||
return replyTo;
|
||||
}
|
||||
|
||||
public int compareTo(User t)
|
||||
@Override
|
||||
public int compareTo(final User other)
|
||||
{
|
||||
return ChatColor.stripColor(this.getDisplayName()).compareToIgnoreCase(ChatColor.stripColor(t.getDisplayName()));
|
||||
return ChatColor.stripColor(this.getDisplayName()).compareToIgnoreCase(ChatColor.stripColor(other.getDisplayName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
public boolean equals(final Object object)
|
||||
{
|
||||
if (!(o instanceof User))
|
||||
if (!(object instanceof User))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User) o).getDisplayName()));
|
||||
|
||||
return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User)object).getDisplayName()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -170,27 +203,33 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return ChatColor.stripColor(this.getDisplayName()).hashCode();
|
||||
}
|
||||
|
||||
public Boolean canSpawnItem(int itemId)
|
||||
public Boolean canSpawnItem(final int itemId)
|
||||
{
|
||||
return !ess.getSettings().itemSpawnBlacklist().contains(itemId);
|
||||
}
|
||||
|
||||
public Location getHome() throws Exception
|
||||
{
|
||||
return getHome(getHomes().get(0));
|
||||
}
|
||||
|
||||
public void setHome()
|
||||
{
|
||||
setHome(getLocation(), true);
|
||||
setHome("home", getLocation());
|
||||
}
|
||||
|
||||
public void setHome(boolean defaultHome)
|
||||
public void setHome(final String name)
|
||||
{
|
||||
setHome(getLocation(), defaultHome);
|
||||
setHome(name, getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastLocation()
|
||||
{
|
||||
setLastLocation(getLocation());
|
||||
}
|
||||
|
||||
public void requestTeleport(User player, boolean here)
|
||||
public void requestTeleport(final User player, final boolean here)
|
||||
{
|
||||
teleportRequester = player;
|
||||
teleportRequestHere = here;
|
||||
@@ -208,26 +247,42 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
|
||||
public String getNick()
|
||||
{
|
||||
String nickname = getNickname();
|
||||
if (ess.getSettings().isCommandDisabled("nick") || nickname == null || nickname.isEmpty() || nickname.equals(getName()))
|
||||
final StringBuilder nickname = new StringBuilder();
|
||||
final String nick = getNickname();
|
||||
if (ess.getSettings().isCommandDisabled("nick") || nick == null || nick.isEmpty() || nick.equals(getName()))
|
||||
{
|
||||
nickname = getName();
|
||||
nickname.append(getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
nickname = ess.getSettings().getNicknamePrefix() + nickname;
|
||||
nickname.append(ess.getSettings().getNicknamePrefix()).append(nick);
|
||||
}
|
||||
if (isOp())
|
||||
{
|
||||
try
|
||||
{
|
||||
nickname = ess.getSettings().getOperatorColor().toString() + nickname + "§f";
|
||||
nickname.insert(0, ess.getSettings().getOperatorColor().toString());
|
||||
nickname.append("§f");
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
return nickname;
|
||||
|
||||
if (ess.getSettings().addPrefixSuffix())
|
||||
{
|
||||
final String prefix = ess.getPermissionsHandler().getPrefix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
||||
final String suffix = ess.getPermissionsHandler().getSuffix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
||||
|
||||
nickname.insert(0, prefix);
|
||||
nickname.append(suffix);
|
||||
if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§"))
|
||||
{
|
||||
nickname.append("§f");
|
||||
}
|
||||
}
|
||||
|
||||
return nickname.toString();
|
||||
}
|
||||
|
||||
public Teleport getTeleport()
|
||||
@@ -235,49 +290,51 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return teleport;
|
||||
}
|
||||
|
||||
public long getLastActivity()
|
||||
public long getLastOnlineActivity()
|
||||
{
|
||||
return lastActivity;
|
||||
return lastOnlineActivity;
|
||||
}
|
||||
|
||||
public void setLastActivity(long timestamp)
|
||||
public void setLastOnlineActivity(final long timestamp)
|
||||
{
|
||||
lastActivity = timestamp;
|
||||
lastOnlineActivity = timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMoney()
|
||||
{
|
||||
if (ess.isRegisterFallbackEnabled() && ess.getPaymentMethod().hasMethod())
|
||||
if (ess.getPaymentMethod().hasMethod())
|
||||
{
|
||||
try
|
||||
{
|
||||
Method method = ess.getPaymentMethod().getMethod();
|
||||
if (!method.hasAccount(this.getName())) {
|
||||
final Method method = ess.getPaymentMethod().getMethod();
|
||||
if (!method.hasAccount(this.getName()))
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
return account.balance();
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
{
|
||||
}
|
||||
}
|
||||
return super.getMoney();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMoney(double value)
|
||||
public void setMoney(final double value)
|
||||
{
|
||||
if (ess.isRegisterFallbackEnabled() && ess.getPaymentMethod().hasMethod())
|
||||
if (ess.getPaymentMethod().hasMethod())
|
||||
{
|
||||
try
|
||||
{
|
||||
Method method = ess.getPaymentMethod().getMethod();
|
||||
if (!method.hasAccount(this.getName())) {
|
||||
final Method method = ess.getPaymentMethod().getMethod();
|
||||
if (!method.hasAccount(this.getName()))
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
account.set(value);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
@@ -286,4 +343,143 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
}
|
||||
super.setMoney(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAfk(final boolean set)
|
||||
{
|
||||
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
|
||||
if (set && !isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
godStateBeforeAfk = isGodModeEnabled();
|
||||
setGodModeEnabled(true);
|
||||
}
|
||||
if (!set && isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
setGodModeEnabled(godStateBeforeAfk);
|
||||
}
|
||||
if (set && !isAfk()) {
|
||||
afkPosition = getLocation();
|
||||
}
|
||||
super.setAfk(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggleAfk()
|
||||
{
|
||||
final boolean now = super.toggleAfk();
|
||||
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : now);
|
||||
return now;
|
||||
}
|
||||
|
||||
public boolean isHidden()
|
||||
{
|
||||
return hidden;
|
||||
}
|
||||
|
||||
public void setHidden(final boolean hidden)
|
||||
{
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
//Returns true if status expired during this check
|
||||
public boolean checkJailTimeout(final long currentTime)
|
||||
{
|
||||
if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed())
|
||||
{
|
||||
setJailTimeout(0);
|
||||
setJailed(false);
|
||||
sendMessage(Util.i18n("haveBeenReleased"));
|
||||
setJail(null);
|
||||
try
|
||||
{
|
||||
getTeleport().back();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//Returns true if status expired during this check
|
||||
public boolean checkMuteTimeout(final long currentTime)
|
||||
{
|
||||
if (getMuteTimeout() > 0 && getMuteTimeout() < currentTime && isMuted())
|
||||
{
|
||||
setMuteTimeout(0);
|
||||
sendMessage(Util.i18n("canTalkAgain"));
|
||||
setMuted(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//Returns true if status expired during this check
|
||||
public boolean checkBanTimeout(final long currentTime)
|
||||
{
|
||||
if (getBanTimeout() > 0 && getBanTimeout() < currentTime && isBanned())
|
||||
{
|
||||
setBanTimeout(0);
|
||||
setBanned(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void updateActivity(final boolean broadcast)
|
||||
{
|
||||
if (isAfk())
|
||||
{
|
||||
setAfk(false);
|
||||
if (broadcast && !isHidden())
|
||||
{
|
||||
ess.broadcastMessage(this, Util.format("userIsNotAway", getDisplayName()));
|
||||
}
|
||||
}
|
||||
lastActivity = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void checkActivity()
|
||||
{
|
||||
final long autoafkkick = ess.getSettings().getAutoAfkKick();
|
||||
if (autoafkkick > 0 && lastActivity + autoafkkick * 1000 < System.currentTimeMillis()
|
||||
&& !isHidden() && !isAuthorized("essentials.kick.exempt") && !isAuthorized("essentials.afk.kickexempt"))
|
||||
{
|
||||
final String kickReason = Util.format("autoAfkKickReason", autoafkkick / 60.0);
|
||||
kickPlayer(kickReason);
|
||||
|
||||
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
if (user.isAuthorized("essentials.kick.notify"))
|
||||
{
|
||||
player.sendMessage(Util.format("playerKicked", Console.NAME, getName(), kickReason));
|
||||
}
|
||||
}
|
||||
}
|
||||
final long autoafk = ess.getSettings().getAutoAfk();
|
||||
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis())
|
||||
{
|
||||
setAfk(true);
|
||||
if (!isHidden()) {
|
||||
ess.broadcastMessage(this, Util.format("userIsAway", getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Location getAfkPosition()
|
||||
{
|
||||
return afkPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggleGodModeEnabled()
|
||||
{
|
||||
if (!isGodModeEnabled()) {
|
||||
setFoodLevel(20);
|
||||
}
|
||||
return super.toggleGodModeEnabled();
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
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.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -36,7 +35,8 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.load();
|
||||
money = _getMoney();
|
||||
unlimited = _getUnlimited();
|
||||
powertools = getPowertools();
|
||||
powertools = _getPowertools();
|
||||
homes = _getHomes();
|
||||
lastLocation = _getLastLocation();
|
||||
lastTeleportTimestamp = _getLastTeleportTimestamp();
|
||||
lastHealTimestamp = _getLastHealTimestamp();
|
||||
@@ -57,19 +57,22 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
geolocation = _getGeoLocation();
|
||||
isSocialSpyEnabled = _isSocialSpyEnabled();
|
||||
isNPC = _isNPC();
|
||||
arePowerToolsEnabled = _arePowerToolsEnabled();
|
||||
}
|
||||
|
||||
private double money;
|
||||
|
||||
private double _getMoney() {
|
||||
|
||||
private double _getMoney()
|
||||
{
|
||||
double money = ess.getSettings().getStartingBalance();
|
||||
if (config.hasProperty("money"))
|
||||
{
|
||||
return config.getDouble("money", ess.getSettings().getStartingBalance());
|
||||
money = config.getDouble("money", money);
|
||||
}
|
||||
else
|
||||
if (Math.abs(money) > ess.getSettings().getMaxMoney())
|
||||
{
|
||||
return ess.getSettings().getStartingBalance();
|
||||
money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney();
|
||||
}
|
||||
return money;
|
||||
}
|
||||
|
||||
public double getMoney()
|
||||
@@ -80,9 +83,98 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
public void setMoney(double value)
|
||||
{
|
||||
money = value;
|
||||
if (Math.abs(money) > ess.getSettings().getMaxMoney())
|
||||
{
|
||||
money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney();
|
||||
}
|
||||
config.setProperty("money", value);
|
||||
config.save();
|
||||
}
|
||||
private Map<String, Object> homes;
|
||||
|
||||
private Map<String, Object> _getHomes()
|
||||
{
|
||||
Object o = config.getProperty("homes");
|
||||
|
||||
if (o instanceof Map)
|
||||
{
|
||||
return (Map<String, Object>)o;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Location getHome(String name) throws Exception
|
||||
{
|
||||
Location loc = config.getLocation("homes." + name, getServer());
|
||||
if (loc == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
loc = config.getLocation("homes." + getHomes().get(Integer.parseInt(name) - 1), getServer());
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return loc;
|
||||
}
|
||||
|
||||
public Location getHome(Location world) throws Exception
|
||||
{
|
||||
Location loc;
|
||||
for (String home : getHomes())
|
||||
{
|
||||
loc = config.getLocation("homes." + home, getServer());
|
||||
if (world.getWorld() == loc.getWorld())
|
||||
{
|
||||
return loc;
|
||||
}
|
||||
|
||||
}
|
||||
loc = config.getLocation("homes." + getHomes().get(0), getServer());
|
||||
return loc;
|
||||
}
|
||||
|
||||
public List<String> getHomes()
|
||||
{
|
||||
List<String> list = new ArrayList(homes.keySet());
|
||||
return list;
|
||||
|
||||
}
|
||||
|
||||
public void setHome(String name, Location loc)
|
||||
{
|
||||
//Invalid names will corrupt the yaml
|
||||
name = Util.sanitizeFileName(name);
|
||||
homes.put(name, loc);
|
||||
config.setProperty("homes." + name, loc);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public void delHome(String name) throws Exception
|
||||
{
|
||||
if (getHome(name) != null)
|
||||
{
|
||||
homes.remove(name);
|
||||
config.removeProperty("homes." + name);
|
||||
config.save();
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO: move this message to messages file
|
||||
throw new Exception("Home " + name + " doesn't exist");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasHome()
|
||||
{
|
||||
@@ -92,40 +184,6 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Location getHome(Location location)
|
||||
{
|
||||
if (!hasHome())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
World world = location.getWorld();
|
||||
String worldHome = "home.worlds." + world.getName().toLowerCase();
|
||||
if (!config.hasProperty(worldHome))
|
||||
{
|
||||
String defaultWorld = config.getString("home.default");
|
||||
worldHome = "home.worlds." + defaultWorld;
|
||||
}
|
||||
Location loc = config.getLocation(worldHome, getServer());
|
||||
return loc;
|
||||
}
|
||||
|
||||
public void setHome(Location loc, boolean b)
|
||||
{
|
||||
String worldName = loc.getWorld().getName().toLowerCase();
|
||||
if (worldName == null || worldName.isEmpty())
|
||||
{
|
||||
logger.log(Level.WARNING, Util.i18n("emptyWorldName"));
|
||||
return;
|
||||
}
|
||||
if (b || !config.hasProperty("home.default"))
|
||||
{
|
||||
config.setProperty("home.default", worldName);
|
||||
}
|
||||
|
||||
config.setProperty("home.worlds." + worldName, loc);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public String getNickname()
|
||||
{
|
||||
@@ -167,46 +225,66 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("unlimited", unlimited);
|
||||
config.save();
|
||||
}
|
||||
private Map<Integer, String> powertools;
|
||||
private Map<Integer, Object> powertools;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<Integer, String> getPowertools()
|
||||
private Map<Integer, Object> _getPowertools()
|
||||
{
|
||||
Object o = config.getProperty("powertools");
|
||||
|
||||
if (o instanceof Map)
|
||||
{
|
||||
return (Map<Integer, String>)o;
|
||||
return (Map<Integer, Object>)o;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new HashMap<Integer, String>();
|
||||
return new HashMap<Integer, Object>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getPowertool(ItemStack stack)
|
||||
public void clearAllPowertools() {
|
||||
powertools.clear();
|
||||
config.setProperty("powertools", powertools);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public List<String> getPowertool(ItemStack stack)
|
||||
{
|
||||
return powertools.get(stack.getTypeId());
|
||||
return (List<String>)powertools.get(stack.getTypeId());
|
||||
}
|
||||
|
||||
public void setPowertool(ItemStack stack, String command)
|
||||
public void setPowertool(ItemStack stack, List<String> commandList)
|
||||
{
|
||||
if (command == null || command.isEmpty())
|
||||
if (commandList == null || commandList.isEmpty())
|
||||
{
|
||||
powertools.remove(stack.getTypeId());
|
||||
}
|
||||
else
|
||||
{
|
||||
powertools.put(stack.getTypeId(), command);
|
||||
powertools.put(stack.getTypeId(), commandList);
|
||||
}
|
||||
config.setProperty("powertools", powertools);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean hasPowerTools()
|
||||
{
|
||||
return powertools.size() > 0;
|
||||
}
|
||||
|
||||
private Location lastLocation;
|
||||
|
||||
private Location _getLastLocation()
|
||||
{
|
||||
return config.getLocation("lastlocation", getServer());
|
||||
try
|
||||
{
|
||||
return config.getLocation("lastlocation", getServer());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Location getLastLocation()
|
||||
@@ -324,7 +402,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
private ItemStack[] _getSavedInventory()
|
||||
{
|
||||
int size = config.getInt("inventory.size", 0);
|
||||
if (size < 1 || size > getInventory().getSize())
|
||||
if (size < 1 || (getInventory() != null && size > getInventory().getSize()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -383,6 +461,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
setTeleportEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean toggleSocialSpy()
|
||||
{
|
||||
boolean ret = !isSocialSpyEnabled();
|
||||
@@ -622,7 +701,6 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
setAfk(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private boolean newplayer;
|
||||
|
||||
private boolean getNew()
|
||||
@@ -641,7 +719,6 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("newplayer", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
private String geolocation;
|
||||
|
||||
private String _getGeoLocation()
|
||||
@@ -668,42 +745,67 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
|
||||
private boolean isSocialSpyEnabled;
|
||||
|
||||
|
||||
private boolean _isSocialSpyEnabled()
|
||||
{
|
||||
return config.getBoolean("socialspy", false);
|
||||
}
|
||||
|
||||
|
||||
public boolean isSocialSpyEnabled()
|
||||
{
|
||||
return isSocialSpyEnabled;
|
||||
}
|
||||
|
||||
|
||||
public void setSocialSpyEnabled(boolean status)
|
||||
{
|
||||
isSocialSpyEnabled = status;
|
||||
config.setProperty("socialspy", status);
|
||||
config.save();
|
||||
}
|
||||
|
||||
private boolean isNPC;
|
||||
|
||||
|
||||
private boolean _isNPC()
|
||||
{
|
||||
return config.getBoolean("npc", false);
|
||||
}
|
||||
|
||||
|
||||
public boolean isNPC()
|
||||
{
|
||||
return isNPC;
|
||||
}
|
||||
|
||||
|
||||
public void setNPC(boolean set)
|
||||
{
|
||||
isNPC = set;
|
||||
config.setProperty("npc", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
private boolean arePowerToolsEnabled;
|
||||
|
||||
public boolean arePowerToolsEnabled()
|
||||
{
|
||||
return arePowerToolsEnabled;
|
||||
}
|
||||
|
||||
public void setPowerToolsEnabled(boolean set)
|
||||
{
|
||||
arePowerToolsEnabled = set;
|
||||
config.setProperty("powertoolsenabled", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean togglePowerToolsEnabled()
|
||||
{
|
||||
boolean ret = !arePowerToolsEnabled();
|
||||
setPowerToolsEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private boolean _arePowerToolsEnabled()
|
||||
{
|
||||
return config.getBoolean("powertoolsenabled", true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ComputationException;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class UserMap implements Function<String, User>, IConf
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
private final transient ConcurrentMap<String, User> users = new MapMaker().softValues().makeComputingMap(this);
|
||||
|
||||
public UserMap(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
loadAllUsersAsync(ess);
|
||||
}
|
||||
|
||||
private void loadAllUsersAsync(final IEssentials ess)
|
||||
{
|
||||
ess.scheduleAsyncDelayedTask(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final File userdir = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdir.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (String string : userdir.list())
|
||||
{
|
||||
if (!string.endsWith(".yml"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final String name = string.substring(0, string.length() - 4);
|
||||
try
|
||||
{
|
||||
users.get(name.toLowerCase());
|
||||
}
|
||||
catch (NullPointerException ex)
|
||||
{
|
||||
// Ignore these
|
||||
}
|
||||
catch (ComputationException ex)
|
||||
{
|
||||
Bukkit.getLogger().log(Level.INFO, "Failed to preload user "+name, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean userExists(final String name)
|
||||
{
|
||||
return users.containsKey(name.toLowerCase());
|
||||
}
|
||||
|
||||
public User getUser(final String name) throws NullPointerException
|
||||
{
|
||||
return users.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public User apply(final String name)
|
||||
{
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
if (player.getName().equalsIgnoreCase(name))
|
||||
{
|
||||
return new User(player, ess);
|
||||
}
|
||||
}
|
||||
final File userFolder = new File(ess.getDataFolder(), "userdata");
|
||||
final File userFile = new File(userFolder, Util.sanitizeFileName(name) + ".yml");
|
||||
if (userFile.exists())
|
||||
{
|
||||
return new User(new OfflinePlayer(name, ess), ess);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
for (User user : users.values())
|
||||
{
|
||||
user.reloadConfig();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeUser(final String name)
|
||||
{
|
||||
users.remove(name.toLowerCase());
|
||||
}
|
||||
|
||||
public Set<User> getAllUsers()
|
||||
{
|
||||
final Set<User> userSet = new HashSet<User>();
|
||||
for (String name : users.keySet())
|
||||
{
|
||||
userSet.add(users.get(name));
|
||||
}
|
||||
return userSet;
|
||||
}
|
||||
|
||||
public int getUniqueUsers()
|
||||
{
|
||||
return users.size();
|
||||
}
|
||||
}
|
||||
@@ -14,9 +14,12 @@ import java.text.MessageFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Enumeration;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -216,55 +219,93 @@ public class Util
|
||||
return c.getTimeInMillis();
|
||||
}
|
||||
|
||||
public static Location getSafeDestination(Location loc) throws Exception
|
||||
// The player can stand inside these materials
|
||||
private static final Set<Integer> AIR_MATERIALS = new HashSet<Integer>();
|
||||
|
||||
static {
|
||||
AIR_MATERIALS.add(Material.AIR.getId());
|
||||
AIR_MATERIALS.add(Material.SAPLING.getId());
|
||||
AIR_MATERIALS.add(Material.POWERED_RAIL.getId());
|
||||
AIR_MATERIALS.add(Material.DETECTOR_RAIL.getId());
|
||||
AIR_MATERIALS.add(Material.DEAD_BUSH.getId());
|
||||
AIR_MATERIALS.add(Material.RAILS.getId());
|
||||
AIR_MATERIALS.add(Material.YELLOW_FLOWER.getId());
|
||||
AIR_MATERIALS.add(Material.RED_ROSE.getId());
|
||||
AIR_MATERIALS.add(Material.RED_MUSHROOM.getId());
|
||||
AIR_MATERIALS.add(Material.BROWN_MUSHROOM.getId());
|
||||
AIR_MATERIALS.add(Material.SEEDS.getId());
|
||||
AIR_MATERIALS.add(Material.SIGN_POST.getId());
|
||||
AIR_MATERIALS.add(Material.WALL_SIGN.getId());
|
||||
AIR_MATERIALS.add(Material.LADDER.getId());
|
||||
AIR_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId());
|
||||
AIR_MATERIALS.add(Material.REDSTONE_WIRE.getId());
|
||||
AIR_MATERIALS.add(Material.REDSTONE_TORCH_OFF.getId());
|
||||
AIR_MATERIALS.add(Material.REDSTONE_TORCH_ON.getId());
|
||||
AIR_MATERIALS.add(Material.TORCH.getId());
|
||||
AIR_MATERIALS.add(Material.SOIL.getId());
|
||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId());
|
||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_ON.getId());
|
||||
AIR_MATERIALS.add(Material.TRAP_DOOR.getId());
|
||||
AIR_MATERIALS.add(Material.STONE_BUTTON.getId());
|
||||
AIR_MATERIALS.add(Material.STONE_PLATE.getId());
|
||||
AIR_MATERIALS.add(Material.WOOD_PLATE.getId());
|
||||
AIR_MATERIALS.add(Material.IRON_DOOR_BLOCK.getId());
|
||||
AIR_MATERIALS.add(Material.WOODEN_DOOR.getId());
|
||||
}
|
||||
|
||||
public static Location getSafeDestination(final Location loc) throws Exception
|
||||
{
|
||||
if (loc == null)
|
||||
if (loc == null || loc.getWorld() == null)
|
||||
{
|
||||
throw new Exception(Util.i18n("destinationNotSet"));
|
||||
}
|
||||
World world = loc.getWorld();
|
||||
double x = Math.floor(loc.getX()) + 0.5;
|
||||
double y = Math.floor(loc.getY());
|
||||
double z = Math.floor(loc.getZ()) + 0.5;
|
||||
|
||||
final World world = loc.getWorld();
|
||||
int x = (int)Math.round(loc.getX());
|
||||
int y = (int)Math.round(loc.getY());
|
||||
int z = (int)Math.round(loc.getZ());
|
||||
|
||||
while (isBlockAboveAir(world, x, y, z))
|
||||
{
|
||||
y -= 1.0D;
|
||||
if (y < 0.0D)
|
||||
y -= 1;
|
||||
if (y < 0)
|
||||
{
|
||||
throw new Exception(Util.i18n("holeInFloor"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (isBlockUnsafe(world, x, y, z))
|
||||
{
|
||||
y += 1.0D;
|
||||
if (y >= 110.0D)
|
||||
y += 1;
|
||||
if (y >= 127)
|
||||
{
|
||||
x += 1.0D;
|
||||
x += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (isBlockUnsafe(world, x, y, z))
|
||||
{
|
||||
y -= 1.0D;
|
||||
if (y <= 1.0D)
|
||||
y -= 1;
|
||||
if (y <= 1)
|
||||
{
|
||||
y = 110.0D;
|
||||
x += 1.0D;
|
||||
y = 127;
|
||||
x += 1;
|
||||
if (x - 32 > loc.getBlockX())
|
||||
{
|
||||
throw new Exception(Util.i18n("holeInFloor"));
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Location(world, x, y, z, loc.getYaw(), loc.getPitch());
|
||||
return new Location(world, x + 0.5D, y, z + 0.5D, loc.getYaw(), loc.getPitch());
|
||||
}
|
||||
|
||||
private static boolean isBlockAboveAir(World world, double x, double y, double z)
|
||||
private static boolean isBlockAboveAir(final World world, final int x, final int y, final int z)
|
||||
{
|
||||
return world.getBlockAt((int)Math.floor(x), (int)Math.floor(y - 1.0D), (int)Math.floor(z)).getType() == Material.AIR;
|
||||
return AIR_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType().getId());
|
||||
}
|
||||
|
||||
public static boolean isBlockUnsafe(World world, double x, double y, double z)
|
||||
public static boolean isBlockUnsafe(final World world, final int x, final int y, final int z)
|
||||
{
|
||||
Block below = world.getBlockAt((int)Math.floor(x), (int)Math.floor(y - 1.0D), (int)Math.floor(z));
|
||||
final Block below = world.getBlockAt(x, y - 1, z);
|
||||
if (below.getType() == Material.LAVA || below.getType() == Material.STATIONARY_LAVA)
|
||||
{
|
||||
return true;
|
||||
@@ -275,8 +316,8 @@ public class Util
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((world.getBlockAt((int)Math.floor(x), (int)Math.floor(y), (int)Math.floor(z)).getType() != Material.AIR)
|
||||
|| (world.getBlockAt((int)Math.floor(x), (int)Math.floor(y + 1.0D), (int)Math.floor(z)).getType() != Material.AIR))
|
||||
if ((!AIR_MATERIALS.contains(world.getBlockAt(x, y, z).getType().getId()))
|
||||
|| (!AIR_MATERIALS.contains(world.getBlockAt(x, y + 1, z).getType().getId())))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -284,9 +325,9 @@ public class Util
|
||||
}
|
||||
private static DecimalFormat df = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
|
||||
|
||||
public static String formatCurrency(double value)
|
||||
public static String formatCurrency(final double value, final IEssentials ess)
|
||||
{
|
||||
String str = Essentials.getStatic().getSettings().getCurrencySymbol() + df.format(value);
|
||||
String str = ess.getSettings().getCurrencySymbol() + df.format(value);
|
||||
if (str.endsWith(".00"))
|
||||
{
|
||||
str = str.substring(0, str.length() - 3);
|
||||
@@ -294,7 +335,7 @@ public class Util
|
||||
return str;
|
||||
}
|
||||
|
||||
public static double roundDouble(double d)
|
||||
public static double roundDouble(final double d)
|
||||
{
|
||||
return Math.round(d * 100.0) / 100.0;
|
||||
}
|
||||
@@ -307,19 +348,21 @@ public class Util
|
||||
|
||||
private static class ConfigClassLoader extends ClassLoader
|
||||
{
|
||||
private final File dataFolder;
|
||||
private final ClassLoader cl;
|
||||
private final transient File dataFolder;
|
||||
private final transient ClassLoader cl;
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public ConfigClassLoader(File dataFolder, ClassLoader cl)
|
||||
public ConfigClassLoader(final ClassLoader cl, final IEssentials ess)
|
||||
{
|
||||
this.dataFolder = dataFolder;
|
||||
this.ess = ess;
|
||||
this.dataFolder = ess.getDataFolder();
|
||||
this.cl = cl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getResource(String string)
|
||||
public URL getResource(final String string)
|
||||
{
|
||||
File file = new File(dataFolder, string);
|
||||
final File file = new File(dataFolder, string);
|
||||
if (file.exists())
|
||||
{
|
||||
try
|
||||
@@ -341,17 +384,18 @@ public class Util
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getResourceAsStream(String string)
|
||||
public InputStream getResourceAsStream(final String string)
|
||||
{
|
||||
File file = new File(dataFolder, string);
|
||||
final File file = new File(dataFolder, string);
|
||||
if (file.exists())
|
||||
{
|
||||
BufferedReader br = null;
|
||||
try
|
||||
{
|
||||
BufferedReader br = new BufferedReader(new FileReader(file));
|
||||
String version = br.readLine();
|
||||
br.close();
|
||||
if (version == null || !version.equals("#version: " + Essentials.getStatic().getDescription().getVersion()))
|
||||
br = new BufferedReader(new FileReader(file));
|
||||
final String version = br.readLine();
|
||||
|
||||
if (version == null || !version.equals("#version: " + ess.getDescription().getVersion()))
|
||||
{
|
||||
logger.log(Level.WARNING, String.format("Translation file %s is not updated for Essentials version. Will use default.", file));
|
||||
return cl.getResourceAsStream(string);
|
||||
@@ -362,36 +406,49 @@ public class Util
|
||||
{
|
||||
return cl.getResourceAsStream(string);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (br != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
br.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return cl.getResourceAsStream(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<URL> getResources(String string) throws IOException
|
||||
public Enumeration<URL> getResources(final String string) throws IOException
|
||||
{
|
||||
return cl.getResources(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> loadClass(String string) throws ClassNotFoundException
|
||||
public Class<?> loadClass(final String string) throws ClassNotFoundException
|
||||
{
|
||||
return cl.loadClass(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setClassAssertionStatus(String string, boolean bln)
|
||||
public synchronized void setClassAssertionStatus(final String string, final boolean bln)
|
||||
{
|
||||
cl.setClassAssertionStatus(string, bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setDefaultAssertionStatus(boolean bln)
|
||||
public synchronized void setDefaultAssertionStatus(final boolean bln)
|
||||
{
|
||||
cl.setDefaultAssertionStatus(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setPackageAssertionStatus(String string, boolean bln)
|
||||
public synchronized void setPackageAssertionStatus(final String string, final boolean bln)
|
||||
{
|
||||
cl.setPackageAssertionStatus(string, bln);
|
||||
}
|
||||
@@ -420,7 +477,7 @@ public class Util
|
||||
return mf.format(objects);
|
||||
}
|
||||
|
||||
public static void updateLocale(String loc, File dataFolder)
|
||||
public static void updateLocale(String loc, IEssentials ess)
|
||||
{
|
||||
if (loc == null || loc.isEmpty())
|
||||
{
|
||||
@@ -440,10 +497,49 @@ public class Util
|
||||
currentLocale = new Locale(parts[0], parts[1], parts[2]);
|
||||
}
|
||||
logger.log(Level.INFO, String.format("Using locale %s", currentLocale.toString()));
|
||||
bundle = ResourceBundle.getBundle("messages", currentLocale, new ConfigClassLoader(dataFolder, Util.class.getClassLoader()));
|
||||
bundle = ResourceBundle.getBundle("messages", currentLocale, new ConfigClassLoader(Util.class.getClassLoader(), ess));
|
||||
if (!bundle.keySet().containsAll(defaultBundle.keySet()))
|
||||
{
|
||||
logger.log(Level.WARNING, String.format("Translation file %s does not contain all translation keys.", currentLocale.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public static String joinList(Object... list)
|
||||
{
|
||||
return joinList(", ", list);
|
||||
}
|
||||
|
||||
public static String joinList(String seperator, Object... list)
|
||||
{
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (Object each : list)
|
||||
{
|
||||
if (buf.length() > 0)
|
||||
{
|
||||
buf.append(seperator);
|
||||
}
|
||||
|
||||
if(each instanceof List)
|
||||
{
|
||||
buf.append(joinList(seperator, ((List)each).toArray()));
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
buf.append(each.toString());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
buf.append(each.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public static String capitalCase(String s)
|
||||
{
|
||||
return s.toUpperCase().charAt(0) + s.toLowerCase().substring(1);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.earth2me.essentials;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -35,9 +36,9 @@ public class Warps implements IConf
|
||||
return warpPoints.isEmpty();
|
||||
}
|
||||
|
||||
public Iterable<String> getWarpNames()
|
||||
public Collection<String> getWarpNames()
|
||||
{
|
||||
List<String> keys = new ArrayList<String>();
|
||||
final List<String> keys = new ArrayList<String>();
|
||||
for (StringIgnoreCase stringIgnoreCase : warpPoints.keySet())
|
||||
{
|
||||
keys.add(stringIgnoreCase.getString());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.EssentialsConf;
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.io.File;
|
||||
@@ -9,6 +9,7 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
/**
|
||||
* Instead of using this api directly, we recommend to use the register plugin:
|
||||
* http://bit.ly/RegisterMethod
|
||||
@@ -19,10 +20,19 @@ public final class Economy
|
||||
{
|
||||
}
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private static IEssentials ess;
|
||||
|
||||
/**
|
||||
* @param aEss the ess to set
|
||||
*/
|
||||
public static void setEss(IEssentials aEss)
|
||||
{
|
||||
ess = aEss;
|
||||
}
|
||||
|
||||
private static void createNPCFile(String name)
|
||||
{
|
||||
File folder = new File(Essentials.getStatic().getDataFolder(), "userdata");
|
||||
File folder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!folder.exists())
|
||||
{
|
||||
folder.mkdirs();
|
||||
@@ -30,13 +40,13 @@ public final class Economy
|
||||
EssentialsConf npcConfig = new EssentialsConf(new File(folder, Util.sanitizeFileName(name) + ".yml"));
|
||||
npcConfig.load();
|
||||
npcConfig.setProperty("npc", true);
|
||||
npcConfig.setProperty("money", Essentials.getStatic().getSettings().getStartingBalance());
|
||||
npcConfig.setProperty("money", ess.getSettings().getStartingBalance());
|
||||
npcConfig.save();
|
||||
}
|
||||
|
||||
|
||||
private static void deleteNPC(String name)
|
||||
{
|
||||
File folder = new File(Essentials.getStatic().getDataFolder(), "userdata");
|
||||
File folder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!folder.exists())
|
||||
{
|
||||
folder.mkdirs();
|
||||
@@ -44,24 +54,27 @@ public final class Economy
|
||||
File config = new File(folder, Util.sanitizeFileName(name) + ".yml");
|
||||
EssentialsConf npcConfig = new EssentialsConf(config);
|
||||
npcConfig.load();
|
||||
if (npcConfig.hasProperty("npc") && npcConfig.getBoolean("npc", false)) {
|
||||
if (!config.delete()) {
|
||||
if (npcConfig.hasProperty("npc") && npcConfig.getBoolean("npc", false))
|
||||
{
|
||||
if (!config.delete())
|
||||
{
|
||||
logger.log(Level.WARNING, Util.format("deleteFileError", config));
|
||||
}
|
||||
ess.getUserMap().removeUser(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static User getUserByName(String name)
|
||||
{
|
||||
User user;
|
||||
Player player = Essentials.getStatic().getServer().getPlayer(name);
|
||||
Player player = ess.getServer().getPlayer(name);
|
||||
if (player != null)
|
||||
{
|
||||
user = Essentials.getStatic().getUser(player);
|
||||
user = ess.getUser(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
user = Essentials.getStatic().getOfflineUser(name);
|
||||
user = ess.getOfflineUser(name);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
@@ -75,7 +88,8 @@ public final class Economy
|
||||
public static double getMoney(String name) throws UserDoesNotExistException
|
||||
{
|
||||
User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
if (user == null)
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
return user.getMoney();
|
||||
@@ -91,7 +105,8 @@ public final class Economy
|
||||
public static void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException
|
||||
{
|
||||
User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
if (user == null)
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
if (balance < 0.0 && !user.isAuthorized("essentials.eco.loan"))
|
||||
@@ -113,7 +128,7 @@ public final class Economy
|
||||
double result = getMoney(name) + amount;
|
||||
setMoney(name, result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Substracts money from the balance of a user
|
||||
* @param name Name of the user
|
||||
@@ -161,7 +176,7 @@ public final class Economy
|
||||
*/
|
||||
public static void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException
|
||||
{
|
||||
setMoney(name, Essentials.getStatic().getSettings().getStartingBalance());
|
||||
setMoney(name, ess.getSettings().getStartingBalance());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,18 +231,19 @@ public final class Economy
|
||||
*/
|
||||
public static String format(double amount)
|
||||
{
|
||||
return Util.formatCurrency(amount);
|
||||
return Util.formatCurrency(amount, ess);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if a player exists to avoid the UserDoesNotExistException
|
||||
* @param name Name of the user
|
||||
* @return true, if the user exists
|
||||
*/
|
||||
public static boolean playerExists(String name) {
|
||||
public static boolean playerExists(String name)
|
||||
{
|
||||
return getUserByName(name) != null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if a player is a npc
|
||||
* @param name Name of the player
|
||||
@@ -237,12 +253,13 @@ public final class Economy
|
||||
public static boolean isNPC(String name) throws UserDoesNotExistException
|
||||
{
|
||||
User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
if (user == null)
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
return user.isNPC();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates dummy files for a npc, if there is no player yet with that name.
|
||||
* @param name Name of the player
|
||||
@@ -251,7 +268,8 @@ public final class Economy
|
||||
public static boolean createNPC(String name)
|
||||
{
|
||||
User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
if (user == null)
|
||||
{
|
||||
createNPCFile(name);
|
||||
return true;
|
||||
}
|
||||
@@ -266,7 +284,8 @@ public final class Economy
|
||||
public static void removeNPC(String name) throws UserDoesNotExistException
|
||||
{
|
||||
User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
if (user == null)
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
deleteNPC(name);
|
||||
|
||||
@@ -15,15 +15,38 @@ public class Commandafk extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
if (args.length > 0 && user.isAuthorized("essentials.afk.others"))
|
||||
{
|
||||
User afkUser = ess.getUser(ess.getServer().matchPlayer(args[0]));
|
||||
if (afkUser != null)
|
||||
{
|
||||
toggleAfk(afkUser);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
toggleAfk(user);
|
||||
}
|
||||
}
|
||||
|
||||
private final void toggleAfk(User user)
|
||||
{
|
||||
if (!user.toggleAfk())
|
||||
{
|
||||
user.sendMessage(Util.i18n("markedAsNotAway"));
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
|
||||
} else {
|
||||
user.sendMessage(Util.i18n("markedAsAway"));
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsAway", user.getDisplayName()));
|
||||
//user.sendMessage(Util.i18n("markedAsNotAway"));
|
||||
if (!user.isHidden())
|
||||
{
|
||||
ess.broadcastMessage(user, Util.format("userIsNotAway", user.getDisplayName()));
|
||||
}
|
||||
user.updateActivity(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
//user.sendMessage(Util.i18n("markedAsAway"));
|
||||
if (!user.isHidden())
|
||||
{
|
||||
ess.broadcastMessage(user, Util.format("userIsAway", user.getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import net.minecraft.server.EntityTNTPrimed;
|
||||
import net.minecraft.server.World;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.TargetBlock;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
||||
|
||||
public class Commandantioch extends EssentialsCommand
|
||||
@@ -17,17 +15,12 @@ public class Commandantioch extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
ess.broadcastMessage(user.getName(), "...lobbest thou thy Holy Hand Grenade of Antioch towards thy foe,");
|
||||
ess.broadcastMessage(user.getName(), "who being naughty in My sight, shall snuff it.");
|
||||
ess.broadcastMessage(user, "...lobbest thou thy Holy Hand Grenade of Antioch towards thy foe,");
|
||||
ess.broadcastMessage(user, "who being naughty in My sight, shall snuff it.");
|
||||
|
||||
Location loc = user.getLocation();
|
||||
World world = ((CraftWorld)user.getWorld()).getHandle();
|
||||
loc = new TargetBlock(user).getTargetBlock().getLocation();
|
||||
EntityTNTPrimed tnt = new EntityTNTPrimed(world, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
world.addEntity(tnt);
|
||||
world.makeSound(tnt, "random.fuse", 1.0F, 1.0F);
|
||||
final Location loc = new TargetBlock(user).getTargetBlock().getLocation();
|
||||
loc.getWorld().spawn(loc, TNTPrimed.class);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Charge;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
@@ -16,7 +16,7 @@ public class Commandback extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
Charge charge = new Charge(this.getName(), ess);
|
||||
Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.sendMessage(Util.i18n("backUsageMsg"));
|
||||
user.getTeleport().back(charge);
|
||||
|
||||
@@ -19,9 +19,8 @@ public class Commandbackup extends EssentialsCommand
|
||||
Backup backup = ess.getBackup();
|
||||
if (backup == null)
|
||||
{
|
||||
return;
|
||||
throw new Exception();
|
||||
}
|
||||
charge(sender);
|
||||
backup.run();
|
||||
sender.sendMessage(Util.i18n("backupStarted"));
|
||||
}
|
||||
|
||||
@@ -20,18 +20,17 @@ public class Commandbalance extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
sender.sendMessage(Util.format("balance", Util.formatCurrency(getPlayer(server, args, 0).getMoney())));
|
||||
sender.sendMessage(Util.format("balance", Util.formatCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
double bal = (args.length < 1
|
||||
|| !(user.isAuthorized("essentials.balance.others")
|
||||
|| user.isAuthorized("essentials.balance.other"))
|
||||
? user
|
||||
: getPlayer(server, args, 0)).getMoney();
|
||||
user.sendMessage(Util.format("balance", Util.formatCurrency(bal)));
|
||||
: getPlayer(server, args, 0, true)).getMoney();
|
||||
user.sendMessage(Util.format("balance", Util.formatCurrency(bal, ess)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandbalancetop extends EssentialsCommand
|
||||
{
|
||||
public Commandbalancetop()
|
||||
{
|
||||
super("balancetop");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
int max = 10;
|
||||
if (args.length > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Integer.parseInt(args[0]) < 10)
|
||||
{
|
||||
max = Integer.parseInt(args[0]);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
//catch it because they tried to enter a string not number.
|
||||
}
|
||||
}
|
||||
final Map<User, Double> balances = new HashMap<User, Double>();
|
||||
for (User u : ess.getUserMap().getAllUsers())
|
||||
{
|
||||
balances.put(u, u.getMoney());
|
||||
}
|
||||
|
||||
final List<Map.Entry<User, Double>> sortedEntries = new ArrayList<Map.Entry<User, Double>>(balances.entrySet());
|
||||
Collections.sort(sortedEntries, new Comparator<Map.Entry<User, Double>>()
|
||||
{
|
||||
public int compare(final Entry<User, Double> entry1, final Entry<User, Double> entry2)
|
||||
{
|
||||
return -entry1.getValue().compareTo(entry2.getValue());
|
||||
}
|
||||
});
|
||||
int count = 0;
|
||||
sender.sendMessage(Util.format("balanceTop", max));
|
||||
for (Map.Entry<User, Double> entry : sortedEntries)
|
||||
{
|
||||
if (count == max)
|
||||
{
|
||||
break;
|
||||
}
|
||||
sender.sendMessage(entry.getKey().getDisplayName() + ", " + Util.formatCurrency(entry.getValue(), ess));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Console;
|
||||
import com.earth2me.essentials.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandban extends EssentialsCommand
|
||||
@@ -15,31 +17,52 @@ public class Commandban extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
User p = null;
|
||||
if (server.matchPlayer(args[0]).isEmpty())
|
||||
final User player = getPlayer(server, args, 0, true);
|
||||
if (player.getBase() instanceof OfflinePlayer)
|
||||
{
|
||||
((CraftServer)server).getHandle().a(args[0]);
|
||||
sender.sendMessage(Util.format("playerBanned",args[0]));
|
||||
if (sender instanceof Player
|
||||
&& !ess.getUser(sender).isAuthorized("essentials.ban.offline"))
|
||||
{
|
||||
sender.sendMessage(Util.i18n("banExempt"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p = ess.getUser(server.matchPlayer(args[0]).get(0));
|
||||
String banReason = Util.i18n("defaultBanReason");
|
||||
if(args.length > 1) {
|
||||
banReason = getFinalArg(args, 1);
|
||||
p.setBanReason(commandLabel);
|
||||
if (player.isAuthorized("essentials.ban.exempt"))
|
||||
{
|
||||
sender.sendMessage(Util.i18n("banExempt"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
String banReason;
|
||||
if (args.length > 1)
|
||||
{
|
||||
banReason = getFinalArg(args, 1);
|
||||
player.setBanReason(commandLabel);
|
||||
}
|
||||
else
|
||||
{
|
||||
banReason = Util.i18n("defaultBanReason");
|
||||
}
|
||||
player.setBanned(true);
|
||||
player.kickPlayer(banReason);
|
||||
String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
|
||||
for(Player p : server.getOnlinePlayers())
|
||||
{
|
||||
User u = ess.getUser(p);
|
||||
if(u.isAuthorized("essentials.ban.notify"))
|
||||
{
|
||||
p.sendMessage(Util.format("playerBanned", senderName, player.getName(), banReason));
|
||||
}
|
||||
p.kickPlayer(banReason);
|
||||
((CraftServer)server).getHandle().a(p.getName());
|
||||
sender.sendMessage(Util.format("playerBanned", p.getName()));
|
||||
}
|
||||
ess.loadBanList();
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
|
||||
|
||||
public class Commandbanip extends EssentialsCommand
|
||||
@@ -21,9 +20,7 @@ public class Commandbanip extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
((CraftServer)server).getHandle().c(args[0]);
|
||||
ess.getServer().banIP(args[0]);
|
||||
sender.sendMessage(Util.i18n("banIpAddress"));
|
||||
ess.loadBanList();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.TargetBlock;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.TreeType;
|
||||
import com.earth2me.essentials.User;
|
||||
@@ -17,7 +18,7 @@ public class Commandbigtree extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
TreeType tree = TreeType.TREE;
|
||||
TreeType tree;
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("redwood"))
|
||||
{
|
||||
tree = TreeType.TALL_REDWOOD;
|
||||
@@ -31,39 +32,20 @@ public class Commandbigtree extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
double x = user.getLocation().getX();
|
||||
double y = user.getLocation().getY();
|
||||
double z = user.getLocation().getZ();
|
||||
|
||||
// offset tree in direction player is facing
|
||||
int r = (int)user.getCorrectedYaw();
|
||||
if (r < 68 || r > 292) // north
|
||||
final int[] ignore =
|
||||
{
|
||||
x -= 3.0D;
|
||||
}
|
||||
else if (r > 112 && r < 248) // south
|
||||
{
|
||||
x += 3.0D;
|
||||
}
|
||||
if (r > 22 && r < 158) // east
|
||||
{
|
||||
z -= 3.0D;
|
||||
}
|
||||
else if (r > 202 && r < 338) // west
|
||||
{
|
||||
z += 3.0D;
|
||||
}
|
||||
|
||||
Location safeLocation = Util.getSafeDestination(new Location(user.getWorld(), x, y, z));
|
||||
boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree);
|
||||
8, 9
|
||||
};
|
||||
final Location loc = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock().getLocation();
|
||||
final Location safeLocation = Util.getSafeDestination(loc);
|
||||
final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree);
|
||||
if (success)
|
||||
{
|
||||
charge(user);
|
||||
user.sendMessage(Util.i18n("bigTreeSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.i18n("bigTreeFailure"));
|
||||
throw new Exception(Util.i18n("bigTreeFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Console;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -15,15 +14,14 @@ public class Commandbroadcast extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
charge(sender);
|
||||
ess.broadcastMessage(sender instanceof Player ? ((Player)sender).getName() : Console.NAME,
|
||||
ess.broadcastMessage(null,
|
||||
Util.format("broadcast", getFinalArg(args, 0)));
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@ public class Commandburn extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
charge(sender);
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
{
|
||||
p.setFireTicks(Integer.parseInt(args[1]) * 20);
|
||||
|
||||
@@ -6,7 +6,6 @@ import org.bukkit.entity.Player;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.List;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
|
||||
public class Commandclearinventory extends EssentialsCommand
|
||||
@@ -21,13 +20,13 @@ 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)
|
||||
{
|
||||
List<Player> online = server.matchPlayer(args[0]);
|
||||
|
||||
if (!online.isEmpty())
|
||||
{
|
||||
charge(user);
|
||||
for (Player p : online)
|
||||
{
|
||||
p.getInventory().clear();
|
||||
@@ -42,7 +41,6 @@ public class Commandclearinventory extends EssentialsCommand
|
||||
Player p = server.getPlayer(args[0]);
|
||||
if (p != null)
|
||||
{
|
||||
charge(user);
|
||||
p.getInventory().clear();
|
||||
user.sendMessage(Util.format("inventoryClearedOthers", p.getDisplayName()));
|
||||
}
|
||||
@@ -54,7 +52,6 @@ public class Commandclearinventory extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
charge(user);
|
||||
user.getInventory().clear();
|
||||
user.sendMessage(Util.i18n("inventoryCleared"));
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ public class Commandcompass extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
int r = (int)user.getCorrectedYaw();
|
||||
String dir;
|
||||
if (r < 23) dir = "N";
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.Util;
|
||||
|
||||
|
||||
public class Commanddelhome extends EssentialsCommand
|
||||
{
|
||||
public Commanddelhome()
|
||||
{
|
||||
super("delhome");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
//Allowing both formats /delhome khobbits house | /delhome khobbits:house
|
||||
final String[] nameParts = args[0].split(":");
|
||||
if (nameParts[0].length() != args[0].length())
|
||||
{
|
||||
args = nameParts;
|
||||
}
|
||||
|
||||
User user = ess.getUser(sender);
|
||||
String name;
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
else if (args.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others")))
|
||||
{
|
||||
user = getPlayer(server, args, 0);
|
||||
name = args[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
name = args[0];
|
||||
}
|
||||
user.delHome(name.toLowerCase());
|
||||
sender.sendMessage(Util.format("deleteHome", name));
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,6 @@ public class Commanddeljail extends EssentialsCommand {
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
charge(sender);
|
||||
ess.getJail().delJail(args[0]);
|
||||
sender.sendMessage(Util.format("deleteJail", args[0]));
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ public class Commanddelwarp extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
charge(sender);
|
||||
ess.getWarps().delWarp(args[0]);
|
||||
sender.sendMessage(Util.format("deleteWarp", args[0]));
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ public class Commanddepth extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
int y = user.getLocation().getBlockY() - 63;
|
||||
if (y > 0)
|
||||
{
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.earth2me.essentials.User;
|
||||
|
||||
@@ -56,28 +55,24 @@ public class Commandeco extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Player p : server.matchPlayer(args[1]))
|
||||
User u = getPlayer(server, args, 1, true);
|
||||
switch (cmd)
|
||||
{
|
||||
User u = ess.getUser(p);
|
||||
switch (cmd)
|
||||
{
|
||||
case GIVE:
|
||||
u.giveMoney(amount);
|
||||
break;
|
||||
case GIVE:
|
||||
u.giveMoney(amount, sender);
|
||||
break;
|
||||
|
||||
case TAKE:
|
||||
u.takeMoney(amount);
|
||||
break;
|
||||
case TAKE:
|
||||
u.takeMoney(amount, sender);
|
||||
break;
|
||||
|
||||
case RESET:
|
||||
u.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
||||
break;
|
||||
}
|
||||
case RESET:
|
||||
u.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private enum EcoCommands
|
||||
{
|
||||
GIVE, TAKE, RESET
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandessentials extends EssentialsCommand
|
||||
@@ -11,12 +17,101 @@ public class Commandessentials extends EssentialsCommand
|
||||
{
|
||||
super("essentials");
|
||||
}
|
||||
private transient int taskid;
|
||||
private final transient Map<Player, Block> noteBlocks = new HashMap<Player, Block>();
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final Map<String, Byte> noteMap = new HashMap<String, Byte>();
|
||||
noteMap.put("1F#", (byte)0x0);
|
||||
noteMap.put("1G", (byte)0x1);
|
||||
noteMap.put("1G#", (byte)0x2);
|
||||
noteMap.put("1A", (byte)0x3);
|
||||
noteMap.put("1A#", (byte)0x4);
|
||||
noteMap.put("1B", (byte)0x5);
|
||||
noteMap.put("1C", (byte)0x6);
|
||||
noteMap.put("1C#", (byte)0x7);
|
||||
noteMap.put("1D", (byte)0x8);
|
||||
noteMap.put("1D#", (byte)0x9);
|
||||
noteMap.put("1E", (byte)0xA);
|
||||
noteMap.put("1F", (byte)0xB);
|
||||
noteMap.put("2F#", (byte)(0x0 + 0xC));
|
||||
noteMap.put("2G", (byte)(0x1 + 0xC));
|
||||
noteMap.put("2G#", (byte)(0x2 + 0xC));
|
||||
noteMap.put("2A", (byte)(0x3 + 0xC));
|
||||
noteMap.put("2A#", (byte)(0x4 + 0xC));
|
||||
noteMap.put("2B", (byte)(0x5 + 0xC));
|
||||
noteMap.put("2C", (byte)(0x6 + 0xC));
|
||||
noteMap.put("2C#", (byte)(0x7 + 0xC));
|
||||
noteMap.put("2D", (byte)(0x8 + 0xC));
|
||||
noteMap.put("2D#", (byte)(0x9 + 0xC));
|
||||
noteMap.put("2E", (byte)(0xA + 0xC));
|
||||
noteMap.put("2F", (byte)(0xB + 0xC));
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("nya"))
|
||||
{
|
||||
if (!noteBlocks.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final String tuneStr = "1D#,1E,2F#,,2A#,1E,1D#,1E,2F#,2B,2D#,2E,2D#,2A#,2B,,2F#,,1D#,1E,2F#,2B,2C#,2A#,2B,2C#,2E,2D#,2E,2C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1B,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1B,,";
|
||||
final String[] tune = tuneStr.split(",");
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
final Location loc = player.getLocation();
|
||||
loc.add(0, 3, 0);
|
||||
while (loc.getBlockY() < player.getLocation().getBlockY() + 10 && loc.getBlock().getTypeId() != 0)
|
||||
{
|
||||
loc.add(0, 1, 0);
|
||||
}
|
||||
if (loc.getBlock().getTypeId() == 0)
|
||||
{
|
||||
noteBlocks.put(player, loc.getBlock());
|
||||
loc.getBlock().setType(Material.NOTE_BLOCK);
|
||||
}
|
||||
}
|
||||
taskid = ess.scheduleSyncRepeatingTask(new Runnable()
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
public void run()
|
||||
{
|
||||
final String note = tune[i];
|
||||
i++;
|
||||
if (i >= tune.length)
|
||||
{
|
||||
Commandessentials.this.stopTune();
|
||||
}
|
||||
if (note.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Map<Player, Block> noteBlocks = Commandessentials.this.noteBlocks;
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
Block block = noteBlocks.get(player);
|
||||
if (block == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
player.playNote(block.getLocation(), (byte)0, noteMap.get(note));
|
||||
}
|
||||
}
|
||||
}, 20, 2);
|
||||
return;
|
||||
}
|
||||
ess.reload();
|
||||
charge(sender);
|
||||
sender.sendMessage(Util.format("essentialsReload", ess.getDescription().getVersion()));
|
||||
}
|
||||
|
||||
private void stopTune()
|
||||
{
|
||||
ess.getScheduler().cancelTask(taskid);
|
||||
for (Block block : noteBlocks.values())
|
||||
{
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
noteBlocks.clear();
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,6 @@ public class Commandext extends EssentialsCommand
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
charge(user);
|
||||
user.setFireTicks(0);
|
||||
user.sendMessage(Util.i18n("extinguish"));
|
||||
return;
|
||||
@@ -43,7 +42,6 @@ public class Commandext extends EssentialsCommand
|
||||
{
|
||||
for (Player p : server.matchPlayer(name))
|
||||
{
|
||||
charge(sender);
|
||||
p.setFireTicks(0);
|
||||
sender.sendMessage(Util.format("extinguishOthers", p.getDisplayName()));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
|
||||
public class Commandfireball extends EssentialsCommand
|
||||
{
|
||||
|
||||
public Commandfireball()
|
||||
{
|
||||
super("fireball");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final Vector direction = user.getEyeLocation().getDirection().multiply(2);
|
||||
user.getWorld().spawn(user.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), Fireball.class);
|
||||
}
|
||||
}
|
||||
@@ -16,9 +16,9 @@ public class Commandgc extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(sender);
|
||||
sender.sendMessage(Util.format("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(Util.format("gcmin", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(Util.format("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(Util.format("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
|
||||
for (World w : server.getWorlds())
|
||||
{
|
||||
sender.sendMessage(
|
||||
|
||||
@@ -15,7 +15,6 @@ public class Commandgetpos extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
Location coords = user.getLocation();
|
||||
user.sendMessage("§7X: " + coords.getBlockX() + " (-North <-> +South)");
|
||||
user.sendMessage("§7Y: " + coords.getBlockY() + " (+Up <-> -Down)");
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.ItemDb;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@@ -17,6 +16,7 @@ public class Commandgive extends EssentialsCommand
|
||||
super("give");
|
||||
}
|
||||
|
||||
//TODO: move these messages to message file
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
@@ -25,7 +25,7 @@ public class Commandgive extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
ItemStack stack = ItemDb.get(args[1]);
|
||||
ItemStack stack = ess.getItemDb().get(args[1]);
|
||||
|
||||
String itemname = stack.getType().toString().toLowerCase().replace("_", "");
|
||||
if (sender instanceof Player
|
||||
@@ -36,8 +36,7 @@ public class Commandgive extends EssentialsCommand
|
||||
: (!ess.getUser(sender).isAuthorized("essentials.itemspawn.exempt")
|
||||
&& !ess.getUser(sender).canSpawnItem(stack.getTypeId()))))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You are not allowed to spawn the item " + itemname);
|
||||
return;
|
||||
throw new Exception(ChatColor.RED + "You are not allowed to spawn the item " + itemname);
|
||||
}
|
||||
if (args.length > 2 && Integer.parseInt(args[2]) > 0)
|
||||
{
|
||||
@@ -46,13 +45,11 @@ public class Commandgive extends EssentialsCommand
|
||||
|
||||
if (stack.getType() == Material.AIR)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You can't give air.");
|
||||
return;
|
||||
throw new Exception(ChatColor.RED + "You can't give air.");
|
||||
}
|
||||
|
||||
User giveTo = getPlayer(server, args, 0);
|
||||
String itemName = stack.getType().name().toLowerCase().replace('_', ' ');
|
||||
charge(sender);
|
||||
String itemName = stack.getType().toString().toLowerCase().replace('_', ' ');
|
||||
sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + ".");
|
||||
giveTo.getInventory().addItem(stack);
|
||||
giveTo.updateInventory();
|
||||
|
||||
@@ -28,7 +28,6 @@ public class Commandgod extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
if (args.length > 0 && user.isAuthorized("essentials.god.others"))
|
||||
{
|
||||
godOtherPlayers(server, user, args[0]);
|
||||
@@ -43,6 +42,10 @@ public class Commandgod extends EssentialsCommand
|
||||
for (Player p : server.matchPlayer(name))
|
||||
{
|
||||
User u = ess.getUser(p);
|
||||
if (u.isHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
boolean enabled = u.toggleGodModeEnabled();
|
||||
u.sendMessage(Util.format("godMode", (enabled ? Util.i18n("enabled") : Util.i18n("disabled"))));
|
||||
sender.sendMessage(Util.format("godMode",Util.format(enabled ? "godEnabledFor": "godDisabledFor", p.getDisplayName())));
|
||||
|
||||
@@ -25,7 +25,6 @@ public class Commandheal extends EssentialsCommand
|
||||
{
|
||||
user.healCooldown();
|
||||
}
|
||||
charge(user);
|
||||
healOtherPlayers(server, user, args[0]);
|
||||
return;
|
||||
}
|
||||
@@ -34,7 +33,6 @@ public class Commandheal extends EssentialsCommand
|
||||
{
|
||||
user.healCooldown();
|
||||
}
|
||||
charge(user);
|
||||
user.setHealth(20);
|
||||
user.sendMessage(Util.i18n("heal"));
|
||||
}
|
||||
@@ -53,13 +51,17 @@ public class Commandheal extends EssentialsCommand
|
||||
private void healOtherPlayers(Server server, CommandSender sender, String name)
|
||||
{
|
||||
List<Player> players = server.matchPlayer(name);
|
||||
if(players.isEmpty())
|
||||
if (players.isEmpty())
|
||||
{
|
||||
sender.sendMessage(Util.i18n("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
for (Player p : players)
|
||||
{
|
||||
if (ess.getUser(p).isHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
p.setHealth(20);
|
||||
sender.sendMessage(Util.format("healOther", p.getDisplayName()));
|
||||
}
|
||||
|
||||
@@ -20,6 +20,9 @@ import java.util.logging.Level;
|
||||
|
||||
public class Commandhelp extends EssentialsCommand
|
||||
{
|
||||
private static final String DESCRIPTION = "description";
|
||||
private static final String PERMISSION = "permission";
|
||||
private static final String PERMISSIONS = "permissions";
|
||||
public final Yaml yaml = new Yaml(new SafeConstructor());
|
||||
|
||||
public Commandhelp()
|
||||
@@ -28,21 +31,39 @@ public class Commandhelp extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
int page;
|
||||
int page = 1;
|
||||
String match = "";
|
||||
try
|
||||
{
|
||||
page = args.length > 0 ? Integer.parseInt(args[0]) : 1;
|
||||
if (args.length > 0)
|
||||
{
|
||||
match = args[0].toLowerCase();
|
||||
page = Integer.parseInt(args[args.length - 1]);
|
||||
if (args.length == 1)
|
||||
{
|
||||
match = "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
page = 1;
|
||||
if (args.length == 1)
|
||||
{
|
||||
match = args[0].toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
List<String> lines = getHelpLines(user);
|
||||
int start = (page - 1) * 9;
|
||||
int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0);
|
||||
final List<String> lines = getHelpLines(user, match);
|
||||
if (lines.isEmpty())
|
||||
{
|
||||
throw new Exception(Util.i18n("noHelpFound"));
|
||||
}
|
||||
|
||||
final int start = (page - 1) * 9;
|
||||
final int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0);
|
||||
|
||||
user.sendMessage(Util.format("helpPages", page, pages));
|
||||
for (int i = start; i < lines.size() && i < start + 9; i++)
|
||||
@@ -52,19 +73,19 @@ public class Commandhelp extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
sender.sendMessage(Util.i18n("helpConsole"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("CallToThreadDumpStack")
|
||||
private List<String> getHelpLines(User user) throws Exception
|
||||
private List<String> getHelpLines(final User user, final String match) throws Exception
|
||||
{
|
||||
List<String> retval = new ArrayList<String>();
|
||||
File helpFile = new File(ess.getDataFolder(), "help_"+Util.sanitizeFileName(user.getName()) +".txt");
|
||||
final List<String> retval = new ArrayList<String>();
|
||||
File helpFile = new File(ess.getDataFolder(), "help_" + Util.sanitizeFileName(user.getName()) + ".txt");
|
||||
if (!helpFile.exists())
|
||||
{
|
||||
helpFile = new File(ess.getDataFolder(), "help_"+Util.sanitizeFileName(user.getGroup()) +".txt");
|
||||
helpFile = new File(ess.getDataFolder(), "help_" + Util.sanitizeFileName(user.getGroup()) + ".txt");
|
||||
}
|
||||
if (!helpFile.exists())
|
||||
{
|
||||
@@ -73,8 +94,9 @@ public class Commandhelp extends EssentialsCommand
|
||||
if (helpFile.exists())
|
||||
{
|
||||
final BufferedReader bufferedReader = new BufferedReader(new FileReader(helpFile));
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
while (bufferedReader.ready())
|
||||
{
|
||||
final String line = bufferedReader.readLine();
|
||||
@@ -95,36 +117,97 @@ public class Commandhelp extends EssentialsCommand
|
||||
try
|
||||
{
|
||||
final PluginDescriptionFile desc = p.getDescription();
|
||||
final HashMap<String, HashMap<String, String>> cmds = (HashMap<String, HashMap<String, String>>)desc.getCommands();
|
||||
for (Entry<String, HashMap<String, String>> k : cmds.entrySet())
|
||||
final HashMap<String, HashMap<String, Object>> cmds = (HashMap<String, HashMap<String, Object>>)desc.getCommands();
|
||||
pluginName = p.getDescription().getName().toLowerCase();
|
||||
for (Entry<String, HashMap<String, Object>> k : cmds.entrySet())
|
||||
{
|
||||
if (p.getDescription().getName().toLowerCase().contains("essentials"))
|
||||
try
|
||||
{
|
||||
final String node = "essentials." + k.getKey();
|
||||
if (!ess.getSettings().isCommandDisabled(k.getKey()) && user.isAuthorized(node))
|
||||
if ((!match.equalsIgnoreCase(""))
|
||||
&& (!k.getKey().toLowerCase().contains(match))
|
||||
&& (!(k.getValue().get(DESCRIPTION) instanceof String
|
||||
&& ((String)k.getValue().get(DESCRIPTION)).toLowerCase().contains(match)))
|
||||
&& (!pluginName.contains(match)))
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + k.getValue().get("description"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ess.getSettings().showNonEssCommandsInHelp())
|
||||
{
|
||||
pluginName = p.getDescription().getName();
|
||||
final HashMap<String, String> value = k.getValue();
|
||||
if (value.containsKey("permission") && value.get("permission") != null && !(value.get("permission").equals("")))
|
||||
{
|
||||
if (user.isAuthorized(value.get("permission")))
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pluginName.contains("essentials"))
|
||||
{
|
||||
final String node = "essentials." + k.getKey();
|
||||
if (!ess.getSettings().isCommandDisabled(k.getKey()) && user.isAuthorized(node))
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + k.getValue().get(DESCRIPTION));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ess.getSettings().showNonEssCommandsInHelp())
|
||||
{
|
||||
final HashMap<String, Object> value = k.getValue();
|
||||
if (value.containsKey(PERMISSION) && value.get(PERMISSION) instanceof String && !(value.get(PERMISSION).equals("")))
|
||||
{
|
||||
if (user.isAuthorized((String)value.get(PERMISSION)))
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
|
||||
}
|
||||
}
|
||||
else if (value.containsKey(PERMISSION) && value.get(PERMISSION) instanceof List && !((List<Object>)value.get(PERMISSION)).isEmpty())
|
||||
{
|
||||
boolean enabled = false;
|
||||
for (Object o : (List<Object>)value.get(PERMISSION))
|
||||
{
|
||||
if (o instanceof String && user.isAuthorized((String)o))
|
||||
{
|
||||
enabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (enabled)
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
|
||||
}
|
||||
}
|
||||
else if (value.containsKey(PERMISSIONS) && value.get(PERMISSIONS) instanceof String && !(value.get(PERMISSIONS).equals("")))
|
||||
{
|
||||
if (user.isAuthorized((String)value.get(PERMISSIONS)))
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
|
||||
}
|
||||
}
|
||||
else if (value.containsKey(PERMISSIONS) && value.get(PERMISSIONS) instanceof List && !((List<Object>)value.get(PERMISSIONS)).isEmpty())
|
||||
{
|
||||
boolean enabled = false;
|
||||
for (Object o : (List<Object>)value.get(PERMISSIONS))
|
||||
{
|
||||
if (o instanceof String && user.isAuthorized((String)o))
|
||||
{
|
||||
enabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (enabled)
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
|
||||
}
|
||||
}
|
||||
else if (user.isAuthorized("essentials.help." + pluginName))
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ess.getSettings().hidePermissionlessHelp())
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NullPointerException ex)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,7 +219,7 @@ public class Commandhelp extends EssentialsCommand
|
||||
{
|
||||
if (!reported)
|
||||
{
|
||||
logger.log(Level.WARNING, "Error getting help for:" + pluginName, ex);
|
||||
logger.log(Level.WARNING, Util.format("commandHelpFailedForPlugin", pluginName), ex);
|
||||
}
|
||||
reported = true;
|
||||
continue;
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
||||
public class Commandhelpop extends EssentialsCommand
|
||||
@@ -21,7 +22,8 @@ public class Commandhelpop extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
charge(user);
|
||||
final String message = Util.format("helpOp", user.getDisplayName(), getFinalArg(args, 0));
|
||||
logger.log(Level.INFO, message);
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
User u = ess.getUser(p);
|
||||
@@ -29,7 +31,7 @@ public class Commandhelpop extends EssentialsCommand
|
||||
{
|
||||
continue;
|
||||
}
|
||||
u.sendMessage(Util.format("helpOp", user.getDisplayName(), getFinalArg(args, 0)));
|
||||
u.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Charge;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class Commandhome extends EssentialsCommand
|
||||
@@ -16,26 +17,51 @@ public class Commandhome extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
Charge charge = new Charge(this.getName(), ess);
|
||||
Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
if(args.length > 0 && user.isAuthorized("essentials.home.others"))
|
||||
User u = user;
|
||||
String homeName = "";
|
||||
String[] nameParts;
|
||||
if (args.length > 0)
|
||||
{
|
||||
User u;
|
||||
try
|
||||
nameParts = args[0].split(":");
|
||||
if (nameParts[0].length() == args[0].length() || !user.isAuthorized("essentials.home.others"))
|
||||
{
|
||||
u = getPlayer(server, args, 0);
|
||||
homeName = nameParts[0];
|
||||
}
|
||||
catch(NoSuchFieldException ex)
|
||||
else
|
||||
{
|
||||
u = ess.getOfflineUser(args[0]);
|
||||
u = getPlayer(server, nameParts[0].split(" "), 0, true);
|
||||
if (nameParts.length > 1)
|
||||
{
|
||||
homeName = nameParts[1];
|
||||
}
|
||||
}
|
||||
if (u == null)
|
||||
{
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
user.getTeleport().home(u, charge);
|
||||
return;
|
||||
}
|
||||
user.getTeleport().home(charge);
|
||||
try
|
||||
{
|
||||
user.getTeleport().home(u, homeName.toLowerCase(), charge);
|
||||
}
|
||||
catch (NotEnoughArgumentsException e)
|
||||
{
|
||||
List<String> homes = u.getHomes();
|
||||
if (homes.isEmpty() && u.equals(user) && ess.getSettings().spawnIfNoHome())
|
||||
{
|
||||
user.getTeleport().respawn(ess.getSpawn(), charge);
|
||||
}
|
||||
else if (homes.isEmpty())
|
||||
{
|
||||
throw new Exception(u == user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer"));
|
||||
}
|
||||
else if (homes.size() == 1 && u.equals(user))
|
||||
{
|
||||
user.getTeleport().home(u, homes.get(0), charge);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.format("homes", Util.joinList(homes)));
|
||||
}
|
||||
}
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
@@ -68,9 +68,8 @@ public class Commandinfo extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(Util.i18n("infoFileDoesNotExist"));
|
||||
file.createNewFile();
|
||||
return;
|
||||
throw new Exception(Util.i18n("infoFileDoesNotExist"));
|
||||
}
|
||||
|
||||
if (bookmarks.isEmpty())
|
||||
@@ -88,7 +87,6 @@ public class Commandinfo extends EssentialsCommand
|
||||
int start = (page - 1) * 9;
|
||||
int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0);
|
||||
|
||||
charge(sender);
|
||||
sender.sendMessage(Util.format("infoPages", page, pages ));
|
||||
for (int i = start; i < lines.size() && i < start + 9; i++)
|
||||
{
|
||||
@@ -140,7 +138,6 @@ public class Commandinfo extends EssentialsCommand
|
||||
}
|
||||
int pages = end / 9 + (end % 9 > 0 ? 1 : 0);
|
||||
|
||||
charge(sender);
|
||||
sender.sendMessage(Util.format("infoPages", page, pages ));
|
||||
for (int i = start; i < end && i < start + 9; i++)
|
||||
{
|
||||
@@ -182,7 +179,6 @@ public class Commandinfo extends EssentialsCommand
|
||||
int page = chapterpage + 1;
|
||||
int pages = (chapterend - chapterstart) / 9 + ((chapterend - chapterstart) % 9 > 0 ? 1 : 0);
|
||||
|
||||
charge(sender);
|
||||
sender.sendMessage(Util.format("infoChapterPages", pageStr, page , pages));
|
||||
for (int i = start; i < chapterend && i < start + 9; i++)
|
||||
{
|
||||
|
||||
@@ -31,11 +31,9 @@ public class Commandinvsee extends EssentialsCommand
|
||||
{
|
||||
invUser.getInventory().setContents(user.getSavedInventory());
|
||||
user.setSavedInventory(null);
|
||||
user.sendMessage(Util.i18n("invRestored"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("invRestored"));
|
||||
}
|
||||
|
||||
charge(user);
|
||||
if (user.getSavedInventory() == null)
|
||||
{
|
||||
user.setSavedInventory(user.getInventory().getContents());
|
||||
@@ -51,5 +49,6 @@ public class Commandinvsee extends EssentialsCommand
|
||||
user.getInventory().setContents(invUserStack);
|
||||
user.sendMessage(Util.format("invSee", invUser.getDisplayName()));
|
||||
user.sendMessage(Util.i18n("invSeeHelp"));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.ItemDb;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -23,7 +21,7 @@ public class Commanditem extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
ItemStack stack = ItemDb.get(args[0]);
|
||||
ItemStack stack = ess.getItemDb().get(args[0]);
|
||||
|
||||
String itemname = stack.getType().toString().toLowerCase().replace("_", "");
|
||||
if (ess.getSettings().permissionBasedItemSpawn()
|
||||
@@ -33,8 +31,7 @@ public class Commanditem extends EssentialsCommand
|
||||
: (!user.isAuthorized("essentials.itemspawn.exempt")
|
||||
&& !user.canSpawnItem(stack.getTypeId())))
|
||||
{
|
||||
user.sendMessage(Util.format("cantSpawnItem", itemname));
|
||||
return;
|
||||
throw new Exception(Util.format("cantSpawnItem", itemname));
|
||||
}
|
||||
|
||||
if (args.length > 1 && Integer.parseInt(args[1]) > 0)
|
||||
@@ -44,12 +41,10 @@ public class Commanditem extends EssentialsCommand
|
||||
|
||||
if (stack.getType() == Material.AIR)
|
||||
{
|
||||
user.sendMessage(Util.format("cantSpawnItem", "Air"));
|
||||
return;
|
||||
throw new Exception(Util.format("cantSpawnItem", "Air"));
|
||||
}
|
||||
|
||||
String itemName = stack.getType().name().toLowerCase().replace('_', ' ');
|
||||
charge(user);
|
||||
String itemName = stack.getType().toString().toLowerCase().replace('_', ' ');
|
||||
user.sendMessage(Util.format("itemSpawn", stack.getAmount(), itemName));
|
||||
user.getInventory().addItem(stack);
|
||||
user.updateInventory();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -14,12 +15,6 @@ public class Commandjails extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
StringBuilder jailList = new StringBuilder();
|
||||
for (String j : ess.getJail().getJails())
|
||||
{
|
||||
jailList.append(j);
|
||||
jailList.append(' ');
|
||||
}
|
||||
sender.sendMessage("§7" + jailList);
|
||||
sender.sendMessage("§7" + Util.joinList(" ", ess.getJail().getJails()));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Charge;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.TargetBlock;
|
||||
@@ -36,7 +36,7 @@ public class Commandjump extends EssentialsCommand
|
||||
throw new Exception(Util.i18n("jumpError"), ex);
|
||||
}
|
||||
|
||||
Charge charge = new Charge(this.getName(), ess);
|
||||
Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.getTeleport().teleport(loc, charge);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Console;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandkick extends EssentialsCommand
|
||||
@@ -13,7 +14,7 @@ public class Commandkick extends EssentialsCommand
|
||||
{
|
||||
super("kick");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
@@ -21,19 +22,23 @@ public class Commandkick extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
User u;
|
||||
try
|
||||
|
||||
User player = getPlayer(server, args, 0);
|
||||
if (player.isAuthorized("essentials.kick.exempt"))
|
||||
{
|
||||
u = ess.getUser(server.matchPlayer(args[0]).get(0));
|
||||
throw new Exception(Util.i18n("kickExempt"));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
final String kickReason = args.length > 1 ? getFinalArg(args, 1) : Util.i18n("kickDefault");
|
||||
player.kickPlayer(kickReason);
|
||||
String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
|
||||
for(Player p : server.getOnlinePlayers())
|
||||
{
|
||||
sender.sendMessage(Util.i18n("playerNotFound"));
|
||||
return;
|
||||
User u = ess.getUser(p);
|
||||
if(u.isAuthorized("essentials.kick.notify"))
|
||||
{
|
||||
p.sendMessage(Util.format("playerKicked", senderName, player.getName(), kickReason));
|
||||
}
|
||||
}
|
||||
|
||||
charge(sender);
|
||||
u.kickPlayer(args.length > 1 ? getFinalArg(args, 1) : Util.i18n("kickDefault"));
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,6 @@ public class Commandkickall extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(sender);
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
if (sender instanceof Player && p.getName().equalsIgnoreCase(((Player)sender).getName()))
|
||||
|
||||
@@ -21,7 +21,6 @@ public class Commandkill extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
charge(sender);
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
{
|
||||
p.setHealth(0);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Charge;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -9,6 +9,7 @@ import org.bukkit.Server;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.GregorianCalendar;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@@ -109,7 +110,7 @@ public class Commandkit extends EssentialsCommand
|
||||
items = (List<String>)kit;
|
||||
}
|
||||
|
||||
Charge charge = new Charge("kit-" + kitName, ess);
|
||||
Trade charge = new Trade("kit-" + kitName, ess);
|
||||
try
|
||||
{
|
||||
charge.isAffordableFor(user);
|
||||
@@ -124,7 +125,7 @@ public class Commandkit extends EssentialsCommand
|
||||
for (String d : items)
|
||||
{
|
||||
String[] parts = d.split("[^0-9]+", 3);
|
||||
int id = Integer.parseInt(parts[0]);
|
||||
int id = Material.getMaterial(Integer.parseInt(parts[0])).getId();
|
||||
int amount = parts.length > 1 ? Integer.parseInt(parts[parts.length > 2 ? 2 : 1]) : 1;
|
||||
short data = parts.length > 2 ? Short.parseShort(parts[1]) : 0;
|
||||
HashMap<Integer,ItemStack> overfilled = user.getInventory().addItem(new ItemStack(id, amount, data));
|
||||
@@ -140,7 +141,6 @@ public class Commandkit extends EssentialsCommand
|
||||
}
|
||||
try
|
||||
{
|
||||
charge(user);
|
||||
charge.charge(user);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -26,20 +26,14 @@ public class Commandlightning extends EssentialsCommand
|
||||
if (args.length < 1 & user != null)
|
||||
{
|
||||
user.getWorld().strikeLightning(user.getTargetBlock(null, 600).getLocation());
|
||||
charge(user);
|
||||
return;
|
||||
}
|
||||
|
||||
if (server.matchPlayer(args[0]).isEmpty())
|
||||
{
|
||||
sender.sendMessage(Util.i18n("playerNotFound"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
charge(user);
|
||||
}
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
{
|
||||
sender.sendMessage(Util.format("lightningUse", p.getDisplayName()));
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
@@ -25,9 +24,33 @@ public class Commandlist extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(sender);
|
||||
boolean showhidden = false;
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
if (ess.getUser(sender).isAuthorized("essentials.list.hidden"))
|
||||
{
|
||||
showhidden = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
showhidden = true;
|
||||
}
|
||||
int playerHidden = 0;
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
if (ess.getUser(p).isHidden())
|
||||
{
|
||||
playerHidden++;
|
||||
}
|
||||
}
|
||||
//TODO: move these to messages file
|
||||
StringBuilder online = new StringBuilder();
|
||||
online.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length);
|
||||
online.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length - playerHidden);
|
||||
if (showhidden && playerHidden > 0)
|
||||
{
|
||||
online.append(ChatColor.GRAY).append("/").append(playerHidden);
|
||||
}
|
||||
online.append(ChatColor.BLUE).append(" out of a maximum ").append(ChatColor.RED).append(server.getMaxPlayers());
|
||||
online.append(ChatColor.BLUE).append(" players online.");
|
||||
sender.sendMessage(online.toString());
|
||||
@@ -38,6 +61,10 @@ public class Commandlist extends EssentialsCommand
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
User u = ess.getUser(p);
|
||||
if (u.isHidden() && !showhidden)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String group = u.getGroup();
|
||||
List<User> list = sort.get(group);
|
||||
if (list == null)
|
||||
@@ -70,7 +97,12 @@ public class Commandlist extends EssentialsCommand
|
||||
{
|
||||
groupString.append("§7[AFK]§f");
|
||||
}
|
||||
if (user.isHidden())
|
||||
{
|
||||
groupString.append("§7[HIDDEN]§f");
|
||||
}
|
||||
groupString.append(user.getDisplayName());
|
||||
groupString.append("§f");
|
||||
}
|
||||
sender.sendMessage(groupString.toString());
|
||||
}
|
||||
@@ -80,7 +112,12 @@ public class Commandlist extends EssentialsCommand
|
||||
List<User> users = new ArrayList<User>();
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
users.add(ess.getUser(p));
|
||||
final User u = ess.getUser(p);
|
||||
if (u.isHidden() && !showhidden)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
users.add(u);
|
||||
}
|
||||
Collections.sort(users);
|
||||
|
||||
@@ -101,7 +138,12 @@ public class Commandlist extends EssentialsCommand
|
||||
{
|
||||
onlineUsers.append("§7[AFK]§f");
|
||||
}
|
||||
if (user.isHidden())
|
||||
{
|
||||
onlineUsers.append("§7[HIDDEN]§f");
|
||||
}
|
||||
onlineUsers.append(user.getDisplayName());
|
||||
onlineUsers.append("§f");
|
||||
}
|
||||
sender.sendMessage(onlineUsers.toString());
|
||||
}
|
||||
|
||||
@@ -23,22 +23,19 @@ public class Commandmail extends EssentialsCommand
|
||||
List<String> mail = user.getMails();
|
||||
if (mail.isEmpty())
|
||||
{
|
||||
user.sendMessage(Util.i18n("noMail"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("noMail"));
|
||||
}
|
||||
for (String s : mail)
|
||||
{
|
||||
user.sendMessage(s);
|
||||
}
|
||||
user.sendMessage(Util.i18n("mailClear"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("mailClear"));
|
||||
}
|
||||
if (args.length >= 3 && "send".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
if (!user.isAuthorized("essentials.mail.send"))
|
||||
{
|
||||
user.sendMessage(Util.i18n("noMailSendPerm"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("noMailSendPerm"));
|
||||
}
|
||||
|
||||
Player player = server.getPlayer(args[1]);
|
||||
@@ -53,10 +50,8 @@ public class Commandmail extends EssentialsCommand
|
||||
}
|
||||
if (u == null)
|
||||
{
|
||||
user.sendMessage(Util.format("playerNeverOnServer", args[1]));
|
||||
return;
|
||||
throw new Exception(Util.format("playerNeverOnServer", args[1]));
|
||||
}
|
||||
charge(user);
|
||||
if (!u.isIgnoredPlayer(user.getName()))
|
||||
{
|
||||
u.addMail(ChatColor.stripColor(user.getDisplayName()) + ": " + getFinalArg(args, 2));
|
||||
@@ -67,9 +62,8 @@ public class Commandmail extends EssentialsCommand
|
||||
if (args.length >= 1 && "clear".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
user.setMails(null);
|
||||
user.sendMessage(Util.i18n("mailCleared"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("mailCleared"));
|
||||
}
|
||||
throw new NotEnoughArgumentsException();
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
@@ -17,21 +17,22 @@ public class Commandme extends EssentialsCommand
|
||||
{
|
||||
if (user.isMuted())
|
||||
{
|
||||
user.sendMessage(Util.i18n("voiceSilenced"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("voiceSilenced"));
|
||||
}
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
StringBuilder message = new StringBuilder();
|
||||
final StringBuilder message = new StringBuilder();
|
||||
message.append("* ");
|
||||
message.append(user.getDisplayName());
|
||||
message.append(' ');
|
||||
for (int i = 0; i < args.length; i++)
|
||||
{
|
||||
message.append(args[i]);
|
||||
message.append(' ');
|
||||
}
|
||||
charge(user);
|
||||
ess.broadcastMessage(user.getName(), "* " + user.getDisplayName() + " " + message);
|
||||
ess.broadcastMessage(user, message.toString());
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ public class Commandmotd extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(sender);
|
||||
for (String m : ess.getMotd(sender, Util.i18n("noMotd")))
|
||||
{
|
||||
sender.sendMessage(m);
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.earth2me.essentials.Console;
|
||||
import com.earth2me.essentials.IReplyTo;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -24,6 +25,15 @@ public class Commandmsg extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
User user = ess.getUser(sender);
|
||||
if (user.isMuted())
|
||||
{
|
||||
throw new Exception(Util.i18n("voiceSilenced"));
|
||||
}
|
||||
}
|
||||
|
||||
String message = getFinalArg(args, 1);
|
||||
String translatedMe = Util.i18n("me");
|
||||
|
||||
@@ -44,15 +54,28 @@ public class Commandmsg extends EssentialsCommand
|
||||
|
||||
if (matches.isEmpty())
|
||||
{
|
||||
sender.sendMessage(Util.i18n("playerNotFound"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
|
||||
charge(sender);
|
||||
int i = 0;
|
||||
for (Player p : matches)
|
||||
{
|
||||
{
|
||||
final User u = ess.getUser(p);
|
||||
if (u.isHidden())
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (i == matches.size())
|
||||
{
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
|
||||
for (Player p : matches)
|
||||
{
|
||||
sender.sendMessage(Util.format("msgFormat", translatedMe, p.getDisplayName(), message));
|
||||
if (sender instanceof Player && ess.getUser(p).isIgnoredPlayer(((Player)sender).getName()))
|
||||
final User u = ess.getUser(p);
|
||||
if (sender instanceof Player && (u.isIgnoredPlayer(((Player)sender).getName()) || u.isHidden()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,11 @@ public class Commandmute extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
User p = getPlayer(server, args, 0);
|
||||
User p = getPlayer(server, args, 0, true);
|
||||
if (!p.isMuted() && p.isAuthorized("essentials.mute.exempt"))
|
||||
{
|
||||
throw new Exception(Util.i18n("muteExempt"));
|
||||
}
|
||||
long muteTimestamp = 0;
|
||||
if (args.length > 1)
|
||||
{
|
||||
@@ -29,14 +33,18 @@ public class Commandmute extends EssentialsCommand
|
||||
muteTimestamp = Util.parseDateDiff(time, true);
|
||||
}
|
||||
p.setMuteTimeout(muteTimestamp);
|
||||
charge(sender);
|
||||
|
||||
|
||||
boolean muted = p.toggleMuted();
|
||||
sender.sendMessage(
|
||||
p.toggleMuted()
|
||||
muted
|
||||
? (muteTimestamp > 0
|
||||
? Util.format("mutedPlayerFor", p.getDisplayName(), Util.formatDateDiff(muteTimestamp))
|
||||
: Util.format("mutedPlayer", p.getDisplayName()))
|
||||
: Util.format("unmutedPlayer", p.getDisplayName()));
|
||||
p.sendMessage(
|
||||
muted
|
||||
? (muteTimestamp > 0
|
||||
? Util.format("playerMutedFor", Util.formatDateDiff(muteTimestamp))
|
||||
: Util.i18n("playerMuted"))
|
||||
: Util.i18n("playerUnmuted"));
|
||||
}
|
||||
}
|
||||
@@ -21,13 +21,16 @@ public class Commandnick extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
if (!ess.getSettings().changeDisplayName()) {
|
||||
throw new Exception(Util.i18n("nickDisplayName"));
|
||||
}
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
if (!user.isAuthorized("essentials.nick.others"))
|
||||
{
|
||||
user.sendMessage(Util.i18n("nickOthersPermission"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("nickOthersPermission"));
|
||||
}
|
||||
|
||||
setOthersNickname(server, user, args);
|
||||
@@ -46,8 +49,7 @@ public class Commandnick extends EssentialsCommand
|
||||
|
||||
if (nick.matches("[^a-zA-Z_0-9]"))
|
||||
{
|
||||
user.sendMessage(Util.i18n("nickNamesAlpha"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("nickNamesAlpha"));
|
||||
}
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
@@ -61,12 +63,10 @@ public class Commandnick extends EssentialsCommand
|
||||
String nk = nick.toLowerCase();
|
||||
if (nk.equals(dn) || nk.equals(n))
|
||||
{
|
||||
user.sendMessage(Util.i18n("nickInUse"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("nickInUse"));
|
||||
}
|
||||
}
|
||||
|
||||
charge(user);
|
||||
user.setDisplayName(ess.getSettings().getNicknamePrefix() + nick);
|
||||
user.setNickname(nick);
|
||||
user.sendMessage(Util.format("nickSet", user.getDisplayName() + "§7."));
|
||||
@@ -80,6 +80,11 @@ public class Commandnick extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
if (!ess.getSettings().changeDisplayName()) {
|
||||
sender.sendMessage(Util.i18n("nickDisplayName"));
|
||||
return;
|
||||
}
|
||||
|
||||
setOthersNickname(server, sender, args);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
||||
|
||||
public class Commandnuke extends EssentialsCommand
|
||||
{
|
||||
public Commandnuke()
|
||||
{
|
||||
super("nuke");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws NoSuchFieldException, NotEnoughArgumentsException
|
||||
{
|
||||
List<Player> targets;
|
||||
if (args.length > 0)
|
||||
{
|
||||
targets = new ArrayList<Player>();
|
||||
int pos = 0;
|
||||
for (String arg : args)
|
||||
{
|
||||
targets.add(getPlayer(server, args, pos));
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
targets = Arrays.asList(server.getOnlinePlayers());
|
||||
}
|
||||
ess.getTNTListener().enable();
|
||||
for (Player player : targets)
|
||||
{
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
player.sendMessage("May death rain upon them");
|
||||
final Location loc = player.getLocation();
|
||||
final World world = loc.getWorld();
|
||||
for (int x = -10; x <= 10; x += 5)
|
||||
{
|
||||
for (int z = -10; z <= 10; z += 5)
|
||||
{
|
||||
final Location tntloc = new Location(world, loc.getBlockX() + x, 127, loc.getBlockZ() + z);
|
||||
final TNTPrimed tnt = world.spawn(tntloc, TNTPrimed.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
|
||||
|
||||
public class Commandpay extends EssentialsCommand
|
||||
@@ -22,10 +23,20 @@ public class Commandpay extends EssentialsCommand
|
||||
|
||||
double amount = Double.parseDouble(args[1].replaceAll("[^0-9\\.]", ""));
|
||||
|
||||
Boolean foundUser = false;
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
{
|
||||
User u = ess.getUser(p);
|
||||
if (u.isHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
user.payUser(u, amount);
|
||||
foundUser = true;
|
||||
}
|
||||
|
||||
if(foundUser == false) {
|
||||
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 371 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user