mirror of
https://github.com/EssentialsX/Essentials.git
synced 2026-11-05 01:00:13 -05:00
Compare commits
1636
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6edf04a60 | ||
|
|
3ba675a899 | ||
|
|
1fed7a9a3a | ||
|
|
80fb91b6d7 | ||
|
|
5b0c2a4131 | ||
|
|
bb43e8f7b6 | ||
|
|
4d9a10147a | ||
|
|
ea4f5cf919 | ||
|
|
295bc9f76d | ||
|
|
327806d9a1 | ||
|
|
80e7558fc0 | ||
|
|
9cda59511e | ||
|
|
c12a031918 | ||
|
|
a4f580e319 | ||
|
|
583bf88207 | ||
|
|
a5f8e83e03 | ||
|
|
e2f17f11d3 | ||
|
|
4f8c040d06 | ||
|
|
af1d068022 | ||
|
|
1bd8d1c85c | ||
|
|
d7fc859d14 | ||
|
|
ac953cd114 | ||
|
|
6e6dd041d5 | ||
|
|
9b3c8a9df2 | ||
|
|
234a481b0d | ||
|
|
89b3c9233e | ||
|
|
5d61a43fe1 | ||
|
|
29d5ccf751 | ||
|
|
fde0665593 | ||
|
|
29541b0995 | ||
|
|
05f31c5ddf | ||
|
|
f89840545d | ||
|
|
18534f8576 | ||
|
|
1382a05dc8 | ||
|
|
1671d4839c | ||
|
|
4d2fbd04c5 | ||
|
|
dc6b9b89cd | ||
|
|
76f36aa895 | ||
|
|
fa835e9c64 | ||
|
|
c8dc874a56 | ||
|
|
b3a6307052 | ||
|
|
3ca0181b79 | ||
|
|
98557dcecf | ||
|
|
3351092c79 | ||
|
|
68cd509d41 | ||
|
|
5fa65b42ae | ||
|
|
bdae259a1d | ||
|
|
fea86ea70e | ||
|
|
1133770aeb | ||
|
|
2c462106bc | ||
|
|
bd1e624c91 | ||
|
|
6875fa4c7e | ||
|
|
def5f2155d | ||
|
|
73d2457fea | ||
|
|
bc52ca856e | ||
|
|
18ccea320a | ||
|
|
f6cb9ff470 | ||
|
|
14c6c2a055 | ||
|
|
68d0aa9688 | ||
|
|
1ef4e15a4d | ||
|
|
d35b4b9128 | ||
|
|
6995be7dbd | ||
|
|
f9de6763d3 | ||
|
|
dfce971565 | ||
|
|
97e3f32d7f | ||
|
|
c86e1a5973 | ||
|
|
ab545dc44c | ||
|
|
11cd57e8fb | ||
|
|
b7c18d0785 | ||
|
|
9aec89f381 | ||
|
|
e34984513d | ||
|
|
cedd42f411 | ||
|
|
c9b75aabb2 | ||
|
|
41ae12ed3d | ||
|
|
dba35f043d | ||
|
|
8046b8594a | ||
|
|
6c64aaefec | ||
|
|
07fa87dc6a | ||
|
|
b58c98bea0 | ||
|
|
08e553bd1a | ||
|
|
e35fb82bc2 | ||
|
|
a92ca63ca9 | ||
|
|
cbfad7b320 | ||
|
|
c16987fb87 | ||
|
|
477f5a7841 | ||
|
|
6f149224d1 | ||
|
|
1a6ad2fdb0 | ||
|
|
76e511a774 | ||
|
|
9681933ec2 | ||
|
|
711bfed557 | ||
|
|
016a1b3421 | ||
|
|
01b9ec4a42 | ||
|
|
9b729dd091 | ||
|
|
0a73be2082 | ||
|
|
c668879070 | ||
|
|
c4d318b7d0 | ||
|
|
e7d9dbfbcf | ||
|
|
1be3daf0b5 | ||
|
|
8f86849aec | ||
|
|
0b4ee9e73e | ||
|
|
65f88834ba | ||
|
|
024c56efdd | ||
|
|
9c487b0aac | ||
|
|
d743f928ad | ||
|
|
07e2fe3af1 | ||
|
|
9f384c71f3 | ||
|
|
7a5aea0bcf | ||
|
|
b6c9bc1439 | ||
|
|
b7f38517ef | ||
|
|
60f54ee37d | ||
|
|
adf1273bf9 | ||
|
|
3c79e9e59d | ||
|
|
1ab1b5713e | ||
|
|
edf2f295d1 | ||
|
|
c043416b11 | ||
|
|
4a471f0a93 | ||
|
|
04a1d8197f | ||
|
|
d9bf099c3d | ||
|
|
d2f2140be9 | ||
|
|
04f88e460b | ||
|
|
d64f73e719 | ||
|
|
2ab4dcbc11 | ||
|
|
846043e9a0 | ||
|
|
ea57e4ae01 | ||
|
|
6aa5e5cc4a | ||
|
|
3e5bd4cf09 | ||
|
|
3d096c1f31 | ||
|
|
b5b6bce758 | ||
|
|
46ed8e954f | ||
|
|
cfca2f7550 | ||
|
|
a09df9bf3a | ||
|
|
dc2462c277 | ||
|
|
25c7ebcf39 | ||
|
|
baab65d776 | ||
|
|
9e2b906048 | ||
|
|
9f3c2683ae | ||
|
|
9e01a1a427 | ||
|
|
db729241c9 | ||
|
|
d5d8c80d74 | ||
|
|
4c48ccb422 | ||
|
|
53e7c83254 | ||
|
|
fdef1062f0 | ||
|
|
b9f8fc2e11 | ||
|
|
db410fb3e7 | ||
|
|
500dadc760 | ||
|
|
7d61953753 | ||
|
|
5b9b76d5e7 | ||
|
|
b9804d8980 | ||
|
|
b960ee365a | ||
|
|
302f0acbaa | ||
|
|
8f5b97b9d2 | ||
|
|
6371cf7517 | ||
|
|
e53520aef6 | ||
|
|
d59fd71ba5 | ||
|
|
4b967a749b | ||
|
|
8f88a8dcb3 | ||
|
|
a58ba406eb | ||
|
|
a93ca9b7bc | ||
|
|
02e6b5f1b3 | ||
|
|
63dd5f3f64 | ||
|
|
a3a50e9cd5 | ||
|
|
8e3c1aaa96 | ||
|
|
8b71437264 | ||
|
|
61d0ed3f01 | ||
|
|
fc2b7b63a2 | ||
|
|
96590a3389 | ||
|
|
a043de3e44 | ||
|
|
81d3900ef6 | ||
|
|
fd136384a1 | ||
|
|
dd5fe117b5 | ||
|
|
e9d29f789f | ||
|
|
1bc1f646fd | ||
|
|
8ad55cb634 | ||
|
|
b19dec120a | ||
|
|
283c088b21 | ||
|
|
d5ffed09b4 | ||
|
|
b7eec09307 | ||
|
|
23f0f98af3 | ||
|
|
6bbdbc89a6 | ||
|
|
12c8623666 | ||
|
|
2bd6ebd2b1 | ||
|
|
40fb496052 | ||
|
|
b72d822f94 | ||
|
|
6d92ac9af6 | ||
|
|
47f27a8016 | ||
|
|
849d095e9a | ||
|
|
923f240aa1 | ||
|
|
8655ff2de3 | ||
|
|
6f61010cf9 | ||
|
|
5082badca4 | ||
|
|
307bd2a35f | ||
|
|
a11552f497 | ||
|
|
8556caaeb4 | ||
|
|
7c09012b3d | ||
|
|
eb596caa00 | ||
|
|
ab4501aa4c | ||
|
|
4b766d373d | ||
|
|
e3574edc5d | ||
|
|
dcb69ddc73 | ||
|
|
1d6ad297a4 | ||
|
|
85a5e517c9 | ||
|
|
b08d380643 | ||
|
|
ad98fc4121 | ||
|
|
810689c037 | ||
|
|
c007700c59 | ||
|
|
8cc3f6626b | ||
|
|
a3b8a4adc9 | ||
|
|
8f817c089b | ||
|
|
ed4e7794c3 | ||
|
|
6f732d410e | ||
|
|
6c8da20883 | ||
|
|
c7d9ce7f7f | ||
|
|
4e7f639076 | ||
|
|
b2c3b3a99f | ||
|
|
77338d66dc | ||
|
|
e2130df596 | ||
|
|
2bbe6d6069 | ||
|
|
c8b8e505f3 | ||
|
|
89743f9900 | ||
|
|
dbc0562fb0 | ||
|
|
76f4dff14c | ||
|
|
baa2a2f24f | ||
|
|
2ca02911b3 | ||
|
|
cf48237049 | ||
|
|
adfe2c1975 | ||
|
|
a782043798 | ||
|
|
90c4a2f53c | ||
|
|
338b371e4c | ||
|
|
347179373d | ||
|
|
3bb45b80b1 | ||
|
|
e3ec0f3b9b | ||
|
|
f20572b30c | ||
|
|
2124cce603 | ||
|
|
ebf60c1e70 | ||
|
|
c31b6c3683 | ||
|
|
ffc83343fe | ||
|
|
2554acd304 | ||
|
|
98239114ad | ||
|
|
c10b39c1c7 | ||
|
|
20e11465e4 | ||
|
|
46e1b95b33 | ||
|
|
279d6f16e1 | ||
|
|
a747eccaa3 | ||
|
|
0bafbc3184 | ||
|
|
8069370b8c | ||
|
|
46f4b92ff7 | ||
|
|
d92f5ce71c | ||
|
|
2314bf8bd4 | ||
|
|
7808b21496 | ||
|
|
18ef412211 | ||
|
|
0678328253 | ||
|
|
5503e1e14c | ||
|
|
9e89cfa4ed | ||
|
|
13f454a022 | ||
|
|
129650dade | ||
|
|
6fa5b80c0a | ||
|
|
04dfcd0965 | ||
|
|
2e818ac709 | ||
|
|
32ef61197f | ||
|
|
fa06cd8253 | ||
|
|
5020983af5 | ||
|
|
f4496b6977 | ||
|
|
a1719d651e | ||
|
|
e7be2b68a3 | ||
|
|
552dcb56a1 | ||
|
|
e158a65603 | ||
|
|
b694e8aaa2 | ||
|
|
a2e09121ba | ||
|
|
4ce7dfa8f0 | ||
|
|
1c4ce7b4bd | ||
|
|
8a04c1e232 | ||
|
|
6e5d378324 | ||
|
|
8e1f3617fd | ||
|
|
2549ed830f | ||
|
|
0ebd64d314 | ||
|
|
843ecb4a42 | ||
|
|
a1a0d34940 | ||
|
|
15bb978dab | ||
|
|
6a7cf39548 | ||
|
|
8ccb70d07d | ||
|
|
45461a93b0 | ||
|
|
b3a54a78bc | ||
|
|
a4182b5ff9 | ||
|
|
215dcde4b9 | ||
|
|
67b2a9a4f4 | ||
|
|
3b51b23ac2 | ||
|
|
e0f19f8121 | ||
|
|
e720fb528a | ||
|
|
518a5454c6 | ||
|
|
2d9c846084 | ||
|
|
59e30f05fc | ||
|
|
0f1085a02d | ||
|
|
882699919e | ||
|
|
f6a70a542e | ||
|
|
785b1fe937 | ||
|
|
bae909ba10 | ||
|
|
dbb9757a9f | ||
|
|
deaeb46ce9 | ||
|
|
219012bc35 | ||
|
|
5f9eb22d23 | ||
|
|
2c33fb6834 | ||
|
|
8bcef6022b | ||
|
|
93d36779f0 | ||
|
|
2502f5e6f2 | ||
|
|
95f2852cf3 | ||
|
|
ff9f712d65 | ||
|
|
60c4e75a1c | ||
|
|
ccf7c48bf1 | ||
|
|
65d81eb31e | ||
|
|
b97eb12dfc | ||
|
|
d2724d77df | ||
|
|
119b21ac67 | ||
|
|
1ff73b3837 | ||
|
|
d98f8b3467 | ||
|
|
ac8b8861cb | ||
|
|
22dc5dcebd | ||
|
|
3c09e72ce4 | ||
|
|
fffc3fcac7 | ||
|
|
bcdbbe9546 | ||
|
|
19f03cd70e | ||
|
|
9b7858b830 | ||
|
|
8bc55387dd | ||
|
|
0584353bfa | ||
|
|
2938330222 | ||
|
|
ef7393036e | ||
|
|
0409f5bc4a | ||
|
|
8ff1ebd7c2 | ||
|
|
9089fe8be3 | ||
|
|
74d96ce624 | ||
|
|
8b7bcbb880 | ||
|
|
dbd86155fb | ||
|
|
9b77c0802b | ||
|
|
cd7fa79560 | ||
|
|
10e9879a64 | ||
|
|
d1dcc47a27 | ||
|
|
7a73301a37 | ||
|
|
e1dec7d9e7 | ||
|
|
99fefdb47d | ||
|
|
5ebce8965e | ||
|
|
5a0b7285d4 | ||
|
|
829110e89a | ||
|
|
dc1a0b65fa | ||
|
|
b140826e60 | ||
|
|
0d9387458d | ||
|
|
f2447a9134 | ||
|
|
2ea3d8943e | ||
|
|
e4cc78a750 | ||
|
|
a08832cfc8 | ||
|
|
c97918df24 | ||
|
|
e9833d1cd2 | ||
|
|
111a18585d | ||
|
|
155d3ec938 | ||
|
|
8bafacbd51 | ||
|
|
0e3f48ee54 | ||
|
|
b566b4a0c6 | ||
|
|
a9ed66d5e0 | ||
|
|
94131edb32 | ||
|
|
e21863956c | ||
|
|
4201e6ef85 | ||
|
|
5deb1de555 | ||
|
|
c65534ebb1 | ||
|
|
f22efce3ca | ||
|
|
5f0909047d | ||
|
|
7cc4dc2f07 | ||
|
|
60ebe9e738 | ||
|
|
a1297feb9d | ||
|
|
09598d0173 | ||
|
|
35fc845040 | ||
|
|
e59950966f | ||
|
|
98cc5b33a3 | ||
|
|
d107d00ac3 | ||
|
|
ccc000a416 | ||
|
|
7790f8818b | ||
|
|
72ca629cf1 | ||
|
|
65017d7f5c | ||
|
|
6d4f7afc79 | ||
|
|
4fcb032791 | ||
|
|
0e668fa0f2 | ||
|
|
68b933a501 | ||
|
|
5236ad9f64 | ||
|
|
937c18fe1d | ||
|
|
fb48aaba9d | ||
|
|
365efe4f2d | ||
|
|
78b2dba42a | ||
|
|
f793b7607f | ||
|
|
c567bc22e9 | ||
|
|
d282462547 | ||
|
|
af4cfd3fe9 | ||
|
|
cfba203981 | ||
|
|
d680ed7363 | ||
|
|
69232c0717 | ||
|
|
b4baa28f01 | ||
|
|
0aa11b58b9 | ||
|
|
7b60b562b9 | ||
|
|
6377cbfb2b | ||
|
|
3f5f9cc717 | ||
|
|
eac1e9b574 | ||
|
|
26d63da7aa | ||
|
|
722181439e | ||
|
|
ddcb7041f1 | ||
|
|
8af33e0ae2 | ||
|
|
d01e12ac14 | ||
|
|
8c0aa840ab | ||
|
|
05118e9498 | ||
|
|
7838adf833 | ||
|
|
e230cee91e | ||
|
|
8e4fc77244 | ||
|
|
0d572036f8 | ||
|
|
26fdd0ff6b | ||
|
|
70a4aee930 | ||
|
|
3631323aa7 | ||
|
|
1fd7d18056 | ||
|
|
a60f67cd0a | ||
|
|
5ba781d00e | ||
|
|
17c5d25996 | ||
|
|
bd9f271eff | ||
|
|
89b4bd2405 | ||
|
|
4da9095c59 | ||
|
|
75e84a5797 | ||
|
|
54d64dbb5f | ||
|
|
03e746953c | ||
|
|
ec8a51b06c | ||
|
|
369c08a624 | ||
|
|
7a8e5e92d9 | ||
|
|
185ec7ff2b | ||
|
|
af986cc7b2 | ||
|
|
25d96ccfa7 | ||
|
|
b45c42ef22 | ||
|
|
ea2ac3d483 | ||
|
|
873df96d0d | ||
|
|
d69495baa7 | ||
|
|
06ff8f24fe | ||
|
|
b996608455 | ||
|
|
6c1c22132e | ||
|
|
8b326d5852 | ||
|
|
dd34f65c98 | ||
|
|
0bd0f853f3 | ||
|
|
e7a75efaff | ||
|
|
2904b50061 | ||
|
|
3b6ac632d9 | ||
|
|
9ad3f0e0d7 | ||
|
|
9529a4ba02 | ||
|
|
69b9ab097b | ||
|
|
4b14c4bcc6 | ||
|
|
5154c670c0 | ||
|
|
09b699cc9c | ||
|
|
f2a212e3a4 | ||
|
|
19ca946e3b | ||
|
|
e21be39c13 | ||
|
|
8fcfff7abd | ||
|
|
bcc150a014 | ||
|
|
3d97e93831 | ||
|
|
9d93d4db54 | ||
|
|
0d8aec7eea | ||
|
|
7b165c6c2c | ||
|
|
d3cee314c6 | ||
|
|
4395245aab | ||
|
|
9d4b0a13c5 | ||
|
|
c908290c27 | ||
|
|
f5c21d1089 | ||
|
|
883fc75f47 | ||
|
|
eaac3049af | ||
|
|
f68fb52af1 | ||
|
|
863bd5a89e | ||
|
|
50225624a5 | ||
|
|
25ddaef423 | ||
|
|
585f2bef07 | ||
|
|
017ea1a4fe | ||
|
|
3b4b5bcd8e | ||
|
|
f57557b43a | ||
|
|
0711fd6f9e | ||
|
|
b5ecbd1739 | ||
|
|
dda5e4e333 | ||
|
|
74b0e71015 | ||
|
|
dde4a36df0 | ||
|
|
31b98fb9f3 | ||
|
|
289d34d96c | ||
|
|
eafd110ed0 | ||
|
|
e72644abf4 | ||
|
|
b267103274 | ||
|
|
3856a690eb | ||
|
|
f214696664 | ||
|
|
9e73c29b40 | ||
|
|
aca83bd462 | ||
|
|
189d6a23c6 | ||
|
|
441f88deea | ||
|
|
6d6666dace | ||
|
|
fb779533e6 | ||
|
|
7325113a8c | ||
|
|
827217823e | ||
|
|
060dfc69f4 | ||
|
|
b831713737 | ||
|
|
7da90b3a6b | ||
|
|
32540c23ab | ||
|
|
d24b0616f8 | ||
|
|
9aef2ef883 | ||
|
|
727d473319 | ||
|
|
8225e51867 | ||
|
|
1ba6c2a596 | ||
|
|
60a166aeb0 | ||
|
|
65c2155bca | ||
|
|
6031c01584 | ||
|
|
da8e8c8a25 | ||
|
|
70a750a32d | ||
|
|
7c63324504 | ||
|
|
dd41b10522 | ||
|
|
7948e764d4 | ||
|
|
82ede4530a | ||
|
|
e8ab2db8e8 | ||
|
|
8882e0214c | ||
|
|
4adb669cdd | ||
|
|
7e1d258dd3 | ||
|
|
417fe29e21 | ||
|
|
bd8ef2a25d | ||
|
|
fd01b75c33 | ||
|
|
1388755d2a | ||
|
|
97cc3d0066 | ||
|
|
694cf7a79e | ||
|
|
da89efb79f | ||
|
|
04ec013407 | ||
|
|
023cf6a1aa | ||
|
|
f7cbb141f8 | ||
|
|
5690952516 | ||
|
|
e94202c55a | ||
|
|
aa6ad271a0 | ||
|
|
3b41bb47b6 | ||
|
|
e7bdb7fabc | ||
|
|
110698223d | ||
|
|
437be593b9 | ||
|
|
502d37b574 | ||
|
|
df59f9f859 | ||
|
|
f436fbab6b | ||
|
|
8404720501 | ||
|
|
4431d452f1 | ||
|
|
6a529d6671 | ||
|
|
78fca9a67a | ||
|
|
0114b5e4f6 | ||
|
|
5a14a64b6c | ||
|
|
b555ea6350 | ||
|
|
361ae1dd16 | ||
|
|
58117eba88 | ||
|
|
6260b49b4f | ||
|
|
988239267b | ||
|
|
19cffe3872 | ||
|
|
3b1cef918e | ||
|
|
3d004d2a81 | ||
|
|
d1bbebad3a | ||
|
|
42714ff8af | ||
|
|
3553328f7a | ||
|
|
0202271f00 | ||
|
|
d91d6a419c | ||
|
|
5173090474 | ||
|
|
c26df8318f | ||
|
|
7b44f0088a | ||
|
|
aa4d3cc9fd | ||
|
|
246fd03265 | ||
|
|
55074872fe | ||
|
|
28559dda3a | ||
|
|
cbcfad5b2e | ||
|
|
a9ad440860 | ||
|
|
5104463593 | ||
|
|
4b1c51c21d | ||
|
|
236ef52980 | ||
|
|
f220c5b406 | ||
|
|
9415582fe1 | ||
|
|
a5a3630727 | ||
|
|
f4c36d9c43 | ||
|
|
64930e3771 | ||
|
|
16381234e0 | ||
|
|
492005d00a | ||
|
|
149d9b61cc | ||
|
|
77ffb6a3d5 | ||
|
|
d95b632884 | ||
|
|
579f554edb | ||
|
|
050287f306 | ||
|
|
dafe156212 | ||
|
|
48bf264178 | ||
|
|
769dbe8852 | ||
|
|
67bccb865a | ||
|
|
d1e60de04a | ||
|
|
89d592ce43 | ||
|
|
c06dda886d | ||
|
|
23d92fac63 | ||
|
|
5922b85290 | ||
|
|
814e5a643e | ||
|
|
3db3a272d5 | ||
|
|
2d703fbc80 | ||
|
|
b49d3cc21c | ||
|
|
02b5d2357a | ||
|
|
1206178eca | ||
|
|
3df3f8a812 | ||
|
|
7049952b07 | ||
|
|
a18ce40921 | ||
|
|
6a6383462d | ||
|
|
44301fae4f | ||
|
|
6ee84510ea | ||
|
|
6ecdc8d7fc | ||
|
|
35a2a4d803 | ||
|
|
7b67b3b858 | ||
|
|
4011810536 | ||
|
|
85ea07c97e | ||
|
|
41b2449cdd | ||
|
|
ec83a5fff2 | ||
|
|
ded6f06ed2 | ||
|
|
2605e050a0 | ||
|
|
19b1e19e42 | ||
|
|
f7a1149cac | ||
|
|
7dd52dab32 | ||
|
|
937aec600a | ||
|
|
4802053da6 | ||
|
|
0105dff7ac | ||
|
|
8cc448efcf | ||
|
|
982b358bf8 | ||
|
|
ffc80d61af | ||
|
|
f55956612c | ||
|
|
cd3b342d74 | ||
|
|
ba959586e2 | ||
|
|
4c07e584b7 | ||
|
|
280d1215de | ||
|
|
22538ba7c9 | ||
|
|
a2a95ed840 | ||
|
|
4bd9461282 | ||
|
|
96adef5269 | ||
|
|
9576ea25a6 | ||
|
|
a7fcafb245 | ||
|
|
73bb41d579 | ||
|
|
0a90d76493 | ||
|
|
010981d3c8 | ||
|
|
3353061e76 | ||
|
|
79bc34047b | ||
|
|
60c90408e7 | ||
|
|
1218c3e226 | ||
|
|
a05fc9d08e | ||
|
|
6906ef2154 | ||
|
|
7d25e84ebc | ||
|
|
121d935315 | ||
|
|
2f66a866d8 | ||
|
|
0e088c17a8 | ||
|
|
4cd8a6636b | ||
|
|
5c7fc763fc | ||
|
|
1e381a59be | ||
|
|
85111f25cb | ||
|
|
f78887a02e | ||
|
|
feba535637 | ||
|
|
3262143c73 | ||
|
|
18feb7967a | ||
|
|
e9b1511117 | ||
|
|
177e5f62f7 | ||
|
|
f3f4395da7 | ||
|
|
442e46b012 | ||
|
|
37d699d05b | ||
|
|
77ed1e1d4a | ||
|
|
50e4cd67b5 | ||
|
|
83a90eb553 | ||
|
|
c29599d39a | ||
|
|
a9fe842242 | ||
|
|
692e0adde4 | ||
|
|
cdba518bae | ||
|
|
b70b67fa1f | ||
|
|
ff0ca9bc7b | ||
|
|
320bc25d94 | ||
|
|
425e955b5d | ||
|
|
33ae9a2597 | ||
|
|
19913d3612 | ||
|
|
0432546746 | ||
|
|
3395bab928 | ||
|
|
a3eb58724f | ||
|
|
0afa00779c | ||
|
|
17d5545804 | ||
|
|
cd70662f01 | ||
|
|
a89c97409b | ||
|
|
102cb6d949 | ||
|
|
6c9c9ad42a | ||
|
|
acbc96fd55 | ||
|
|
ca721c1acb | ||
|
|
3bf669c42a | ||
|
|
cdc5f75fcb | ||
|
|
d74f19970b | ||
|
|
2ddde37771 | ||
|
|
c1c422e03d | ||
|
|
7608b7d658 | ||
|
|
d1d5ae814f | ||
|
|
452fa61717 | ||
|
|
825f697fd2 | ||
|
|
4ea71ae88e | ||
|
|
bdb32f5878 | ||
|
|
e3c726b8f6 | ||
|
|
96c6c7b1ca | ||
|
|
634d62f9ef | ||
|
|
2806156cf4 | ||
|
|
e642192461 | ||
|
|
959c788f22 | ||
|
|
cda520589a | ||
|
|
5c1db129d3 | ||
|
|
c718962426 | ||
|
|
575a11b645 | ||
|
|
f97c5fc1ff | ||
|
|
81397d98b8 | ||
|
|
82b2ff0b3f | ||
|
|
05fcb7b1aa | ||
|
|
c79db98978 | ||
|
|
303aa77901 | ||
|
|
65a4ef7ee5 | ||
|
|
1be7fbd8a6 | ||
|
|
935b5cfe0f | ||
|
|
bad02729db | ||
|
|
80f7ded687 | ||
|
|
f569b89d8f | ||
|
|
fec655a29c | ||
|
|
610774b0b9 | ||
|
|
9487665fae | ||
|
|
d5b43b7162 | ||
|
|
718d9d9d3a | ||
|
|
3705dbdd2b | ||
|
|
c37d516980 | ||
|
|
b27a6b5b8e | ||
|
|
98809fafd7 | ||
|
|
dd9a0de98d | ||
|
|
de2298cf0a | ||
|
|
56fb8b06cd | ||
|
|
3b1eb683e1 | ||
|
|
1029305382 | ||
|
|
9b39509e88 | ||
|
|
9da58dde5c | ||
|
|
e2507d2ff1 | ||
|
|
b867f121c9 | ||
|
|
3c6a869336 | ||
|
|
f357e76980 | ||
|
|
946a1fbb7c | ||
|
|
37acdc18f2 | ||
|
|
4dc1d2c50e | ||
|
|
ed72d117a5 | ||
|
|
a302913130 | ||
|
|
659f1a271a | ||
|
|
3fb4b7958d | ||
|
|
3ef0f20b0d | ||
|
|
340baa9703 | ||
|
|
0e9232ba81 | ||
|
|
299afdc6a1 | ||
|
|
04feed8524 | ||
|
|
773979cb37 | ||
|
|
c27d05fd4b | ||
|
|
52d814f2cc | ||
|
|
5009b3b545 | ||
|
|
4e165d375c | ||
|
|
306f7a7872 | ||
|
|
6c11569ac9 | ||
|
|
4be28ba193 | ||
|
|
a1e98f898b | ||
|
|
c5376d3088 | ||
|
|
3e1857b966 | ||
|
|
b8a8232bc3 | ||
|
|
504a7aef0f | ||
|
|
1ddb1822ef | ||
|
|
d3cd4e356d | ||
|
|
bef440760a | ||
|
|
768b92749f | ||
|
|
03b25a0f06 | ||
|
|
a44775cafb | ||
|
|
187c4eb371 | ||
|
|
49201b9945 | ||
|
|
6225dc8ed1 | ||
|
|
aa622f8d27 | ||
|
|
849efa9756 | ||
|
|
8aa764f69f | ||
|
|
de57a8c602 | ||
|
|
4873beb100 | ||
|
|
27d9f3725a | ||
|
|
16b2c3dee3 | ||
|
|
2ced9469d7 | ||
|
|
45c806128a | ||
|
|
3d60aa1747 | ||
|
|
967bb44d94 | ||
|
|
7298393ec9 | ||
|
|
817caf299f | ||
|
|
2ff29dab80 | ||
|
|
030eb3375b | ||
|
|
3237632eb4 | ||
|
|
b29f98c525 | ||
|
|
70387f73f6 | ||
|
|
7adb931ea8 | ||
|
|
b2a5280971 | ||
|
|
613e852ffd | ||
|
|
823f1c2ee3 | ||
|
|
7d7c58fa7c | ||
|
|
a468ec5e08 | ||
|
|
ce1e584266 | ||
|
|
ecd6c5f81a | ||
|
|
61c1485083 | ||
|
|
9f6d0fa2d6 | ||
|
|
1c398f819e | ||
|
|
c7000846cd | ||
|
|
d3c4c2ba6a | ||
|
|
95ac4a4853 | ||
|
|
0d5da063fb | ||
|
|
06f04b8fba | ||
|
|
d24fbc9f55 | ||
|
|
7e40d13947 | ||
|
|
43e520a03e | ||
|
|
4e8e7bec3f | ||
|
|
fe7b6097c9 | ||
|
|
0d634853b6 | ||
|
|
29b05eb167 | ||
|
|
834454491e | ||
|
|
a9a80b5766 | ||
|
|
b21f42ee7c | ||
|
|
d92884800b | ||
|
|
e57d0e96e2 | ||
|
|
983f3a7935 | ||
|
|
37dfd81cc9 | ||
|
|
05400429db | ||
|
|
e4a8222d48 | ||
|
|
fb5ebdb0c2 | ||
|
|
1ef1cd98db | ||
|
|
d581f48cd1 | ||
|
|
752565b8f1 | ||
|
|
8e61753894 | ||
|
|
ba35efd021 | ||
|
|
09af6ad186 | ||
|
|
16a496c706 | ||
|
|
71d50f4e1e | ||
|
|
8a815b42d3 | ||
|
|
d69e3a2f48 | ||
|
|
e38b15531d | ||
|
|
fcc7c3af78 | ||
|
|
5f7d226158 | ||
|
|
738efe8c50 | ||
|
|
0897ca57ff | ||
|
|
938f94e130 | ||
|
|
cfcdb47529 | ||
|
|
76f845f5f4 | ||
|
|
c65b7b6462 | ||
|
|
ace361af60 | ||
|
|
67528b25a8 | ||
|
|
d4138ce843 | ||
|
|
377c716d52 | ||
|
|
cd43355d4c | ||
|
|
b096ee9703 | ||
|
|
9e2bb0b277 | ||
|
|
b8df59ae46 | ||
|
|
98f42c6974 | ||
|
|
db19788e21 | ||
|
|
67d17472e0 | ||
|
|
f68a6eb00d | ||
|
|
b5a6df4fe2 | ||
|
|
290379651d | ||
|
|
6ffbb86169 | ||
|
|
d8b6f87087 | ||
|
|
7aad95ec08 | ||
|
|
574e1bc1e7 | ||
|
|
081c6f0263 | ||
|
|
fc590f82a2 | ||
|
|
729af4bb4d | ||
|
|
c8cb9b3735 | ||
|
|
4f8ea06db1 | ||
|
|
9378df0ff2 | ||
|
|
1f0f77ff72 | ||
|
|
147c5e0ddf | ||
|
|
1518db17f8 | ||
|
|
ef1e57f445 | ||
|
|
87c6672212 | ||
|
|
ab087e941e | ||
|
|
4f70d623a1 | ||
|
|
ba143f8657 | ||
|
|
b6aea0a5f8 | ||
|
|
50e2d27d5b | ||
|
|
f0bf359df3 | ||
|
|
fd6717d06d | ||
|
|
126046a039 | ||
|
|
6705513cb3 | ||
|
|
28fb18b6c7 | ||
|
|
17bb5fe1da | ||
|
|
3e908b9c01 | ||
|
|
8977425475 | ||
|
|
8f92e3f217 | ||
|
|
f07f132cfd | ||
|
|
3444c8b0d6 | ||
|
|
822315a279 | ||
|
|
732da86710 | ||
|
|
5fbc412542 | ||
|
|
cd7e0963ce | ||
|
|
9dc58948b2 | ||
|
|
f0b262cbd5 | ||
|
|
ff37ef3bc5 | ||
|
|
68fab2c328 | ||
|
|
f9d81c4302 | ||
|
|
d16e67c51e | ||
|
|
5fa2ce7d9e | ||
|
|
0a0c45238c | ||
|
|
3d33bbc33d | ||
|
|
ea36ee37a2 | ||
|
|
a907dab432 | ||
|
|
53c604c1b5 | ||
|
|
2975118e5b | ||
|
|
e3ee9cb4c7 | ||
|
|
9a3b4db387 | ||
|
|
297a616460 | ||
|
|
afe0ff0ca7 | ||
|
|
adf1bc291c | ||
|
|
034ffbd0bc | ||
|
|
127a7bb2ce | ||
|
|
e8bfac0790 | ||
|
|
62d5dd3516 | ||
|
|
bcd66fec39 | ||
|
|
cdabe4a46e | ||
|
|
29bc7ca19e | ||
|
|
36ee10a52b | ||
|
|
1a820ad9b7 | ||
|
|
dcbc106e62 | ||
|
|
cdf777384e | ||
|
|
849b329213 | ||
|
|
d555c1b081 | ||
|
|
43cbab37f0 | ||
|
|
6f7af90488 | ||
|
|
3a6f04e461 | ||
|
|
d36f6e45de | ||
|
|
f8ddb50140 | ||
|
|
be076509f2 | ||
|
|
73457453bb | ||
|
|
3091849ff8 | ||
|
|
5136eb84f4 | ||
|
|
c14d565b56 | ||
|
|
57e87d9d4e | ||
|
|
c1eccf499e | ||
|
|
e5b76083b7 | ||
|
|
a8d9139b6c | ||
|
|
703186e931 | ||
|
|
e6fc459080 | ||
|
|
90feb9941f | ||
|
|
2c4ff35796 | ||
|
|
13ccabecf2 | ||
|
|
fcda6c3b3b | ||
|
|
910ef26c79 | ||
|
|
1664da55a4 | ||
|
|
f8ea7f5e1f | ||
|
|
ed5aa1f469 | ||
|
|
b34697040a | ||
|
|
b0205b9499 | ||
|
|
e05796f80e | ||
|
|
a70fa78267 | ||
|
|
e20693de60 | ||
|
|
f10a766442 | ||
|
|
86315fed8d | ||
|
|
4ff9fe8666 | ||
|
|
3512c4c8e6 | ||
|
|
430f08b25f | ||
|
|
f85170eea3 | ||
|
|
5a0ec91159 | ||
|
|
a049a03faa | ||
|
|
365ae356bd | ||
|
|
04755cee33 | ||
|
|
e4fbe28f95 | ||
|
|
1bc0768683 | ||
|
|
1f42e1e2c1 | ||
|
|
91b2622ba2 | ||
|
|
eb341c0704 | ||
|
|
09eecb1c3b | ||
|
|
1562a8f3ca | ||
|
|
13fbd31124 | ||
|
|
433ebe4a21 | ||
|
|
e5c7ba72e5 | ||
|
|
203d6561ac | ||
|
|
117704b0bc | ||
|
|
7958cd0b88 | ||
|
|
51f2a04958 | ||
|
|
a27eb17684 | ||
|
|
05d2b6ccda | ||
|
|
ec61ffcaad | ||
|
|
ed0ad87632 | ||
|
|
4802744ce7 | ||
|
|
adf7e22324 | ||
|
|
09f63364dc | ||
|
|
8c256664b2 | ||
|
|
0354ffa4f8 | ||
|
|
d5f15b8283 | ||
|
|
c4009233a3 | ||
|
|
e02bceaf5d | ||
|
|
8796dbeb56 | ||
|
|
fd63a7df4e | ||
|
|
7fbc721db6 | ||
|
|
210494d0d1 | ||
|
|
9963476218 | ||
|
|
50f2e7a95f | ||
|
|
d7685dc1bc | ||
|
|
301a3a72df | ||
|
|
518a43db9c | ||
|
|
243e69649f | ||
|
|
781204aa20 | ||
|
|
9a714eb537 | ||
|
|
d5cbfefc21 | ||
|
|
12930cfce4 | ||
|
|
298c292ffb | ||
|
|
341263b934 | ||
|
|
11a03bbce9 | ||
|
|
3831464665 | ||
|
|
2fe05b4ff4 | ||
|
|
ec3dc50e20 | ||
|
|
171b2b6a37 | ||
|
|
14a02c0602 | ||
|
|
34e3582557 | ||
|
|
01592e9770 | ||
|
|
3fba6e9ad0 | ||
|
|
bbe0ca9302 | ||
|
|
e572788a8c | ||
|
|
4c0857fbb5 | ||
|
|
44ed1e2d44 | ||
|
|
8fd532c648 | ||
|
|
7c0fa46b4d | ||
|
|
85d0644868 | ||
|
|
4bd3cffc4e | ||
|
|
3ecebdc758 | ||
|
|
f13e355010 | ||
|
|
c28d749548 | ||
|
|
d0760ddd04 | ||
|
|
af5d2c2fca | ||
|
|
4bfabaa1d3 | ||
|
|
747420b4c8 | ||
|
|
78b710dc22 | ||
|
|
7973f544ff | ||
|
|
0b1e1676d0 | ||
|
|
705c1c60c8 | ||
|
|
abfec5a60f | ||
|
|
ca28d8aa84 | ||
|
|
198d852995 | ||
|
|
5f83766dc1 | ||
|
|
442d97a1b1 | ||
|
|
fcbd3deb6b | ||
|
|
dadc6b2d3a | ||
|
|
6231a25413 | ||
|
|
bc08b11011 | ||
|
|
36b08e9b1d | ||
|
|
d73ec779e0 | ||
|
|
6bc9f2140c | ||
|
|
a6f1e305ef | ||
|
|
5fda1d018b | ||
|
|
c919eba206 | ||
|
|
61b3ca531c | ||
|
|
96164f5851 | ||
|
|
4102b11f15 | ||
|
|
3c18efc4a6 | ||
|
|
cfc2b7ff2f | ||
|
|
ad94cca95b | ||
|
|
6ade8132af | ||
|
|
e5b5994593 | ||
|
|
944ddf8d70 | ||
|
|
8b0659a2b4 | ||
|
|
35388c3b19 | ||
|
|
27ab90ab2a | ||
|
|
d41af02ade | ||
|
|
e0a578d06c | ||
|
|
db47460a79 | ||
|
|
a1bcbdc181 | ||
|
|
d1dda6a166 | ||
|
|
7290dbc5a5 | ||
|
|
8bc47c45a4 | ||
|
|
1f5b659f2d | ||
|
|
a591dba8ef | ||
|
|
85d6c836a8 | ||
|
|
7498a5f983 | ||
|
|
63b5068591 | ||
|
|
c54da35a39 | ||
|
|
6789e5c0de | ||
|
|
1fed66d652 | ||
|
|
f42904e5ae | ||
|
|
58828d7924 | ||
|
|
ee64f7c4ff | ||
|
|
3c0424226e | ||
|
|
dd226dfdcf | ||
|
|
16e05cc17b | ||
|
|
13bceb9f5d | ||
|
|
03c652cd55 | ||
|
|
00301b26e6 | ||
|
|
611429b6f6 | ||
|
|
34979c8e84 | ||
|
|
3a6da5cd26 | ||
|
|
9c18b94ec8 | ||
|
|
5187be5d02 | ||
|
|
1c009e1ebc | ||
|
|
8927fe9ea9 | ||
|
|
63b5cb9ec7 | ||
|
|
30d5fbdf8d | ||
|
|
5960f55339 | ||
|
|
743ac51c4c | ||
|
|
2493c655f8 | ||
|
|
f1d9cda5eb | ||
|
|
a76b20f1b5 | ||
|
|
017082c07a | ||
|
|
352c92b880 | ||
|
|
948cce4ceb | ||
|
|
6fe87184ae | ||
|
|
c4c303dbfb | ||
|
|
87adbb477d | ||
|
|
3245ce10ac | ||
|
|
5540683013 | ||
|
|
75d1254dda | ||
|
|
83b944eb4b | ||
|
|
6cbb8c846b | ||
|
|
e0d69d05eb | ||
|
|
4f971ad8e5 | ||
|
|
fa59a3f65c | ||
|
|
8d921d78c5 | ||
|
|
953e44c4a4 | ||
|
|
b664159231 | ||
|
|
5867cd2e1b | ||
|
|
535fb43915 | ||
|
|
0952115776 | ||
|
|
79401c3cf7 | ||
|
|
0ab9f04ea4 | ||
|
|
04f14285e7 | ||
|
|
2a2aef53fb | ||
|
|
3651e672d4 | ||
|
|
9dfa650d7e | ||
|
|
a0a166b553 | ||
|
|
e7f4b46de8 | ||
|
|
b5148cd0ec | ||
|
|
e90b0c28c6 | ||
|
|
3a439bcdb5 | ||
|
|
23e8498b47 | ||
|
|
c9f1b0fdc5 | ||
|
|
19f6510840 | ||
|
|
0a1feaf044 | ||
|
|
890c32949d | ||
|
|
8b37bb5bd7 | ||
|
|
1aff0c2dcb | ||
|
|
a7f137d122 | ||
|
|
148fa7d6da | ||
|
|
20594d2523 | ||
|
|
142315140e | ||
|
|
8d3d2ebd50 | ||
|
|
e674056b3a | ||
|
|
785bd5bfcf | ||
|
|
fb72555e6b | ||
|
|
42f4d43682 | ||
|
|
caeb59ede4 | ||
|
|
992ef5dc91 | ||
|
|
d37433e81c | ||
|
|
d75e0ce26e | ||
|
|
09acbcdb05 | ||
|
|
864dadab80 | ||
|
|
d174cea42e | ||
|
|
e95fad0453 | ||
|
|
ebe6abd885 | ||
|
|
0a563b91a2 | ||
|
|
5cbcd7469b | ||
|
|
dabcb51034 | ||
|
|
0237d485bf | ||
|
|
b673630a7e | ||
|
|
282ec81af1 | ||
|
|
a267fb16b8 | ||
|
|
795ffec8b8 | ||
|
|
dba9dab985 | ||
|
|
abfa815cf1 | ||
|
|
872b25e0c5 | ||
|
|
3fa810e329 | ||
|
|
4951c4822e | ||
|
|
5842b5f51d | ||
|
|
ac4a1565a1 | ||
|
|
203e8b0a75 | ||
|
|
c75594f314 | ||
|
|
690dbea924 | ||
|
|
e7c81504a9 | ||
|
|
fdd5bc5a8e | ||
|
|
91bebabc7f | ||
|
|
5eec83f726 | ||
|
|
827891f10a | ||
|
|
f4fa24cd7f | ||
|
|
2bf1f24db2 | ||
|
|
34c6155fe9 | ||
|
|
3ead31ef14 | ||
|
|
d0ea32dfa1 | ||
|
|
7c1a0ed719 | ||
|
|
b050b13aa3 | ||
|
|
60548e4523 | ||
|
|
8fe002f820 | ||
|
|
65a2e942c4 | ||
|
|
4adb59ab98 | ||
|
|
fa0bbde236 | ||
|
|
e5b1e6c0ad | ||
|
|
731455649e | ||
|
|
ec1215b227 | ||
|
|
dcb14170b9 | ||
|
|
c266778c1e | ||
|
|
8116ce39d7 | ||
|
|
8167002092 | ||
|
|
5cddb84a58 | ||
|
|
a9e41841e9 | ||
|
|
37f6deab85 | ||
|
|
a4aa6a22b7 | ||
|
|
d57f7af453 | ||
|
|
7f8c801c07 | ||
|
|
c627b26f49 | ||
|
|
7c788dfa31 | ||
|
|
3896b27c54 | ||
|
|
97561667a0 | ||
|
|
bdb81123d6 | ||
|
|
f1c57371a3 | ||
|
|
873f9404bf | ||
|
|
7eac272386 | ||
|
|
e6d177c09a | ||
|
|
65f2051e87 | ||
|
|
767abe83f9 | ||
|
|
6eb63fd3fd | ||
|
|
03c59a9f17 | ||
|
|
3fd925c1fd | ||
|
|
6ea8f7b621 | ||
|
|
4e77fc0f0b | ||
|
|
6d347881b7 | ||
|
|
73ad945101 | ||
|
|
d39615d906 | ||
|
|
dcc6e2f23f | ||
|
|
24e068b94d | ||
|
|
6b6cf41782 | ||
|
|
d17bd144a2 | ||
|
|
a5686a17e2 | ||
|
|
2fab3b9957 | ||
|
|
9e2a9abee1 | ||
|
|
10eed23430 | ||
|
|
7967f62131 | ||
|
|
8102bab3ff | ||
|
|
dd026700be | ||
|
|
0001665ece | ||
|
|
d0a7c5a0ec | ||
|
|
ba97e5fff5 | ||
|
|
e90455463f | ||
|
|
72760096f5 | ||
|
|
148cbd06e0 | ||
|
|
62c2c57d4d | ||
|
|
b8f7918a4a | ||
|
|
526118e7d3 | ||
|
|
37c20d5b6d | ||
|
|
5b60998b0a | ||
|
|
833713bee2 | ||
|
|
cf1f2f8f03 | ||
|
|
f6cbda0e04 | ||
|
|
7d33814d5b | ||
|
|
7c59d61b32 | ||
|
|
844a4a0574 | ||
|
|
5968a6bc27 | ||
|
|
f94e242a75 | ||
|
|
ddee7d1b94 | ||
|
|
30fce436dd | ||
|
|
dfdc6a52be | ||
|
|
ba5ce33464 | ||
|
|
7809615896 | ||
|
|
27a297a18d | ||
|
|
bbf657e251 | ||
|
|
c6d2746959 | ||
|
|
d895d40fbf | ||
|
|
a1d40f24a7 | ||
|
|
fd697aeb83 | ||
|
|
6e05327934 | ||
|
|
a4871cac36 | ||
|
|
b17f5d32c9 | ||
|
|
3896bcbd64 | ||
|
|
9c986aa25f | ||
|
|
419d2d8282 | ||
|
|
d570570394 | ||
|
|
0347badeda | ||
|
|
eb924b9861 | ||
|
|
38c8a8e666 | ||
|
|
9f75f1aad3 | ||
|
|
a669163196 | ||
|
|
87842a36ba | ||
|
|
2d3691107d | ||
|
|
134fbdf1df | ||
|
|
ab490cd588 | ||
|
|
2e903acbaa | ||
|
|
06417910e2 | ||
|
|
c56dd6e302 | ||
|
|
19dcb33eb7 | ||
|
|
540fa98a44 | ||
|
|
7428b7f981 | ||
|
|
6fc19b92eb | ||
|
|
1a701e69ca | ||
|
|
569c848764 | ||
|
|
ad93d15197 | ||
|
|
4a0507a838 | ||
|
|
bc4737562d | ||
|
|
55f3a14343 | ||
|
|
72e99a8833 | ||
|
|
0eb5063332 | ||
|
|
ca387687a5 | ||
|
|
2d376bc72f | ||
|
|
58948b45b3 | ||
|
|
514f9b90f0 | ||
|
|
0c41363914 | ||
|
|
9bf0b65016 | ||
|
|
cdfe2b1487 | ||
|
|
fe936a683f | ||
|
|
e3cc5f2df8 | ||
|
|
3c0dc1e455 | ||
|
|
d5b781fd60 | ||
|
|
0a876c33a7 | ||
|
|
fc8ee7f25f | ||
|
|
cf448cd1cc | ||
|
|
928f05ca8f | ||
|
|
7b60552ec1 | ||
|
|
26045e2ec0 | ||
|
|
e5ebeaf724 | ||
|
|
dc24bb53c2 | ||
|
|
2175cb8a44 | ||
|
|
756ea346e6 | ||
|
|
23f3d69d38 | ||
|
|
a134e99c8c | ||
|
|
607f1980a1 | ||
|
|
fb4af9fefc | ||
|
|
447b9db397 | ||
|
|
77eb430b0b | ||
|
|
d4ab25b200 | ||
|
|
faaa4a4b1e | ||
|
|
a844e8b5ad | ||
|
|
84143d06fa | ||
|
|
9805f3f4d1 | ||
|
|
bae6f89fa5 | ||
|
|
a721e04119 | ||
|
|
6360c690cf | ||
|
|
aa75a3f20d | ||
|
|
3edfec2491 | ||
|
|
c364adcf00 | ||
|
|
7d6714f713 | ||
|
|
8485bd44f9 | ||
|
|
c0800afeeb | ||
|
|
046752f8c2 | ||
|
|
9307f9b9c1 | ||
|
|
ee2018416e | ||
|
|
6c38b6c6fb | ||
|
|
cafb297594 | ||
|
|
8bec43f7a2 | ||
|
|
fe1dd0d0f3 | ||
|
|
b066d4dd83 | ||
|
|
792c7d5e91 | ||
|
|
76498e86f5 | ||
|
|
540a15160c | ||
|
|
6eb5aded38 | ||
|
|
891605380f | ||
|
|
fe9348b3fb | ||
|
|
c592a9d361 | ||
|
|
fae159cdbd | ||
|
|
d7b0f74a75 | ||
|
|
d5301824fc | ||
|
|
28607ce58c | ||
|
|
9fb0ab57e6 | ||
|
|
6143b088c3 | ||
|
|
06e24b3bc2 | ||
|
|
3283b8c0a3 | ||
|
|
f43501e828 | ||
|
|
192ced4e4c | ||
|
|
dd65a1e76c | ||
|
|
0b042dad43 | ||
|
|
14384f6bfa | ||
|
|
b9f293f8a7 | ||
|
|
d03d85b52b | ||
|
|
cf9c9f7073 | ||
|
|
7fb263e75c | ||
|
|
1d20184f0b | ||
|
|
500384abf3 | ||
|
|
d1b18da36e | ||
|
|
3b3acbcfda | ||
|
|
6c35dfcb3d | ||
|
|
01ad006ca3 | ||
|
|
7e580920f6 | ||
|
|
5227824608 | ||
|
|
1c78f5cc3b | ||
|
|
306aab0d8d | ||
|
|
e33c42e123 | ||
|
|
9ccfd4aac0 | ||
|
|
549da08f87 | ||
|
|
b6c7799cc2 | ||
|
|
d063b5a894 | ||
|
|
cd78211cdf | ||
|
|
4e9d6d22dd | ||
|
|
3a3d1a5981 | ||
|
|
b15d868f77 | ||
|
|
a6232b6bb6 | ||
|
|
6ca3712b79 | ||
|
|
db6724acdf | ||
|
|
16c7bf2eb3 | ||
|
|
0331fafa77 | ||
|
|
1d63209691 | ||
|
|
140ece68d3 | ||
|
|
e95ca8444e | ||
|
|
dce381fb28 | ||
|
|
121b262d1b | ||
|
|
51b52ac343 | ||
|
|
8793add589 | ||
|
|
e4f6bb363d | ||
|
|
6bd34f44ef | ||
|
|
be60e10ebd | ||
|
|
56cfffb2ef | ||
|
|
20a59ddb6e | ||
|
|
bfa93cc189 | ||
|
|
480055b3d7 | ||
|
|
5e605f992a | ||
|
|
3634cab1a5 | ||
|
|
8e2ffe08f8 | ||
|
|
b6957db352 | ||
|
|
ff3b1e810f | ||
|
|
14c4ed8379 | ||
|
|
a224894380 | ||
|
|
f5a4c8f11e | ||
|
|
73ac6488ce | ||
|
|
c03765803c | ||
|
|
65fc8a9c41 | ||
|
|
e8e15d2cd4 | ||
|
|
d7849f4120 | ||
|
|
c48f68f0dc | ||
|
|
fe49e08340 | ||
|
|
5051f3c4d7 | ||
|
|
0c8695a888 | ||
|
|
d63e342f78 | ||
|
|
9f4ccf9eaf | ||
|
|
1f14ac5c18 | ||
|
|
8f71261646 | ||
|
|
1a9954428b | ||
|
|
e43ae47a78 | ||
|
|
57213dd625 | ||
|
|
ce5ffb9bd7 | ||
|
|
5375ff3790 | ||
|
|
37d4dc70e5 | ||
|
|
e7337d06b5 | ||
|
|
bcc76aff63 | ||
|
|
154d43819a | ||
|
|
318e0eabea | ||
|
|
0a2f1a3dfe | ||
|
|
b19dbb1b8f | ||
|
|
904a9700b2 | ||
|
|
f5daf7085e | ||
|
|
f500e2ce9a | ||
|
|
e2a67365f9 | ||
|
|
2273329e29 | ||
|
|
be1acfdccd | ||
|
|
2f39811a46 | ||
|
|
f995676fad | ||
|
|
ea4c966003 | ||
|
|
fe5de8a854 | ||
|
|
fa43f39015 | ||
|
|
4d0e6254dd | ||
|
|
e94e908bed | ||
|
|
179dbe19fd | ||
|
|
d6eb846488 | ||
|
|
6796d460dc | ||
|
|
4be2fc1a90 | ||
|
|
20f79f117f | ||
|
|
4169996e7a | ||
|
|
667fc18abf | ||
|
|
4f72ff47bc | ||
|
|
b7704a4ea8 | ||
|
|
ac0858dcdb | ||
|
|
7439dc01a5 | ||
|
|
090e0b6757 | ||
|
|
effad664d5 | ||
|
|
01bf7d1389 | ||
|
|
b7c7e4ad23 | ||
|
|
5ca02e6596 | ||
|
|
6b2f87c5a9 | ||
|
|
9a265aac48 | ||
|
|
5b052c170f | ||
|
|
555f151692 | ||
|
|
c22978c3f9 | ||
|
|
54b3a23ae2 | ||
|
|
f5b40dba34 | ||
|
|
f8160c6318 | ||
|
|
b113bb59d4 | ||
|
|
15bd41fefc | ||
|
|
4e6aef3d24 | ||
|
|
c798f995ca | ||
|
|
9bca2b44ab | ||
|
|
dde0b20775 | ||
|
|
ad13062117 | ||
|
|
d11a295ffd | ||
|
|
ffea359661 | ||
|
|
037456c99d | ||
|
|
5125a137f4 | ||
|
|
3f1c996959 | ||
|
|
53a7cd732f | ||
|
|
4fd026ff99 | ||
|
|
d9fbd68529 | ||
|
|
49d80462d1 | ||
|
|
1d859e49ad | ||
|
|
a2c43d822c | ||
|
|
7907565377 | ||
|
|
d1c014fe16 | ||
|
|
465041b98b | ||
|
|
ed56afda26 | ||
|
|
23f14bc2d5 | ||
|
|
c829a32555 | ||
|
|
ae984c2055 | ||
|
|
0c416c8366 | ||
|
|
51be2131f7 | ||
|
|
575a8142ff | ||
|
|
093a1f677b | ||
|
|
8311da2653 | ||
|
|
b5976a52e0 | ||
|
|
4e6c98ac57 | ||
|
|
a2c692af39 | ||
|
|
a131527a15 | ||
|
|
0b925e6fc0 | ||
|
|
97c8f5192e | ||
|
|
7c372cd978 | ||
|
|
02fe58161c | ||
|
|
2ba2ebaa43 | ||
|
|
549500eaf2 | ||
|
|
8e7589e450 | ||
|
|
9b69403ee1 | ||
|
|
6269ce9a3f | ||
|
|
0f6625aea9 | ||
|
|
dbceccaa3e | ||
|
|
6c7ba6a76f | ||
|
|
f76a517339 | ||
|
|
2c747ecf36 | ||
|
|
1f8b60081e | ||
|
|
a800359e0b | ||
|
|
4854961901 | ||
|
|
50a815bdb9 | ||
|
|
1690b9d83d | ||
|
|
7804516793 | ||
|
|
c54e9b5dba | ||
|
|
71936cfe22 | ||
|
|
27890e2b22 | ||
|
|
da6df89126 | ||
|
|
95ff197910 | ||
|
|
2215b0f53f | ||
|
|
3887fdd47d | ||
|
|
7e9328bd25 | ||
|
|
9d9af25c7f | ||
|
|
5a2fd19bcf | ||
|
|
3a50850734 | ||
|
|
812de5c35c | ||
|
|
bffea1d7c8 | ||
|
|
b00f458e67 | ||
|
|
80ef955eae | ||
|
|
44509ff6e4 | ||
|
|
e1d4129869 | ||
|
|
00655f724d | ||
|
|
4590e7ea26 | ||
|
|
2ac1ce4f56 | ||
|
|
f726035660 | ||
|
|
57bb1ee475 | ||
|
|
889dde7549 | ||
|
|
ada2fe01a2 | ||
|
|
cf29a0ba6a | ||
|
|
c929ebb89a | ||
|
|
8159530906 | ||
|
|
7e8ba9a256 | ||
|
|
b145ec59ea | ||
|
|
429a7275ee | ||
|
|
3bd0608b6e | ||
|
|
9307e0cb71 | ||
|
|
4672e51806 | ||
|
|
18811122b3 | ||
|
|
cbaf126a25 | ||
|
|
8e7abe325e | ||
|
|
ed9e4ecd28 | ||
|
|
bd866de950 | ||
|
|
4ecb6b5fdb | ||
|
|
0d6bca2080 | ||
|
|
05ef05dcac | ||
|
|
7ba097c640 | ||
|
|
6adacbb357 | ||
|
|
69f62574c4 | ||
|
|
b00c31730f | ||
|
|
f09180659d | ||
|
|
c12373bf41 | ||
|
|
04666b66b4 | ||
|
|
363aee70d5 | ||
|
|
01d03d5d41 | ||
|
|
4575fc5aff | ||
|
|
27e9e3aa88 | ||
|
|
b0187698b9 | ||
|
|
0364d4e0de | ||
|
|
86b57804c6 | ||
|
|
211dc220d8 | ||
|
|
aae586f79a | ||
|
|
32f49350cf | ||
|
|
9739784e75 | ||
|
|
a0e93af758 | ||
|
|
81c6291338 | ||
|
|
24509d60be | ||
|
|
f0947e9a7c | ||
|
|
92bb4e0e66 | ||
|
|
8f810ad447 | ||
|
|
3f35a6b59c | ||
|
|
427dd714c9 | ||
|
|
9d7a2043f7 | ||
|
|
ff3ec84b0d | ||
|
|
1f9e72c5e2 | ||
|
|
67be18566c | ||
|
|
862e71bc85 | ||
|
|
395655ba19 | ||
|
|
1bb569fff2 | ||
|
|
e66ad88451 | ||
|
|
3bf3093177 | ||
|
|
5eb82add06 | ||
|
|
8bd1a9f3bc | ||
|
|
145d24c34c | ||
|
|
229ff9f0e4 | ||
|
|
0557aa58b0 | ||
|
|
b40aa43872 | ||
|
|
a1cdfa19b0 | ||
|
|
d62b401db8 | ||
|
|
887957756e | ||
|
|
b6d6b24796 | ||
|
|
b6c0871daa | ||
|
|
b080187808 | ||
|
|
3c613fd59b | ||
|
|
547c6e4073 | ||
|
|
6098086a99 | ||
|
|
87f90e9bdd | ||
|
|
65b1821196 | ||
|
|
756321d280 | ||
|
|
3dbf69f163 | ||
|
|
e8ace54036 | ||
|
|
22e1c14e7e | ||
|
|
cd38aeb544 | ||
|
|
9e9409da1e | ||
|
|
36e580474f | ||
|
|
e007331581 | ||
|
|
8d435ec86e | ||
|
|
214d64e4ad | ||
|
|
737fadc390 | ||
|
|
10de6ac929 | ||
|
|
fe9fbf585f | ||
|
|
af3f3fb4c7 | ||
|
|
0e6a5240db | ||
|
|
f272a7ecd6 | ||
|
|
104caea3c9 | ||
|
|
44fbd05df7 | ||
|
|
6cfb5084e1 | ||
|
|
ae1804758a | ||
|
|
4b470b32c5 | ||
|
|
cfe89dde17 | ||
|
|
30dae51ddf | ||
|
|
0b11abf8f4 | ||
|
|
b673882b2f | ||
|
|
200dbda6d3 | ||
|
|
5724c0c8df |
No files matched your search
@@ -0,0 +1,183 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||
|
||||
<!-- based on https://github.com/KyoriPowered/adventure/blob/master/.checkstyle/checkstyle.xml -->
|
||||
|
||||
<module name="Checker">
|
||||
<property name="charset" value="UTF-8"/>
|
||||
<property name="fileExtensions" value="java, properties, xml"/>
|
||||
<property name="severity" value="error"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_filefilters.html#BeforeExecutionExclusionFileFilter -->
|
||||
<module name="BeforeExecutionExclusionFileFilter">
|
||||
<property name="fileNamePattern" value="module\-info\.java$"/>
|
||||
</module>
|
||||
|
||||
<!-- https://checkstyle.org/config_whitespace.html#FileTabCharacter -->
|
||||
<module name="FileTabCharacter">
|
||||
<property name="eachLine" value="true"/>
|
||||
</module>
|
||||
|
||||
<!-- https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
|
||||
<module name="NewlineAtEndOfFile"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
|
||||
<module name="SuppressionFilter">
|
||||
<property name="file" value="${checkstyle.suppressions.file}"/>
|
||||
</module>
|
||||
|
||||
<!-- https://checkstyle.org/config_filters.html#SuppressWithPlainTextCommentFilter -->
|
||||
<module name="SuppressWithPlainTextCommentFilter"/>
|
||||
|
||||
<module name="TreeWalker">
|
||||
<!-- https://checkstyle.org/config_misc.html#ArrayTypeStyle -->
|
||||
<module name="ArrayTypeStyle"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_imports.html#AvoidStarImport -->
|
||||
<module name="AvoidStarImport"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_misc.html#AvoidEscapedUnicodeCharacters -->
|
||||
<module name="AvoidEscapedUnicodeCharacters">
|
||||
<property name="allowByTailComment" value="true"/>
|
||||
<property name="allowEscapesForControlCharacters" value="true"/>
|
||||
<property name="allowNonPrintableEscapes" value="true"/>
|
||||
<property name="severity" value="info"/>
|
||||
</module>
|
||||
|
||||
<!-- https://checkstyle.org/config_misc.html#CommentsIndentation -->
|
||||
<module name="CommentsIndentation"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_whitespace.html#EmptyForInitializerPad -->
|
||||
<module name="EmptyForInitializerPad"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_whitespace.html#EmptyForIteratorPad -->
|
||||
<module name="EmptyForIteratorPad"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_whitespace.html#EmptyLineSeparator -->
|
||||
<module name="EmptyLineSeparator">
|
||||
<property name="allowMultipleEmptyLines" value="false"/>
|
||||
<property name="allowMultipleEmptyLinesInsideClassMembers" value="false"/>
|
||||
<property name="allowNoEmptyLineBetweenFields" value="true"/>
|
||||
<property name="tokens"
|
||||
value="CLASS_DEF, CTOR_DEF, ENUM_DEF, IMPORT, INSTANCE_INIT, INTERFACE_DEF, METHOD_DEF, STATIC_IMPORT, STATIC_INIT, VARIABLE_DEF"/> <!-- remove PACKAGE_DEF, temporarily remove COMPACT_CTOR_DEF, RECORD_DEF -->
|
||||
</module>
|
||||
|
||||
<!-- https://checkstyle.org/config_coding.html#FallThrough -->
|
||||
<module name="FallThrough">
|
||||
<property name="checkLastCaseGroup" value="true"/>
|
||||
</module>
|
||||
|
||||
<!-- https://checkstyle.org/config_design.html#FinalClass -->
|
||||
<module name="FinalClass"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_coding.html#FinalLocalVariable -->
|
||||
<module name="FinalLocalVariable"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_whitespace.html#GenericWhitespace -->
|
||||
<module name="GenericWhitespace"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_design.html#HideUtilityClassConstructor -->
|
||||
<module name="HideUtilityClassConstructor"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_imports.html#IllegalImport -->
|
||||
<module name="IllegalImport">
|
||||
<property name="illegalPkgs" value="sun, jdk, com.sun"/>
|
||||
</module>
|
||||
|
||||
<!-- https://checkstyle.org/config_coding.html#IllegalTokenText -->
|
||||
<module name="IllegalTokenText">
|
||||
<property name="format"
|
||||
value="\\u00(09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
|
||||
<property name="message"
|
||||
value="Consider using special escape sequence instead of octal value or Unicode escaped value."/>
|
||||
<property name="tokens" value="CHAR_LITERAL, STRING_LITERAL"/>
|
||||
</module>
|
||||
|
||||
<!-- https://checkstyle.org/config_misc.html#Indentation -->
|
||||
<module name="Indentation"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_blocks.html#LeftCurly -->
|
||||
<module name="LeftCurly"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_naming.html#MethodName -->
|
||||
<module name="MethodName">
|
||||
<property name="format" value="^[_]?[a-z][a-zA-Z0-9]*$"/>
|
||||
</module>
|
||||
|
||||
<!-- https://checkstyle.org/config_whitespace.html#MethodParamPad -->
|
||||
<module name="MethodParamPad"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_javadoc.html#MissingJavadocMethod -->
|
||||
<module name="MissingJavadocMethod">
|
||||
<property name="allowMissingPropertyJavadoc" value="true"/>
|
||||
<property name="tokens" value="METHOD_DEF, ANNOTATION_FIELD_DEF"/> <!-- remove CTOR_DEF, COMPACT_CTOR_DEF -->
|
||||
</module>
|
||||
|
||||
<!-- https://checkstyle.org/config_javadoc.html#MissingJavadocType -->
|
||||
<module name="MissingJavadocType"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_coding.html#NoFinalizer -->
|
||||
<module name="NoFinalizer"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_whitespace.html#NoLineWrap -->
|
||||
<module name="NoLineWrap"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_whitespace.html#NoWhitespaceAfter -->
|
||||
<module name="NoWhitespaceAfter">
|
||||
<property name="allowLineBreaks" value="false"/>
|
||||
</module>
|
||||
|
||||
<!-- https://checkstyle.org/config_whitespace.html#NoWhitespaceBefore -->
|
||||
<module name="NoWhitespaceBefore">
|
||||
<property name="allowLineBreaks" value="true"/>
|
||||
</module>
|
||||
|
||||
<!-- https://checkstyle.org/config_coding.html#OneStatementPerLine -->
|
||||
<module name="OneStatementPerLine"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_misc.html#OuterTypeFilename -->
|
||||
<module name="OuterTypeFilename"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_imports.html#RedundantImport -->
|
||||
<module name="RedundantImport"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_modifier.html#RedundantModifier -->
|
||||
<module name="RedundantModifier">
|
||||
<property name="tokens"
|
||||
value="ANNOTATION_FIELD_DEF, CLASS_DEF, CTOR_DEF, ENUM_DEF, INTERFACE_DEF, VARIABLE_DEF"/> <!-- remove METHOD_DEF and RESOURCE -->
|
||||
</module>
|
||||
|
||||
<!-- https://checkstyle.org/config_coding.html#RequireThis -->
|
||||
<module name="RequireThis"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_blocks.html#RightCurly -->
|
||||
<module name="RightCurly">
|
||||
<property name="id" value="RightCurlyAlone"/>
|
||||
<property name="option" value="alone"/>
|
||||
<property name="tokens"
|
||||
value="ANNOTATION_DEF, CLASS_DEF, CTOR_DEF, ENUM_DEF, INSTANCE_INIT, LITERAL_FOR, LITERAL_WHILE, METHOD_DEF, STATIC_INIT"/>
|
||||
</module>
|
||||
<module name="RightCurly">
|
||||
<property name="id" value="RightCurlySame"/>
|
||||
<property name="option" value="same"/>
|
||||
<property name="tokens"
|
||||
value="LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF, LITERAL_TRY"/> <!-- add LITERAL_DO -->
|
||||
</module>
|
||||
|
||||
<!-- https://checkstyle.org/config_whitespace.html#SingleSpaceSeparator -->
|
||||
<module name="SingleSpaceSeparator">
|
||||
<property name="validateComments" value="true"/>
|
||||
</module>
|
||||
|
||||
<!-- https://checkstyle.org/config_whitespace.html#TypecastParenPad -->
|
||||
<module name="TypecastParenPad"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_coding.html#UnnecessaryParentheses -->
|
||||
<module name="UnnecessaryParentheses"/>
|
||||
|
||||
<!-- https://checkstyle.org/config_imports.html#UnusedImports -->
|
||||
<module name="UnusedImports"/>
|
||||
|
||||
</module>
|
||||
</module>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE suppressions PUBLIC "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN" "http://checkstyle.org/dtds/suppressions_1_2.dtd">
|
||||
<suppressions>
|
||||
<suppress files=".*[\\/]test[\\/]java[\\/].*" checks="RequireExplicitVisibilityModifier"/>
|
||||
<!-- TODO: don't suppress I-prefixed API interfaces under com.earth2me.essentials -->
|
||||
<suppress files="(com[\\/]earth2me[\\/]essentials[\\/]|net[\\/]ess3[\\/])(?:[^\\/]+$|(?!api)[^\\/]+[\\/])" checks="MissingJavadoc(Method|Type)"/>
|
||||
</suppressions>
|
||||
@@ -0,0 +1,13 @@
|
||||
# Currently used
|
||||
patreon: EssentialsX
|
||||
ko_fi: essentialsx
|
||||
|
||||
# Currently not used
|
||||
#github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
#open_collective: # Replace with a single Open Collective username
|
||||
#tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
#community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
#liberapay: # Replace with a single Liberapay username
|
||||
#issuehunt: # Replace with a single IssueHunt username
|
||||
#otechie: # Replace with a single Otechie username
|
||||
#custom: # Replace with a single custom sponsorship URL
|
||||
@@ -0,0 +1,5 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: MOSS Discord Server
|
||||
url: https://discord.gg/casfFyh
|
||||
about: Need help with using EssentialsX? Join the MOSS Discord server for help.
|
||||
@@ -0,0 +1,86 @@
|
||||
---
|
||||
name: Help!
|
||||
about: Encountered a problem with EssentialsX? Not sure how to fix it?
|
||||
labels: 'type: question'
|
||||
|
||||
---
|
||||
|
||||
<!-- EssentialsX help request guide
|
||||
|
||||
NOTE: Failure to fill out this template properly may result in your issue being
|
||||
delayed or ignored.
|
||||
|
||||
Don't type between any arrows in the template, as this text will be hidden.
|
||||
This includes this header block and any other explanatory text blocks.
|
||||
|
||||
Want faster support? Come join our Discord server to get help from both
|
||||
developers and community members: https://discord.gg/F7gexAQ
|
||||
|
||||
If you're happy to wait (or you were sent here from Discord), read on:
|
||||
|
||||
1. Check the Common Issues page.
|
||||
Read through the wiki page to see if you've encountered a regular issue:
|
||||
https://essentialsx.net/wiki/Common-Issues.html
|
||||
|
||||
2. Fill out the template.
|
||||
Run the commands in the console. Don't just put "latest" as a version, or
|
||||
we will ignore it. This will help us understand what problem you've
|
||||
encountered and help us find a solution.
|
||||
|
||||
3. When linking logs or config files, do not attach them to the post!
|
||||
Copy and paste any logs into https://gist.github.com/, then paste a
|
||||
link to them in the relevant parts of the template. Do not use Hastebin
|
||||
or Pastebin, as this can cause issues when trying to solve issues in the
|
||||
future.
|
||||
**DO NOT drag logs into this text box!**
|
||||
|
||||
4. If you are encountering a performance issue, please include a link to a
|
||||
Timings and/or profiler report.
|
||||
|
||||
-->
|
||||
|
||||
### Information
|
||||
|
||||
**Full output of `/ess version`:**
|
||||
<!--
|
||||
Run /ess version in the console, then paste the full output of the command
|
||||
between the ```s.
|
||||
-->
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
**Server startup log:**
|
||||
<!--
|
||||
Restart your server and upload `logs/latest.log` to
|
||||
https://gist.github.com/. You may redact sensitive data (such as IP
|
||||
addresses), but you should make it clear what data was removed. Once
|
||||
uploaded, paste the link below this block.
|
||||
-->
|
||||
|
||||
|
||||
**EssentialsX config:**
|
||||
<!--
|
||||
Upload `plugins/Essentials/config.yml` (and other config files if relevant)
|
||||
to https://gist.github.com/ then paste the link below this block.
|
||||
-->
|
||||
|
||||
|
||||
### Help request
|
||||
|
||||
**Problem:**
|
||||
<!-- What problem did you encounter? Type below this line. -->
|
||||
|
||||
**What I have tried:**
|
||||
<!-- What have you tried so far? Type below this line. -->
|
||||
|
||||
**Console stack trace:**
|
||||
<!--
|
||||
If you are reporting an error in the console, paste it between the ```s.
|
||||
-->
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
**Screenshots:**
|
||||
<!-- If relevant, include any screenshots or a video below this line. -->
|
||||
@@ -0,0 +1,83 @@
|
||||
---
|
||||
name: Report a bug
|
||||
about: Report an EssentialsX bug. Only use this if you're 100% sure there's something wrong with EssentialsX - otherwise, try "Help!".
|
||||
labels: 'bug: unconfirmed'
|
||||
|
||||
---
|
||||
|
||||
<!-- EssentialsX bug reporting guide
|
||||
|
||||
NOTE: Failure to fill out this template properly may result in your issue being
|
||||
delayed or ignored.
|
||||
|
||||
Don't type between any arrows in the template, as this text will be hidden.
|
||||
This includes this header block and any other explanatory text blocks.
|
||||
|
||||
If you are reporting a bug, please follow the following steps:
|
||||
|
||||
1. Fill out the template in full.
|
||||
Run the commands in the console. Don't just put "latest" as a version,
|
||||
or we will ignore it.
|
||||
|
||||
2. When linking files, do not attach them to the post!
|
||||
Copy and paste any logs into https://gist.github.com/, then paste a
|
||||
link to them in the relevant parts of the template. Avoid using
|
||||
Hastebin or Pastebin, as this makes providing support more difficult.
|
||||
**DO NOT drag files into this text box!**
|
||||
|
||||
3. If you are reporting a performance issue, please include a link to a
|
||||
Timings and/or profiler report.
|
||||
|
||||
4. If you are reporting a bug with commands or something else in-game,
|
||||
please include screenshots to help us diagnose the problem.
|
||||
|
||||
-->
|
||||
|
||||
### Information
|
||||
|
||||
**Full output of `/ess version`:**
|
||||
<!--
|
||||
Run /ess version in the console, then paste the full output of the command
|
||||
between the ```s.
|
||||
-->
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
**Server startup log:**
|
||||
<!--
|
||||
Restart your server and upload `logs/latest.log` to
|
||||
https://gist.github.com/. You may redact sensitive data (such as IP
|
||||
addresses), but you should make it clear what data was removed. Once
|
||||
uploaded, paste the link below this block.
|
||||
-->
|
||||
|
||||
|
||||
**EssentialsX config:**
|
||||
<!--
|
||||
Upload `plugins/Essentials/config.yml` (and other config files if relevant)
|
||||
to https://gist.github.com/ then paste the link below this block.
|
||||
-->
|
||||
|
||||
|
||||
### Details
|
||||
|
||||
**Description:**
|
||||
<!-- What is the bug? Type a brief summary below this line. -->
|
||||
|
||||
**Steps to reproduce:**
|
||||
<!-- How did you cause it? Describe what you did to cause the bug below. -->
|
||||
|
||||
**Expected behavior:**
|
||||
<!-- What did you expect to happen? Type below this line. -->
|
||||
|
||||
**Console stack trace:**
|
||||
<!--
|
||||
If you are encountering an error in the console, paste it between the ```s.
|
||||
-->
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
**Screenshots:**
|
||||
<!-- If necessary, include screenshots or a video below this line. -->
|
||||
@@ -0,0 +1,52 @@
|
||||
---
|
||||
name: Request a feature
|
||||
about: Suggest a feature you want to see in EssentialsX!
|
||||
labels: 'type: enhancement'
|
||||
|
||||
---
|
||||
|
||||
<!-- EssentialsX feature request guide
|
||||
|
||||
NOTE: Failure to fill out this template properly may result in your issue being
|
||||
delayed or ignored.
|
||||
|
||||
Don't type between any arrows in the template, as this text will be hidden.
|
||||
This includes this header block and any other explanatory text blocks.
|
||||
|
||||
Not sure if your feature fits in EssentialsX? Feel free to ask on our Discord
|
||||
server: https://discord.gg/F7gexAQ
|
||||
|
||||
If you have a feature suggestion for EssentialsX, read the following tips:
|
||||
|
||||
1. Fill out the template.
|
||||
This will help us understand what you're requesting and why you want us
|
||||
to add it.
|
||||
|
||||
2. Keep it simple.
|
||||
Make sure it's easy to understand what you're requesting. A good way is
|
||||
to keep it to one request per GitHub issue, as we can then easily track
|
||||
feature requests.
|
||||
|
||||
3. Check whether it has already been asked or added.
|
||||
You can search the issue tracker to see if your feature has already been
|
||||
requested at https://github.com/EssentialsX/Essentials/issues. You can
|
||||
also check the changelogs to see if the feature was recently added:
|
||||
https://github.com/EssentialsX/Essentials/releases
|
||||
|
||||
4. Ask yourself: "Does this belong in EssentialsX?"
|
||||
There are lots of features that we reject because most servers won't
|
||||
need or use them. If your feature is very specific or already exists in
|
||||
another plugin, it might not be a good fit for EssentialsX.
|
||||
|
||||
-->
|
||||
|
||||
### Feature request
|
||||
|
||||
**Feature description:**
|
||||
<!-- What feature are you suggesting? Type below this line. -->
|
||||
|
||||
**How the feature is useful:**
|
||||
<!--
|
||||
How is the feature useful to players, server owners and/or developers?
|
||||
Type below this block.
|
||||
-->
|
||||
@@ -0,0 +1,82 @@
|
||||
---
|
||||
name: Bug fix
|
||||
about: Use this if your PR fixes a bug in EssentialsX.
|
||||
labels: 'type: bugfix'
|
||||
---
|
||||
|
||||
<!-- EssentialsX bug fix submission guide
|
||||
|
||||
NOTE: Failure to fill out this template properly may result in your PR being
|
||||
delayed or ignored without warning.
|
||||
|
||||
Don't type between any arrows in the template, as this text will be hidden.
|
||||
This includes this header block and any other explanatory text blocks.
|
||||
|
||||
Want to discuss your PR before submitting it? Join the EssentialsX Development
|
||||
server: https://discord.gg/CUN7qVb
|
||||
|
||||
By contributing to EssentialsX, you agree to license your code under the
|
||||
GNU General Public License version 3, which can be found at the link below:
|
||||
https://github.com/EssentialsX/Essentials/blob/2.x/LICENSE
|
||||
|
||||
If you are submitting a bug fix, please follow the following steps:
|
||||
|
||||
1. Fill out the template in full.
|
||||
This includes providing screenshots and a link to the original bug
|
||||
report. If there isn't an existing bug report, we recommend opening a new
|
||||
detailed bug report BEFORE opening your PR to fix it, else your PR may be
|
||||
delayed or rejected without warning.
|
||||
|
||||
You can open a new bug report by following this link:
|
||||
https://github.com/EssentialsX/Essentials/issues/new/choose
|
||||
|
||||
2. When linking logs or config files, do not attach them to the post!
|
||||
Copy and paste any logs into https://gist.github.com/, then paste a
|
||||
link to them in the relevant parts of the template. Do not use Hastebin
|
||||
or Pastebin, as this can cause issues with future reviews.
|
||||
**DO NOT drag logs into this text box!**
|
||||
|
||||
3. If you are fixing a performance issue, please include a link to a
|
||||
Timings and/or profiler report, both before and after your PR.
|
||||
|
||||
4. If you are fixing a visual bug, such as in commands, please include
|
||||
screenshots so that we can more easily review the proposed fix.
|
||||
(You may drag screenshots directly into this box.)
|
||||
|
||||
-->
|
||||
|
||||
### Information
|
||||
|
||||
<!--
|
||||
Replace #nnnn with the number of the original issue. If this PR fixes
|
||||
multiple issues, you should repeat the phrase "fixes #nnnn" for each issue.
|
||||
-->
|
||||
|
||||
This PR fixes #nnnn.
|
||||
|
||||
### Details
|
||||
|
||||
**Proposed fix:**
|
||||
<!-- Type a description of your proposed fix below this line. -->
|
||||
|
||||
|
||||
**Environments tested:**
|
||||
<!--
|
||||
Below this line, put an "x" inside the box for the environments you have
|
||||
tested this bug fix on, and if relevant alter the OS and Java version
|
||||
accordingly. If this feature does not apply to an environment, strike
|
||||
through the environment using ~~strikethrough~~. If you have tested on
|
||||
other environments, add a new line with relevant details.
|
||||
-->
|
||||
|
||||
- [ ] [Latest](https://papermc.io/downloads) Paper Version (any OS, any Java 8+ version)
|
||||
- [ ] CraftBukkit/Spigot/Paper 1.12.2 (any OS, any Java 8+ version)
|
||||
- [ ] CraftBukkit 1.8.8 (any OS, any Java 8+ version)
|
||||
|
||||
|
||||
**Demonstration:**
|
||||
<!--
|
||||
Below this block, include screenshots/log snippets from before and after as
|
||||
necessary. If you have created or used a test case plugin, please link to a
|
||||
download of the plugin, source code and exact version used where possible.
|
||||
-->
|
||||
@@ -0,0 +1,8 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: MOSS Discord Server
|
||||
url: https://discord.gg/casfFyh
|
||||
about: Need help with using EssentialsX? Join the MOSS Discord server for help.
|
||||
- name: EssentialsX Development Discord Server
|
||||
url: https://discord.gg/CUN7qVb
|
||||
about: Got questions or want to discuss changes before opening your PR? Join the EssentialsX Development Discord server. (Need help? Join MOSS instead.)
|
||||
@@ -0,0 +1,82 @@
|
||||
---
|
||||
name: Feature addition
|
||||
about: Use this if your PR adds a new feature to EssentialsX.
|
||||
labels: 'type: enhancement'
|
||||
---
|
||||
|
||||
<!-- EssentialsX feature submission guide
|
||||
|
||||
NOTE: Failure to fill out this template properly may result in your PR being
|
||||
delayed or ignored without warning.
|
||||
|
||||
Don't type between any arrows in the template, as this text will be hidden.
|
||||
This includes this header block and any other explanatory text blocks.
|
||||
|
||||
Want to discuss your PR before submitting it? Join the EssentialsX Development
|
||||
server: https://discord.gg/CUN7qVb
|
||||
|
||||
By contributing to EssentialsX, you agree to license your code under the
|
||||
GNU General Public License version 3, which can be found at the link below:
|
||||
https://github.com/EssentialsX/Essentials/blob/2.x/LICENSE
|
||||
|
||||
If you are submitting a new feature, please follow the following steps:
|
||||
|
||||
1. Fill out the template in full.
|
||||
This includes providing screenshots and a link to the original feature
|
||||
request. If there isn't an existing feature request, we strongly
|
||||
recommend opening a new feature request BEFORE opening your PR to
|
||||
implement it, as this allows us to review whether we're likely to accept
|
||||
your feature in advance, and also allows us to discuss possible
|
||||
implementations for the feature. If there is no associated feature
|
||||
request, your PR may be delayed or rejected without warning.
|
||||
|
||||
You can open a new feature request by following this link:
|
||||
https://github.com/EssentialsX/Essentials/issues/new/choose
|
||||
|
||||
2. If you are fixing a performance issue, please use the "Bug fix" PR template
|
||||
instead. The "bug fix" template is better suited to performance issues.
|
||||
|
||||
3. Include a demonstration.
|
||||
If you are adding commands, please provide screenshots and/or a video
|
||||
demonstration of the feature. Similarly, if you are adding a new API,
|
||||
please include a link to example code that takes advantage of your
|
||||
proposed API. This will aid us in reviewing PRs and speed up the process
|
||||
significantly.
|
||||
|
||||
-->
|
||||
|
||||
### Information
|
||||
|
||||
<!--
|
||||
Replace #nnnn with the number of the original issue. If this PR implements
|
||||
features from multiple issues, you should repeat the phrase "closes #nnnn"
|
||||
for each issue.
|
||||
-->
|
||||
|
||||
This PR closes #nnnn.
|
||||
|
||||
### Details
|
||||
|
||||
**Proposed feature**
|
||||
<!-- Type a description of your proposed feature below this line. -->
|
||||
|
||||
**Environments tested:**
|
||||
<!--
|
||||
Below this block, put an "x" inside the box for the environments you have
|
||||
tested this bug fix on, and if relevant alter the OS and Java version
|
||||
accordingly. If this feature does not apply to an environment, strike
|
||||
through the environment using ~~strikethrough~~. If you have tested on
|
||||
other environments, add a new line with relevant details.
|
||||
-->
|
||||
|
||||
- [ ] [Latest](https://papermc.io/downloads) Paper Version (any OS, any Java 8+ version)
|
||||
- [ ] CraftBukkit/Spigot/Paper 1.12.2 (any OS, any Java 8+ version)
|
||||
- [ ] CraftBukkit 1.8.8 (any OS, any Java 8+ version)
|
||||
|
||||
**Demonstration:**
|
||||
<!--
|
||||
Below this block, include screenshots/code snippets from before and after
|
||||
as necessary. If you have created or used a test case plugin, please link
|
||||
to a download of the plugin, source code and exact version used where
|
||||
possible.
|
||||
-->
|
||||
@@ -0,0 +1,38 @@
|
||||
name: Build EssentialsX
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 2.x
|
||||
- mc/*
|
||||
pull_request:
|
||||
branches:
|
||||
- 2.x
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Git repo
|
||||
uses: actions/checkout@v1
|
||||
- name: Restore Maven cache
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
- name: Build with Maven
|
||||
run: mvn package verify --file pom.xml
|
||||
- name: Copy artifacts
|
||||
run: mkdir -p ./out/ && cp -t ./out/ **/target/Essentials*.jar
|
||||
- uses: actions/upload-artifact@master
|
||||
with:
|
||||
name: Plugin jars
|
||||
path: out/
|
||||
+22
-51
@@ -1,51 +1,22 @@
|
||||
.DS_Store
|
||||
/BuildAll/nbproject/private/
|
||||
/EssentialsProtect/nbproject/private/
|
||||
/EssentialsChat/nbproject/private/
|
||||
/EssentialsGroupBridge/nbproject/private/
|
||||
/EssentialsGeoIP/nbproject/private/
|
||||
/EssentialsSpawn/nbproject/private/
|
||||
/EssentialsXMPP/nbproject/private/
|
||||
/EssentialsGroupManager/nbproject/private/
|
||||
/BuildAll/build/
|
||||
/EssentialsGroupBridge/dist/
|
||||
/EssentialsGroupBridge/build/
|
||||
/EssentialsGeoIP/dist/
|
||||
/EssentialsGeoIP/build/
|
||||
/EssentialsGroupManager/build/
|
||||
/EssentialsGroupManager/dist/
|
||||
/BuildAll/dist/
|
||||
/EssentialsChat/build/
|
||||
/EssentialsChat/dist/
|
||||
/EssentialsSpawn/build/
|
||||
/EssentialsSpawn/dist/
|
||||
/EssentialsXMPP/dist/
|
||||
/EssentialsXMPP/build/
|
||||
/EssentialsProtect/dist/
|
||||
/EssentialsProtect/build/
|
||||
/EssentialsPermissionsCommands/nbproject/private/
|
||||
/EssentialsPermissionsCommands/build/
|
||||
/EssentialsPermissionsCommands/dist/
|
||||
/Essentials/nbproject/private/
|
||||
/Essentials/dist/
|
||||
/Essentials/build/
|
||||
/YamlAnnotations/
|
||||
/EssentialsUpdate/nbproject/private/
|
||||
/EssentialsRelease/
|
||||
/EssentialsUpdate/dist/
|
||||
/EssentialsUpdate/build/
|
||||
/WebPush/apikey.php
|
||||
/WebPush/nbproject/private
|
||||
/EssentialsGroupManager/bin
|
||||
/EssentialsGroupManager/.externalToolBuilders
|
||||
/EssentialsAntiBuild/nbproject/private/
|
||||
/EssentialsAntiBuild/dist/
|
||||
/EssentialsAntiBuild/build/
|
||||
/jars
|
||||
/out
|
||||
.idea/
|
||||
*.iml
|
||||
target/
|
||||
dependency-reduced-pom.xml
|
||||
/Essentials/config.yml
|
||||
/Essentials/userdata/testplayer1.yml
|
||||
# Other IDE files
|
||||
*.classpath
|
||||
*.project
|
||||
*.settings/
|
||||
.idea/*
|
||||
*.iml
|
||||
.DS_Store
|
||||
|
||||
# Checkstyle-IDEA config
|
||||
!.idea/checkstyle-idea.xml
|
||||
|
||||
# Essentials files
|
||||
/Essentials/userdata
|
||||
/Essentials/config.yml
|
||||
/Essentials/kits.yml
|
||||
/Essentials/userdata/testplayer1.yml
|
||||
/Essentials/usermap.csv
|
||||
|
||||
# Build files
|
||||
target/
|
||||
jars/
|
||||
out/
|
||||
Generated
+19
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CheckStyle-IDEA">
|
||||
<option name="configuration">
|
||||
<map>
|
||||
<entry key="active-configuration" value="PROJECT_RELATIVE:$PROJECT_DIR$/.checkstyle/checkstyle.xml:EssentialsX" />
|
||||
<entry key="checkstyle-version" value="8.36.2" />
|
||||
<entry key="copy-libs" value="true" />
|
||||
<entry key="location-0" value="BUNDLED:(bundled):Sun Checks" />
|
||||
<entry key="location-1" value="BUNDLED:(bundled):Google Checks" />
|
||||
<entry key="location-2" value="PROJECT_RELATIVE:$PROJECT_DIR$/.checkstyle/checkstyle.xml:EssentialsX" />
|
||||
<entry key="property-2.checkstyle.suppressions.file" value=".checkstyle/suppressions.xml" />
|
||||
<entry key="scan-before-checkin" value="false" />
|
||||
<entry key="scanscope" value="JavaOnly" />
|
||||
<entry key="suppress-errors" value="false" />
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
language: java
|
||||
jdk:
|
||||
- oraclejdk7
|
||||
- openjdk7
|
||||
- openjdk6
|
||||
script: mvn compile test
|
||||
install: true
|
||||
notifications:
|
||||
irc:
|
||||
channels:
|
||||
- "irc.esper.net#lain"
|
||||
on_success: change
|
||||
on_failure: always
|
||||
email:
|
||||
recipients:
|
||||
- "khobbits@ess3.net"
|
||||
on_success: change
|
||||
on_failure: always
|
||||
@@ -0,0 +1,31 @@
|
||||
Contributing to EssentialsX
|
||||
===========================
|
||||
|
||||
Want to help improve EssentialsX? There are several ways you can support and contribute to the project.
|
||||
|
||||
If you'd like to make a financial contribution to the project, you can join our [Patreon](https://www.patreon.com/essentialsx/),
|
||||
or to make a one-off donation you can visit our [Ko-fi page](https://ko-fi.com/essentialsx). If you can't make a
|
||||
donation, don't worry! There are lots of other ways to contribute:
|
||||
|
||||
* Do you run a server? Take a look at our ["help wanted"](https://github.com/EssentialsX/Essentials/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22help+wanted%22)
|
||||
and ["bug: unconfirmed"](https://github.com/EssentialsX/Essentials/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22bug%3A+unconfirmed%22)
|
||||
issues, where you can find issues that need extra testing and investigation.
|
||||
* Do you speak multiple languages? If so, we always welcome contributions to our [Crowdin project](https://crowdin.com/project/essentialsx-official).
|
||||
* Do you enjoy helping others? If so, why not contribute to the [EssentialsX documentation](https://github.com/EssentialsX/wiki)?
|
||||
You can also join the [MOSS Discord community](https://discord.gg/casfFyh) and provide direct community support to
|
||||
other EssentialsX users.
|
||||
* If you're a developer, you could look through our ["open to PR"](https://github.com/EssentialsX/Essentials/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22status%3A+open+to+PR%22)
|
||||
issues. We're always happy to receive bug fixes and feature additions as pull requests.
|
||||
|
||||
Submitting a PR
|
||||
---------------
|
||||
|
||||
EssentialsX has extensive templates for PRs that detail how to submit your PR. To find out more, see the PR templates for:
|
||||
* [Bug fixes](https://github.com/EssentialsX/Essentials/blob/2.x/.github/PULL_REQUEST_TEMPLATE/bug-fix.md)
|
||||
* [New features](https://github.com/EssentialsX/Essentials/blob/2.x/.github/PULL_REQUEST_TEMPLATE/new-feature.md)
|
||||
|
||||
Want to discuss a feature before opening a PR? Join the [EssentialsX Development Discord server](https://discord.gg/CUN7qVb). Note that this server is **not for end-users** - if you need support with EssentialsX, you should join [MOSS](https://discord.gg/casfFyh) instead.
|
||||
|
||||
By contributing to EssentialsX, you agree to license your code under the [GNU General Public License version 3](https://github.com/EssentialsX/Essentials/blob/2.x/LICENSE).
|
||||
|
||||
|
||||
+112
-127
@@ -1,133 +1,118 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>EssentialsParent</artifactId>
|
||||
<version>2.x-SNAPSHOT</version>
|
||||
</parent>
|
||||
<parent>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>EssentialsXParent</artifactId>
|
||||
<version>2.18.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>Essentials</artifactId>
|
||||
<artifactId>EssentialsX</artifactId>
|
||||
|
||||
<url>http://ess3.net/</url>
|
||||
<build>
|
||||
<finalName>EssentialsX-${full.version}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<configuration>
|
||||
<showDeprecation>false</showDeprecation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>io.papermc.lib</pattern>
|
||||
<shadedPattern>com.earth2me.essentials.paperlib</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<organization>
|
||||
<name>Essentials Team</name>
|
||||
<url>http://ess3.net/</url>
|
||||
</organization>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>GPLv3</name>
|
||||
<url>http://www.gnu.org/copyleft/gpl.html</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:https://github.com/essentials/Essentials.git</connection>
|
||||
<developerConnection>scm:git:https://github.com/essentials/Essentials.git</developerConnection>
|
||||
<url>https://github.com/essentials/Essentials</url>
|
||||
</scm>
|
||||
|
||||
<issueManagement>
|
||||
<system>JIRA</system>
|
||||
<url>http://essentials3.atlassian.net</url>
|
||||
</issueManagement>
|
||||
|
||||
<ciManagement>
|
||||
<system>TeamCity</system>
|
||||
<url>http://ci.ess3.net/</url>
|
||||
</ciManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.7.2-R0.3-SNAPSHOT</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/../lib/bukkit.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>BOSEconomy</groupId>
|
||||
<artifactId>BOSEconomy</artifactId>
|
||||
<version>v0.7.8.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/../lib/BOSEconomy.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.bananaco</groupId>
|
||||
<artifactId>bPermissions</artifactId>
|
||||
<version>v2.12-DEV</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>iConomy</groupId>
|
||||
<artifactId>iConomy5</artifactId>
|
||||
<version>5</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/../lib/iCo5.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>iConomy</groupId>
|
||||
<artifactId>iConomy6</artifactId>
|
||||
<version>6</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/../lib/iCo6.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>GroupManager</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/../EssentialsGroupManager/dist/EssentialsGroupManager.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>MultiCurrency</groupId>
|
||||
<artifactId>MultiCurrency</artifactId>
|
||||
<version>2.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/../lib/MultiCurrency.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.platymuus</groupId>
|
||||
<artifactId>bukkit-permissions</artifactId>
|
||||
<version>2.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/../lib/PermissionsBukkit.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.tehkode</groupId>
|
||||
<artifactId>PermissionsEx</artifactId>
|
||||
<version>1.20.4</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/../lib/PermissionsEx.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>Privileges</groupId>
|
||||
<artifactId>Privileges</artifactId>
|
||||
<version>1.8.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/../lib/Privileges.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>SimplyPerms</groupId>
|
||||
<artifactId>SimplyPerms</artifactId>
|
||||
<version>1.7.6</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/../lib/SimplyPerms.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl</groupId>
|
||||
<artifactId>vault</artifactId>
|
||||
<version>1.2.27</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>zPermissions</groupId>
|
||||
<artifactId>zPermissions</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/../lib/zPermissions.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.milkbowl</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.luckperms</groupId>
|
||||
<artifactId>api</artifactId>
|
||||
<version>5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<version>1.0.6-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>BaseProviders</artifactId>
|
||||
<version>2.18.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>NMSReflectionProvider</artifactId>
|
||||
<version>2.18.2</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>PaperProvider</artifactId>
|
||||
<version>2.18.2</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.destroystokyo.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>1_8Provider</artifactId>
|
||||
<version>2.18.2</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -13,6 +13,6 @@ Minecraft colors:
|
||||
&8 &&8 &9 &&9 &a &&a &b &&b
|
||||
&c &&c &d &&d &e &&e &f &&f
|
||||
&0
|
||||
&&k &kMagic&r &&l &lBold
|
||||
&&m &mStrike&r &&n &nUline
|
||||
&&o &oItalic&r &&r &rReset
|
||||
&&k &kMagic&r &&l &lBold&r
|
||||
&&m &mStrike&r &&n &nUline&r
|
||||
&&o &oItalic&r &&r &rReset
|
||||
@@ -1,139 +1,108 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.PluginCommandYamlParser;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class AlternativeCommandsHandler
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Essentials");
|
||||
private final transient Map<String, List<PluginCommand>> altcommands = new HashMap<String, List<PluginCommand>>();
|
||||
private final transient Map<String, String> disabledList = new HashMap<String, String>();
|
||||
private final transient IEssentials ess;
|
||||
public class AlternativeCommandsHandler {
|
||||
private static final Logger LOGGER = Logger.getLogger("Essentials");
|
||||
private final transient Map<String, List<PluginCommand>> altcommands = new HashMap<>();
|
||||
private final transient Map<String, String> disabledList = new HashMap<>();
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public AlternativeCommandsHandler(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
for (Plugin plugin : ess.getServer().getPluginManager().getPlugins())
|
||||
{
|
||||
if (plugin.isEnabled())
|
||||
{
|
||||
addPlugin(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
public AlternativeCommandsHandler(final IEssentials ess) {
|
||||
this.ess = ess;
|
||||
for (final Plugin plugin : ess.getServer().getPluginManager().getPlugins()) {
|
||||
if (plugin.isEnabled()) {
|
||||
addPlugin(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void addPlugin(final Plugin plugin)
|
||||
{
|
||||
if (plugin.getDescription().getMain().contains("com.earth2me.essentials"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final List<Command> commands = PluginCommandYamlParser.parse(plugin);
|
||||
final String pluginName = plugin.getDescription().getName().toLowerCase(Locale.ENGLISH);
|
||||
public final void addPlugin(final Plugin plugin) {
|
||||
if (plugin.getDescription().getMain().contains("com.earth2me.essentials")) {
|
||||
return;
|
||||
}
|
||||
final List<Command> commands = PluginCommandYamlParser.parse(plugin);
|
||||
final String pluginName = plugin.getDescription().getName().toLowerCase(Locale.ENGLISH);
|
||||
|
||||
for (Command command : commands)
|
||||
{
|
||||
final PluginCommand pc = (PluginCommand)command;
|
||||
final List<String> labels = new ArrayList<String>(pc.getAliases());
|
||||
labels.add(pc.getName());
|
||||
for (final Command command : commands) {
|
||||
final PluginCommand pc = (PluginCommand) command;
|
||||
final List<String> labels = new ArrayList<>(pc.getAliases());
|
||||
labels.add(pc.getName());
|
||||
|
||||
PluginCommand reg = ess.getServer().getPluginCommand(pluginName + ":" + pc.getName().toLowerCase(Locale.ENGLISH));
|
||||
if (reg == null)
|
||||
{
|
||||
reg = ess.getServer().getPluginCommand(pc.getName().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
if (reg == null || !reg.getPlugin().equals(plugin))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (String label : labels)
|
||||
{
|
||||
List<PluginCommand> plugincommands = altcommands.get(label.toLowerCase(Locale.ENGLISH));
|
||||
if (plugincommands == null)
|
||||
{
|
||||
plugincommands = new ArrayList<PluginCommand>();
|
||||
altcommands.put(label.toLowerCase(Locale.ENGLISH), plugincommands);
|
||||
}
|
||||
boolean found = false;
|
||||
for (PluginCommand pc2 : plugincommands)
|
||||
{
|
||||
if (pc2.getPlugin().equals(plugin))
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
plugincommands.add(reg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
PluginCommand reg = ess.getServer().getPluginCommand(pluginName + ":" + pc.getName().toLowerCase(Locale.ENGLISH));
|
||||
if (reg == null) {
|
||||
reg = ess.getServer().getPluginCommand(pc.getName().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
if (reg == null || !reg.getPlugin().equals(plugin)) {
|
||||
continue;
|
||||
}
|
||||
for (final String label : labels) {
|
||||
final List<PluginCommand> plugincommands = altcommands.computeIfAbsent(label.toLowerCase(Locale.ENGLISH), k -> new ArrayList<>());
|
||||
boolean found = false;
|
||||
for (final PluginCommand pc2 : plugincommands) {
|
||||
if (pc2.getPlugin().equals(plugin)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
plugincommands.add(reg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removePlugin(final Plugin plugin)
|
||||
{
|
||||
final Iterator<Map.Entry<String, List<PluginCommand>>> iterator = altcommands.entrySet().iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
final Map.Entry<String, List<PluginCommand>> entry = iterator.next();
|
||||
final Iterator<PluginCommand> pcIterator = entry.getValue().iterator();
|
||||
while (pcIterator.hasNext())
|
||||
{
|
||||
final PluginCommand pc = pcIterator.next();
|
||||
if (pc.getPlugin() == null || pc.getPlugin().equals(plugin))
|
||||
{
|
||||
pcIterator.remove();
|
||||
}
|
||||
}
|
||||
if (entry.getValue().isEmpty())
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
public void removePlugin(final Plugin plugin) {
|
||||
final Iterator<Map.Entry<String, List<PluginCommand>>> iterator = altcommands.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final Map.Entry<String, List<PluginCommand>> entry = iterator.next();
|
||||
entry.getValue().removeIf(pc -> pc.getPlugin() == null || pc.getPlugin().equals(plugin));
|
||||
if (entry.getValue().isEmpty()) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PluginCommand getAlternative(final String label)
|
||||
{
|
||||
final List<PluginCommand> commands = altcommands.get(label);
|
||||
if (commands == null || commands.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (commands.size() == 1)
|
||||
{
|
||||
return commands.get(0);
|
||||
}
|
||||
// return the first command that is not an alias
|
||||
for (PluginCommand command : commands)
|
||||
{
|
||||
if (command.getName().equalsIgnoreCase(label))
|
||||
{
|
||||
return command;
|
||||
}
|
||||
}
|
||||
// return the first alias
|
||||
return commands.get(0);
|
||||
}
|
||||
public PluginCommand getAlternative(final String label) {
|
||||
final List<PluginCommand> commands = altcommands.get(label);
|
||||
if (commands == null || commands.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (commands.size() == 1) {
|
||||
return commands.get(0);
|
||||
}
|
||||
// return the first command that is not an alias
|
||||
for (final PluginCommand command : commands) {
|
||||
if (command.getName().equalsIgnoreCase(label)) {
|
||||
return command;
|
||||
}
|
||||
}
|
||||
// return the first alias
|
||||
return commands.get(0);
|
||||
}
|
||||
|
||||
public void executed(final String label, final PluginCommand pc)
|
||||
{
|
||||
final String altString = pc.getPlugin().getName() + ":" + pc.getLabel();
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials: Alternative command " + label + " found, using " + altString);
|
||||
}
|
||||
disabledList.put(label, altString);
|
||||
}
|
||||
public void executed(final String label, final PluginCommand pc) {
|
||||
final String altString = pc.getPlugin().getName() + ":" + pc.getLabel();
|
||||
if (ess.getSettings().isDebug()) {
|
||||
LOGGER.log(Level.INFO, "Essentials: Alternative command " + label + " found, using " + altString);
|
||||
}
|
||||
disabledList.put(label, altString);
|
||||
}
|
||||
|
||||
public Map<String, String> disabledCommands()
|
||||
{
|
||||
return disabledList;
|
||||
}
|
||||
public Map<String, String> disabledCommands() {
|
||||
return disabledList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,455 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.IAsyncTeleport;
|
||||
import com.earth2me.essentials.commands.WarpNotFoundException;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import com.earth2me.essentials.utils.LocationUtil;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.api.InvalidWorldException;
|
||||
import net.ess3.api.events.UserWarpEvent;
|
||||
import net.ess3.api.events.teleport.PreTeleportEvent;
|
||||
import net.ess3.api.events.teleport.TeleportWarmupEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class AsyncTeleport implements IAsyncTeleport {
|
||||
private final IUser teleportOwner;
|
||||
private final IEssentials ess;
|
||||
private AsyncTimedTeleport timedTeleport;
|
||||
|
||||
private TeleportType tpType;
|
||||
|
||||
public AsyncTeleport(final IUser user, final IEssentials ess) {
|
||||
this.teleportOwner = user;
|
||||
this.ess = ess;
|
||||
tpType = TeleportType.NORMAL;
|
||||
}
|
||||
|
||||
public void cooldown(final boolean check) throws Throwable {
|
||||
final CompletableFuture<Boolean> exceptionFuture = new CompletableFuture<>();
|
||||
if (cooldown(check, exceptionFuture)) {
|
||||
try {
|
||||
exceptionFuture.get();
|
||||
} catch (final ExecutionException e) {
|
||||
throw e.getCause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean cooldown(final boolean check, final CompletableFuture<Boolean> future) {
|
||||
final Calendar time = new GregorianCalendar();
|
||||
if (teleportOwner.getLastTeleportTimestamp() > 0) {
|
||||
// Take the current time, and remove the delay from it.
|
||||
final double cooldown = ess.getSettings().getTeleportCooldown();
|
||||
final Calendar earliestTime = new GregorianCalendar();
|
||||
earliestTime.add(Calendar.SECOND, -(int) cooldown);
|
||||
earliestTime.add(Calendar.MILLISECOND, -(int) ((cooldown * 1000.0) % 1000.0));
|
||||
// This value contains the most recent time a teleportPlayer could have been used that would allow another use.
|
||||
final long earliestLong = earliestTime.getTimeInMillis();
|
||||
|
||||
// When was the last teleportPlayer used?
|
||||
final long lastTime = teleportOwner.getLastTeleportTimestamp();
|
||||
|
||||
if (lastTime > time.getTimeInMillis()) {
|
||||
// This is to make sure time didn't get messed up on last teleportPlayer use.
|
||||
// If this happens, let's give the user the benifit of the doubt.
|
||||
teleportOwner.setLastTeleportTimestamp(time.getTimeInMillis());
|
||||
return false;
|
||||
} else if (lastTime > earliestLong
|
||||
&& cooldownApplies()) {
|
||||
time.setTimeInMillis(lastTime);
|
||||
time.add(Calendar.SECOND, (int) cooldown);
|
||||
time.add(Calendar.MILLISECOND, (int) ((cooldown * 1000.0) % 1000.0));
|
||||
future.completeExceptionally(new Exception(tl("timeBeforeTeleport", DateUtil.formatDateDiff(time.getTimeInMillis()))));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// if justCheck is set, don't update lastTeleport; we're just checking
|
||||
if (!check) {
|
||||
teleportOwner.setLastTeleportTimestamp(time.getTimeInMillis());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean cooldownApplies() {
|
||||
boolean applies = true;
|
||||
final String globalBypassPerm = "essentials.teleport.cooldown.bypass";
|
||||
switch (tpType) {
|
||||
case NORMAL:
|
||||
applies = !teleportOwner.isAuthorized(globalBypassPerm);
|
||||
break;
|
||||
case BACK:
|
||||
applies = !(teleportOwner.isAuthorized(globalBypassPerm) &&
|
||||
teleportOwner.isAuthorized("essentials.teleport.cooldown.bypass.back"));
|
||||
break;
|
||||
case TPA:
|
||||
applies = !(teleportOwner.isAuthorized(globalBypassPerm) &&
|
||||
teleportOwner.isAuthorized("essentials.teleport.cooldown.bypass.tpa"));
|
||||
break;
|
||||
}
|
||||
return applies;
|
||||
}
|
||||
|
||||
private void warnUser(final IUser user, final double delay) {
|
||||
final Calendar c = new GregorianCalendar();
|
||||
c.add(Calendar.SECOND, (int) delay);
|
||||
c.add(Calendar.MILLISECOND, (int) ((delay * 1000.0) % 1000.0));
|
||||
user.sendMessage(tl("dontMoveMessage", DateUtil.formatDateDiff(c.getTimeInMillis())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void now(final Location loc, final boolean cooldown, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
if (cooldown && cooldown(false, future)) {
|
||||
return;
|
||||
}
|
||||
final ITarget target = new LocationTarget(loc);
|
||||
nowAsync(teleportOwner, target, cause, future);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void now(final Player entity, final boolean cooldown, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
if (cooldown && cooldown(false, future)) {
|
||||
future.complete(false);
|
||||
return;
|
||||
}
|
||||
final ITarget target = new PlayerTarget(entity);
|
||||
nowAsync(teleportOwner, target, cause, future);
|
||||
future.thenAccept(success -> {
|
||||
if (success) {
|
||||
teleportOwner.sendMessage(tl("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void runOnMain(final Runnable runnable) throws ExecutionException, InterruptedException {
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
runnable.run();
|
||||
return;
|
||||
}
|
||||
final CompletableFuture<Object> taskLock = new CompletableFuture<>();
|
||||
Bukkit.getScheduler().runTask(ess, () -> {
|
||||
runnable.run();
|
||||
taskLock.complete(new Object());
|
||||
});
|
||||
taskLock.get();
|
||||
}
|
||||
|
||||
protected void nowAsync(final IUser teleportee, final ITarget target, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
cancel(false);
|
||||
|
||||
final PreTeleportEvent event = new PreTeleportEvent(teleportee, cause, target);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
teleportee.setLastLocation();
|
||||
|
||||
if (!ess.getSettings().isForcePassengerTeleport() && !teleportee.getBase().isEmpty()) {
|
||||
if (!ess.getSettings().isTeleportPassengerDismount()) {
|
||||
future.completeExceptionally(new Exception(tl("passengerTeleportFail")));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
runOnMain(() -> teleportee.getBase().eject()); //EntityDismountEvent requires a sync context.
|
||||
} catch (final ExecutionException | InterruptedException e) {
|
||||
future.completeExceptionally(e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
teleportee.setLastLocation();
|
||||
final Location targetLoc = target.getLocation();
|
||||
if (ess.getSettings().isTeleportSafetyEnabled() && LocationUtil.isBlockOutsideWorldBorder(targetLoc.getWorld(), targetLoc.getBlockX(), targetLoc.getBlockZ())) {
|
||||
targetLoc.setX(LocationUtil.getXInsideWorldBorder(targetLoc.getWorld(), targetLoc.getBlockX()));
|
||||
targetLoc.setZ(LocationUtil.getZInsideWorldBorder(targetLoc.getWorld(), targetLoc.getBlockZ()));
|
||||
}
|
||||
PaperLib.getChunkAtAsync(targetLoc).thenAccept(chunk -> {
|
||||
Location loc = targetLoc;
|
||||
if (LocationUtil.isBlockUnsafeForUser(teleportee, chunk.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) {
|
||||
if (ess.getSettings().isTeleportSafetyEnabled()) {
|
||||
if (ess.getSettings().isForceDisableTeleportSafety()) {
|
||||
//The chunk we're teleporting to is 100% going to be loaded here, no need to teleport async.
|
||||
teleportee.getBase().teleport(loc, cause);
|
||||
} else {
|
||||
try {
|
||||
//There's a chance the safer location is outside the loaded chunk so still teleport async here.
|
||||
PaperLib.teleportAsync(teleportee.getBase(), LocationUtil.getSafeDestination(ess, teleportee, loc), cause);
|
||||
} catch (final Exception e) {
|
||||
future.completeExceptionally(e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
future.completeExceptionally(new Exception(tl("unsafeTeleportDestination", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (ess.getSettings().isForceDisableTeleportSafety()) {
|
||||
//The chunk we're teleporting to is 100% going to be loaded here, no need to teleport async.
|
||||
teleportee.getBase().teleport(loc, cause);
|
||||
} else {
|
||||
if (ess.getSettings().isTeleportToCenterLocation()) {
|
||||
loc = LocationUtil.getRoundedDestination(loc);
|
||||
}
|
||||
//There's a *small* chance the rounded destination produces a location outside the loaded chunk so still teleport async here.
|
||||
PaperLib.teleportAsync(teleportee.getBase(), loc, cause);
|
||||
}
|
||||
}
|
||||
future.complete(true);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(final Location loc, final Trade chargeFor, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
teleport(teleportOwner, new LocationTarget(loc), chargeFor, cause, future);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(final Player entity, final Trade chargeFor, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
teleportOwner.sendMessage(tl("teleportToPlayer", entity.getDisplayName()));
|
||||
teleport(teleportOwner, new PlayerTarget(entity), chargeFor, cause, future);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleportPlayer(final IUser otherUser, final Location loc, final Trade chargeFor, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
teleport(otherUser, new LocationTarget(loc), chargeFor, cause, future);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleportPlayer(final IUser otherUser, final Player entity, final Trade chargeFor, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
final ITarget target = new PlayerTarget(entity);
|
||||
teleport(otherUser, target, chargeFor, cause, future);
|
||||
future.thenAccept(success -> {
|
||||
if (success) {
|
||||
otherUser.sendMessage(tl("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ()));
|
||||
teleportOwner.sendMessage(tl("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void teleport(final IUser teleportee, final ITarget target, final Trade chargeFor, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
|
||||
final TeleportWarmupEvent event = new TeleportWarmupEvent(teleportee, cause, target, delay);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
delay = event.getDelay();
|
||||
|
||||
Trade cashCharge = chargeFor;
|
||||
|
||||
if (chargeFor != null) {
|
||||
chargeFor.isAffordableFor(teleportOwner, future);
|
||||
if (future.isCompletedExceptionally()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//This code is to make sure that commandcosts are checked in the initial world, and not in the resulting world.
|
||||
if (!chargeFor.getCommandCost(teleportOwner).equals(BigDecimal.ZERO)) {
|
||||
//By converting a command cost to a regular cost, the command cost permission isn't checked when executing the charge after teleport.
|
||||
cashCharge = new Trade(chargeFor.getCommandCost(teleportOwner), ess);
|
||||
}
|
||||
}
|
||||
|
||||
if (cooldown(true, future)) {
|
||||
return;
|
||||
}
|
||||
if (delay <= 0 || teleportOwner.isAuthorized("essentials.teleport.timer.bypass") || teleportee.isAuthorized("essentials.teleport.timer.bypass")) {
|
||||
if (cooldown(false, future)) {
|
||||
return;
|
||||
}
|
||||
nowAsync(teleportee, target, cause, future);
|
||||
if (cashCharge != null) {
|
||||
cashCharge.charge(teleportOwner, future);
|
||||
if (future.isCompletedExceptionally()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
cancel(false);
|
||||
warnUser(teleportee, delay);
|
||||
initTimer((long) (delay * 1000.0), teleportee, target, cashCharge, cause, false);
|
||||
}
|
||||
|
||||
private void teleportOther(final IUser teleporter, final IUser teleportee, final ITarget target, final Trade chargeFor, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
|
||||
final TeleportWarmupEvent event = new TeleportWarmupEvent(teleportee, cause, target, delay);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
delay = event.getDelay();
|
||||
|
||||
Trade cashCharge = chargeFor;
|
||||
|
||||
if (teleporter != null && chargeFor != null) {
|
||||
chargeFor.isAffordableFor(teleporter, future);
|
||||
if (future.isCompletedExceptionally()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//This code is to make sure that commandcosts are checked in the initial world, and not in the resulting world.
|
||||
if (!chargeFor.getCommandCost(teleporter).equals(BigDecimal.ZERO)) {
|
||||
//By converting a command cost to a regular cost, the command cost permission isn't checked when executing the charge after teleport.
|
||||
cashCharge = new Trade(chargeFor.getCommandCost(teleporter), ess);
|
||||
}
|
||||
}
|
||||
|
||||
if (cooldown(true, future)) {
|
||||
return;
|
||||
}
|
||||
if (delay <= 0 || teleporter == null
|
||||
|| teleporter.isAuthorized("essentials.teleport.timer.bypass")
|
||||
|| teleportOwner.isAuthorized("essentials.teleport.timer.bypass")
|
||||
|| teleportee.isAuthorized("essentials.teleport.timer.bypass")) {
|
||||
if (cooldown(false, future)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nowAsync(teleportee, target, cause, future);
|
||||
if (teleporter != null && cashCharge != null) {
|
||||
cashCharge.charge(teleporter, future);
|
||||
if (future.isCompletedExceptionally()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
cancel(false);
|
||||
warnUser(teleportee, delay);
|
||||
initTimer((long) (delay * 1000.0), teleportee, target, cashCharge, cause, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void respawn(final Trade chargeFor, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
|
||||
final TeleportWarmupEvent event = new TeleportWarmupEvent(teleportOwner, cause, null, delay);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
delay = event.getDelay();
|
||||
|
||||
if (chargeFor != null) {
|
||||
chargeFor.isAffordableFor(teleportOwner, future);
|
||||
if (future.isCompletedExceptionally()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (cooldown(true, future)) {
|
||||
return;
|
||||
}
|
||||
if (delay <= 0 || teleportOwner.isAuthorized("essentials.teleport.timer.bypass")) {
|
||||
if (cooldown(false, future)) {
|
||||
return;
|
||||
}
|
||||
respawnNow(teleportOwner, cause, future);
|
||||
if (chargeFor != null) {
|
||||
chargeFor.charge(teleportOwner, future);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
cancel(false);
|
||||
warnUser(teleportOwner, delay);
|
||||
initTimer((long) (delay * 1000.0), teleportOwner, null, chargeFor, cause, true);
|
||||
}
|
||||
|
||||
void respawnNow(final IUser teleportee, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
final Player player = teleportee.getBase();
|
||||
PaperLib.getBedSpawnLocationAsync(player, true).thenAccept(location -> {
|
||||
if (location != null) {
|
||||
nowAsync(teleportee, new LocationTarget(location), cause, future);
|
||||
} else {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().info("Could not find bed spawn, forcing respawn event.");
|
||||
}
|
||||
final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, player.getWorld().getSpawnLocation(), false);
|
||||
ess.getServer().getPluginManager().callEvent(pre);
|
||||
nowAsync(teleportee, new LocationTarget(pre.getRespawnLocation()), cause, future);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warp(final IUser otherUser, String warp, final Trade chargeFor, final TeleportCause cause, final CompletableFuture<Boolean> future) {
|
||||
final UserWarpEvent event = new UserWarpEvent(otherUser, warp, chargeFor);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
warp = event.getWarp();
|
||||
final Location loc;
|
||||
try {
|
||||
loc = ess.getWarps().getWarp(warp);
|
||||
} catch (final WarpNotFoundException | InvalidWorldException e) {
|
||||
future.completeExceptionally(e);
|
||||
return;
|
||||
}
|
||||
otherUser.sendMessage(tl("warpingTo", warp, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
if (!otherUser.equals(teleportOwner)) {
|
||||
teleportOwner.sendMessage(tl("warpingTo", warp, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
}
|
||||
teleport(otherUser, new LocationTarget(loc), chargeFor, cause, future);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void back(final Trade chargeFor, final CompletableFuture<Boolean> future) {
|
||||
back(teleportOwner, chargeFor, future);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void back(final IUser teleporter, final Trade chargeFor, final CompletableFuture<Boolean> future) {
|
||||
tpType = TeleportType.BACK;
|
||||
final Location loc = teleportOwner.getLastLocation();
|
||||
teleportOwner.sendMessage(tl("backUsageMsg", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
teleportOther(teleporter, teleportOwner, new LocationTarget(loc), chargeFor, TeleportCause.COMMAND, future);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void back(final CompletableFuture<Boolean> future) {
|
||||
nowAsync(teleportOwner, new LocationTarget(teleportOwner.getLastLocation()), TeleportCause.COMMAND, future);
|
||||
}
|
||||
|
||||
public void setTpType(final TeleportType tpType) {
|
||||
this.tpType = tpType;
|
||||
}
|
||||
|
||||
//If we need to cancelTimer a pending teleportPlayer call this method
|
||||
private void cancel(final boolean notifyUser) {
|
||||
if (timedTeleport != null) {
|
||||
timedTeleport.cancelTimer(notifyUser);
|
||||
timedTeleport = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void initTimer(final long delay, final IUser teleportUser, final ITarget target, final Trade chargeFor, final TeleportCause cause, final boolean respawn) {
|
||||
timedTeleport = new AsyncTimedTeleport(teleportOwner, ess, this, delay, teleportUser, target, chargeFor, cause, respawn);
|
||||
}
|
||||
|
||||
public enum TeleportType {
|
||||
TPA,
|
||||
BACK,
|
||||
NORMAL
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class AsyncTimedTeleport implements Runnable {
|
||||
private static final double MOVE_CONSTANT = 0.3;
|
||||
private final IUser teleportOwner;
|
||||
private final IEssentials ess;
|
||||
private final AsyncTeleport teleport;
|
||||
private final UUID timer_teleportee;
|
||||
private final long timer_started; // time this task was initiated
|
||||
private final long timer_delay; // how long to delay the teleportPlayer
|
||||
// note that I initially stored a clone of the location for reference, but...
|
||||
// when comparing locations, I got incorrect mismatches (rounding errors, looked like)
|
||||
// so, the X/Y/Z values are stored instead and rounded off
|
||||
private final long timer_initX;
|
||||
private final long timer_initY;
|
||||
private final long timer_initZ;
|
||||
private final ITarget timer_teleportTarget;
|
||||
private final boolean timer_respawn;
|
||||
private final boolean timer_canMove;
|
||||
private final Trade timer_chargeFor;
|
||||
private final TeleportCause timer_cause;
|
||||
private int timer_task;
|
||||
private double timer_health;
|
||||
|
||||
AsyncTimedTeleport(final IUser user, final IEssentials ess, final AsyncTeleport teleport, final long delay, final IUser teleportUser, final ITarget target, final Trade chargeFor, final TeleportCause cause, final boolean respawn) {
|
||||
this.teleportOwner = user;
|
||||
this.ess = ess;
|
||||
this.teleport = teleport;
|
||||
this.timer_started = System.currentTimeMillis();
|
||||
this.timer_delay = delay;
|
||||
this.timer_health = teleportUser.getBase().getHealth();
|
||||
this.timer_initX = Math.round(teleportUser.getBase().getLocation().getX() * MOVE_CONSTANT);
|
||||
this.timer_initY = Math.round(teleportUser.getBase().getLocation().getY() * MOVE_CONSTANT);
|
||||
this.timer_initZ = Math.round(teleportUser.getBase().getLocation().getZ() * MOVE_CONSTANT);
|
||||
this.timer_teleportee = teleportUser.getBase().getUniqueId();
|
||||
this.timer_teleportTarget = target;
|
||||
this.timer_chargeFor = chargeFor;
|
||||
this.timer_cause = cause;
|
||||
this.timer_respawn = respawn;
|
||||
this.timer_canMove = user.isAuthorized("essentials.teleport.timer.move");
|
||||
|
||||
timer_task = ess.runTaskTimerAsynchronously(this, 20, 20).getTaskId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if (teleportOwner == null || !teleportOwner.getBase().isOnline() || teleportOwner.getBase().getLocation() == null) {
|
||||
cancelTimer(false);
|
||||
return;
|
||||
}
|
||||
|
||||
final IUser teleportUser = ess.getUser(this.timer_teleportee);
|
||||
|
||||
if (teleportUser == null || !teleportUser.getBase().isOnline()) {
|
||||
cancelTimer(false);
|
||||
return;
|
||||
}
|
||||
|
||||
final Location currLocation = teleportUser.getBase().getLocation();
|
||||
if (currLocation == null) {
|
||||
cancelTimer(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!timer_canMove && (Math.round(currLocation.getX() * MOVE_CONSTANT) != timer_initX || Math.round(currLocation.getY() * MOVE_CONSTANT) != timer_initY || Math.round(currLocation.getZ() * MOVE_CONSTANT) != timer_initZ || teleportUser.getBase().getHealth() < timer_health)) {
|
||||
// user moved, cancelTimer teleportPlayer
|
||||
cancelTimer(true);
|
||||
return;
|
||||
}
|
||||
|
||||
class DelayedTeleportTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
timer_health = teleportUser.getBase().getHealth(); // in case user healed, then later gets injured
|
||||
final long now = System.currentTimeMillis();
|
||||
if (now > timer_started + timer_delay) {
|
||||
try {
|
||||
teleport.cooldown(false);
|
||||
} catch (final Throwable ex) {
|
||||
teleportOwner.sendMessage(tl("cooldownWithMessage", ex.getMessage()));
|
||||
if (teleportOwner != teleportUser) {
|
||||
teleportUser.sendMessage(tl("cooldownWithMessage", ex.getMessage()));
|
||||
}
|
||||
}
|
||||
try {
|
||||
cancelTimer(false);
|
||||
teleportUser.sendMessage(tl("teleportationCommencing"));
|
||||
|
||||
final CompletableFuture<Boolean> future = new CompletableFuture<>();
|
||||
future.exceptionally(e -> {
|
||||
ess.showError(teleportOwner.getSource(), e, "\\ teleport");
|
||||
return false;
|
||||
});
|
||||
if (timer_chargeFor != null) {
|
||||
timer_chargeFor.isAffordableFor(teleportOwner);
|
||||
}
|
||||
if (timer_respawn) {
|
||||
teleport.respawnNow(teleportUser, timer_cause, future);
|
||||
} else {
|
||||
teleport.nowAsync(teleportUser, timer_teleportTarget, timer_cause, future);
|
||||
}
|
||||
future.thenAccept(success -> {
|
||||
if (timer_chargeFor != null) {
|
||||
try {
|
||||
timer_chargeFor.charge(teleportOwner);
|
||||
} catch (final ChargeException ex) {
|
||||
ess.showError(teleportOwner.getSource(), ex, "\\ teleport");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} catch (final Exception ex) {
|
||||
ess.showError(teleportOwner.getSource(), ex, "\\ teleport");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ess.scheduleSyncDelayedTask(new DelayedTeleportTask());
|
||||
}
|
||||
|
||||
//If we need to cancelTimer a pending teleportPlayer call this method
|
||||
void cancelTimer(final boolean notifyUser) {
|
||||
if (timer_task == -1) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
ess.getServer().getScheduler().cancelTask(timer_task);
|
||||
if (notifyUser) {
|
||||
teleportOwner.sendMessage(tl("pendingTeleportCancelled"));
|
||||
if (timer_teleportee != null && !timer_teleportee.equals(teleportOwner.getBase().getUniqueId())) {
|
||||
ess.getUser(timer_teleportee).sendMessage(tl("pendingTeleportCancelled"));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
timer_task = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,167 +1,133 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class Backup implements Runnable
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Essentials");
|
||||
private transient final Server server;
|
||||
private transient final IEssentials ess;
|
||||
private transient boolean running = false;
|
||||
private transient int taskId = -1;
|
||||
private transient boolean active = false;
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public Backup(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
server = ess.getServer();
|
||||
if (server.getOnlinePlayers().length > 0)
|
||||
{
|
||||
ess.runTaskAsynchronously(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
startTask();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
public class Backup implements Runnable {
|
||||
private static final Logger LOGGER = Logger.getLogger("Essentials");
|
||||
private transient final Server server;
|
||||
private transient final IEssentials ess;
|
||||
private final AtomicBoolean pendingShutdown = new AtomicBoolean(false);
|
||||
private transient boolean running = false;
|
||||
private transient int taskId = -1;
|
||||
private transient boolean active = false;
|
||||
private transient CompletableFuture<Object> taskLock = null;
|
||||
|
||||
public void onPlayerJoin()
|
||||
{
|
||||
startTask();
|
||||
}
|
||||
public Backup(final IEssentials ess) {
|
||||
this.ess = ess;
|
||||
server = ess.getServer();
|
||||
if (!ess.getOnlinePlayers().isEmpty() || ess.getSettings().isAlwaysRunBackup()) {
|
||||
ess.runTaskAsynchronously(this::startTask);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void stopTask()
|
||||
{
|
||||
running = false;
|
||||
if (taskId != -1)
|
||||
{
|
||||
server.getScheduler().cancelTask(taskId);
|
||||
}
|
||||
taskId = -1;
|
||||
}
|
||||
public void onPlayerJoin() {
|
||||
startTask();
|
||||
}
|
||||
|
||||
private synchronized void startTask()
|
||||
{
|
||||
if (!running)
|
||||
{
|
||||
final long interval = ess.getSettings().getBackupInterval() * 1200; // minutes -> ticks
|
||||
if (interval < 1200)
|
||||
{
|
||||
return;
|
||||
}
|
||||
taskId = ess.scheduleSyncRepeatingTask(this, interval, interval);
|
||||
running = true;
|
||||
}
|
||||
}
|
||||
public synchronized void stopTask() {
|
||||
running = false;
|
||||
if (taskId != -1) {
|
||||
server.getScheduler().cancelTask(taskId);
|
||||
}
|
||||
taskId = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
active = true;
|
||||
final String command = ess.getSettings().getBackupCommand();
|
||||
if (command == null || "".equals(command))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ("save-all".equalsIgnoreCase(command))
|
||||
{
|
||||
final CommandSender cs = server.getConsoleSender();
|
||||
server.dispatchCommand(cs, "save-all");
|
||||
active = false;
|
||||
return;
|
||||
}
|
||||
LOGGER.log(Level.INFO, _("backupStarted"));
|
||||
final CommandSender cs = server.getConsoleSender();
|
||||
server.dispatchCommand(cs, "save-all");
|
||||
server.dispatchCommand(cs, "save-off");
|
||||
private synchronized void startTask() {
|
||||
if (!running) {
|
||||
final long interval = ess.getSettings().getBackupInterval() * 1200; // minutes -> ticks
|
||||
if (interval < 1200) {
|
||||
return;
|
||||
}
|
||||
taskId = ess.scheduleSyncRepeatingTask(this, interval, interval);
|
||||
running = true;
|
||||
}
|
||||
}
|
||||
|
||||
ess.runTaskAsynchronously(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
final ProcessBuilder childBuilder = new ProcessBuilder(command);
|
||||
childBuilder.redirectErrorStream(true);
|
||||
childBuilder.directory(ess.getDataFolder().getParentFile().getParentFile());
|
||||
final Process child = childBuilder.start();
|
||||
ess.runTaskAsynchronously(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(child.getInputStream()));
|
||||
try
|
||||
{
|
||||
String line;
|
||||
do
|
||||
{
|
||||
line = reader.readLine();
|
||||
if (line != null)
|
||||
{
|
||||
LOGGER.log(Level.INFO, line);
|
||||
}
|
||||
}
|
||||
while (line != null);
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
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()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
server.dispatchCommand(cs, "save-on");
|
||||
if (server.getOnlinePlayers().length == 0)
|
||||
{
|
||||
stopTask();
|
||||
}
|
||||
active = false;
|
||||
LOGGER.log(Level.INFO, _("backupFinished"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
public CompletableFuture<Object> getTaskLock() {
|
||||
return taskLock;
|
||||
}
|
||||
|
||||
public void setPendingShutdown(final boolean shutdown) {
|
||||
pendingShutdown.set(shutdown);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (active) {
|
||||
return;
|
||||
}
|
||||
final String command = ess.getSettings().getBackupCommand();
|
||||
if (command == null || "".equals(command)) {
|
||||
return;
|
||||
}
|
||||
active = true;
|
||||
taskLock = new CompletableFuture<>();
|
||||
if ("save-all".equalsIgnoreCase(command)) {
|
||||
final CommandSender cs = server.getConsoleSender();
|
||||
server.dispatchCommand(cs, "save-all");
|
||||
active = false;
|
||||
taskLock.complete(new Object());
|
||||
return;
|
||||
}
|
||||
LOGGER.log(Level.INFO, tl("backupStarted"));
|
||||
final CommandSender cs = server.getConsoleSender();
|
||||
server.dispatchCommand(cs, "save-all");
|
||||
server.dispatchCommand(cs, "save-off");
|
||||
|
||||
ess.runTaskAsynchronously(() -> {
|
||||
try {
|
||||
final ProcessBuilder childBuilder = new ProcessBuilder(command.split(" "));
|
||||
childBuilder.redirectErrorStream(true);
|
||||
childBuilder.directory(ess.getDataFolder().getParentFile().getParentFile());
|
||||
final Process child = childBuilder.start();
|
||||
ess.runTaskAsynchronously(() -> {
|
||||
try {
|
||||
try (final BufferedReader reader = new BufferedReader(new InputStreamReader(child.getInputStream()))) {
|
||||
String line;
|
||||
do {
|
||||
line = reader.readLine();
|
||||
if (line != null) {
|
||||
LOGGER.log(Level.INFO, line);
|
||||
}
|
||||
} while (line != null);
|
||||
}
|
||||
} catch (final IOException ex) {
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
});
|
||||
child.waitFor();
|
||||
} catch (final InterruptedException | IOException ex) {
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
} finally {
|
||||
class BackupEnableSaveTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
server.dispatchCommand(cs, "save-on");
|
||||
if (!ess.getSettings().isAlwaysRunBackup() && ess.getOnlinePlayers().isEmpty()) {
|
||||
stopTask();
|
||||
}
|
||||
active = false;
|
||||
taskLock.complete(new Object());
|
||||
LOGGER.log(Level.INFO, tl("backupFinished"));
|
||||
}
|
||||
}
|
||||
|
||||
if (!pendingShutdown.get()) {
|
||||
ess.scheduleSyncDelayedTask(new BackupEnableSaveTask());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,11 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
public class ChargeException extends Exception {
|
||||
public ChargeException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public class ChargeException extends Exception
|
||||
{
|
||||
public ChargeException(final String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ChargeException(final String message, final Throwable throwable)
|
||||
{
|
||||
super(message, throwable);
|
||||
}
|
||||
public ChargeException(final String message, final Throwable throwable) {
|
||||
super(message, throwable);
|
||||
}
|
||||
}
|
||||
@@ -3,59 +3,54 @@ package com.earth2me.essentials;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandSource {
|
||||
protected CommandSender sender;
|
||||
|
||||
public class CommandSource implements IReplyTo
|
||||
{
|
||||
private CommandSource replyTo = null;
|
||||
protected CommandSender sender;
|
||||
public CommandSource(final CommandSender base) {
|
||||
this.sender = base;
|
||||
}
|
||||
|
||||
public CommandSource(final CommandSender base)
|
||||
{
|
||||
this.sender = base;
|
||||
}
|
||||
public final CommandSender getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public final CommandSender getSender()
|
||||
{
|
||||
return sender;
|
||||
}
|
||||
public final Player getPlayer() {
|
||||
if (sender instanceof Player) {
|
||||
return (Player) sender;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public final Player getPlayer()
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
return (Player)sender;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public final boolean isPlayer()
|
||||
{
|
||||
return (sender instanceof Player);
|
||||
}
|
||||
public final net.ess3.api.IUser getUser(final IEssentials ess) {
|
||||
if (sender instanceof Player) {
|
||||
return ess.getUser((Player) sender);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public final CommandSender setSender(final CommandSender base)
|
||||
{
|
||||
return this.sender = base;
|
||||
}
|
||||
|
||||
|
||||
public void sendMessage(String message)
|
||||
{
|
||||
if (!message.isEmpty())
|
||||
{
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
}
|
||||
public final boolean isPlayer() {
|
||||
return sender instanceof Player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReplyTo(final CommandSource user)
|
||||
{
|
||||
replyTo = user;
|
||||
}
|
||||
public final CommandSender setSender(final CommandSender base) {
|
||||
return this.sender = base;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSource getReplyTo()
|
||||
{
|
||||
return replyTo;
|
||||
}
|
||||
public void sendMessage(final String message) {
|
||||
if (!message.isEmpty()) {
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAuthorized(final String permission, final IEssentials ess) {
|
||||
return !(sender instanceof Player) || getUser(ess).isAuthorized(permission);
|
||||
}
|
||||
|
||||
public String getSelfSelector() {
|
||||
return sender instanceof Player ? getPlayer().getName() : "*";
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return sender instanceof Player ? getPlayer().getDisplayName() : getSender().getName();
|
||||
}
|
||||
}
|
||||
@@ -1,38 +1,89 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.messaging.IMessageRecipient;
|
||||
import com.earth2me.essentials.messaging.SimpleMessageRecipient;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public final class Console implements IMessageRecipient {
|
||||
public static final String NAME = "Console";
|
||||
private static Console instance; // Set in essentials
|
||||
|
||||
public final class Console implements IReplyTo
|
||||
{
|
||||
private static final Console instance = new Console();
|
||||
private CommandSource replyTo;
|
||||
public final static String NAME = "Console";
|
||||
private final IEssentials ess;
|
||||
private final IMessageRecipient messageRecipient;
|
||||
|
||||
private Console()
|
||||
{
|
||||
}
|
||||
private Console(final IEssentials ess) {
|
||||
this.ess = ess;
|
||||
this.messageRecipient = new SimpleMessageRecipient(ess, this);
|
||||
}
|
||||
|
||||
public static CommandSender getCommandSender(Server server) throws Exception
|
||||
{
|
||||
return server.getConsoleSender();
|
||||
}
|
||||
public static Console getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReplyTo(CommandSource user)
|
||||
{
|
||||
replyTo = user;
|
||||
}
|
||||
static void setInstance(final IEssentials ess) { // Called in Essentials#onEnable()
|
||||
instance = new Console(ess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSource getReplyTo()
|
||||
{
|
||||
return replyTo;
|
||||
}
|
||||
/**
|
||||
* @deprecated Use {@link Console#getCommandSender()}
|
||||
*/
|
||||
@Deprecated
|
||||
public static CommandSender getCommandSender(final Server server) throws Exception {
|
||||
return server.getConsoleSender();
|
||||
}
|
||||
|
||||
public static Console getConsoleReplyTo()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
public CommandSender getCommandSender() {
|
||||
return ess.getServer().getConsoleSender();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return Console.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return Console.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(final String message) {
|
||||
getCommandSender().sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReachable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ================================
|
||||
* >> DELEGATE METHODS
|
||||
* ================================ */
|
||||
|
||||
@Override
|
||||
public MessageResponse sendMessage(final IMessageRecipient recipient, final String message) {
|
||||
return this.messageRecipient.sendMessage(recipient, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageResponse onReceiveMessage(final IMessageRecipient sender, final String message) {
|
||||
return this.messageRecipient.onReceiveMessage(sender, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessageRecipient getReplyRecipient() {
|
||||
return this.messageRecipient.getReplyRecipient();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReplyRecipient(final IMessageRecipient recipient) {
|
||||
this.messageRecipient.setReplyRecipient(recipient);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHiddenFrom(Player player) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,187 +1,304 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
public final class Enchantments {
|
||||
private static final Map<String, Enchantment> ENCHANTMENTS = new HashMap<>();
|
||||
private static final Map<String, Enchantment> ALIASENCHANTMENTS = new HashMap<>();
|
||||
private static boolean isFlat;
|
||||
|
||||
public class Enchantments
|
||||
{
|
||||
private static final Map<String, Enchantment> ENCHANTMENTS = new HashMap<String, Enchantment>();
|
||||
private static final Map<String, Enchantment> ALIASENCHANTMENTS = new HashMap<String, Enchantment>();
|
||||
static {
|
||||
ENCHANTMENTS.put("alldamage", Enchantment.DAMAGE_ALL);
|
||||
ALIASENCHANTMENTS.put("alldmg", Enchantment.DAMAGE_ALL);
|
||||
ENCHANTMENTS.put("sharpness", Enchantment.DAMAGE_ALL);
|
||||
ALIASENCHANTMENTS.put("sharp", Enchantment.DAMAGE_ALL);
|
||||
ALIASENCHANTMENTS.put("dal", Enchantment.DAMAGE_ALL);
|
||||
|
||||
static
|
||||
{
|
||||
ENCHANTMENTS.put("alldamage", Enchantment.DAMAGE_ALL);
|
||||
ALIASENCHANTMENTS.put("alldmg", Enchantment.DAMAGE_ALL);
|
||||
ENCHANTMENTS.put("sharpness", Enchantment.DAMAGE_ALL);
|
||||
ALIASENCHANTMENTS.put("sharp", Enchantment.DAMAGE_ALL);
|
||||
ALIASENCHANTMENTS.put("dal", Enchantment.DAMAGE_ALL);
|
||||
ENCHANTMENTS.put("ardmg", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ENCHANTMENTS.put("baneofarthropods", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ALIASENCHANTMENTS.put("baneofarthropod", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ALIASENCHANTMENTS.put("arthropod", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ALIASENCHANTMENTS.put("dar", Enchantment.DAMAGE_ARTHROPODS);
|
||||
|
||||
ENCHANTMENTS.put("ardmg", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ENCHANTMENTS.put("baneofarthropods", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ALIASENCHANTMENTS.put("baneofarthropod", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ALIASENCHANTMENTS.put("arthropod", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ALIASENCHANTMENTS.put("dar", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ENCHANTMENTS.put("undeaddamage", Enchantment.DAMAGE_UNDEAD);
|
||||
ENCHANTMENTS.put("smite", Enchantment.DAMAGE_UNDEAD);
|
||||
ALIASENCHANTMENTS.put("du", Enchantment.DAMAGE_UNDEAD);
|
||||
|
||||
ENCHANTMENTS.put("undeaddamage", Enchantment.DAMAGE_UNDEAD);
|
||||
ENCHANTMENTS.put("smite", Enchantment.DAMAGE_UNDEAD);
|
||||
ALIASENCHANTMENTS.put("du", Enchantment.DAMAGE_UNDEAD);
|
||||
ENCHANTMENTS.put("digspeed", Enchantment.DIG_SPEED);
|
||||
ENCHANTMENTS.put("efficiency", Enchantment.DIG_SPEED);
|
||||
ALIASENCHANTMENTS.put("minespeed", Enchantment.DIG_SPEED);
|
||||
ALIASENCHANTMENTS.put("cutspeed", Enchantment.DIG_SPEED);
|
||||
ALIASENCHANTMENTS.put("ds", Enchantment.DIG_SPEED);
|
||||
ALIASENCHANTMENTS.put("eff", Enchantment.DIG_SPEED);
|
||||
|
||||
ENCHANTMENTS.put("digspeed", Enchantment.DIG_SPEED);
|
||||
ENCHANTMENTS.put("efficiency", Enchantment.DIG_SPEED);
|
||||
ALIASENCHANTMENTS.put("minespeed", Enchantment.DIG_SPEED);
|
||||
ALIASENCHANTMENTS.put("cutspeed", Enchantment.DIG_SPEED);
|
||||
ALIASENCHANTMENTS.put("ds", Enchantment.DIG_SPEED);
|
||||
ALIASENCHANTMENTS.put("eff", Enchantment.DIG_SPEED);
|
||||
ENCHANTMENTS.put("durability", Enchantment.DURABILITY);
|
||||
ALIASENCHANTMENTS.put("dura", Enchantment.DURABILITY);
|
||||
ENCHANTMENTS.put("unbreaking", Enchantment.DURABILITY);
|
||||
ALIASENCHANTMENTS.put("d", Enchantment.DURABILITY);
|
||||
|
||||
ENCHANTMENTS.put("durability", Enchantment.DURABILITY);
|
||||
ALIASENCHANTMENTS.put("dura", Enchantment.DURABILITY);
|
||||
ENCHANTMENTS.put("unbreaking", Enchantment.DURABILITY);
|
||||
ALIASENCHANTMENTS.put("d", Enchantment.DURABILITY);
|
||||
ENCHANTMENTS.put("thorns", Enchantment.THORNS);
|
||||
ENCHANTMENTS.put("highcrit", Enchantment.THORNS);
|
||||
ALIASENCHANTMENTS.put("thorn", Enchantment.THORNS);
|
||||
ALIASENCHANTMENTS.put("highercrit", Enchantment.THORNS);
|
||||
ALIASENCHANTMENTS.put("t", Enchantment.THORNS);
|
||||
|
||||
ENCHANTMENTS.put("thorns", Enchantment.THORNS);
|
||||
ENCHANTMENTS.put("highcrit", Enchantment.THORNS);
|
||||
ALIASENCHANTMENTS.put("thorn", Enchantment.THORNS);
|
||||
ALIASENCHANTMENTS.put("highercrit", Enchantment.THORNS);
|
||||
ALIASENCHANTMENTS.put("t", Enchantment.THORNS);
|
||||
ENCHANTMENTS.put("fireaspect", Enchantment.FIRE_ASPECT);
|
||||
ENCHANTMENTS.put("fire", Enchantment.FIRE_ASPECT);
|
||||
ALIASENCHANTMENTS.put("meleefire", Enchantment.FIRE_ASPECT);
|
||||
ALIASENCHANTMENTS.put("meleeflame", Enchantment.FIRE_ASPECT);
|
||||
ALIASENCHANTMENTS.put("fa", Enchantment.FIRE_ASPECT);
|
||||
|
||||
ENCHANTMENTS.put("fireaspect", Enchantment.FIRE_ASPECT);
|
||||
ENCHANTMENTS.put("fire", Enchantment.FIRE_ASPECT);
|
||||
ALIASENCHANTMENTS.put("meleefire", Enchantment.FIRE_ASPECT);
|
||||
ALIASENCHANTMENTS.put("meleeflame", Enchantment.FIRE_ASPECT);
|
||||
ALIASENCHANTMENTS.put("fa", Enchantment.FIRE_ASPECT);
|
||||
ENCHANTMENTS.put("knockback", Enchantment.KNOCKBACK);
|
||||
ALIASENCHANTMENTS.put("kback", Enchantment.KNOCKBACK);
|
||||
ALIASENCHANTMENTS.put("kb", Enchantment.KNOCKBACK);
|
||||
ALIASENCHANTMENTS.put("k", Enchantment.KNOCKBACK);
|
||||
|
||||
ENCHANTMENTS.put("knockback", Enchantment.KNOCKBACK);
|
||||
ALIASENCHANTMENTS.put("kback", Enchantment.KNOCKBACK);
|
||||
ALIASENCHANTMENTS.put("kb", Enchantment.KNOCKBACK);
|
||||
ALIASENCHANTMENTS.put("k", Enchantment.KNOCKBACK);
|
||||
ALIASENCHANTMENTS.put("blockslootbonus", Enchantment.LOOT_BONUS_BLOCKS);
|
||||
ENCHANTMENTS.put("fortune", Enchantment.LOOT_BONUS_BLOCKS);
|
||||
ALIASENCHANTMENTS.put("fort", Enchantment.LOOT_BONUS_BLOCKS);
|
||||
ALIASENCHANTMENTS.put("lbb", Enchantment.LOOT_BONUS_BLOCKS);
|
||||
|
||||
ALIASENCHANTMENTS.put("blockslootbonus", Enchantment.LOOT_BONUS_BLOCKS);
|
||||
ENCHANTMENTS.put("fortune", Enchantment.LOOT_BONUS_BLOCKS);
|
||||
ALIASENCHANTMENTS.put("fort", Enchantment.LOOT_BONUS_BLOCKS);
|
||||
ALIASENCHANTMENTS.put("lbb", Enchantment.LOOT_BONUS_BLOCKS);
|
||||
ALIASENCHANTMENTS.put("mobslootbonus", Enchantment.LOOT_BONUS_MOBS);
|
||||
ENCHANTMENTS.put("mobloot", Enchantment.LOOT_BONUS_MOBS);
|
||||
ENCHANTMENTS.put("looting", Enchantment.LOOT_BONUS_MOBS);
|
||||
ALIASENCHANTMENTS.put("lbm", Enchantment.LOOT_BONUS_MOBS);
|
||||
|
||||
ALIASENCHANTMENTS.put("mobslootbonus", Enchantment.LOOT_BONUS_MOBS);
|
||||
ENCHANTMENTS.put("mobloot", Enchantment.LOOT_BONUS_MOBS);
|
||||
ENCHANTMENTS.put("looting", Enchantment.LOOT_BONUS_MOBS);
|
||||
ALIASENCHANTMENTS.put("lbm", Enchantment.LOOT_BONUS_MOBS);
|
||||
ALIASENCHANTMENTS.put("oxygen", Enchantment.OXYGEN);
|
||||
ENCHANTMENTS.put("respiration", Enchantment.OXYGEN);
|
||||
ALIASENCHANTMENTS.put("breathing", Enchantment.OXYGEN);
|
||||
ENCHANTMENTS.put("breath", Enchantment.OXYGEN);
|
||||
ALIASENCHANTMENTS.put("o", Enchantment.OXYGEN);
|
||||
|
||||
ALIASENCHANTMENTS.put("oxygen", Enchantment.OXYGEN);
|
||||
ENCHANTMENTS.put("respiration", Enchantment.OXYGEN);
|
||||
ALIASENCHANTMENTS.put("breathing", Enchantment.OXYGEN);
|
||||
ENCHANTMENTS.put("breath", Enchantment.OXYGEN);
|
||||
ALIASENCHANTMENTS.put("o", Enchantment.OXYGEN);
|
||||
ENCHANTMENTS.put("protection", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
ALIASENCHANTMENTS.put("prot", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
ENCHANTMENTS.put("protect", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
ALIASENCHANTMENTS.put("p", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
|
||||
ENCHANTMENTS.put("protection", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
ALIASENCHANTMENTS.put("prot", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
ENCHANTMENTS.put("protect", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
ALIASENCHANTMENTS.put("p", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
ALIASENCHANTMENTS.put("explosionsprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ALIASENCHANTMENTS.put("explosionprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ALIASENCHANTMENTS.put("expprot", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ALIASENCHANTMENTS.put("blastprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ALIASENCHANTMENTS.put("bprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ALIASENCHANTMENTS.put("bprotect", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ENCHANTMENTS.put("blastprotect", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ALIASENCHANTMENTS.put("pe", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
|
||||
ALIASENCHANTMENTS.put("explosionsprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ALIASENCHANTMENTS.put("explosionprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ALIASENCHANTMENTS.put("expprot", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ALIASENCHANTMENTS.put("blastprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ALIASENCHANTMENTS.put("bprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ALIASENCHANTMENTS.put("bprotect", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ENCHANTMENTS.put("blastprotect", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ALIASENCHANTMENTS.put("pe", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ALIASENCHANTMENTS.put("fallprotection", Enchantment.PROTECTION_FALL);
|
||||
ENCHANTMENTS.put("fallprot", Enchantment.PROTECTION_FALL);
|
||||
ENCHANTMENTS.put("featherfall", Enchantment.PROTECTION_FALL);
|
||||
ALIASENCHANTMENTS.put("featherfalling", Enchantment.PROTECTION_FALL);
|
||||
ALIASENCHANTMENTS.put("pfa", Enchantment.PROTECTION_FALL);
|
||||
|
||||
ALIASENCHANTMENTS.put("fallprotection", Enchantment.PROTECTION_FALL);
|
||||
ENCHANTMENTS.put("fallprot", Enchantment.PROTECTION_FALL);
|
||||
ENCHANTMENTS.put("featherfall", Enchantment.PROTECTION_FALL);
|
||||
ALIASENCHANTMENTS.put("featherfalling", Enchantment.PROTECTION_FALL);
|
||||
ALIASENCHANTMENTS.put("pfa", Enchantment.PROTECTION_FALL);
|
||||
ALIASENCHANTMENTS.put("fireprotection", Enchantment.PROTECTION_FIRE);
|
||||
ALIASENCHANTMENTS.put("flameprotection", Enchantment.PROTECTION_FIRE);
|
||||
ENCHANTMENTS.put("fireprotect", Enchantment.PROTECTION_FIRE);
|
||||
ALIASENCHANTMENTS.put("flameprotect", Enchantment.PROTECTION_FIRE);
|
||||
ENCHANTMENTS.put("fireprot", Enchantment.PROTECTION_FIRE);
|
||||
ALIASENCHANTMENTS.put("flameprot", Enchantment.PROTECTION_FIRE);
|
||||
ALIASENCHANTMENTS.put("pf", Enchantment.PROTECTION_FIRE);
|
||||
|
||||
ALIASENCHANTMENTS.put("fireprotection", Enchantment.PROTECTION_FIRE);
|
||||
ALIASENCHANTMENTS.put("flameprotection", Enchantment.PROTECTION_FIRE);
|
||||
ENCHANTMENTS.put("fireprotect", Enchantment.PROTECTION_FIRE);
|
||||
ALIASENCHANTMENTS.put("flameprotect", Enchantment.PROTECTION_FIRE);
|
||||
ENCHANTMENTS.put("fireprot", Enchantment.PROTECTION_FIRE);
|
||||
ALIASENCHANTMENTS.put("flameprot", Enchantment.PROTECTION_FIRE);
|
||||
ALIASENCHANTMENTS.put("pf", Enchantment.PROTECTION_FIRE);
|
||||
ENCHANTMENTS.put("projectileprotection", Enchantment.PROTECTION_PROJECTILE);
|
||||
ENCHANTMENTS.put("projprot", Enchantment.PROTECTION_PROJECTILE);
|
||||
ALIASENCHANTMENTS.put("pp", Enchantment.PROTECTION_PROJECTILE);
|
||||
|
||||
ENCHANTMENTS.put("projectileprotection", Enchantment.PROTECTION_PROJECTILE);
|
||||
ENCHANTMENTS.put("projprot", Enchantment.PROTECTION_PROJECTILE);
|
||||
ALIASENCHANTMENTS.put("pp", Enchantment.PROTECTION_PROJECTILE);
|
||||
ENCHANTMENTS.put("silktouch", Enchantment.SILK_TOUCH);
|
||||
ALIASENCHANTMENTS.put("softtouch", Enchantment.SILK_TOUCH);
|
||||
ALIASENCHANTMENTS.put("st", Enchantment.SILK_TOUCH);
|
||||
|
||||
ENCHANTMENTS.put("silktouch", Enchantment.SILK_TOUCH);
|
||||
ALIASENCHANTMENTS.put("softtouch", Enchantment.SILK_TOUCH);
|
||||
ALIASENCHANTMENTS.put("st", Enchantment.SILK_TOUCH);
|
||||
ENCHANTMENTS.put("waterworker", Enchantment.WATER_WORKER);
|
||||
ENCHANTMENTS.put("aquaaffinity", Enchantment.WATER_WORKER);
|
||||
ALIASENCHANTMENTS.put("watermine", Enchantment.WATER_WORKER);
|
||||
ALIASENCHANTMENTS.put("ww", Enchantment.WATER_WORKER);
|
||||
|
||||
ENCHANTMENTS.put("waterworker", Enchantment.WATER_WORKER);
|
||||
ENCHANTMENTS.put("aquaaffinity", Enchantment.WATER_WORKER);
|
||||
ALIASENCHANTMENTS.put("watermine", Enchantment.WATER_WORKER);
|
||||
ALIASENCHANTMENTS.put("ww", Enchantment.WATER_WORKER);
|
||||
ALIASENCHANTMENTS.put("firearrow", Enchantment.ARROW_FIRE);
|
||||
ENCHANTMENTS.put("flame", Enchantment.ARROW_FIRE);
|
||||
ENCHANTMENTS.put("flamearrow", Enchantment.ARROW_FIRE);
|
||||
ALIASENCHANTMENTS.put("af", Enchantment.ARROW_FIRE);
|
||||
|
||||
ALIASENCHANTMENTS.put("firearrow", Enchantment.ARROW_FIRE);
|
||||
ENCHANTMENTS.put("flame", Enchantment.ARROW_FIRE);
|
||||
ENCHANTMENTS.put("flamearrow", Enchantment.ARROW_FIRE);
|
||||
ALIASENCHANTMENTS.put("af", Enchantment.ARROW_FIRE);
|
||||
ENCHANTMENTS.put("arrowdamage", Enchantment.ARROW_DAMAGE);
|
||||
ENCHANTMENTS.put("power", Enchantment.ARROW_DAMAGE);
|
||||
ALIASENCHANTMENTS.put("arrowpower", Enchantment.ARROW_DAMAGE);
|
||||
ALIASENCHANTMENTS.put("ad", Enchantment.ARROW_DAMAGE);
|
||||
|
||||
ENCHANTMENTS.put("arrowdamage", Enchantment.ARROW_DAMAGE);
|
||||
ENCHANTMENTS.put("power", Enchantment.ARROW_DAMAGE);
|
||||
ALIASENCHANTMENTS.put("arrowpower", Enchantment.ARROW_DAMAGE);
|
||||
ALIASENCHANTMENTS.put("ad", Enchantment.ARROW_DAMAGE);
|
||||
ENCHANTMENTS.put("arrowknockback", Enchantment.ARROW_KNOCKBACK);
|
||||
ALIASENCHANTMENTS.put("arrowkb", Enchantment.ARROW_KNOCKBACK);
|
||||
ENCHANTMENTS.put("punch", Enchantment.ARROW_KNOCKBACK);
|
||||
ALIASENCHANTMENTS.put("arrowpunch", Enchantment.ARROW_KNOCKBACK);
|
||||
ALIASENCHANTMENTS.put("ak", Enchantment.ARROW_KNOCKBACK);
|
||||
|
||||
ENCHANTMENTS.put("arrowknockback", Enchantment.ARROW_KNOCKBACK);
|
||||
ALIASENCHANTMENTS.put("arrowkb", Enchantment.ARROW_KNOCKBACK);
|
||||
ENCHANTMENTS.put("punch", Enchantment.ARROW_KNOCKBACK);
|
||||
ALIASENCHANTMENTS.put("arrowpunch", Enchantment.ARROW_KNOCKBACK);
|
||||
ALIASENCHANTMENTS.put("ak", Enchantment.ARROW_KNOCKBACK);
|
||||
ALIASENCHANTMENTS.put("infinitearrows", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("infarrows", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("infinity", Enchantment.ARROW_INFINITE);
|
||||
ALIASENCHANTMENTS.put("infinite", Enchantment.ARROW_INFINITE);
|
||||
ALIASENCHANTMENTS.put("unlimited", Enchantment.ARROW_INFINITE);
|
||||
ALIASENCHANTMENTS.put("unlimitedarrows", Enchantment.ARROW_INFINITE);
|
||||
ALIASENCHANTMENTS.put("ai", Enchantment.ARROW_INFINITE);
|
||||
|
||||
ALIASENCHANTMENTS.put("infinitearrows", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("infarrows", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("infinity", Enchantment.ARROW_INFINITE);
|
||||
ALIASENCHANTMENTS.put("infinite", Enchantment.ARROW_INFINITE);
|
||||
ALIASENCHANTMENTS.put("unlimited", Enchantment.ARROW_INFINITE);
|
||||
ALIASENCHANTMENTS.put("unlimitedarrows", Enchantment.ARROW_INFINITE);
|
||||
ALIASENCHANTMENTS.put("ai", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("luck", Enchantment.LUCK);
|
||||
ALIASENCHANTMENTS.put("luckofsea", Enchantment.LUCK);
|
||||
ALIASENCHANTMENTS.put("luckofseas", Enchantment.LUCK);
|
||||
ALIASENCHANTMENTS.put("rodluck", Enchantment.LUCK);
|
||||
|
||||
try // 1.7 update
|
||||
{
|
||||
ENCHANTMENTS.put("luck", Enchantment.LUCK);
|
||||
ALIASENCHANTMENTS.put("luckofsea", Enchantment.LUCK);
|
||||
ALIASENCHANTMENTS.put("luckofseas", Enchantment.LUCK);
|
||||
ALIASENCHANTMENTS.put("rodluck", Enchantment.LUCK);
|
||||
ENCHANTMENTS.put("lure", Enchantment.LURE);
|
||||
ALIASENCHANTMENTS.put("rodlure", Enchantment.LURE);
|
||||
|
||||
ENCHANTMENTS.put("lure", Enchantment.LURE);
|
||||
ALIASENCHANTMENTS.put("rodlure", Enchantment.LURE);
|
||||
}
|
||||
catch (java.lang.NoSuchFieldError e)
|
||||
{
|
||||
Essentials.wrongVersion();
|
||||
}
|
||||
}
|
||||
// 1.8
|
||||
try {
|
||||
final Enchantment depthStrider = Enchantment.getByName("DEPTH_STRIDER");
|
||||
if (depthStrider != null) {
|
||||
ENCHANTMENTS.put("depthstrider", depthStrider);
|
||||
ALIASENCHANTMENTS.put("depth", depthStrider);
|
||||
ALIASENCHANTMENTS.put("strider", depthStrider);
|
||||
}
|
||||
} catch (final IllegalArgumentException ignored) {
|
||||
}
|
||||
|
||||
public static Enchantment getByName(String name)
|
||||
{
|
||||
Enchantment enchantment;
|
||||
if (NumberUtil.isInt(name))
|
||||
{
|
||||
enchantment = Enchantment.getById(Integer.parseInt(name));
|
||||
}
|
||||
else
|
||||
{
|
||||
enchantment = Enchantment.getByName(name.toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
if (enchantment == null)
|
||||
{
|
||||
enchantment = ENCHANTMENTS.get(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
if (enchantment == null)
|
||||
{
|
||||
enchantment = ALIASENCHANTMENTS.get(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
return enchantment;
|
||||
}
|
||||
// 1.9
|
||||
try {
|
||||
final Enchantment frostWalker = Enchantment.getByName("FROST_WALKER");
|
||||
if (frostWalker != null) {
|
||||
ENCHANTMENTS.put("frostwalker", frostWalker);
|
||||
ALIASENCHANTMENTS.put("frost", frostWalker);
|
||||
ALIASENCHANTMENTS.put("walker", frostWalker);
|
||||
}
|
||||
|
||||
public static Set<Entry<String, Enchantment>> entrySet()
|
||||
{
|
||||
return ENCHANTMENTS.entrySet();
|
||||
}
|
||||
final Enchantment mending = Enchantment.getByName("MENDING");
|
||||
if (mending != null) {
|
||||
ENCHANTMENTS.put("mending", mending);
|
||||
}
|
||||
} catch (final IllegalArgumentException ignored) {
|
||||
}
|
||||
|
||||
// 1.11
|
||||
try {
|
||||
final Enchantment bindingCurse = Enchantment.getByName("BINDING_CURSE");
|
||||
if (bindingCurse != null) {
|
||||
ENCHANTMENTS.put("bindingcurse", bindingCurse);
|
||||
ALIASENCHANTMENTS.put("bindcurse", bindingCurse);
|
||||
ALIASENCHANTMENTS.put("binding", bindingCurse);
|
||||
ALIASENCHANTMENTS.put("bind", bindingCurse);
|
||||
}
|
||||
final Enchantment vanishingCurse = Enchantment.getByName("VANISHING_CURSE");
|
||||
if (vanishingCurse != null) {
|
||||
ENCHANTMENTS.put("vanishingcurse", vanishingCurse);
|
||||
ALIASENCHANTMENTS.put("vanishcurse", vanishingCurse);
|
||||
ALIASENCHANTMENTS.put("vanishing", vanishingCurse);
|
||||
ALIASENCHANTMENTS.put("vanish", vanishingCurse);
|
||||
}
|
||||
final Enchantment sweeping = Enchantment.getByName("SWEEPING_EDGE");
|
||||
if (sweeping != null) {
|
||||
ENCHANTMENTS.put("sweepingedge", sweeping);
|
||||
ALIASENCHANTMENTS.put("sweepedge", sweeping);
|
||||
ALIASENCHANTMENTS.put("sweeping", sweeping);
|
||||
}
|
||||
} catch (final IllegalArgumentException ignored) {
|
||||
}
|
||||
|
||||
try { // 1.13
|
||||
final Enchantment loyalty = Enchantment.getByName("LOYALTY");
|
||||
if (loyalty != null) {
|
||||
ENCHANTMENTS.put("loyalty", loyalty);
|
||||
ALIASENCHANTMENTS.put("loyal", loyalty);
|
||||
ALIASENCHANTMENTS.put("return", loyalty);
|
||||
}
|
||||
final Enchantment impaling = Enchantment.getByName("IMPALING");
|
||||
if (impaling != null) {
|
||||
ENCHANTMENTS.put("impaling", impaling);
|
||||
ALIASENCHANTMENTS.put("impale", impaling);
|
||||
ALIASENCHANTMENTS.put("oceandamage", impaling);
|
||||
ALIASENCHANTMENTS.put("oceandmg", impaling);
|
||||
}
|
||||
final Enchantment riptide = Enchantment.getByName("RIPTIDE");
|
||||
if (riptide != null) {
|
||||
ENCHANTMENTS.put("riptide", riptide);
|
||||
ALIASENCHANTMENTS.put("rip", riptide);
|
||||
ALIASENCHANTMENTS.put("tide", riptide);
|
||||
ALIASENCHANTMENTS.put("launch", riptide);
|
||||
}
|
||||
final Enchantment channelling = Enchantment.getByName("CHANNELING");
|
||||
if (channelling != null) {
|
||||
ENCHANTMENTS.put("channelling", channelling);
|
||||
ALIASENCHANTMENTS.put("chanelling", channelling);
|
||||
ALIASENCHANTMENTS.put("channeling", channelling);
|
||||
ALIASENCHANTMENTS.put("chaneling", channelling);
|
||||
ALIASENCHANTMENTS.put("channel", channelling);
|
||||
}
|
||||
} catch (final IllegalArgumentException ignored) {
|
||||
}
|
||||
|
||||
try { // 1.14
|
||||
final Enchantment multishot = Enchantment.getByName("MULTISHOT");
|
||||
if (multishot != null) {
|
||||
ENCHANTMENTS.put("multishot", multishot);
|
||||
ALIASENCHANTMENTS.put("tripleshot", multishot);
|
||||
}
|
||||
final Enchantment quickCharge = Enchantment.getByName("QUICK_CHARGE");
|
||||
if (quickCharge != null) {
|
||||
ENCHANTMENTS.put("quickcharge", quickCharge);
|
||||
ALIASENCHANTMENTS.put("quickdraw", quickCharge);
|
||||
ALIASENCHANTMENTS.put("fastcharge", quickCharge);
|
||||
ALIASENCHANTMENTS.put("fastdraw", quickCharge);
|
||||
}
|
||||
final Enchantment piercing = Enchantment.getByName("PIERCING");
|
||||
if (piercing != null) {
|
||||
ENCHANTMENTS.put("piercing", piercing);
|
||||
}
|
||||
} catch (final IllegalArgumentException ignored) {
|
||||
}
|
||||
|
||||
try { // 1.16
|
||||
final Enchantment soulspeed = Enchantment.getByName("SOUL_SPEED");
|
||||
if (soulspeed != null) {
|
||||
ENCHANTMENTS.put("soulspeed", soulspeed);
|
||||
ALIASENCHANTMENTS.put("soilspeed", soulspeed);
|
||||
ALIASENCHANTMENTS.put("sandspeed", soulspeed);
|
||||
}
|
||||
} catch (final IllegalArgumentException ignored) {
|
||||
}
|
||||
|
||||
try {
|
||||
final Class<?> namespacedKeyClass = Class.forName("org.bukkit.NamespacedKey");
|
||||
final Class<?> enchantmentClass = Class.forName("org.bukkit.enchantments.Enchantment");
|
||||
enchantmentClass.getDeclaredMethod("getByKey", namespacedKeyClass);
|
||||
isFlat = true;
|
||||
} catch (final ClassNotFoundException | NoSuchMethodException e) {
|
||||
isFlat = false;
|
||||
}
|
||||
}
|
||||
|
||||
private Enchantments() {
|
||||
}
|
||||
|
||||
public static Enchantment getByName(final String name) {
|
||||
Enchantment enchantment = null;
|
||||
if (isFlat) { // 1.13+ only
|
||||
enchantment = Enchantment.getByKey(NamespacedKey.minecraft(name.toLowerCase()));
|
||||
}
|
||||
|
||||
if (enchantment == null) {
|
||||
enchantment = Enchantment.getByName(name.toUpperCase());
|
||||
}
|
||||
if (enchantment == null) {
|
||||
enchantment = ENCHANTMENTS.get(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
if (enchantment == null) {
|
||||
enchantment = ALIASENCHANTMENTS.get(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
return enchantment;
|
||||
}
|
||||
|
||||
public static Set<Entry<String, Enchantment>> entrySet() {
|
||||
return ENCHANTMENTS.entrySet();
|
||||
}
|
||||
|
||||
public static Set<String> keySet() {
|
||||
return ENCHANTMENTS.keySet();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,10 +1,9 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.utils.LocationUtil;
|
||||
import java.util.Locale;
|
||||
import com.earth2me.essentials.utils.MaterialUtil;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -14,58 +13,50 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class EssentialsBlockListener implements Listener
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
public class EssentialsBlockListener implements Listener {
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public EssentialsBlockListener(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
public EssentialsBlockListener(final IEssentials ess) {
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockPlace(final BlockPlaceEvent event)
|
||||
{
|
||||
// Do not rely on getItemInHand();
|
||||
// http://leaky.bukkit.org/issues/663
|
||||
final ItemStack is = LocationUtil.convertBlockToItem(event.getBlockPlaced());
|
||||
if (is == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockPlace(final BlockPlaceEvent event) {
|
||||
// Do not rely on getItemInHand();
|
||||
// http://leaky.bukkit.org/issues/663
|
||||
final ItemStack is = LocationUtil.convertBlockToItem(event.getBlockPlaced());
|
||||
|
||||
if (is.getType() == Material.MOB_SPAWNER && event.getItemInHand() != null && event.getPlayer() != null
|
||||
&& event.getItemInHand().getType() == Material.MOB_SPAWNER)
|
||||
{
|
||||
final BlockState blockState = event.getBlockPlaced().getState();
|
||||
if (blockState instanceof CreatureSpawner)
|
||||
{
|
||||
final CreatureSpawner spawner = (CreatureSpawner)blockState;
|
||||
final EntityType type = EntityType.fromId(event.getItemInHand().getData().getData());
|
||||
if (type != null && Mob.fromBukkitType(type) != null)
|
||||
{
|
||||
if (ess.getUser(event.getPlayer()).isAuthorized("essentials.spawnerconvert." + Mob.fromBukkitType(type).name().toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
spawner.setSpawnedType(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.hasUnlimited(is) && user.getGameMode() == GameMode.SURVIVAL)
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
user.getBase().getInventory().addItem(is);
|
||||
user.getBase().updateInventory();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (is.getType() == MaterialUtil.SPAWNER && event.getItemInHand() != null && event.getPlayer() != null && event.getItemInHand().getType() == MaterialUtil.SPAWNER) {
|
||||
final BlockState blockState = event.getBlockPlaced().getState();
|
||||
if (blockState instanceof CreatureSpawner) {
|
||||
final CreatureSpawner spawner = (CreatureSpawner) blockState;
|
||||
final EntityType type = ess.getSpawnerItemProvider().getEntityType(event.getItemInHand());
|
||||
if (type != null && Mob.fromBukkitType(type) != null) {
|
||||
if (ess.getUser(event.getPlayer()).isAuthorized("essentials.spawnerconvert." + Mob.fromBukkitType(type).name().toLowerCase(Locale.ENGLISH))) {
|
||||
spawner.setSpawnedType(type);
|
||||
spawner.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.hasUnlimited(is) && user.getBase().getGameMode() == GameMode.SURVIVAL) {
|
||||
class UnlimitedItemSpawnTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
user.getBase().getInventory().addItem(is);
|
||||
user.getBase().updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
ess.scheduleSyncDelayedTask(new UnlimitedItemSpawnTask());
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,225 +1,300 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.entity.PotionSplashEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class EssentialsEntityListener implements Listener
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Essentials");
|
||||
private static final transient Pattern powertoolPlayer = Pattern.compile("\\{player\\}");
|
||||
private final IEssentials ess;
|
||||
public class EssentialsEntityListener implements Listener {
|
||||
private static final Logger LOGGER = Logger.getLogger("Essentials");
|
||||
private static final transient Pattern powertoolPlayer = Pattern.compile("\\{player\\}");
|
||||
private final IEssentials ess;
|
||||
|
||||
public EssentialsEntityListener(IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
public EssentialsEntityListener(final IEssentials ess) {
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
// This method does something undocumented reguarding certain bucket types #EasterEgg
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onEntityDamage(final EntityDamageByEntityEvent event)
|
||||
{
|
||||
final Entity eAttack = event.getDamager();
|
||||
final Entity eDefend = event.getEntity();
|
||||
if (eAttack instanceof Player)
|
||||
{
|
||||
final User attacker = ess.getUser((Player)eAttack);
|
||||
if (eDefend instanceof Player)
|
||||
{
|
||||
onPlayerVsPlayerDamage(event, (Player)eDefend, attacker);
|
||||
}
|
||||
else if (eDefend instanceof Ageable)
|
||||
{
|
||||
final ItemStack hand = attacker.getItemInHand();
|
||||
if (hand != null && hand.getType() == Material.MILK_BUCKET)
|
||||
{
|
||||
((Ageable)eDefend).setBaby();
|
||||
hand.setType(Material.BUCKET);
|
||||
attacker.setItemInHand(hand);
|
||||
attacker.updateInventory();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
attacker.updateActivity(true);
|
||||
}
|
||||
else if (eAttack instanceof Projectile && eDefend instanceof Player)
|
||||
{
|
||||
final Projectile projectile = (Projectile)event.getDamager();
|
||||
//This should return a ProjectileSource on 1.7.3 beta +
|
||||
final Object shooter = projectile.getShooter();
|
||||
if (shooter instanceof Player)
|
||||
{
|
||||
final User attacker = ess.getUser((Player)shooter);
|
||||
onPlayerVsPlayerDamage(event, (Player)eDefend, attacker);
|
||||
attacker.updateActivity(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
// This method does something undocumented reguarding certain bucket types #EasterEgg
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onEntityDamage(final EntityDamageByEntityEvent event) {
|
||||
final Entity eAttack = event.getDamager();
|
||||
final Entity eDefend = event.getEntity();
|
||||
if (eAttack instanceof Player) {
|
||||
final User attacker = ess.getUser((Player) eAttack);
|
||||
if (eDefend instanceof Player) {
|
||||
onPlayerVsPlayerDamage(event, (Player) eDefend, attacker);
|
||||
} else if (eDefend instanceof Ageable) {
|
||||
final ItemStack hand = attacker.getBase().getItemInHand();
|
||||
if (ess.getSettings().isMilkBucketEasterEggEnabled()
|
||||
&& hand != null && hand.getType() == Material.MILK_BUCKET) {
|
||||
((Ageable) eDefend).setBaby();
|
||||
hand.setType(Material.BUCKET);
|
||||
attacker.getBase().setItemInHand(hand);
|
||||
attacker.getBase().updateInventory();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
attacker.updateActivityOnInteract(true);
|
||||
} else if (eAttack instanceof Projectile && eDefend instanceof Player) {
|
||||
final Projectile projectile = (Projectile) event.getDamager();
|
||||
//This should return a ProjectileSource on 1.7.3 beta +
|
||||
final Object shooter = projectile.getShooter();
|
||||
if (shooter instanceof Player) {
|
||||
final User attacker = ess.getUser((Player) shooter);
|
||||
onPlayerVsPlayerDamage(event, (Player) eDefend, attacker);
|
||||
attacker.updateActivityOnInteract(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onPlayerVsPlayerDamage(final EntityDamageByEntityEvent event, final Player defender, final User attacker)
|
||||
{
|
||||
if (ess.getSettings().getLoginAttackDelay() > 0
|
||||
&& (System.currentTimeMillis() < (attacker.getLastLogin() + ess.getSettings().getLoginAttackDelay()))
|
||||
&& !attacker.isAuthorized("essentials.pvpdelay.exempt"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
private void onPlayerVsPlayerDamage(final EntityDamageByEntityEvent event, final Player defender, final User attacker) {
|
||||
if (ess.getSettings().getLoginAttackDelay() > 0 && (System.currentTimeMillis() < (attacker.getLastLogin() + ess.getSettings().getLoginAttackDelay())) && !attacker.isAuthorized("essentials.pvpdelay.exempt")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (!defender.equals(attacker.getBase()) && (attacker.hasInvulnerabilityAfterTeleport() || ess.getUser(defender).hasInvulnerabilityAfterTeleport()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (!defender.equals(attacker.getBase()) && (attacker.hasInvulnerabilityAfterTeleport() || ess.getUser(defender).hasInvulnerabilityAfterTeleport())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (attacker.isGodModeEnabled() && !attacker.isAuthorized("essentials.god.pvp"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (attacker.isGodModeEnabled() && !attacker.isAuthorized("essentials.god.pvp")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (attacker.isHidden() && !attacker.isAuthorized("essentials.vanish.pvp"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (attacker.isHidden() && !attacker.isAuthorized("essentials.vanish.pvp")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
onPlayerVsPlayerPowertool(event, defender, attacker);
|
||||
}
|
||||
if (attacker.arePowerToolsEnabled()) {
|
||||
onPlayerVsPlayerPowertool(event, defender, attacker);
|
||||
}
|
||||
}
|
||||
|
||||
private void onPlayerVsPlayerPowertool(final EntityDamageByEntityEvent event, final Player defender, final User attacker)
|
||||
{
|
||||
final List<String> commandList = attacker.getPowertool(attacker.getItemInHand());
|
||||
if (commandList != null && !commandList.isEmpty())
|
||||
{
|
||||
for (final String tempCommand : commandList)
|
||||
{
|
||||
final String command = powertoolPlayer.matcher(tempCommand).replaceAll(defender.getName());
|
||||
if (command != null && !command.isEmpty() && !command.equals(tempCommand))
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
attacker.getServer().dispatchCommand(attacker.getBase(), command);
|
||||
LOGGER.log(Level.INFO, String.format("[PT] %s issued server command: /%s", attacker.getName(), command));
|
||||
}
|
||||
});
|
||||
private void onPlayerVsPlayerPowertool(final EntityDamageByEntityEvent event, final Player defender, final User attacker) {
|
||||
final List<String> commandList = attacker.getPowertool(attacker.getBase().getItemInHand());
|
||||
if (commandList != null && !commandList.isEmpty()) {
|
||||
for (final String tempCommand : commandList) {
|
||||
final String command = powertoolPlayer.matcher(tempCommand).replaceAll(defender.getName());
|
||||
if (command != null && !command.isEmpty() && !command.equals(tempCommand)) {
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
class PowerToolInteractTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
attacker.getBase().chat("/" + command);
|
||||
LOGGER.log(Level.INFO, String.format("[PT] %s issued server command: /%s", attacker.getName(), command));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityDamage(final EntityDamageEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player && ess.getUser((Player)event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
final Player player = (Player)event.getEntity();
|
||||
player.setFireTicks(0);
|
||||
player.setRemainingAir(player.getMaximumAir());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
ess.scheduleSyncDelayedTask(new PowerToolInteractTask());
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityCombust(final EntityCombustEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player && ess.getUser((Player)event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerDeathEvent(final PlayerDeathEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getEntity());
|
||||
if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back"))
|
||||
{
|
||||
user.setLastLocation();
|
||||
user.sendMessage(_("backAfterDeath"));
|
||||
}
|
||||
if (!ess.getSettings().areDeathMessagesEnabled())
|
||||
{
|
||||
event.setDeathMessage("");
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityDamage(final EntityDamageEvent event) {
|
||||
if (event.getEntity() instanceof Player && ess.getUser((Player) event.getEntity()).isGodModeEnabled()) {
|
||||
final Player player = (Player) event.getEntity();
|
||||
player.setFireTicks(0);
|
||||
player.setRemainingAir(player.getMaximumAir());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerDeathExpEvent(final PlayerDeathEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getEntity());
|
||||
if (user.isAuthorized("essentials.keepxp"))
|
||||
{
|
||||
event.setKeepLevel(true);
|
||||
event.setDroppedExp(0);
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityCombust(final EntityCombustEvent event) {
|
||||
if (event.getEntity() instanceof Player && ess.getUser((Player) event.getEntity()).isGodModeEnabled()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onFoodLevelChange(final FoodLevelChangeEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player)
|
||||
{
|
||||
final User user = ess.getUser((Player)event.getEntity());
|
||||
if (user.isGodModeEnabled())
|
||||
{
|
||||
if (user.isGodModeEnabledRaw())
|
||||
{
|
||||
user.setFoodLevel(20);
|
||||
user.setSaturation(10);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onEntityCombustByEntity(final EntityCombustByEntityEvent event) {
|
||||
if (event.getCombuster() instanceof Arrow && event.getEntity() instanceof Player) {
|
||||
final Arrow combuster = (Arrow) event.getCombuster();
|
||||
if (combuster.getShooter() instanceof Player) {
|
||||
final Player shooter = (Player) combuster.getShooter();
|
||||
if (shooter.hasMetadata("NPC")) {
|
||||
return;
|
||||
}
|
||||
final User srcCombuster = ess.getUser(shooter.getUniqueId());
|
||||
if (srcCombuster.isGodModeEnabled() && !srcCombuster.isAuthorized("essentials.god.pvp")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (srcCombuster.isHidden() && !srcCombuster.isAuthorized("essentials.vanish.pvp")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityRegainHealth(final EntityRegainHealthEvent event)
|
||||
{
|
||||
if (event.getRegainReason() == RegainReason.SATIATED && event.getEntity() instanceof Player
|
||||
&& ess.getUser((Player)event.getEntity()).isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerDeathEvent(final PlayerDeathEvent event) {
|
||||
final Entity entity = event.getEntity();
|
||||
if (entity.hasMetadata("NPC")) {
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser(event.getEntity());
|
||||
if (ess.getSettings().infoAfterDeath()) {
|
||||
final Location loc = user.getLocation();
|
||||
user.sendMessage(tl("infoAfterDeath", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
}
|
||||
if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back")) {
|
||||
user.setLastLocation();
|
||||
user.sendMessage(tl("backAfterDeath"));
|
||||
}
|
||||
if (!ess.getSettings().areDeathMessagesEnabled()) {
|
||||
event.setDeathMessage("");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPotionSplashEvent(final PotionSplashEvent event)
|
||||
{
|
||||
for (LivingEntity entity : event.getAffectedEntities())
|
||||
{
|
||||
if (entity instanceof Player && ess.getUser((Player)entity).isGodModeEnabled())
|
||||
{
|
||||
event.setIntensity(entity, 0d);
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerDeathExpEvent(final PlayerDeathEvent event) {
|
||||
final User user = ess.getUser(event.getEntity());
|
||||
if (user.isAuthorized("essentials.keepxp")) {
|
||||
event.setKeepLevel(true);
|
||||
event.setDroppedExp(0);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityShootBow(EntityShootBowEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player)
|
||||
{
|
||||
final User user = ess.getUser((Player)event.getEntity());
|
||||
if (user.isAfk())
|
||||
{
|
||||
user.updateActivity(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerDeathInvEvent(final PlayerDeathEvent event) {
|
||||
final User user = ess.getUser(event.getEntity());
|
||||
if (user.isAuthorized("essentials.keepinv")) {
|
||||
event.setKeepInventory(true);
|
||||
event.getDrops().clear();
|
||||
final ISettings.KeepInvPolicy vanish = ess.getSettings().getVanishingItemsPolicy();
|
||||
final ISettings.KeepInvPolicy bind = ess.getSettings().getBindingItemsPolicy();
|
||||
if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_11_2_R01) && (vanish != ISettings.KeepInvPolicy.KEEP || bind != ISettings.KeepInvPolicy.KEEP)) {
|
||||
for (final ItemStack stack : event.getEntity().getInventory()) {
|
||||
if (stack != null) {
|
||||
if (stack.getEnchantments().containsKey(Enchantment.VANISHING_CURSE)) {
|
||||
if (vanish == ISettings.KeepInvPolicy.DELETE) {
|
||||
event.getEntity().getInventory().remove(stack);
|
||||
} else if (vanish == ISettings.KeepInvPolicy.DROP) {
|
||||
event.getDrops().add(stack);
|
||||
event.getEntity().getInventory().remove(stack);
|
||||
}
|
||||
}
|
||||
if (stack.getEnchantments().containsKey(Enchantment.BINDING_CURSE)) {
|
||||
if (bind == ISettings.KeepInvPolicy.DELETE) {
|
||||
event.getEntity().getInventory().remove(stack);
|
||||
} else if (bind == ISettings.KeepInvPolicy.DROP) {
|
||||
event.getEntity().getInventory().remove(stack);
|
||||
event.getDrops().add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final ItemStack[] armor = event.getEntity().getInventory().getArmorContents();
|
||||
for (int i = 0; i < armor.length; i++) {
|
||||
final ItemStack stack = armor[i];
|
||||
if (stack != null) {
|
||||
if (stack.getEnchantments().containsKey(Enchantment.VANISHING_CURSE)) {
|
||||
if (vanish == ISettings.KeepInvPolicy.DELETE) {
|
||||
armor[i] = null;
|
||||
} else if (vanish == ISettings.KeepInvPolicy.DROP) {
|
||||
if (!event.getDrops().contains(stack)) {
|
||||
event.getDrops().add(stack);
|
||||
}
|
||||
armor[i] = null;
|
||||
}
|
||||
}
|
||||
if (stack.getEnchantments().containsKey(Enchantment.BINDING_CURSE)) {
|
||||
if (bind == ISettings.KeepInvPolicy.DELETE) {
|
||||
armor[i] = null;
|
||||
} else if (bind == ISettings.KeepInvPolicy.DROP) {
|
||||
if (!event.getDrops().contains(stack)) {
|
||||
event.getDrops().add(stack);
|
||||
}
|
||||
armor[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
event.getEntity().getInventory().setArmorContents(armor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onFoodLevelChange(final FoodLevelChangeEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
final User user = ess.getUser((Player) event.getEntity());
|
||||
if (user.isGodModeEnabled()) {
|
||||
if (user.isGodModeEnabledRaw()) {
|
||||
user.getBase().setFoodLevel(20);
|
||||
user.getBase().setSaturation(10);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityRegainHealth(final EntityRegainHealthEvent event) {
|
||||
if (event.getRegainReason() == RegainReason.SATIATED && event.getEntity() instanceof Player && ess.getUser((Player) event.getEntity()).isAfk() && ess.getSettings().getFreezeAfkPlayers()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPotionSplashEvent(final PotionSplashEvent event) {
|
||||
for (final LivingEntity entity : event.getAffectedEntities()) {
|
||||
if (entity instanceof Player && ess.getUser((Player) entity).isGodModeEnabled()) {
|
||||
event.setIntensity(entity, 0d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityShootBow(final EntityShootBowEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
final User user = ess.getUser((Player) event.getEntity());
|
||||
if (user.isAfk()) {
|
||||
user.updateActivityOnInteract(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityTarget(final EntityTargetEvent event) {
|
||||
if (event.getTarget() instanceof Player) {
|
||||
final User user = ess.getUser((Player) event.getTarget());
|
||||
if (user.isVanished()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,8 +1,6 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.perm.PermissionsHandler;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import java.util.logging.Level;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -10,56 +8,43 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class EssentialsPluginListener implements Listener, IConf
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
public class EssentialsPluginListener implements Listener, IConf {
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public EssentialsPluginListener(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
public EssentialsPluginListener(final IEssentials ess) {
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(final PluginEnableEvent event)
|
||||
{
|
||||
if (event.getPlugin().getName().equals("EssentialsChat"))
|
||||
{
|
||||
ess.getSettings().setEssentialsChatActive(true);
|
||||
}
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
ess.getAlternativeCommandsHandler().addPlugin(event.getPlugin());
|
||||
if (!Methods.hasMethod() && Methods.setMethod(ess.getServer().getPluginManager()))
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "Payment method found (" + Methods.getMethod().getLongName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(final PluginEnableEvent event) {
|
||||
if (event.getPlugin().getName().equals("EssentialsChat")) {
|
||||
ess.getSettings().setEssentialsChatActive(true);
|
||||
}
|
||||
ess.getPermissionsHandler().setUseSuperperms(ess.getSettings().useBukkitPermissions());
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
ess.getAlternativeCommandsHandler().addPlugin(event.getPlugin());
|
||||
if (!Methods.hasMethod() && Methods.setMethod(ess.getServer().getPluginManager())) {
|
||||
ess.getLogger().log(Level.INFO, "Payment method found (" + Methods.getMethod().getLongName() + " version: " + Methods.getMethod().getVersion() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(final PluginDisableEvent event)
|
||||
{
|
||||
if (event.getPlugin().getName().equals("EssentialsChat"))
|
||||
{
|
||||
ess.getSettings().setEssentialsChatActive(false);
|
||||
}
|
||||
PermissionsHandler permHandler = ess.getPermissionsHandler();
|
||||
if (permHandler != null)
|
||||
{
|
||||
permHandler.checkPermissions();
|
||||
}
|
||||
ess.getAlternativeCommandsHandler().removePlugin(event.getPlugin());
|
||||
// Check to see if the plugin thats being disabled is the one we are using
|
||||
if (ess.getPaymentMethod() != null && Methods.hasMethod() && Methods.checkDisabled(event.getPlugin()))
|
||||
{
|
||||
ess.getPaymentMethod().reset();
|
||||
ess.getLogger().log(Level.INFO, "Payment method was disabled. No longer accepting payments.");
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(final PluginDisableEvent event) {
|
||||
if (event.getPlugin().getName().equals("EssentialsChat")) {
|
||||
ess.getSettings().setEssentialsChatActive(false);
|
||||
}
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
ess.getAlternativeCommandsHandler().removePlugin(event.getPlugin());
|
||||
// Check to see if the plugin thats being disabled is the one we are using
|
||||
if (Methods.hasMethod() && Methods.checkDisabled(event.getPlugin())) {
|
||||
Methods.reset();
|
||||
ess.getLogger().log(Level.INFO, "Payment method was disabled. No longer accepting payments.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
ess.getPermissionsHandler().setUseSuperperms(ess.getSettings().useBukkitPermissions());
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
}
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.nms.refl.ReflUtil;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class EssentialsServerListener implements Listener {
|
||||
private static final List<String> ignoredSLPECallers = Arrays.asList(
|
||||
".LegacyPingHandler.channelRead(", // CB responding to pings from pre-Netty clients
|
||||
"de.dytanic.cloudnet.bridge.BukkitBootstrap", // CloudNet v2 doing... something
|
||||
"de.dytanic.cloudnet.ext.bridge.bukkit.BukkitCloudNetBridgePlugin" // CloudNet v3 doing... something else
|
||||
);
|
||||
|
||||
private final transient IEssentials ess;
|
||||
private final boolean isPaperSample;
|
||||
private boolean unsupportedLogged = false;
|
||||
private boolean npeWarned = false;
|
||||
private Method setSampleText;
|
||||
private Method getSampleText;
|
||||
|
||||
public EssentialsServerListener(final IEssentials ess) {
|
||||
this.ess = ess;
|
||||
|
||||
if (ReflUtil.getClassCached("com.destroystokyo.paper.event.server.PaperServerListPingEvent") == null) {
|
||||
// This workaround is only necessary for older Paper builds
|
||||
setSampleText = ReflUtil.getMethodCached(ServerListPingEvent.class, "setSampleText", List.class);
|
||||
getSampleText = ReflUtil.getMethodCached(ServerListPingEvent.class, "getSampleText");
|
||||
if (setSampleText != null && getSampleText != null) {
|
||||
ess.getLogger().info("ServerListPingEvent: Paper 1.12.2 setSampleText API");
|
||||
isPaperSample = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ess.getLogger().info("ServerListPingEvent: Spigot iterator API");
|
||||
isPaperSample = false;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onServerListPing(final ServerListPingEvent event) throws Exception {
|
||||
if (isPaperSample) {
|
||||
try {
|
||||
final List<String> playerNames = (List<String>) getSampleText.invoke(event, null);
|
||||
playerNames.removeIf(player -> ess.getUser(player).isVanished());
|
||||
setSampleText.invoke(event, playerNames);
|
||||
} catch (final IllegalAccessException | InvocationTargetException | ClassCastException e) {
|
||||
if (!unsupportedLogged && shouldWarnSLPECaller(e)) {
|
||||
ess.getLogger().log(Level.WARNING, "Unable to hide players from server list ping "
|
||||
+ "using Paper 1.12 method!", e);
|
||||
unsupportedLogged = true;
|
||||
}
|
||||
} catch (final NullPointerException e) {
|
||||
if (!npeWarned && shouldWarnSLPECaller(e)) {
|
||||
npeWarned = true;
|
||||
final Exception ex = new Exception("A plugin has fired a ServerListPingEvent "
|
||||
+ "without implementing Paper's methods. Point the author to https://git.io/v7Xzl.");
|
||||
ex.setStackTrace(e.getStackTrace());
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
final Iterator<Player> iterator = event.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final Player player = iterator.next();
|
||||
if (ess.getUser(player).isVanished()) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
} catch (final UnsupportedOperationException e) {
|
||||
if (!unsupportedLogged && shouldWarnSLPECaller(e)) {
|
||||
ess.getLogger().log(Level.WARNING, "Could not hide vanished players while handling " + event.getClass().getName(), e);
|
||||
unsupportedLogged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Should we warn about this SLPE caller, or should we silently ignore it?
|
||||
* This checks against the ignoredSLPECallers strings, and if it matches one of those, we
|
||||
* return false.
|
||||
*
|
||||
* @param throwable A throwable caught by a catch block
|
||||
* @return Whether or not to send a warning about this particular caller
|
||||
*/
|
||||
private boolean shouldWarnSLPECaller(final Throwable throwable) {
|
||||
final int maxStackDepth = 20; // Limit the depth when searching through the stack trace
|
||||
int depth = 0;
|
||||
for (final StackTraceElement element : throwable.getStackTrace()) {
|
||||
depth++;
|
||||
if (depth > maxStackDepth) {
|
||||
break;
|
||||
}
|
||||
|
||||
for (final String ignoredString : ignoredSLPECallers) {
|
||||
if (element.toString().contains(ignoredString)) {
|
||||
return false; // We know about this error and should ignore it, so don't warn
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true; // We don't know for certain that we can ignore this, so warn just to be safe
|
||||
}
|
||||
}
|
||||
@@ -1,124 +1,111 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class EssentialsTimer implements Runnable {
|
||||
private final transient IEssentials ess;
|
||||
private final transient Set<UUID> onlineUsers = new HashSet<>(); // Field is necessary for hidden users
|
||||
private final LinkedList<Double> history = new LinkedList<>();
|
||||
@SuppressWarnings("FieldCanBeLocal")
|
||||
private final long maxTime = 10 * 1000000;
|
||||
@SuppressWarnings("FieldCanBeLocal")
|
||||
private final long tickInterval = 50;
|
||||
private transient long lastPoll = System.nanoTime();
|
||||
private int skip1 = 0;
|
||||
private int skip2 = 0;
|
||||
|
||||
public class EssentialsTimer implements Runnable
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
private final transient Set<String> onlineUsers = new HashSet<String>();
|
||||
private transient long lastPoll = System.nanoTime();
|
||||
private final LinkedList<Double> history = new LinkedList<Double>();
|
||||
private int skip1 = 0;
|
||||
private int skip2 = 0;
|
||||
private final long maxTime = 10 * 1000000;
|
||||
private final long tickInterval = 50;
|
||||
|
||||
EssentialsTimer(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
history.add(20d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final long startTime = System.nanoTime();
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
long timeSpent = (startTime - lastPoll) / 1000;
|
||||
if (timeSpent == 0)
|
||||
{
|
||||
timeSpent = 1;
|
||||
}
|
||||
if (history.size() > 10)
|
||||
{
|
||||
history.remove();
|
||||
}
|
||||
double tps = tickInterval * 1000000.0 / timeSpent;
|
||||
if (tps <= 21)
|
||||
{
|
||||
history.add(tps);
|
||||
}
|
||||
lastPoll = startTime;
|
||||
int count = 0;
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
count++;
|
||||
if (skip1 > 0)
|
||||
{
|
||||
skip1--;
|
||||
continue;
|
||||
}
|
||||
if (count % 10 == 0)
|
||||
{
|
||||
if (System.nanoTime() - startTime > maxTime / 2)
|
||||
{
|
||||
skip1 = count - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
onlineUsers.add(user.getName());
|
||||
user.setLastOnlineActivity(currentTime);
|
||||
user.checkActivity();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ess.getLogger().log(Level.WARNING, "EssentialsTimer Error:", e);
|
||||
}
|
||||
}
|
||||
|
||||
count = 0;
|
||||
final Iterator<String> iterator = onlineUsers.iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
count++;
|
||||
if (skip2 > 0)
|
||||
{
|
||||
skip2--;
|
||||
continue;
|
||||
}
|
||||
if (count % 10 == 0)
|
||||
{
|
||||
if (System.nanoTime() - startTime > maxTime)
|
||||
{
|
||||
skip2 = count - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
final User user = ess.getUser(iterator.next());
|
||||
if (user.getLastOnlineActivity() < currentTime && user.getLastOnlineActivity() > user.getLastLogout())
|
||||
{
|
||||
if (!user.isHidden()) {
|
||||
user.setLastLogout(user.getLastOnlineActivity());
|
||||
}
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
user.checkMuteTimeout(currentTime);
|
||||
user.checkJailTimeout(currentTime);
|
||||
user.resetInvulnerabilityAfterTeleport();
|
||||
}
|
||||
}
|
||||
|
||||
public double getAverageTPS()
|
||||
{
|
||||
double avg = 0;
|
||||
for (Double f : history)
|
||||
{
|
||||
if (f != null)
|
||||
{
|
||||
avg += f;
|
||||
}
|
||||
}
|
||||
return avg / history.size();
|
||||
}
|
||||
EssentialsTimer(final IEssentials ess) {
|
||||
this.ess = ess;
|
||||
history.add(20d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final long startTime = System.nanoTime();
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
long timeSpent = (startTime - lastPoll) / 1000;
|
||||
if (timeSpent == 0) {
|
||||
timeSpent = 1;
|
||||
}
|
||||
if (history.size() > 10) {
|
||||
history.remove();
|
||||
}
|
||||
final double tps = tickInterval * 1000000.0 / timeSpent;
|
||||
if (tps <= 21) {
|
||||
history.add(tps);
|
||||
}
|
||||
lastPoll = startTime;
|
||||
int count = 0;
|
||||
for (final Player player : ess.getOnlinePlayers()) {
|
||||
count++;
|
||||
if (skip1 > 0) {
|
||||
skip1--;
|
||||
continue;
|
||||
}
|
||||
if (count % 10 == 0) {
|
||||
if (System.nanoTime() - startTime > maxTime / 2) {
|
||||
skip1 = count - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
final User user = ess.getUser(player);
|
||||
onlineUsers.add(user.getBase().getUniqueId());
|
||||
user.setLastOnlineActivity(currentTime);
|
||||
user.checkActivity();
|
||||
} catch (final Exception e) {
|
||||
ess.getLogger().log(Level.WARNING, "EssentialsTimer Error:", e);
|
||||
}
|
||||
}
|
||||
|
||||
count = 0;
|
||||
final Iterator<UUID> iterator = onlineUsers.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
count++;
|
||||
if (skip2 > 0) {
|
||||
skip2--;
|
||||
continue;
|
||||
}
|
||||
if (count % 10 == 0) {
|
||||
if (System.nanoTime() - startTime > maxTime) {
|
||||
skip2 = count - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
final User user = ess.getUser(iterator.next());
|
||||
// Not sure why this would happen, but it does
|
||||
if (user == null) {
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
if (user.getLastOnlineActivity() < currentTime && user.getLastOnlineActivity() > user.getLastLogout()) {
|
||||
if (!user.isHidden()) {
|
||||
user.setLastLogout(user.getLastOnlineActivity());
|
||||
}
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
user.checkMuteTimeout(currentTime);
|
||||
user.checkJailTimeout(currentTime);
|
||||
user.resetInvulnerabilityAfterTeleport();
|
||||
}
|
||||
}
|
||||
|
||||
public double getAverageTPS() {
|
||||
double avg = 0;
|
||||
for (final Double f : history) {
|
||||
if (f != null) {
|
||||
avg += f;
|
||||
}
|
||||
}
|
||||
return avg / history.size();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,62 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.Files;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class EssentialsUserConf extends EssentialsConf {
|
||||
public final String username;
|
||||
public final UUID uuid;
|
||||
|
||||
public EssentialsUserConf(final String username, final UUID uuid, final File configFile) {
|
||||
super(configFile);
|
||||
this.username = username;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean legacyFileExists() {
|
||||
final File file = new File(configFile.getParentFile(), username + ".yml");
|
||||
return file.exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convertLegacyFile() {
|
||||
final File file = new File(configFile.getParentFile(), username + ".yml");
|
||||
try {
|
||||
Files.move(file, new File(configFile.getParentFile(), uuid + ".yml"));
|
||||
} catch (final IOException ex) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed to migrate user: " + username, ex);
|
||||
}
|
||||
|
||||
setProperty("lastAccountName", username);
|
||||
}
|
||||
|
||||
private File getAltFile() {
|
||||
final UUID fn = UUID.nameUUIDFromBytes(("OfflinePlayer:" + username.toLowerCase(Locale.ENGLISH)).getBytes(Charsets.UTF_8));
|
||||
return new File(configFile.getParentFile(), fn.toString() + ".yml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean altFileExists() {
|
||||
if (username.equals(username.toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
return getAltFile().exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convertAltFile() {
|
||||
try {
|
||||
Files.move(getAltFile(), new File(configFile.getParentFile(), uuid + ".yml"));
|
||||
} catch (final IOException ex) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed to migrate user: " + username, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,84 +6,67 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ExecuteTimer {
|
||||
private final transient List<ExecuteRecord> times;
|
||||
private final transient DecimalFormat decimalFormat = new DecimalFormat("#0.000", DecimalFormatSymbols.getInstance(Locale.US));
|
||||
|
||||
public class ExecuteTimer
|
||||
{
|
||||
private final transient List<ExecuteRecord> times;
|
||||
private final transient DecimalFormat decimalFormat = new DecimalFormat("#0.000", DecimalFormatSymbols.getInstance(Locale.US));
|
||||
public ExecuteTimer() {
|
||||
times = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void start() {
|
||||
times.clear();
|
||||
mark("start");
|
||||
|
||||
public ExecuteTimer()
|
||||
{
|
||||
times = new ArrayList<ExecuteRecord>();
|
||||
}
|
||||
}
|
||||
|
||||
public void start()
|
||||
{
|
||||
times.clear();
|
||||
mark("start");
|
||||
public void mark(final String label) {
|
||||
if (!times.isEmpty() || "start".equals(label)) {
|
||||
times.add(new ExecuteRecord(label, System.nanoTime()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public String end() {
|
||||
final StringBuilder output = new StringBuilder();
|
||||
output.append("execution time: ");
|
||||
String mark;
|
||||
long time0 = 0;
|
||||
long time1 = 0;
|
||||
long time2 = 0;
|
||||
double duration;
|
||||
|
||||
public void mark(final String label)
|
||||
{
|
||||
if (!times.isEmpty() || "start".equals(label))
|
||||
{
|
||||
times.add(new ExecuteRecord(label, System.nanoTime()));
|
||||
}
|
||||
}
|
||||
for (final ExecuteRecord pair : times) {
|
||||
mark = pair.getMark();
|
||||
time2 = pair.getTime();
|
||||
if (time1 > 0) {
|
||||
duration = (time2 - time1) / 1000000.0;
|
||||
output.append(mark).append(": ").append(decimalFormat.format(duration)).append("ms - ");
|
||||
} else {
|
||||
time0 = time2;
|
||||
}
|
||||
time1 = time2;
|
||||
}
|
||||
duration = (time1 - time0) / 1000000.0;
|
||||
output.append("Total: ").append(decimalFormat.format(duration)).append("ms");
|
||||
times.clear();
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
public String end()
|
||||
{
|
||||
final StringBuilder output = new StringBuilder();
|
||||
output.append("execution time: ");
|
||||
String mark;
|
||||
long time0 = 0;
|
||||
long time1 = 0;
|
||||
long time2 = 0;
|
||||
double duration;
|
||||
private static class ExecuteRecord {
|
||||
private final String mark;
|
||||
private final long time;
|
||||
|
||||
for (ExecuteRecord pair : times)
|
||||
{
|
||||
mark = (String)pair.getMark();
|
||||
time2 = (Long)pair.getTime();
|
||||
if (time1 > 0)
|
||||
{
|
||||
duration = (time2 - time1)/1000000.0;
|
||||
output.append(mark).append(": ").append(decimalFormat.format(duration)).append("ms - ");
|
||||
}
|
||||
else
|
||||
{
|
||||
time0 = time2;
|
||||
}
|
||||
time1 = time2;
|
||||
}
|
||||
duration = (time1 - time0)/1000000.0;
|
||||
output.append("Total: ").append(decimalFormat.format(duration)).append("ms");
|
||||
times.clear();
|
||||
return output.toString();
|
||||
}
|
||||
ExecuteRecord(final String mark, final long time) {
|
||||
this.mark = mark;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getMark() {
|
||||
return mark;
|
||||
}
|
||||
|
||||
private static class ExecuteRecord
|
||||
{
|
||||
private final String mark;
|
||||
private final long time;
|
||||
|
||||
public ExecuteRecord(final String mark, final long time)
|
||||
{
|
||||
this.mark = mark;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getMark()
|
||||
{
|
||||
return mark;
|
||||
}
|
||||
|
||||
public long getTime()
|
||||
{
|
||||
return time;
|
||||
}
|
||||
}
|
||||
}
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,189 +1,210 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import net.ess3.api.IEssentials;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.PropertyResourceBundle;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
import net.ess3.api.IEssentials;
|
||||
|
||||
public class I18n implements net.ess3.api.II18n {
|
||||
private static final String MESSAGES = "messages";
|
||||
private static final Pattern NODOUBLEMARK = Pattern.compile("''");
|
||||
private static final ResourceBundle NULL_BUNDLE = new ResourceBundle() {
|
||||
public Enumeration<String> getKeys() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public class I18n implements net.ess3.api.II18n
|
||||
{
|
||||
private static I18n instance;
|
||||
private static final String MESSAGES = "messages";
|
||||
private final transient Locale defaultLocale = Locale.getDefault();
|
||||
private transient Locale currentLocale = defaultLocale;
|
||||
private transient ResourceBundle customBundle;
|
||||
private transient ResourceBundle localeBundle;
|
||||
private final transient ResourceBundle defaultBundle;
|
||||
private final transient Map<String, MessageFormat> messageFormatCache = new HashMap<String, MessageFormat>();
|
||||
private final transient IEssentials ess;
|
||||
private static final Pattern NODOUBLEMARK = Pattern.compile("''");
|
||||
protected Object handleGetObject(final String key) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
private static I18n instance;
|
||||
private final transient Locale defaultLocale = Locale.getDefault();
|
||||
private final transient ResourceBundle defaultBundle;
|
||||
private final transient IEssentials ess;
|
||||
private transient Locale currentLocale = defaultLocale;
|
||||
private transient ResourceBundle customBundle;
|
||||
private transient ResourceBundle localeBundle;
|
||||
private transient Map<String, MessageFormat> messageFormatCache = new HashMap<>();
|
||||
|
||||
public I18n(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
customBundle = ResourceBundle.getBundle(MESSAGES, defaultLocale, new FileResClassLoader(I18n.class.getClassLoader(), ess));
|
||||
localeBundle = ResourceBundle.getBundle(MESSAGES, defaultLocale);
|
||||
defaultBundle = ResourceBundle.getBundle(MESSAGES, Locale.ENGLISH);
|
||||
}
|
||||
public I18n(final IEssentials ess) {
|
||||
this.ess = ess;
|
||||
defaultBundle = ResourceBundle.getBundle(MESSAGES, Locale.ENGLISH, new UTF8PropertiesControl());
|
||||
localeBundle = defaultBundle;
|
||||
customBundle = NULL_BUNDLE;
|
||||
}
|
||||
|
||||
public void onEnable()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
public static String tl(final String string, final Object... objects) {
|
||||
if (instance == null) {
|
||||
return "";
|
||||
}
|
||||
if (objects.length == 0) {
|
||||
return NODOUBLEMARK.matcher(instance.translate(string)).replaceAll("'");
|
||||
} else {
|
||||
return instance.format(string, objects);
|
||||
}
|
||||
}
|
||||
|
||||
public void onDisable()
|
||||
{
|
||||
instance = null;
|
||||
}
|
||||
public static String capitalCase(final String input) {
|
||||
return input == null || input.length() == 0 ? input : input.toUpperCase(Locale.ENGLISH).charAt(0) + input.toLowerCase(Locale.ENGLISH).substring(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getCurrentLocale()
|
||||
{
|
||||
return currentLocale;
|
||||
}
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private String translate(final String string)
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
return customBundle.getString(string);
|
||||
}
|
||||
catch (MissingResourceException ex)
|
||||
{
|
||||
return localeBundle.getString(string);
|
||||
}
|
||||
}
|
||||
catch (MissingResourceException ex)
|
||||
{
|
||||
Logger.getLogger("Essentials").log(Level.WARNING, String.format("Missing translation key \"%s\" in translation file %s", ex.getKey(), localeBundle.getLocale().toString()), ex);
|
||||
return defaultBundle.getString(string);
|
||||
}
|
||||
}
|
||||
public void onDisable() {
|
||||
instance = null;
|
||||
}
|
||||
|
||||
public static String _(final String string, final Object... objects)
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
if (objects.length == 0)
|
||||
{
|
||||
return NODOUBLEMARK.matcher(instance.translate(string)).replaceAll("'");
|
||||
}
|
||||
else
|
||||
{
|
||||
return instance.format(string, objects);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Locale getCurrentLocale() {
|
||||
return currentLocale;
|
||||
}
|
||||
|
||||
public String format(final String string, final Object... objects)
|
||||
{
|
||||
String format = translate(string);
|
||||
MessageFormat messageFormat = messageFormatCache.get(format);
|
||||
if (messageFormat == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
messageFormat = new MessageFormat(format);
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
ess.getLogger().log(Level.SEVERE, "Invalid Translation key for '" + string + "': " + e.getMessage());
|
||||
format = format.replaceAll("\\{(\\D*?)\\}", "\\[$1\\]");
|
||||
messageFormat = new MessageFormat(format);
|
||||
}
|
||||
messageFormatCache.put(format, messageFormat);
|
||||
}
|
||||
return messageFormat.format(objects);
|
||||
}
|
||||
private String translate(final String string) {
|
||||
try {
|
||||
try {
|
||||
return customBundle.getString(string);
|
||||
} catch (final MissingResourceException ex) {
|
||||
return localeBundle.getString(string);
|
||||
}
|
||||
} catch (final MissingResourceException ex) {
|
||||
Logger.getLogger("Essentials").log(Level.WARNING, String.format("Missing translation key \"%s\" in translation file %s", ex.getKey(), localeBundle.getLocale().toString()), ex);
|
||||
return defaultBundle.getString(string);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateLocale(final String loc)
|
||||
{
|
||||
if (loc == null || loc.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final String[] parts = loc.split("[_\\.]");
|
||||
if (parts.length == 1)
|
||||
{
|
||||
currentLocale = new Locale(parts[0]);
|
||||
}
|
||||
if (parts.length == 2)
|
||||
{
|
||||
currentLocale = new Locale(parts[0], parts[1]);
|
||||
}
|
||||
if (parts.length == 3)
|
||||
{
|
||||
currentLocale = new Locale(parts[0], parts[1], parts[2]);
|
||||
}
|
||||
ResourceBundle.clearCache();
|
||||
Logger.getLogger("Essentials").log(Level.INFO, String.format("Using locale %s", currentLocale.toString()));
|
||||
customBundle = ResourceBundle.getBundle(MESSAGES, currentLocale, new FileResClassLoader(I18n.class.getClassLoader(), ess));
|
||||
localeBundle = ResourceBundle.getBundle(MESSAGES, currentLocale);
|
||||
}
|
||||
public String format(final String string, final Object... objects) {
|
||||
String format = translate(string);
|
||||
MessageFormat messageFormat = messageFormatCache.get(format);
|
||||
if (messageFormat == null) {
|
||||
try {
|
||||
messageFormat = new MessageFormat(format);
|
||||
} catch (final IllegalArgumentException e) {
|
||||
ess.getLogger().log(Level.SEVERE, "Invalid Translation key for '" + string + "': " + e.getMessage());
|
||||
format = format.replaceAll("\\{(\\D*?)\\}", "\\[$1\\]");
|
||||
messageFormat = new MessageFormat(format);
|
||||
}
|
||||
messageFormatCache.put(format, messageFormat);
|
||||
}
|
||||
return messageFormat.format(objects).replace(' ', ' '); // replace nbsp with a space
|
||||
}
|
||||
|
||||
public static String capitalCase(final String input)
|
||||
{
|
||||
return input == null || input.length() == 0
|
||||
? input
|
||||
: input.toUpperCase(Locale.ENGLISH).charAt(0)
|
||||
+ input.toLowerCase(Locale.ENGLISH).substring(1);
|
||||
}
|
||||
public void updateLocale(final String loc) {
|
||||
if (loc != null && !loc.isEmpty()) {
|
||||
final String[] parts = loc.split("[_\\.]");
|
||||
if (parts.length == 1) {
|
||||
currentLocale = new Locale(parts[0]);
|
||||
}
|
||||
if (parts.length == 2) {
|
||||
currentLocale = new Locale(parts[0], parts[1]);
|
||||
}
|
||||
if (parts.length == 3) {
|
||||
currentLocale = new Locale(parts[0], parts[1], parts[2]);
|
||||
}
|
||||
}
|
||||
ResourceBundle.clearCache();
|
||||
messageFormatCache = new HashMap<>();
|
||||
Logger.getLogger("Essentials").log(Level.INFO, String.format("Using locale %s", currentLocale.toString()));
|
||||
|
||||
try {
|
||||
localeBundle = ResourceBundle.getBundle(MESSAGES, currentLocale, new UTF8PropertiesControl());
|
||||
} catch (final MissingResourceException ex) {
|
||||
localeBundle = NULL_BUNDLE;
|
||||
}
|
||||
|
||||
private static class FileResClassLoader extends ClassLoader
|
||||
{
|
||||
private final transient File dataFolder;
|
||||
try {
|
||||
customBundle = ResourceBundle.getBundle(MESSAGES, currentLocale, new FileResClassLoader(I18n.class.getClassLoader(), ess), new UTF8PropertiesControl());
|
||||
} catch (final MissingResourceException ex) {
|
||||
customBundle = NULL_BUNDLE;
|
||||
}
|
||||
}
|
||||
|
||||
FileResClassLoader(final ClassLoader classLoader, final IEssentials ess)
|
||||
{
|
||||
super(classLoader);
|
||||
this.dataFolder = ess.getDataFolder();
|
||||
}
|
||||
/**
|
||||
* Attempts to load properties files from the plugin directory before falling back to the jar.
|
||||
*/
|
||||
private static class FileResClassLoader extends ClassLoader {
|
||||
private final transient File dataFolder;
|
||||
|
||||
@Override
|
||||
public URL getResource(final String string)
|
||||
{
|
||||
final File file = new File(dataFolder, string);
|
||||
if (file.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
return file.toURI().toURL();
|
||||
}
|
||||
catch (MalformedURLException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
return super.getResource(string);
|
||||
}
|
||||
FileResClassLoader(final ClassLoader classLoader, final IEssentials ess) {
|
||||
super(classLoader);
|
||||
this.dataFolder = ess.getDataFolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getResourceAsStream(final String string)
|
||||
{
|
||||
final File file = new File(dataFolder, string);
|
||||
if (file.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
return new FileInputStream(file);
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
return super.getResourceAsStream(string);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public URL getResource(final String string) {
|
||||
final File file = new File(dataFolder, string);
|
||||
if (file.exists()) {
|
||||
try {
|
||||
return file.toURI().toURL();
|
||||
} catch (final MalformedURLException ignored) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getResourceAsStream(final String string) {
|
||||
final File file = new File(dataFolder, string);
|
||||
if (file.exists()) {
|
||||
try {
|
||||
return new FileInputStream(file);
|
||||
} catch (final FileNotFoundException ignored) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads .properties files as UTF-8 instead of ISO-8859-1, which is the default on Java 8/below.
|
||||
* Java 9 fixes this by defaulting to UTF-8 for .properties files.
|
||||
*/
|
||||
private static class UTF8PropertiesControl extends ResourceBundle.Control {
|
||||
public ResourceBundle newBundle(final String baseName, final Locale locale, final String format, final ClassLoader loader, final boolean reload) throws IOException {
|
||||
final String resourceName = toResourceName(toBundleName(baseName, locale), "properties");
|
||||
ResourceBundle bundle = null;
|
||||
InputStream stream = null;
|
||||
if (reload) {
|
||||
final URL url = loader.getResource(resourceName);
|
||||
if (url != null) {
|
||||
final URLConnection connection = url.openConnection();
|
||||
if (connection != null) {
|
||||
connection.setUseCaches(false);
|
||||
stream = connection.getInputStream();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
stream = loader.getResourceAsStream(resourceName);
|
||||
}
|
||||
if (stream != null) {
|
||||
try {
|
||||
// use UTF-8 here, this is the important bit
|
||||
bundle = new PropertyResourceBundle(new InputStreamReader(stream, StandardCharsets.UTF_8));
|
||||
} finally {
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
return bundle;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
public interface IConf
|
||||
{
|
||||
public void reloadConfig();
|
||||
public interface IConf {
|
||||
void reloadConfig();
|
||||
}
|
||||
@@ -3,10 +3,12 @@ package com.earth2me.essentials;
|
||||
import com.earth2me.essentials.api.IItemDb;
|
||||
import com.earth2me.essentials.api.IJails;
|
||||
import com.earth2me.essentials.api.IWarps;
|
||||
import com.earth2me.essentials.metrics.Metrics;
|
||||
import com.earth2me.essentials.perm.PermissionsHandler;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import java.util.List;
|
||||
import net.ess3.provider.ContainerProvider;
|
||||
import net.ess3.provider.KnownCommandsProvider;
|
||||
import net.ess3.provider.ServerStateProvider;
|
||||
import net.ess3.provider.SpawnerBlockProvider;
|
||||
import net.ess3.provider.SpawnerItemProvider;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -15,75 +17,105 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public interface IEssentials extends Plugin
|
||||
{
|
||||
void addReloadListener(IConf listener);
|
||||
public interface IEssentials extends Plugin {
|
||||
void addReloadListener(IConf listener);
|
||||
|
||||
void reload();
|
||||
void reload();
|
||||
|
||||
boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix, IEssentialsModule module);
|
||||
List<String> onTabCompleteEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix, IEssentialsModule module);
|
||||
|
||||
@Deprecated
|
||||
User getUser(Object base);
|
||||
|
||||
User getUser(String base);
|
||||
|
||||
User getUser(Player base);
|
||||
boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix, IEssentialsModule module);
|
||||
|
||||
I18n getI18n();
|
||||
@Deprecated
|
||||
User getUser(Object base);
|
||||
|
||||
User getOfflineUser(String name);
|
||||
User getUser(UUID base);
|
||||
|
||||
World getWorld(String name);
|
||||
User getUser(String base);
|
||||
|
||||
int broadcastMessage(String message);
|
||||
User getUser(Player base);
|
||||
|
||||
int broadcastMessage(IUser sender, String message);
|
||||
I18n getI18n();
|
||||
|
||||
int broadcastMessage(String permission, String message);
|
||||
User getOfflineUser(String name);
|
||||
|
||||
ISettings getSettings();
|
||||
World getWorld(String name);
|
||||
|
||||
BukkitScheduler getScheduler();
|
||||
int broadcastMessage(String message);
|
||||
|
||||
IJails getJails();
|
||||
int broadcastMessage(IUser sender, String message);
|
||||
|
||||
IWarps getWarps();
|
||||
int broadcastMessage(IUser sender, String message, Predicate<IUser> shouldExclude);
|
||||
|
||||
Worth getWorth();
|
||||
int broadcastMessage(String permission, String message);
|
||||
|
||||
Backup getBackup();
|
||||
ISettings getSettings();
|
||||
|
||||
Methods getPaymentMethod();
|
||||
BukkitScheduler getScheduler();
|
||||
|
||||
BukkitTask runTaskAsynchronously(Runnable run);
|
||||
IJails getJails();
|
||||
|
||||
BukkitTask runTaskLaterAsynchronously(Runnable run, long delay);
|
||||
IWarps getWarps();
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run);
|
||||
Worth getWorth();
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run, long delay);
|
||||
Backup getBackup();
|
||||
|
||||
int scheduleSyncRepeatingTask(final Runnable run, long delay, long period);
|
||||
Kits getKits();
|
||||
|
||||
TNTExplodeListener getTNTListener();
|
||||
RandomTeleport getRandomTeleport();
|
||||
|
||||
PermissionsHandler getPermissionsHandler();
|
||||
BukkitTask runTaskAsynchronously(Runnable run);
|
||||
|
||||
AlternativeCommandsHandler getAlternativeCommandsHandler();
|
||||
BukkitTask runTaskLaterAsynchronously(Runnable run, long delay);
|
||||
|
||||
void showError(final CommandSource sender, final Throwable exception, final String commandLabel);
|
||||
BukkitTask runTaskTimerAsynchronously(Runnable run, long delay, long period);
|
||||
|
||||
IItemDb getItemDb();
|
||||
int scheduleSyncDelayedTask(Runnable run);
|
||||
|
||||
UserMap getUserMap();
|
||||
int scheduleSyncDelayedTask(Runnable run, long delay);
|
||||
|
||||
Metrics getMetrics();
|
||||
int scheduleSyncRepeatingTask(Runnable run, long delay, long period);
|
||||
|
||||
void setMetrics(Metrics metrics);
|
||||
TNTExplodeListener getTNTListener();
|
||||
|
||||
EssentialsTimer getTimer();
|
||||
PermissionsHandler getPermissionsHandler();
|
||||
|
||||
List<String> getVanishedPlayers();
|
||||
AlternativeCommandsHandler getAlternativeCommandsHandler();
|
||||
|
||||
void showError(CommandSource sender, Throwable exception, String commandLabel);
|
||||
|
||||
IItemDb getItemDb();
|
||||
|
||||
UserMap getUserMap();
|
||||
|
||||
EssentialsTimer getTimer();
|
||||
|
||||
/**
|
||||
* Get a list of players who are vanished.
|
||||
*
|
||||
* @return A list of players who are vanished
|
||||
* @deprecated Use {@link net.ess3.api.IEssentials#getVanishedPlayersNew()} where possible.
|
||||
*/
|
||||
@Deprecated
|
||||
List<String> getVanishedPlayers();
|
||||
|
||||
Collection<Player> getOnlinePlayers();
|
||||
|
||||
Iterable<User> getOnlineUsers();
|
||||
|
||||
SpawnerItemProvider getSpawnerItemProvider();
|
||||
|
||||
SpawnerBlockProvider getSpawnerBlockProvider();
|
||||
|
||||
ServerStateProvider getServerStateProvider();
|
||||
|
||||
ContainerProvider getContainerProvider();
|
||||
|
||||
KnownCommandsProvider getKnownCommandsProvider();
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
|
||||
public interface IEssentialsModule
|
||||
{
|
||||
public interface IEssentialsModule {
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
public interface IReplyTo
|
||||
{
|
||||
/**
|
||||
* Sets the user to reply to
|
||||
* @param user
|
||||
*/
|
||||
public void setReplyTo(CommandSource user);
|
||||
|
||||
/**
|
||||
* Gets the user the sender should reply to
|
||||
* @return
|
||||
*/
|
||||
public CommandSource getReplyTo();
|
||||
}
|
||||
@@ -3,210 +3,384 @@ package com.earth2me.essentials;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.signs.EssentialsSign;
|
||||
import com.earth2me.essentials.textreader.IText;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public interface ISettings extends IConf
|
||||
{
|
||||
boolean areSignsDisabled();
|
||||
public interface ISettings extends IConf {
|
||||
boolean areSignsDisabled();
|
||||
|
||||
IText getAnnounceNewPlayerFormat();
|
||||
IText getAnnounceNewPlayerFormat();
|
||||
|
||||
boolean getAnnounceNewPlayers();
|
||||
boolean getAnnounceNewPlayers();
|
||||
|
||||
String getNewPlayerKit();
|
||||
String getNewPlayerKit();
|
||||
|
||||
String getBackupCommand();
|
||||
String getBackupCommand();
|
||||
|
||||
long getBackupInterval();
|
||||
long getBackupInterval();
|
||||
|
||||
String getChatFormat(String group);
|
||||
boolean isAlwaysRunBackup();
|
||||
|
||||
int getChatRadius();
|
||||
String getChatFormat(String group);
|
||||
|
||||
BigDecimal getCommandCost(IEssentialsCommand cmd);
|
||||
int getChatRadius();
|
||||
|
||||
BigDecimal getCommandCost(String label);
|
||||
int getNearRadius();
|
||||
|
||||
String getCurrencySymbol();
|
||||
char getChatShout();
|
||||
|
||||
int getOversizedStackSize();
|
||||
char getChatQuestion();
|
||||
|
||||
int getDefaultStackSize();
|
||||
BigDecimal getCommandCost(IEssentialsCommand cmd);
|
||||
|
||||
double getHealCooldown();
|
||||
BigDecimal getCommandCost(String label);
|
||||
|
||||
Set<String> getSocialSpyCommands();
|
||||
String getCurrencySymbol();
|
||||
|
||||
Map<String, Object> getKit(String name);
|
||||
boolean isCurrencySymbolSuffixed();
|
||||
|
||||
ConfigurationSection getKits();
|
||||
int getOversizedStackSize();
|
||||
|
||||
String getLocale();
|
||||
int getDefaultStackSize();
|
||||
|
||||
String getNewbieSpawn();
|
||||
double getHealCooldown();
|
||||
|
||||
String getNicknamePrefix();
|
||||
Set<String> getSocialSpyCommands();
|
||||
|
||||
ChatColor getOperatorColor() throws Exception;
|
||||
boolean getSocialSpyListenMutedPlayers();
|
||||
|
||||
boolean getPerWarpPermission();
|
||||
Set<String> getMuteCommands();
|
||||
|
||||
boolean getProtectBoolean(final String configName, boolean def);
|
||||
/**
|
||||
* @Deprecated in favor of {@link Kits#getKits()}
|
||||
*/
|
||||
@Deprecated
|
||||
ConfigurationSection getKits();
|
||||
|
||||
int getProtectCreeperMaxHeight();
|
||||
/**
|
||||
* @Deprecated in favor of {@link Kits#getKit(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
Map<String, Object> getKit(String kit);
|
||||
|
||||
List<Integer> getProtectList(final String configName);
|
||||
/**
|
||||
* @Deprecated in favor of {@link Kits#addKit(String, List, long)}}
|
||||
*/
|
||||
@Deprecated
|
||||
void addKit(String name, List<String> lines, long delay);
|
||||
|
||||
boolean getProtectPreventSpawn(final String creatureName);
|
||||
@Deprecated
|
||||
ConfigurationSection getKitSection();
|
||||
|
||||
String getProtectString(final String configName);
|
||||
boolean isSkippingUsedOneTimeKitsFromKitList();
|
||||
|
||||
boolean getRespawnAtHome();
|
||||
String getLocale();
|
||||
|
||||
Set getMultipleHomes();
|
||||
String getNewbieSpawn();
|
||||
|
||||
int getHomeLimit(String set);
|
||||
String getNicknamePrefix();
|
||||
|
||||
int getHomeLimit(User user);
|
||||
String getOperatorColor() throws Exception;
|
||||
|
||||
int getSpawnMobLimit();
|
||||
boolean getPerWarpPermission();
|
||||
|
||||
BigDecimal getStartingBalance();
|
||||
boolean getProtectBoolean(final String configName, boolean def);
|
||||
|
||||
boolean isTeleportSafetyEnabled();
|
||||
int getProtectCreeperMaxHeight();
|
||||
|
||||
double getTeleportCooldown();
|
||||
List<Material> getProtectList(final String configName);
|
||||
|
||||
double getTeleportDelay();
|
||||
boolean getProtectPreventSpawn(final String creatureName);
|
||||
|
||||
boolean hidePermissionlessHelp();
|
||||
String getProtectString(final String configName);
|
||||
|
||||
boolean isCommandDisabled(final IEssentialsCommand cmd);
|
||||
boolean getRespawnAtHome();
|
||||
|
||||
boolean isCommandDisabled(String label);
|
||||
boolean isRespawnAtAnchor();
|
||||
|
||||
boolean isCommandOverridden(String name);
|
||||
Set getMultipleHomes();
|
||||
|
||||
boolean isDebug();
|
||||
int getHomeLimit(String set);
|
||||
|
||||
boolean isEcoDisabled();
|
||||
int getHomeLimit(User user);
|
||||
|
||||
boolean isTradeInStacks(int id);
|
||||
int getSpawnMobLimit();
|
||||
|
||||
List<Integer> itemSpawnBlacklist();
|
||||
BigDecimal getStartingBalance();
|
||||
|
||||
List<EssentialsSign> enabledSigns();
|
||||
boolean isTeleportSafetyEnabled();
|
||||
|
||||
boolean permissionBasedItemSpawn();
|
||||
boolean isForceDisableTeleportSafety();
|
||||
|
||||
boolean showNonEssCommandsInHelp();
|
||||
boolean isAlwaysTeleportSafety();
|
||||
|
||||
boolean warnOnBuildDisallow();
|
||||
boolean isTeleportPassengerDismount();
|
||||
|
||||
boolean warnOnSmite();
|
||||
boolean isForcePassengerTeleport();
|
||||
|
||||
BigDecimal getMaxMoney();
|
||||
double getTeleportCooldown();
|
||||
|
||||
BigDecimal getMinMoney();
|
||||
double getTeleportDelay();
|
||||
|
||||
boolean isEcoLogEnabled();
|
||||
boolean hidePermissionlessHelp();
|
||||
|
||||
boolean isEcoLogUpdateEnabled();
|
||||
boolean isCommandDisabled(final IEssentialsCommand cmd);
|
||||
|
||||
boolean removeGodOnDisconnect();
|
||||
boolean isCommandDisabled(String label);
|
||||
|
||||
boolean changeDisplayName();
|
||||
boolean isCommandOverridden(String name);
|
||||
|
||||
boolean changePlayerListName();
|
||||
boolean isDebug();
|
||||
|
||||
boolean isPlayerCommand(String string);
|
||||
void setDebug(boolean debug);
|
||||
|
||||
boolean useBukkitPermissions();
|
||||
boolean isEcoDisabled();
|
||||
|
||||
boolean addPrefixSuffix();
|
||||
@Deprecated
|
||||
boolean isTradeInStacks(int id);
|
||||
|
||||
boolean disablePrefix();
|
||||
boolean isTradeInStacks(Material type);
|
||||
|
||||
boolean disableSuffix();
|
||||
List<Material> itemSpawnBlacklist();
|
||||
|
||||
long getAutoAfk();
|
||||
List<EssentialsSign> enabledSigns();
|
||||
|
||||
long getAutoAfkKick();
|
||||
boolean permissionBasedItemSpawn();
|
||||
|
||||
boolean getFreezeAfkPlayers();
|
||||
boolean showNonEssCommandsInHelp();
|
||||
|
||||
boolean cancelAfkOnMove();
|
||||
boolean warnOnBuildDisallow();
|
||||
|
||||
boolean cancelAfkOnInteract();
|
||||
boolean warnOnSmite();
|
||||
|
||||
boolean areDeathMessagesEnabled();
|
||||
BigDecimal getMaxMoney();
|
||||
|
||||
void setDebug(boolean debug);
|
||||
BigDecimal getMinMoney();
|
||||
|
||||
Set<String> getNoGodWorlds();
|
||||
boolean isEcoLogEnabled();
|
||||
|
||||
boolean getUpdateBedAtDaytime();
|
||||
boolean isEcoLogUpdateEnabled();
|
||||
|
||||
boolean allowUnsafeEnchantments();
|
||||
boolean realNamesOnList();
|
||||
|
||||
boolean getRepairEnchanted();
|
||||
boolean removeGodOnDisconnect();
|
||||
|
||||
boolean isWorldTeleportPermissions();
|
||||
boolean changeDisplayName();
|
||||
|
||||
boolean isWorldHomePermissions();
|
||||
boolean changePlayerListName();
|
||||
|
||||
boolean registerBackInListener();
|
||||
boolean isPlayerCommand(String string);
|
||||
|
||||
boolean getDisableItemPickupWhileAfk();
|
||||
boolean useBukkitPermissions();
|
||||
|
||||
EventPriority getRespawnPriority();
|
||||
boolean addPrefixSuffix();
|
||||
|
||||
long getTpaAcceptCancellation();
|
||||
boolean disablePrefix();
|
||||
|
||||
boolean isMetricsEnabled();
|
||||
boolean disableSuffix();
|
||||
|
||||
void setMetricsEnabled(boolean metricsEnabled);
|
||||
long getAutoAfk();
|
||||
|
||||
long getTeleportInvulnerability();
|
||||
long getAutoAfkKick();
|
||||
|
||||
boolean isTeleportInvulnerability();
|
||||
boolean getFreezeAfkPlayers();
|
||||
|
||||
long getLoginAttackDelay();
|
||||
boolean cancelAfkOnMove();
|
||||
|
||||
int getSignUsePerSecond();
|
||||
boolean cancelAfkOnInteract();
|
||||
|
||||
double getMaxFlySpeed();
|
||||
boolean sleepIgnoresAfkPlayers();
|
||||
|
||||
double getMaxWalkSpeed();
|
||||
boolean isAfkListName();
|
||||
|
||||
int getMailsPerMinute();
|
||||
String getAfkListName();
|
||||
|
||||
long getEconomyLagWarning();
|
||||
boolean broadcastAfkMessage();
|
||||
|
||||
void setEssentialsChatActive(boolean b);
|
||||
boolean areDeathMessagesEnabled();
|
||||
|
||||
long getMaxTempban();
|
||||
KeepInvPolicy getVanishingItemsPolicy();
|
||||
|
||||
Map<String, Object> getListGroupConfig();
|
||||
KeepInvPolicy getBindingItemsPolicy();
|
||||
|
||||
int getMaxNickLength();
|
||||
int getJoinQuitMessagePlayerCount();
|
||||
|
||||
int getMaxUserCacheCount();
|
||||
boolean hasJoinQuitMessagePlayerCount();
|
||||
|
||||
boolean allowSilentJoinQuit();
|
||||
Set<String> getNoGodWorlds();
|
||||
|
||||
boolean isCustomJoinMessage();
|
||||
boolean getUpdateBedAtDaytime();
|
||||
|
||||
String getCustomJoinMessage();
|
||||
boolean allowUnsafeEnchantments();
|
||||
|
||||
boolean isCustomQuitMessage();
|
||||
boolean getRepairEnchanted();
|
||||
|
||||
boolean isWorldTeleportPermissions();
|
||||
|
||||
boolean isWorldHomePermissions();
|
||||
|
||||
boolean registerBackInListener();
|
||||
|
||||
boolean getDisableItemPickupWhileAfk();
|
||||
|
||||
EventPriority getRespawnPriority();
|
||||
|
||||
EventPriority getSpawnJoinPriority();
|
||||
|
||||
long getTpaAcceptCancellation();
|
||||
|
||||
long getTeleportInvulnerability();
|
||||
|
||||
boolean isTeleportInvulnerability();
|
||||
|
||||
long getLoginAttackDelay();
|
||||
|
||||
int getSignUsePerSecond();
|
||||
|
||||
double getMaxFlySpeed();
|
||||
|
||||
double getMaxWalkSpeed();
|
||||
|
||||
int getMailsPerMinute();
|
||||
|
||||
long getEconomyLagWarning();
|
||||
|
||||
long getPermissionsLagWarning();
|
||||
|
||||
void setEssentialsChatActive(boolean b);
|
||||
|
||||
long getMaxMute();
|
||||
|
||||
long getMaxTempban();
|
||||
|
||||
Map<String, Object> getListGroupConfig();
|
||||
|
||||
int getMaxNickLength();
|
||||
|
||||
boolean ignoreColorsInMaxLength();
|
||||
|
||||
boolean hideDisplayNameInVanish();
|
||||
|
||||
int getMaxUserCacheCount();
|
||||
|
||||
boolean allowSilentJoinQuit();
|
||||
|
||||
boolean isCustomJoinMessage();
|
||||
|
||||
String getCustomJoinMessage();
|
||||
|
||||
boolean isCustomQuitMessage();
|
||||
|
||||
String getCustomQuitMessage();
|
||||
|
||||
boolean isNotifyNoNewMail();
|
||||
|
||||
boolean isDropItemsIfFull();
|
||||
|
||||
boolean isLastMessageReplyRecipient();
|
||||
|
||||
boolean isReplyToVanished();
|
||||
|
||||
BigDecimal getMinimumPayAmount();
|
||||
|
||||
boolean isPayExcludesIgnoreList();
|
||||
|
||||
long getLastMessageReplyRecipientTimeout();
|
||||
|
||||
boolean isMilkBucketEasterEggEnabled();
|
||||
|
||||
boolean isSendFlyEnableOnJoin();
|
||||
|
||||
boolean isWorldTimePermissions();
|
||||
|
||||
boolean isSpawnOnJoin();
|
||||
|
||||
List<String> getSpawnOnJoinGroups();
|
||||
|
||||
boolean isUserInSpawnOnJoinGroup(IUser user);
|
||||
|
||||
boolean isTeleportToCenterLocation();
|
||||
|
||||
boolean isCommandCooldownsEnabled();
|
||||
|
||||
boolean isWorldChangeFlyResetEnabled();
|
||||
|
||||
boolean isWorldChangeSpeedResetEnabled();
|
||||
|
||||
long getCommandCooldownMs(String label);
|
||||
|
||||
Entry<Pattern, Long> getCommandCooldownEntry(String label);
|
||||
|
||||
boolean isCommandCooldownPersistent(String label);
|
||||
|
||||
boolean isNpcsInBalanceRanking();
|
||||
|
||||
NumberFormat getCurrencyFormat();
|
||||
|
||||
List<EssentialsSign> getUnprotectedSignNames();
|
||||
|
||||
boolean isPastebinCreateKit();
|
||||
|
||||
boolean isAllowBulkBuySell();
|
||||
|
||||
boolean isAllowSellNamedItems();
|
||||
|
||||
boolean isAddingPrefixInPlayerlist();
|
||||
|
||||
boolean isAddingSuffixInPlayerlist();
|
||||
|
||||
int getNotifyPlayerOfMailCooldown();
|
||||
|
||||
int getMotdDelay();
|
||||
|
||||
boolean isDirectHatAllowed();
|
||||
|
||||
List<String> getDefaultEnabledConfirmCommands();
|
||||
|
||||
boolean isConfirmCommandEnabledByDefault(String commandName);
|
||||
|
||||
boolean isTeleportBackWhenFreedFromJail();
|
||||
|
||||
boolean isCompassTowardsHomePerm();
|
||||
|
||||
boolean isAllowWorldInBroadcastworld();
|
||||
|
||||
String getItemDbType();
|
||||
|
||||
boolean allowOldIdSigns();
|
||||
|
||||
boolean isWaterSafe();
|
||||
|
||||
boolean isSafeUsermap();
|
||||
|
||||
boolean logCommandBlockCommands();
|
||||
|
||||
Set<Predicate<String>> getNickBlacklist();
|
||||
|
||||
double getMaxProjectileSpeed();
|
||||
|
||||
boolean isRemovingEffectsOnHeal();
|
||||
|
||||
boolean isSpawnIfNoHome();
|
||||
|
||||
boolean isConfirmHomeOverwrite();
|
||||
|
||||
boolean infoAfterDeath();
|
||||
|
||||
enum KeepInvPolicy {
|
||||
KEEP,
|
||||
DELETE,
|
||||
DROP
|
||||
}
|
||||
|
||||
String getCustomQuitMessage();
|
||||
}
|
||||
@@ -2,8 +2,6 @@ package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
|
||||
public interface ITarget
|
||||
{
|
||||
public Location getLocation();
|
||||
}
|
||||
public interface ITarget {
|
||||
Location getLocation();
|
||||
}
|
||||
@@ -1,145 +1,213 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.IAsyncTeleport;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import net.ess3.api.ITeleport;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import net.ess3.api.events.AfkStatusChangeEvent;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import net.ess3.api.ITeleport;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Provides access to the user abstraction and stored data. Maintainers should add methods to <i>this interface</i>.
|
||||
*
|
||||
* @deprecated External plugins should use {@link net.ess3.api.IUser} instead of this interface, in case future APIs are added.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IUser {
|
||||
boolean isAuthorized(String node);
|
||||
|
||||
public interface IUser
|
||||
{
|
||||
boolean isAuthorized(String node);
|
||||
boolean isAuthorized(IEssentialsCommand cmd);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd);
|
||||
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
|
||||
boolean isPermissionSet(String node);
|
||||
|
||||
void healCooldown() throws Exception;
|
||||
void healCooldown() throws Exception;
|
||||
|
||||
void giveMoney(BigDecimal value) throws MaxMoneyException;
|
||||
void giveMoney(BigDecimal value) throws MaxMoneyException;
|
||||
|
||||
void giveMoney(final BigDecimal value, final CommandSource initiator) throws MaxMoneyException;
|
||||
|
||||
void payUser(final User reciever, final BigDecimal value) throws Exception;
|
||||
void giveMoney(final BigDecimal value, final CommandSource initiator) throws MaxMoneyException;
|
||||
|
||||
void takeMoney(BigDecimal value);
|
||||
void payUser(final User reciever, final BigDecimal value) throws Exception;
|
||||
|
||||
void takeMoney(final BigDecimal value, final CommandSource initiator);
|
||||
void takeMoney(BigDecimal value);
|
||||
|
||||
boolean canAfford(BigDecimal value);
|
||||
void takeMoney(final BigDecimal value, final CommandSource initiator);
|
||||
|
||||
Boolean canSpawnItem(final int itemId);
|
||||
boolean canAfford(BigDecimal value);
|
||||
|
||||
void setLastLocation();
|
||||
Boolean canSpawnItem(final Material material);
|
||||
|
||||
void setLogoutLocation();
|
||||
void setLastLocation();
|
||||
|
||||
void requestTeleport(final User player, final boolean here);
|
||||
void setLogoutLocation();
|
||||
|
||||
ITeleport getTeleport();
|
||||
void requestTeleport(final User player, final boolean here);
|
||||
|
||||
BigDecimal getMoney();
|
||||
/**
|
||||
* Returns whether this user has an outstanding teleport request to deal with.
|
||||
*
|
||||
* @return whether there is a teleport request
|
||||
*/
|
||||
boolean hasOutstandingTeleportRequest();
|
||||
|
||||
void setMoney(final BigDecimal value) throws MaxMoneyException;
|
||||
/**
|
||||
* @deprecated This API is not asynchronous. Use {@link com.earth2me.essentials.api.IAsyncTeleport IAsyncTeleport} with {@link IUser#getAsyncTeleport()}
|
||||
*/
|
||||
@Deprecated
|
||||
ITeleport getTeleport();
|
||||
|
||||
void setAfk(final boolean set);
|
||||
IAsyncTeleport getAsyncTeleport();
|
||||
|
||||
/**
|
||||
* 'Hidden' Represents when a player is hidden from others. This status includes when the player is hidden via other
|
||||
* supported plugins. Use isVanished() if you want to check if a user is vanished by Essentials.
|
||||
*
|
||||
* @return If the user is hidden or not
|
||||
* @see isVanished
|
||||
*/
|
||||
boolean isHidden();
|
||||
BigDecimal getMoney();
|
||||
|
||||
void setHidden(boolean vanish);
|
||||
void setMoney(final BigDecimal value) throws MaxMoneyException;
|
||||
|
||||
boolean isGodModeEnabled();
|
||||
void setAfk(final boolean set, final AfkStatusChangeEvent.Cause cause);
|
||||
|
||||
String getGroup();
|
||||
/**
|
||||
* 'Hidden' Represents when a player is hidden from others. This status includes when the player is hidden via other
|
||||
* supported plugins. Use isVanished() if you want to check if a user is vanished by Essentials.
|
||||
*
|
||||
* @return If the user is hidden or not
|
||||
* @see IUser#isVanished()
|
||||
*/
|
||||
boolean isHidden();
|
||||
|
||||
boolean inGroup(final String group);
|
||||
void setHidden(boolean vanish);
|
||||
|
||||
boolean canBuild();
|
||||
boolean isGodModeEnabled();
|
||||
|
||||
long getTeleportRequestTime();
|
||||
String getGroup();
|
||||
|
||||
void enableInvulnerabilityAfterTeleport();
|
||||
boolean inGroup(final String group);
|
||||
|
||||
void resetInvulnerabilityAfterTeleport();
|
||||
boolean canBuild();
|
||||
|
||||
boolean hasInvulnerabilityAfterTeleport();
|
||||
long getTeleportRequestTime();
|
||||
|
||||
/**
|
||||
* 'Vanished' Represents when a player is hidden from others by Essentials. This status does NOT include when the
|
||||
* player is hidden via other plugins. Use isHidden() if you want to check if a user is vanished by any supported
|
||||
* plugin.
|
||||
*
|
||||
* @return If the user is vanished or not
|
||||
* @see isHidden
|
||||
*/
|
||||
boolean isVanished();
|
||||
void enableInvulnerabilityAfterTeleport();
|
||||
|
||||
void setVanished(boolean vanish);
|
||||
void resetInvulnerabilityAfterTeleport();
|
||||
|
||||
boolean isIgnoreExempt();
|
||||
boolean hasInvulnerabilityAfterTeleport();
|
||||
|
||||
public void sendMessage(String message);
|
||||
/**
|
||||
* 'Vanished' Represents when a player is hidden from others by Essentials. This status does NOT include when the
|
||||
* player is hidden via other plugins. Use isHidden() if you want to check if a user is vanished by any supported
|
||||
* plugin.
|
||||
*
|
||||
* @return If the user is vanished or not
|
||||
* @see IUser#isHidden()
|
||||
*/
|
||||
boolean isVanished();
|
||||
|
||||
/*
|
||||
* UserData
|
||||
*/
|
||||
Location getHome(String name) throws Exception;
|
||||
void setVanished(boolean vanish);
|
||||
|
||||
Location getHome(Location loc) throws Exception;
|
||||
boolean isIgnoreExempt();
|
||||
|
||||
List<String> getHomes();
|
||||
void sendMessage(String message);
|
||||
|
||||
void setHome(String name, Location loc);
|
||||
/*
|
||||
* UserData
|
||||
*/
|
||||
Location getHome(String name) throws Exception;
|
||||
|
||||
void delHome(String name) throws Exception;
|
||||
Location getHome(Location loc) throws Exception;
|
||||
|
||||
boolean hasHome();
|
||||
List<String> getHomes();
|
||||
|
||||
Location getLastLocation();
|
||||
void setHome(String name, Location loc);
|
||||
|
||||
Location getLogoutLocation();
|
||||
void delHome(String name) throws Exception;
|
||||
|
||||
long getLastTeleportTimestamp();
|
||||
boolean hasHome();
|
||||
|
||||
void setLastTeleportTimestamp(long time);
|
||||
Location getLastLocation();
|
||||
|
||||
String getJail();
|
||||
Location getLogoutLocation();
|
||||
|
||||
void setJail(String jail);
|
||||
long getLastTeleportTimestamp();
|
||||
|
||||
List<String> getMails();
|
||||
void setLastTeleportTimestamp(long time);
|
||||
|
||||
void addMail(String mail);
|
||||
String getJail();
|
||||
|
||||
boolean isAfk();
|
||||
void setJail(String jail);
|
||||
|
||||
void setConfigProperty(String node, Object object);
|
||||
List<String> getMails();
|
||||
|
||||
Set<String> getConfigKeys();
|
||||
void addMail(String mail);
|
||||
|
||||
Map<String, Object> getConfigMap();
|
||||
boolean isAfk();
|
||||
|
||||
Map<String, Object> getConfigMap(String node);
|
||||
@Deprecated
|
||||
void setAfk(final boolean set);
|
||||
|
||||
/*
|
||||
* PlayerExtension
|
||||
*/
|
||||
Player getBase();
|
||||
boolean isIgnoreMsg();
|
||||
|
||||
CommandSource getSource();
|
||||
void setIgnoreMsg(boolean ignoreMsg);
|
||||
|
||||
public String getName();
|
||||
void setConfigProperty(String node, Object object);
|
||||
|
||||
Set<String> getConfigKeys();
|
||||
|
||||
Map<String, Object> getConfigMap();
|
||||
|
||||
Map<String, Object> getConfigMap(String node);
|
||||
|
||||
Map<Pattern, Long> getCommandCooldowns();
|
||||
|
||||
Date getCommandCooldownExpiry(String label);
|
||||
|
||||
void addCommandCooldown(Pattern pattern, Date expiresAt, boolean save);
|
||||
|
||||
boolean clearCommandCooldown(Pattern pattern);
|
||||
|
||||
/*
|
||||
* PlayerExtension
|
||||
*/
|
||||
Player getBase();
|
||||
|
||||
CommandSource getSource();
|
||||
|
||||
String getName();
|
||||
|
||||
String getDisplayName();
|
||||
|
||||
String getAfkMessage();
|
||||
|
||||
void setAfkMessage(final String message);
|
||||
|
||||
long getAfkSince();
|
||||
|
||||
boolean isAcceptingPay();
|
||||
|
||||
void setAcceptingPay(boolean acceptingPay);
|
||||
|
||||
boolean isPromptingPayConfirm();
|
||||
|
||||
void setPromptingPayConfirm(boolean prompt);
|
||||
|
||||
boolean isPromptingClearConfirm();
|
||||
|
||||
void setPromptingClearConfirm(boolean prompt);
|
||||
|
||||
boolean isLastMessageReplyRecipient();
|
||||
|
||||
void setLastMessageReplyRecipient(boolean enabled);
|
||||
|
||||
Map<User, BigDecimal> getConfirmingPayments();
|
||||
|
||||
Block getTargetBlock(int maxDistance);
|
||||
}
|
||||
@@ -1,313 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class ItemDb implements IConf, net.ess3.api.IItemDb
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
private final transient Map<String, Integer> items = new HashMap<String, Integer>();
|
||||
private final transient Map<ItemData, List<String>> names = new HashMap<ItemData, List<String>>();
|
||||
private final transient Map<ItemData, String> primaryName = new HashMap<ItemData, String>();
|
||||
private final transient Map<String, Short> durabilities = new HashMap<String, Short>();
|
||||
private final transient ManagedFile file;
|
||||
private final transient Pattern splitPattern = Pattern.compile("((.*)[:+',;.](\\d+))");
|
||||
|
||||
public ItemDb(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
file = new ManagedFile("items.csv", ess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
final List<String> lines = file.getLines();
|
||||
|
||||
if (lines.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
durabilities.clear();
|
||||
items.clear();
|
||||
names.clear();
|
||||
primaryName.clear();
|
||||
|
||||
for (String line : lines)
|
||||
{
|
||||
line = line.trim().toLowerCase(Locale.ENGLISH);
|
||||
if (line.length() > 0 && line.charAt(0) == '#')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final String[] parts = line.split("[^a-z0-9]");
|
||||
if (parts.length < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final int numeric = Integer.parseInt(parts[1]);
|
||||
final short data = parts.length > 2 && !parts[2].equals("0") ? Short.parseShort(parts[2]) : 0;
|
||||
String itemName = parts[0].toLowerCase(Locale.ENGLISH);
|
||||
|
||||
durabilities.put(itemName, data);
|
||||
items.put(itemName, numeric);
|
||||
|
||||
ItemData itemData = new ItemData(numeric, data);
|
||||
if (names.containsKey(itemData))
|
||||
{
|
||||
List<String> nameList = names.get(itemData);
|
||||
nameList.add(itemName);
|
||||
Collections.sort(nameList, new LengthCompare());
|
||||
}
|
||||
else
|
||||
{
|
||||
List<String> nameList = new ArrayList<String>();
|
||||
nameList.add(itemName);
|
||||
names.put(itemData, nameList);
|
||||
primaryName.put(itemData, itemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack get(final String id, final int quantity) throws Exception
|
||||
{
|
||||
final ItemStack retval = get(id.toLowerCase(Locale.ENGLISH));
|
||||
retval.setAmount(quantity);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack get(final String id) throws Exception
|
||||
{
|
||||
int itemid = 0;
|
||||
String itemname = null;
|
||||
short metaData = 0;
|
||||
Matcher parts = splitPattern.matcher(id);
|
||||
if (parts.matches())
|
||||
{
|
||||
itemname = parts.group(2);
|
||||
metaData = Short.parseShort(parts.group(3));
|
||||
}
|
||||
else
|
||||
{
|
||||
itemname = id;
|
||||
}
|
||||
|
||||
if (NumberUtil.isInt(itemname))
|
||||
{
|
||||
itemid = Integer.parseInt(itemname);
|
||||
}
|
||||
else if (NumberUtil.isInt(id))
|
||||
{
|
||||
itemid = Integer.parseInt(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemname = itemname.toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
if (itemid < 1)
|
||||
{
|
||||
if (items.containsKey(itemname))
|
||||
{
|
||||
itemid = items.get(itemname);
|
||||
if (durabilities.containsKey(itemname) && metaData == 0)
|
||||
{
|
||||
metaData = durabilities.get(itemname);
|
||||
}
|
||||
}
|
||||
else if (Material.getMaterial(itemname.toUpperCase(Locale.ENGLISH)) != null)
|
||||
{
|
||||
Material bMaterial = Material.getMaterial(itemname.toUpperCase(Locale.ENGLISH));
|
||||
itemid = bMaterial.getId();
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
Material bMaterial = Bukkit.getUnsafe().getMaterialFromInternalName(itemname.toLowerCase(Locale.ENGLISH));
|
||||
itemid = bMaterial.getId();
|
||||
}
|
||||
catch (Throwable throwable)
|
||||
{
|
||||
throw new Exception(_("unknownItemName", itemname), throwable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (itemid < 1)
|
||||
{
|
||||
throw new Exception(_("unknownItemName", itemname));
|
||||
}
|
||||
|
||||
final Material mat = Material.getMaterial(itemid);
|
||||
if (mat == null)
|
||||
{
|
||||
throw new Exception(_("unknownItemId", itemid));
|
||||
}
|
||||
final ItemStack retval = new ItemStack(mat);
|
||||
retval.setAmount(mat.getMaxStackSize());
|
||||
retval.setDurability(metaData);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getMatching(User user, String[] args) throws Exception
|
||||
{
|
||||
List<ItemStack> is = new ArrayList<ItemStack>();
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
is.add(user.getItemInHand());
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("hand"))
|
||||
{
|
||||
is.add(user.getItemInHand());
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("inventory") || args[0].equalsIgnoreCase("invent") || args[0].equalsIgnoreCase("all"))
|
||||
{
|
||||
for (ItemStack stack : user.getInventory().getContents())
|
||||
{
|
||||
if (stack == null || stack.getType() == Material.AIR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
is.add(stack);
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("blocks"))
|
||||
{
|
||||
for (ItemStack stack : user.getInventory().getContents())
|
||||
{
|
||||
if (stack == null || stack.getTypeId() > 255 || stack.getType() == Material.AIR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
is.add(stack);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
is.add(get(args[0]));
|
||||
}
|
||||
|
||||
if (is.isEmpty() || is.get(0).getType() == Material.AIR)
|
||||
{
|
||||
throw new Exception(_("itemSellAir"));
|
||||
}
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String names(ItemStack item)
|
||||
{
|
||||
ItemData itemData = new ItemData(item.getTypeId(), item.getDurability());
|
||||
List<String> nameList = names.get(itemData);
|
||||
if (nameList == null)
|
||||
{
|
||||
itemData = new ItemData(item.getTypeId(), (short)0);
|
||||
nameList = names.get(itemData);
|
||||
if (nameList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (nameList.size() > 15)
|
||||
{
|
||||
nameList = nameList.subList(0, 14);
|
||||
}
|
||||
return StringUtil.joinList(", ", nameList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name(ItemStack item)
|
||||
{
|
||||
ItemData itemData = new ItemData(item.getTypeId(), item.getDurability());
|
||||
String name = primaryName.get(itemData);
|
||||
if (name == null)
|
||||
{
|
||||
itemData = new ItemData(item.getTypeId(), (short)0);
|
||||
name = primaryName.get(itemData);
|
||||
if (name == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
static class ItemData
|
||||
{
|
||||
final private int itemNo;
|
||||
final private short itemData;
|
||||
|
||||
ItemData(final int itemNo, final short itemData)
|
||||
{
|
||||
this.itemNo = itemNo;
|
||||
this.itemData = itemData;
|
||||
}
|
||||
|
||||
public int getItemNo()
|
||||
{
|
||||
return itemNo;
|
||||
}
|
||||
|
||||
public short getItemData()
|
||||
{
|
||||
return itemData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return (31 * itemNo) ^ itemData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (o == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!(o instanceof ItemData))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ItemData pairo = (ItemData)o;
|
||||
return this.itemNo == pairo.getItemNo()
|
||||
&& this.itemData == pairo.getItemData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class LengthCompare implements java.util.Comparator<String>
|
||||
{
|
||||
public LengthCompare()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(String s1, String s2)
|
||||
{
|
||||
return s1.length() - s2.length();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,6 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -21,6 +16,7 @@ import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
@@ -28,313 +24,279 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.settings.Jails> implements net.ess3.api.IJails
|
||||
{
|
||||
private static final transient Logger LOGGER = Bukkit.getLogger();
|
||||
private static transient boolean enabled = false;
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public Jails(final IEssentials ess)
|
||||
{
|
||||
super(ess, com.earth2me.essentials.settings.Jails.class);
|
||||
reloadConfig();
|
||||
}
|
||||
public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.settings.Jails> implements net.ess3.api.IJails {
|
||||
private static final transient Logger LOGGER = Bukkit.getLogger();
|
||||
private static transient boolean enabled = false;
|
||||
|
||||
private void registerListeners()
|
||||
{
|
||||
enabled = true;
|
||||
final PluginManager pluginManager = ess.getServer().getPluginManager();
|
||||
final JailListener blockListener = new JailListener();
|
||||
pluginManager.registerEvents(blockListener, ess);
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Registering Jail listener");
|
||||
}
|
||||
}
|
||||
public Jails(final IEssentials ess) {
|
||||
super(ess, com.earth2me.essentials.settings.Jails.class);
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getStorageFile()
|
||||
{
|
||||
return new File(ess.getDataFolder(), "jail.yml");
|
||||
}
|
||||
private void registerListeners() {
|
||||
enabled = true;
|
||||
final PluginManager pluginManager = ess.getServer().getPluginManager();
|
||||
final JailListener blockListener = new JailListener();
|
||||
pluginManager.registerEvents(blockListener, ess);
|
||||
if (ess.getSettings().isDebug()) {
|
||||
LOGGER.log(Level.INFO, "Registering Jail listener");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishRead()
|
||||
{
|
||||
checkRegister();
|
||||
}
|
||||
@Override
|
||||
public File getStorageFile() {
|
||||
return new File(ess.getDataFolder(), "jail.yml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishWrite()
|
||||
{
|
||||
checkRegister();
|
||||
}
|
||||
@Override
|
||||
public void finishRead() {
|
||||
checkRegister();
|
||||
}
|
||||
|
||||
public void resetListener()
|
||||
{
|
||||
enabled = false;
|
||||
checkRegister();
|
||||
}
|
||||
@Override
|
||||
public void finishWrite() {
|
||||
checkRegister();
|
||||
}
|
||||
|
||||
private void checkRegister()
|
||||
{
|
||||
if (enabled == false && getCount() > 0)
|
||||
{
|
||||
registerListeners();
|
||||
}
|
||||
}
|
||||
public void resetListener() {
|
||||
enabled = false;
|
||||
checkRegister();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getJail(final String jailName) throws Exception
|
||||
{
|
||||
acquireReadLock();
|
||||
try
|
||||
{
|
||||
if (getData().getJails() == null || jailName == null
|
||||
|| !getData().getJails().containsKey(jailName.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new Exception(_("jailNotExist"));
|
||||
}
|
||||
Location loc = getData().getJails().get(jailName.toLowerCase(Locale.ENGLISH));
|
||||
if (loc == null || loc.getWorld() == null)
|
||||
{
|
||||
throw new Exception(_("jailNotExist"));
|
||||
}
|
||||
return loc;
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
private void checkRegister() {
|
||||
if (!enabled && getCount() > 0) {
|
||||
registerListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getList() throws Exception
|
||||
{
|
||||
acquireReadLock();
|
||||
try
|
||||
{
|
||||
if (getData().getJails() == null)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return new ArrayList<String>(getData().getJails().keySet());
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Location getJail(final String jailName) throws Exception {
|
||||
acquireReadLock();
|
||||
try {
|
||||
if (getData().getJails() == null || jailName == null || !getData().getJails().containsKey(jailName.toLowerCase(Locale.ENGLISH))) {
|
||||
throw new Exception(tl("jailNotExist"));
|
||||
}
|
||||
final Location loc = getData().getJails().get(jailName.toLowerCase(Locale.ENGLISH));
|
||||
if (loc == null || loc.getWorld() == null) {
|
||||
throw new Exception(tl("jailNotExist"));
|
||||
}
|
||||
return loc;
|
||||
} finally {
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeJail(final String jail) throws Exception
|
||||
{
|
||||
acquireWriteLock();
|
||||
try
|
||||
{
|
||||
if (getData().getJails() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
getData().getJails().remove(jail.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Collection<String> getList() throws Exception {
|
||||
acquireReadLock();
|
||||
try {
|
||||
if (getData().getJails() == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return new ArrayList<>(getData().getJails().keySet());
|
||||
} finally {
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendToJail(final IUser user, final String jail) throws Exception
|
||||
{
|
||||
acquireReadLock();
|
||||
try
|
||||
{
|
||||
if (user.getBase().isOnline())
|
||||
{
|
||||
Location loc = getJail(jail);
|
||||
user.getTeleport().now(loc, false, TeleportCause.COMMAND);
|
||||
}
|
||||
user.setJail(jail);
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void removeJail(final String jail) throws Exception {
|
||||
acquireWriteLock();
|
||||
try {
|
||||
if (getData().getJails() == null) {
|
||||
return;
|
||||
}
|
||||
getData().getJails().remove(jail.toLowerCase(Locale.ENGLISH));
|
||||
} finally {
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setJail(final String jailName, final Location loc) throws Exception
|
||||
{
|
||||
acquireWriteLock();
|
||||
try
|
||||
{
|
||||
if (getData().getJails() == null)
|
||||
{
|
||||
getData().setJails(new HashMap<String, Location>());
|
||||
}
|
||||
getData().getJails().put(jailName.toLowerCase(Locale.ENGLISH), loc);
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @deprecated This method does not use asynchronous teleportation. Use {@link Jails#sendToJail(IUser, String, CompletableFuture)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void sendToJail(final IUser user, final String jail) throws Exception {
|
||||
acquireReadLock();
|
||||
try {
|
||||
if (user.getBase().isOnline()) {
|
||||
final Location loc = getJail(jail);
|
||||
user.getTeleport().now(loc, false, TeleportCause.COMMAND);
|
||||
}
|
||||
user.setJail(jail);
|
||||
} finally {
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount()
|
||||
{
|
||||
try
|
||||
{
|
||||
return getList().size();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void sendToJail(final IUser user, final String jail, final CompletableFuture<Boolean> future) throws Exception {
|
||||
acquireReadLock();
|
||||
try {
|
||||
if (user.getBase().isOnline()) {
|
||||
final Location loc = getJail(jail);
|
||||
user.getAsyncTeleport().now(loc, false, TeleportCause.COMMAND, future);
|
||||
future.thenAccept(success -> user.setJail(jail));
|
||||
return;
|
||||
}
|
||||
user.setJail(jail);
|
||||
} finally {
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setJail(final String jailName, final Location loc) throws Exception {
|
||||
acquireWriteLock();
|
||||
try {
|
||||
if (getData().getJails() == null) {
|
||||
getData().setJails(new HashMap<>());
|
||||
}
|
||||
getData().getJails().put(jailName.toLowerCase(Locale.ENGLISH), loc);
|
||||
} finally {
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private class JailListener implements Listener
|
||||
{
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockBreak(final BlockBreakEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int getCount() {
|
||||
try {
|
||||
return getList().size();
|
||||
} catch (final Exception ex) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockPlace(final BlockPlaceEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
private class JailListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onJailBlockBreak(final BlockBreakEvent event) {
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed() && !user.isAuthorized("essentials.jail.allow-break")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockDamage(final BlockDamageEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onJailBlockPlace(final BlockPlaceEvent event) {
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed() && !user.isAuthorized("essentials.jail.allow-place")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityDamageByEntity(final EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (event.getCause() != DamageCause.ENTITY_ATTACK || event.getEntity().getType() != EntityType.PLAYER)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final Entity damager = event.getDamager();
|
||||
if (damager.getType() == EntityType.PLAYER)
|
||||
{
|
||||
final User user = ess.getUser((Player)damager);
|
||||
if (user != null && user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onJailBlockDamage(final BlockDamageEvent event) {
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed() && !user.isAuthorized("essentials.jail.allow-block-damage")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onJailEntityDamageByEntity(final EntityDamageByEntityEvent event) {
|
||||
if (event.getCause() != DamageCause.ENTITY_ATTACK || event.getEntity().getType() != EntityType.PLAYER) {
|
||||
return;
|
||||
}
|
||||
final Entity damager = event.getDamager();
|
||||
if (damager.getType() == EntityType.PLAYER) {
|
||||
final User user = ess.getUser((Player) damager);
|
||||
if (user != null && user.isJailed()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerRespawn(final PlayerRespawnEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onJailPlayerInteract(final PlayerInteractEvent event) {
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed() && !user.isAuthorized("essentials.jail.allow-interact")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
event.setRespawnLocation(getJail(user.getJail()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onJailPlayerGameModeChange(final PlayerGameModeChangeEvent event) {
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerTeleport(final PlayerTeleportEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onJailPlayerRespawn(final PlayerRespawnEvent event) {
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
event.setTo(getJail(user.getJail()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
|
||||
}
|
||||
}
|
||||
user.sendMessage(_("jailMessage"));
|
||||
}
|
||||
try {
|
||||
event.setRespawnLocation(getJail(user.getJail()));
|
||||
} catch (final Exception ex) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
LOGGER.log(Level.INFO, tl("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
|
||||
} else {
|
||||
LOGGER.log(Level.INFO, tl("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
user.checkJailTimeout(currentTime);
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onJailPlayerTeleport(final PlayerTeleportEvent event) {
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
sendToJail(user, user.getJail());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
|
||||
}
|
||||
}
|
||||
user.sendMessage(_("jailMessage"));
|
||||
}
|
||||
}
|
||||
try {
|
||||
event.setTo(getJail(user.getJail()));
|
||||
} catch (final Exception ex) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
LOGGER.log(Level.INFO, tl("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
|
||||
} else {
|
||||
LOGGER.log(Level.INFO, tl("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
|
||||
}
|
||||
}
|
||||
user.sendMessage(tl("jailMessage"));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onJailPlayerJoin(final PlayerJoinEvent event) {
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
user.checkJailTimeout(currentTime);
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final CompletableFuture<Boolean> future = new CompletableFuture<>();
|
||||
future.exceptionally(ex -> {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
LOGGER.log(Level.INFO, tl("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
|
||||
} else {
|
||||
LOGGER.log(Level.INFO, tl("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
|
||||
}
|
||||
return false;
|
||||
});
|
||||
future.thenAccept(success -> user.sendMessage(tl("jailMessage")));
|
||||
|
||||
try {
|
||||
sendToJail(user, user.getJail(), future);
|
||||
} catch (final Exception ex) {
|
||||
future.completeExceptionally(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import static com.earth2me.essentials.I18n.capitalCase;
|
||||
import com.earth2me.essentials.Trade.OverflowType;
|
||||
import com.earth2me.essentials.commands.NoChargeException;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
@@ -10,230 +8,249 @@ import com.earth2me.essentials.textreader.KeywordReplacer;
|
||||
import com.earth2me.essentials.textreader.SimpleTextInput;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.events.KitClaimEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Kit
|
||||
{
|
||||
//TODO: Convert this to use one of the new text classes?
|
||||
public static String listKits(final IEssentials ess, final User user) throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
final ConfigurationSection kits = ess.getSettings().getKits();
|
||||
final StringBuilder list = new StringBuilder();
|
||||
for (String kitItem : kits.getKeys(false))
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
list.append(" ").append(capitalCase(kitItem));
|
||||
}
|
||||
else if (user.isAuthorized("essentials.kits." + kitItem.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
String cost = "";
|
||||
String name = capitalCase(kitItem);
|
||||
BigDecimal costPrice = new Trade("kit-" + kitItem.toLowerCase(Locale.ENGLISH), ess).getCommandCost(user);
|
||||
if (costPrice.signum() > 0)
|
||||
{
|
||||
cost = _("kitCost", NumberUtil.displayCurrency(costPrice, ess));
|
||||
}
|
||||
final Map<String, Object> kit = ess.getSettings().getKit(kitItem);
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
if (Kit.getNextUse(user, kitItem, kit) != 0)
|
||||
{
|
||||
name = _("kitDelay", name);
|
||||
}
|
||||
public class Kit {
|
||||
final IEssentials ess;
|
||||
final String kitName;
|
||||
final Map<String, Object> kit;
|
||||
final Trade charge;
|
||||
|
||||
list.append(" ").append(name).append(cost);
|
||||
}
|
||||
}
|
||||
return list.toString().trim();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(_("kitError"), ex);
|
||||
}
|
||||
public Kit(final String kitName, final IEssentials ess) throws Exception {
|
||||
this.kitName = kitName;
|
||||
this.ess = ess;
|
||||
this.kit = ess.getKits().getKit(kitName);
|
||||
this.charge = new Trade("kit-" + kitName, new Trade("kit-kit", ess), ess);
|
||||
|
||||
}
|
||||
if (kit == null) {
|
||||
throw new Exception(tl("kitNotFound"));
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkTime(final User user, final String kitName, final Map<String, Object> els) throws Exception
|
||||
{
|
||||
final Calendar time = new GregorianCalendar();
|
||||
long nextUse = getNextUse(user, kitName, els);
|
||||
public String getName() {
|
||||
return kitName;
|
||||
}
|
||||
|
||||
if (nextUse == 0L)
|
||||
{
|
||||
user.setKitTimestamp(kitName, time.getTimeInMillis());
|
||||
}
|
||||
else if (nextUse < 0L)
|
||||
{
|
||||
user.sendMessage(_("kitOnce"));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(_("kitTimed", DateUtil.formatDateDiff(nextUse)));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
public void checkPerms(final User user) throws Exception {
|
||||
if (!user.isAuthorized("essentials.kits." + kitName)) {
|
||||
throw new Exception(tl("noKitPermission", "essentials.kits." + kitName));
|
||||
}
|
||||
}
|
||||
|
||||
public static long getNextUse(final User user, final String kitName, final Map<String, Object> els) throws Exception
|
||||
{
|
||||
if (user.isAuthorized("essentials.kit.exemptdelay"))
|
||||
{
|
||||
return 0L;
|
||||
}
|
||||
public void checkDelay(final User user) throws Exception {
|
||||
final long nextUse = getNextUse(user);
|
||||
|
||||
final Calendar time = new GregorianCalendar();
|
||||
if (nextUse == 0L) {
|
||||
} else if (nextUse < 0L) {
|
||||
user.sendMessage(tl("kitOnce"));
|
||||
throw new NoChargeException();
|
||||
} else {
|
||||
user.sendMessage(tl("kitTimed", DateUtil.formatDateDiff(nextUse)));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
||||
double delay = 0;
|
||||
try
|
||||
{
|
||||
// Make sure delay is valid
|
||||
delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0.0d;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Exception(_("kitError2"));
|
||||
}
|
||||
public void checkAffordable(final User user) throws Exception {
|
||||
charge.isAffordableFor(user);
|
||||
}
|
||||
|
||||
// When was the last kit used?
|
||||
final long lastTime = user.getKitTimestamp(kitName);
|
||||
public void setTime(final User user) throws Exception {
|
||||
final Calendar time = new GregorianCalendar();
|
||||
user.setKitTimestamp(kitName, time.getTimeInMillis());
|
||||
}
|
||||
|
||||
// When can be use the kit again?
|
||||
final Calendar delayTime = new GregorianCalendar();
|
||||
delayTime.setTimeInMillis(lastTime);
|
||||
delayTime.add(Calendar.SECOND, (int)delay);
|
||||
delayTime.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
|
||||
public void chargeUser(final User user) throws Exception {
|
||||
charge.charge(user);
|
||||
}
|
||||
|
||||
if (lastTime == 0L || lastTime > time.getTimeInMillis())
|
||||
{
|
||||
// If we have no record of kit use, or its corrupted, give them benifit of the doubt.
|
||||
return 0L;
|
||||
}
|
||||
else if (delay < 0d)
|
||||
{
|
||||
// If the kit has a negative kit time, it can only be used once.
|
||||
return -1;
|
||||
}
|
||||
else if (delayTime.before(time))
|
||||
{
|
||||
// If the kit was used in the past, but outside the delay time, it can be used.
|
||||
return 0L;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the kit has been used recently, return the next time it can be used.
|
||||
return delayTime.getTimeInMillis();
|
||||
}
|
||||
}
|
||||
public long getNextUse(final User user) throws Exception {
|
||||
if (user.isAuthorized("essentials.kit.exemptdelay")) {
|
||||
return 0L;
|
||||
}
|
||||
|
||||
public static List<String> getItems(final IEssentials ess, final User user, final String kitName, final Map<String, Object> kit) throws Exception
|
||||
{
|
||||
if (kit == null)
|
||||
{
|
||||
throw new Exception(_("kitNotFound"));
|
||||
}
|
||||
try
|
||||
{
|
||||
final List<String> itemList = new ArrayList<String>();
|
||||
final Object kitItems = kit.get("items");
|
||||
if (kitItems instanceof List)
|
||||
{
|
||||
for (Object item : (List)kitItems)
|
||||
{
|
||||
if (item instanceof String)
|
||||
{
|
||||
itemList.add(item.toString());
|
||||
continue;
|
||||
}
|
||||
throw new Exception("Invalid kit item: " + item.toString());
|
||||
}
|
||||
return itemList;
|
||||
}
|
||||
throw new Exception("Invalid item list");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ess.getLogger().log(Level.WARNING, "Error parsing kit " + kitName + ": " + e.getMessage());
|
||||
throw new Exception(_("kitError2"), e);
|
||||
}
|
||||
}
|
||||
final Calendar time = new GregorianCalendar();
|
||||
|
||||
public static void expandItems(final IEssentials ess, final User user, final List<String> items) throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
IText input = new SimpleTextInput(items);
|
||||
IText output = new KeywordReplacer(input, user.getSource(), ess);
|
||||
double delay = 0;
|
||||
try {
|
||||
// Make sure delay is valid
|
||||
delay = kit.containsKey("delay") ? ((Number) kit.get("delay")).doubleValue() : 0.0d;
|
||||
} catch (final Exception e) {
|
||||
throw new Exception(tl("kitError2"));
|
||||
}
|
||||
|
||||
boolean spew = false;
|
||||
final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
|
||||
for (String kitItem : output.getLines())
|
||||
{
|
||||
if (kitItem.startsWith(ess.getSettings().getCurrencySymbol()))
|
||||
{
|
||||
BigDecimal value = new BigDecimal(kitItem.substring(ess.getSettings().getCurrencySymbol().length()).trim());
|
||||
Trade t = new Trade(value, ess);
|
||||
t.pay(user, OverflowType.DROP);
|
||||
continue;
|
||||
}
|
||||
// When was the last kit used?
|
||||
final long lastTime = user.getKitTimestamp(kitName);
|
||||
|
||||
final String[] parts = kitItem.split(" +");
|
||||
final ItemStack parseStack = ess.getItemDb().get(parts[0], parts.length > 1 ? Integer.parseInt(parts[1]) : 1);
|
||||
|
||||
if (parseStack.getType() == Material.AIR) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final MetaItemStack metaStack = new MetaItemStack(parseStack);
|
||||
// When can be use the kit again?
|
||||
final Calendar delayTime = new GregorianCalendar();
|
||||
delayTime.setTimeInMillis(lastTime);
|
||||
delayTime.add(Calendar.SECOND, (int) delay);
|
||||
delayTime.add(Calendar.MILLISECOND, (int) ((delay * 1000.0) % 1000.0));
|
||||
|
||||
if (parts.length > 2)
|
||||
{
|
||||
// We pass a null sender here because kits should not do perm checks
|
||||
metaStack.parseStringMeta(null, allowUnsafe, parts, 2, ess);
|
||||
}
|
||||
if (lastTime == 0L || lastTime > time.getTimeInMillis()) {
|
||||
// If we have no record of kit use, or its corrupted, give them benefit of the doubt.
|
||||
return 0L;
|
||||
} else if (delay < 0d) {
|
||||
// If the kit has a negative kit time, it can only be used once.
|
||||
return -1;
|
||||
} else if (delayTime.before(time)) {
|
||||
// If the kit was used in the past, but outside the delay time, it can be used.
|
||||
return 0L;
|
||||
} else {
|
||||
// If the kit has been used recently, return the next time it can be used.
|
||||
return delayTime.getTimeInMillis();
|
||||
}
|
||||
}
|
||||
|
||||
final Map<Integer, ItemStack> overfilled;
|
||||
final boolean allowOversizedStacks = user.isAuthorized("essentials.oversizedstacks");
|
||||
if (allowOversizedStacks)
|
||||
{
|
||||
overfilled = InventoryWorkaround.addOversizedItems(user.getInventory(), ess.getSettings().getOversizedStackSize(), metaStack.getItemStack());
|
||||
}
|
||||
else
|
||||
{
|
||||
overfilled = InventoryWorkaround.addItems(user.getInventory(), metaStack.getItemStack());
|
||||
}
|
||||
for (ItemStack itemStack : overfilled.values())
|
||||
{
|
||||
int spillAmount = itemStack.getAmount();
|
||||
if (!allowOversizedStacks) {
|
||||
itemStack.setAmount(spillAmount < itemStack.getMaxStackSize() ? spillAmount : itemStack.getMaxStackSize());
|
||||
}
|
||||
while (spillAmount > 0) {
|
||||
user.getWorld().dropItemNaturally(user.getLocation(), itemStack);
|
||||
spillAmount -= itemStack.getAmount();
|
||||
}
|
||||
spew = true;
|
||||
}
|
||||
}
|
||||
user.updateInventory();
|
||||
if (spew)
|
||||
{
|
||||
user.sendMessage(_("kitInvFull"));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
user.updateInventory();
|
||||
ess.getLogger().log(Level.WARNING, e.getMessage());
|
||||
throw new Exception(_("kitError2"), e);
|
||||
}
|
||||
}
|
||||
@Deprecated
|
||||
public List<String> getItems(final User user) throws Exception {
|
||||
return getItems();
|
||||
}
|
||||
|
||||
public List<String> getItems() throws Exception {
|
||||
if (kit == null) {
|
||||
throw new Exception(tl("kitNotFound"));
|
||||
}
|
||||
try {
|
||||
final List<String> itemList = new ArrayList<>();
|
||||
final Object kitItems = kit.get("items");
|
||||
if (kitItems instanceof List) {
|
||||
for (final Object item : (List) kitItems) {
|
||||
if (item instanceof String) {
|
||||
itemList.add(item.toString());
|
||||
continue;
|
||||
}
|
||||
throw new Exception("Invalid kit item: " + item.toString());
|
||||
}
|
||||
return itemList;
|
||||
}
|
||||
throw new Exception("Invalid item list");
|
||||
} catch (final Exception e) {
|
||||
ess.getLogger().log(Level.WARNING, "Error parsing kit " + kitName + ": " + e.getMessage());
|
||||
throw new Exception(tl("kitError2"), e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean expandItems(final User user) throws Exception {
|
||||
return expandItems(user, getItems(user));
|
||||
}
|
||||
|
||||
public boolean expandItems(final User user, final List<String> items) throws Exception {
|
||||
try {
|
||||
final IText input = new SimpleTextInput(items);
|
||||
final IText output = new KeywordReplacer(input, user.getSource(), ess, true, true);
|
||||
|
||||
final KitClaimEvent event = new KitClaimEvent(user, this);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean spew = false;
|
||||
final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
|
||||
final boolean currencyIsSuffix = ess.getSettings().isCurrencySymbolSuffixed();
|
||||
final List<ItemStack> itemList = new ArrayList<>();
|
||||
final List<String> commandQueue = new ArrayList<>();
|
||||
final List<String> moneyQueue = new ArrayList<>();
|
||||
for (final String kitItem : output.getLines()) {
|
||||
if (!currencyIsSuffix ? kitItem.startsWith(ess.getSettings().getCurrencySymbol()) : kitItem.endsWith(ess.getSettings().getCurrencySymbol())) {
|
||||
moneyQueue.add(NumberUtil.sanitizeCurrencyString(kitItem, ess));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (kitItem.startsWith("/")) {
|
||||
String command = kitItem.substring(1);
|
||||
final String name = user.getName();
|
||||
command = command.replace("{player}", name);
|
||||
commandQueue.add(command);
|
||||
continue;
|
||||
}
|
||||
|
||||
final String[] parts = kitItem.split(" +");
|
||||
final ItemStack parseStack = ess.getItemDb().get(parts[0], parts.length > 1 ? Integer.parseInt(parts[1]) : 1);
|
||||
|
||||
if (parseStack.getType() == Material.AIR) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final MetaItemStack metaStack = new MetaItemStack(parseStack);
|
||||
|
||||
if (parts.length > 2) {
|
||||
// We pass a null sender here because kits should not do perm checks
|
||||
metaStack.parseStringMeta(null, allowUnsafe, parts, 2, ess);
|
||||
}
|
||||
|
||||
itemList.add(metaStack.getItemStack());
|
||||
}
|
||||
|
||||
final Map<Integer, ItemStack> overfilled;
|
||||
final boolean allowOversizedStacks = user.isAuthorized("essentials.oversizedstacks");
|
||||
final boolean isDropItemsIfFull = ess.getSettings().isDropItemsIfFull();
|
||||
if (isDropItemsIfFull) {
|
||||
if (allowOversizedStacks) {
|
||||
overfilled = InventoryWorkaround.addOversizedItems(user.getBase().getInventory(), ess.getSettings().getOversizedStackSize(), itemList.toArray(new ItemStack[0]));
|
||||
} else {
|
||||
overfilled = InventoryWorkaround.addItems(user.getBase().getInventory(), itemList.toArray(new ItemStack[0]));
|
||||
}
|
||||
for (final ItemStack itemStack : overfilled.values()) {
|
||||
int spillAmount = itemStack.getAmount();
|
||||
if (!allowOversizedStacks) {
|
||||
itemStack.setAmount(Math.min(spillAmount, itemStack.getMaxStackSize()));
|
||||
}
|
||||
while (spillAmount > 0) {
|
||||
user.getWorld().dropItemNaturally(user.getLocation(), itemStack);
|
||||
spillAmount -= itemStack.getAmount();
|
||||
}
|
||||
spew = true;
|
||||
}
|
||||
} else {
|
||||
if (allowOversizedStacks) {
|
||||
overfilled = InventoryWorkaround.addAllOversizedItems(user.getBase().getInventory(), ess.getSettings().getOversizedStackSize(), itemList.toArray(new ItemStack[0]));
|
||||
} else {
|
||||
overfilled = InventoryWorkaround.addAllItems(user.getBase().getInventory(), itemList.toArray(new ItemStack[0]));
|
||||
}
|
||||
if (overfilled != null) {
|
||||
user.sendMessage(tl("kitInvFullNoDrop"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
user.getBase().updateInventory();
|
||||
|
||||
// Process money & command queues
|
||||
// Done after all items have been processed so commands are not run and money is not given if
|
||||
// an error occurs during the item giving process
|
||||
for (final String valueString : moneyQueue) {
|
||||
final BigDecimal value = new BigDecimal(valueString.trim());
|
||||
final Trade t = new Trade(value, ess);
|
||||
t.pay(user, OverflowType.DROP);
|
||||
}
|
||||
|
||||
for (final String cmd : commandQueue) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
}
|
||||
|
||||
if (spew) {
|
||||
user.sendMessage(tl("kitInvFull"));
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
user.getBase().updateInventory();
|
||||
ess.getLogger().log(Level.WARNING, e.getMessage());
|
||||
throw new Exception(tl("kitError2"), e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.MemoryConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.earth2me.essentials.I18n.capitalCase;
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Kits implements IConf {
|
||||
|
||||
private final EssentialsConf config;
|
||||
private ConfigurationSection kits;
|
||||
|
||||
public Kits(final IEssentials essentials) {
|
||||
config = new EssentialsConf(new File(essentials.getDataFolder(), "kits.yml"));
|
||||
config.setTemplateName("/kits.yml");
|
||||
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
config.load();
|
||||
kits = _getKits();
|
||||
}
|
||||
|
||||
private ConfigurationSection _getKits() {
|
||||
if (config.isConfigurationSection("kits")) {
|
||||
final ConfigurationSection section = config.getConfigurationSection("kits");
|
||||
final ConfigurationSection newSection = new MemoryConfiguration();
|
||||
for (final String kitItem : section.getKeys(false)) {
|
||||
if (section.isConfigurationSection(kitItem)) {
|
||||
newSection.set(kitItem.toLowerCase(Locale.ENGLISH), section.getConfigurationSection(kitItem));
|
||||
}
|
||||
}
|
||||
return newSection;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public EssentialsConf getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public ConfigurationSection getKits() {
|
||||
return kits;
|
||||
}
|
||||
|
||||
public Map<String, Object> getKit(String name) {
|
||||
name = name.replace('.', '_').replace('/', '_');
|
||||
if (getKits() != null) {
|
||||
final ConfigurationSection kits = getKits();
|
||||
// For some reason, YAML doesn't sees keys as always lowercase even if they aren't defined like that.
|
||||
// Workaround is to toLowercase when getting from the config, but showing normally elsewhere.
|
||||
// ODDLY ENOUGH when you get the configuration section for ALL kits, it will return the proper
|
||||
// case of each kit. But when you check for each kit's configuration section, it won't return the kit
|
||||
// you just found if you don't toLowercase it.
|
||||
if (kits.isConfigurationSection(name.toLowerCase())) {
|
||||
return kits.getConfigurationSection(name.toLowerCase()).getValues(true);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Tries to find an existing kit name that matches the given name, ignoring case. Returns null if no match.
|
||||
public String matchKit(final String name) {
|
||||
if (config.isConfigurationSection("kits")) {
|
||||
final ConfigurationSection section = config.getConfigurationSection("kits");
|
||||
if (section != null) {
|
||||
for (final String kitName : section.getKeys(false)) {
|
||||
if (kitName.equalsIgnoreCase(name)) {
|
||||
return kitName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addKit(final String name, final List<String> lines, final long delay) {
|
||||
// Will overwrite but w/e
|
||||
config.set("kits." + name + ".delay", delay);
|
||||
config.set("kits." + name + ".items", lines);
|
||||
kits = _getKits();
|
||||
config.save();
|
||||
}
|
||||
|
||||
public void removeKit(final String name) {
|
||||
config.set("kits." + name, null);
|
||||
kits = _getKits();
|
||||
config.save();
|
||||
}
|
||||
|
||||
public String listKits(final net.ess3.api.IEssentials ess, final User user) throws Exception {
|
||||
try {
|
||||
final ConfigurationSection kits = config.getConfigurationSection("kits");
|
||||
final StringBuilder list = new StringBuilder();
|
||||
for (final String kitItem : kits.getKeys(false)) {
|
||||
if (user == null) {
|
||||
list.append(" ").append(capitalCase(kitItem));
|
||||
} else if (user.isAuthorized("essentials.kits." + kitItem.toLowerCase(Locale.ENGLISH))) {
|
||||
String cost = "";
|
||||
String name = capitalCase(kitItem);
|
||||
final BigDecimal costPrice = new Trade("kit-" + kitItem.toLowerCase(Locale.ENGLISH), ess).getCommandCost(user);
|
||||
if (costPrice.signum() > 0) {
|
||||
cost = tl("kitCost", NumberUtil.displayCurrency(costPrice, ess));
|
||||
}
|
||||
|
||||
final Kit kit = new Kit(kitItem, ess);
|
||||
final double nextUse = kit.getNextUse(user);
|
||||
if (nextUse == -1 && ess.getSettings().isSkippingUsedOneTimeKitsFromKitList()) {
|
||||
continue;
|
||||
} else if (nextUse != 0) {
|
||||
name = tl("kitDelay", name);
|
||||
}
|
||||
|
||||
list.append(" ").append(name).append(cost);
|
||||
}
|
||||
}
|
||||
return list.toString().trim();
|
||||
} catch (final Exception ex) {
|
||||
throw new Exception(tl("kitError"), ex);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,19 +2,15 @@ package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class LocationTarget implements ITarget {
|
||||
private final Location location;
|
||||
|
||||
public class LocationTarget implements ITarget
|
||||
{
|
||||
private final Location location;
|
||||
LocationTarget(final Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
LocationTarget(Location location)
|
||||
{
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation()
|
||||
{
|
||||
return location;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,18 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.io.*;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
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;
|
||||
@@ -11,218 +22,133 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class ManagedFile
|
||||
{
|
||||
private static final int BUFFERSIZE = 1024 * 8;
|
||||
private final transient File file;
|
||||
public class ManagedFile {
|
||||
private static final int BUFFERSIZE = 1024 * 8;
|
||||
private final transient File file;
|
||||
|
||||
public ManagedFile(final String filename, final IEssentials ess)
|
||||
{
|
||||
file = new File(ess.getDataFolder(), filename);
|
||||
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 {
|
||||
if (checkForVersion(file, ess.getDescription().getVersion()) && !file.delete()) {
|
||||
throw new IOException("Could not delete file " + file.toString());
|
||||
}
|
||||
} catch (final 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, _("itemsCsvNotLoaded"), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
copyResourceAscii("/" + filename, file);
|
||||
} catch (final IOException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, tl("itemsCsvNotLoaded", filename), 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 void copyResourceAscii(final String resourceName, final File file) throws IOException {
|
||||
try (final InputStreamReader reader = new InputStreamReader(ManagedFile.class.getResourceAsStream(resourceName))) {
|
||||
final MessageDigest digest = getDigest();
|
||||
try (final DigestOutputStream digestStream = new DigestOutputStream(new FileOutputStream(file), digest)) {
|
||||
try (final OutputStreamWriter writer = new OutputStreamWriter(digestStream)) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 != null && hash.matches("#[a-f0-9]{32}"))
|
||||
{
|
||||
hash = hash.substring(1);
|
||||
bais.reset();
|
||||
final String versionline = reader.readLine();
|
||||
if (versionline != null && 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 boolean checkForVersion(final File file, final String version) throws IOException {
|
||||
if (file.length() < 33) {
|
||||
return false;
|
||||
}
|
||||
try (final BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file))) {
|
||||
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;
|
||||
}
|
||||
try (final BufferedReader reader = new BufferedReader(new InputStreamReader(bais))) {
|
||||
String hash = reader.readLine();
|
||||
if (hash != null && hash.matches("#[a-f0-9]{32}")) {
|
||||
hash = hash.substring(1);
|
||||
bais.reset();
|
||||
final String versionline = reader.readLine();
|
||||
if (versionline != null && versionline.matches("#version: .+")) {
|
||||
final String versioncheck = versionline.substring(10);
|
||||
if (!versioncheck.equalsIgnoreCase(version)) {
|
||||
bais.reset();
|
||||
final MessageDigest digest = getDigest();
|
||||
try (final DigestInputStream digestStream = new DigestInputStream(bais, digest)) {
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static MessageDigest getDigest() throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
return MessageDigest.getInstance("MD5");
|
||||
}
|
||||
catch (NoSuchAlgorithmException ex)
|
||||
{
|
||||
throw new IOException(ex);
|
||||
}
|
||||
}
|
||||
public static MessageDigest getDigest() throws IOException {
|
||||
try {
|
||||
return MessageDigest.getInstance("MD5");
|
||||
} catch (final 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();
|
||||
}
|
||||
}
|
||||
public List<String> getLines() {
|
||||
try {
|
||||
try (final BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
final List<String> lines = new ArrayList<>();
|
||||
do {
|
||||
final String line = reader.readLine();
|
||||
if (line == null) {
|
||||
break;
|
||||
} else {
|
||||
lines.add(line);
|
||||
}
|
||||
} while (true);
|
||||
return lines;
|
||||
}
|
||||
} catch (final IOException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,138 +1,192 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
// Suffixes can be appended on the end of a mob name to make it plural
|
||||
// Entities without a suffix, will default to 's'
|
||||
public enum Mob
|
||||
{
|
||||
CHICKEN("Chicken", Enemies.FRIENDLY, EntityType.CHICKEN),
|
||||
COW("Cow", Enemies.FRIENDLY, EntityType.COW),
|
||||
CREEPER("Creeper", Enemies.ENEMY, EntityType.CREEPER),
|
||||
GHAST("Ghast", Enemies.ENEMY, EntityType.GHAST),
|
||||
GIANT("Giant", Enemies.ENEMY, EntityType.GIANT),
|
||||
HORSE("Horse", Enemies.FRIENDLY, EntityType.HORSE),
|
||||
PIG("Pig", Enemies.FRIENDLY, EntityType.PIG),
|
||||
PIGZOMB("PigZombie", Enemies.NEUTRAL, EntityType.PIG_ZOMBIE),
|
||||
SHEEP("Sheep", Enemies.FRIENDLY, "", EntityType.SHEEP),
|
||||
SKELETON("Skeleton", Enemies.ENEMY, EntityType.SKELETON),
|
||||
SLIME("Slime", Enemies.ENEMY, EntityType.SLIME),
|
||||
SPIDER("Spider", Enemies.ENEMY, EntityType.SPIDER),
|
||||
SQUID("Squid", Enemies.FRIENDLY, EntityType.SQUID),
|
||||
ZOMBIE("Zombie", Enemies.ENEMY, EntityType.ZOMBIE),
|
||||
WOLF("Wolf", Enemies.NEUTRAL, "", EntityType.WOLF),
|
||||
CAVESPIDER("CaveSpider", Enemies.ENEMY, EntityType.CAVE_SPIDER),
|
||||
ENDERMAN("Enderman", Enemies.ENEMY, "", EntityType.ENDERMAN),
|
||||
SILVERFISH("Silverfish", Enemies.ENEMY, "", EntityType.SILVERFISH),
|
||||
ENDERDRAGON("EnderDragon", Enemies.ENEMY, EntityType.ENDER_DRAGON),
|
||||
VILLAGER("Villager", Enemies.FRIENDLY, EntityType.VILLAGER),
|
||||
BLAZE("Blaze", Enemies.ENEMY, EntityType.BLAZE),
|
||||
MUSHROOMCOW("MushroomCow", Enemies.FRIENDLY, EntityType.MUSHROOM_COW),
|
||||
MAGMACUBE("MagmaCube", Enemies.ENEMY, EntityType.MAGMA_CUBE),
|
||||
SNOWMAN("Snowman", Enemies.FRIENDLY, "", EntityType.SNOWMAN),
|
||||
OCELOT("Ocelot", Enemies.NEUTRAL, EntityType.OCELOT),
|
||||
IRONGOLEM("IronGolem", Enemies.NEUTRAL, EntityType.IRON_GOLEM),
|
||||
WITHER("Wither", Enemies.ENEMY, EntityType.WITHER),
|
||||
BAT("Bat", Enemies.FRIENDLY, EntityType.BAT),
|
||||
WITCH("Witch", Enemies.ENEMY, EntityType.WITCH),
|
||||
BOAT("Boat", Enemies.NEUTRAL, EntityType.BOAT),
|
||||
MINECART("Minecart", Enemies.NEUTRAL, EntityType.MINECART),
|
||||
MINECART_CHEST("ChestMinecart", Enemies.NEUTRAL, EntityType.MINECART_CHEST),
|
||||
MINECART_FURNACE("FurnaceMinecart", Enemies.NEUTRAL, EntityType.MINECART_FURNACE),
|
||||
MINECART_TNT("TNTMinecart", Enemies.NEUTRAL, EntityType.MINECART_TNT),
|
||||
MINECART_HOPPER("HopperMinecart", Enemies.NEUTRAL, EntityType.MINECART_HOPPER),
|
||||
MINECART_MOB_SPAWNER("SpawnerMinecart", Enemies.NEUTRAL, EntityType.MINECART_MOB_SPAWNER),
|
||||
ENDERCRYSTAL("EnderCrystal", Enemies.NEUTRAL, EntityType.ENDER_CRYSTAL),
|
||||
EXPERIENCEORB("ExperienceOrb", Enemies.NEUTRAL, EntityType.EXPERIENCE_ORB);
|
||||
public static final Logger logger = Logger.getLogger("Essentials");
|
||||
public enum Mob {
|
||||
CHICKEN("Chicken", Enemies.FRIENDLY, EntityType.CHICKEN),
|
||||
COW("Cow", Enemies.FRIENDLY, EntityType.COW),
|
||||
CREEPER("Creeper", Enemies.ENEMY, EntityType.CREEPER),
|
||||
GHAST("Ghast", Enemies.ENEMY, EntityType.GHAST),
|
||||
GIANT("Giant", Enemies.ENEMY, EntityType.GIANT),
|
||||
HORSE("Horse", Enemies.FRIENDLY, EntityType.HORSE),
|
||||
PIG("Pig", Enemies.FRIENDLY, EntityType.PIG),
|
||||
PIGZOMB("PigZombie", Enemies.NEUTRAL, MobCompat.ZOMBIFIED_PIGLIN),
|
||||
ZOMBIFIED_PIGLIN("ZombifiedPiglin", Enemies.NEUTRAL, MobCompat.ZOMBIFIED_PIGLIN),
|
||||
SHEEP("Sheep", Enemies.FRIENDLY, "", EntityType.SHEEP),
|
||||
SKELETON("Skeleton", Enemies.ENEMY, EntityType.SKELETON),
|
||||
SLIME("Slime", Enemies.ENEMY, EntityType.SLIME),
|
||||
SPIDER("Spider", Enemies.ENEMY, EntityType.SPIDER),
|
||||
SQUID("Squid", Enemies.FRIENDLY, EntityType.SQUID),
|
||||
ZOMBIE("Zombie", Enemies.ENEMY, EntityType.ZOMBIE),
|
||||
WOLF("Wolf", Enemies.NEUTRAL, "", EntityType.WOLF),
|
||||
CAVESPIDER("CaveSpider", Enemies.ENEMY, EntityType.CAVE_SPIDER),
|
||||
ENDERMAN("Enderman", Enemies.ENEMY, "", EntityType.ENDERMAN),
|
||||
SILVERFISH("Silverfish", Enemies.ENEMY, "", EntityType.SILVERFISH),
|
||||
ENDERDRAGON("EnderDragon", Enemies.ENEMY, EntityType.ENDER_DRAGON),
|
||||
VILLAGER("Villager", Enemies.FRIENDLY, EntityType.VILLAGER),
|
||||
BLAZE("Blaze", Enemies.ENEMY, EntityType.BLAZE),
|
||||
MUSHROOMCOW("MushroomCow", Enemies.FRIENDLY, EntityType.MUSHROOM_COW),
|
||||
MAGMACUBE("MagmaCube", Enemies.ENEMY, EntityType.MAGMA_CUBE),
|
||||
SNOWMAN("Snowman", Enemies.FRIENDLY, "", EntityType.SNOWMAN),
|
||||
OCELOT("Ocelot", Enemies.NEUTRAL, EntityType.OCELOT),
|
||||
IRONGOLEM("IronGolem", Enemies.NEUTRAL, EntityType.IRON_GOLEM),
|
||||
WITHER("Wither", Enemies.ENEMY, EntityType.WITHER),
|
||||
BAT("Bat", Enemies.FRIENDLY, EntityType.BAT),
|
||||
WITCH("Witch", Enemies.ENEMY, EntityType.WITCH),
|
||||
BOAT("Boat", Enemies.NEUTRAL, EntityType.BOAT),
|
||||
MINECART("Minecart", Enemies.NEUTRAL, EntityType.MINECART),
|
||||
MINECART_CHEST("ChestMinecart", Enemies.NEUTRAL, EntityType.MINECART_CHEST),
|
||||
MINECART_FURNACE("FurnaceMinecart", Enemies.NEUTRAL, EntityType.MINECART_FURNACE),
|
||||
MINECART_TNT("TNTMinecart", Enemies.NEUTRAL, EntityType.MINECART_TNT),
|
||||
MINECART_HOPPER("HopperMinecart", Enemies.NEUTRAL, EntityType.MINECART_HOPPER),
|
||||
MINECART_MOB_SPAWNER("SpawnerMinecart", Enemies.NEUTRAL, EntityType.MINECART_MOB_SPAWNER),
|
||||
ENDERCRYSTAL("EnderCrystal", Enemies.NEUTRAL, EntityType.ENDER_CRYSTAL),
|
||||
EXPERIENCEORB("ExperienceOrb", Enemies.NEUTRAL, "EXPERIENCE_ORB"),
|
||||
ARMOR_STAND("ArmorStand", Enemies.NEUTRAL, "ARMOR_STAND"),
|
||||
ENDERMITE("Endermite", Enemies.ENEMY, "ENDERMITE"),
|
||||
GUARDIAN("Guardian", Enemies.ENEMY, "GUARDIAN"),
|
||||
ELDER_GUARDIAN("ElderGuardian", Enemies.ENEMY, "ELDER_GUARDIAN"),
|
||||
RABBIT("Rabbit", Enemies.FRIENDLY, "RABBIT"),
|
||||
SHULKER("Shulker", Enemies.ENEMY, "SHULKER"),
|
||||
POLAR_BEAR("PolarBear", Enemies.NEUTRAL, "POLAR_BEAR"),
|
||||
WITHER_SKELETON("WitherSkeleton", Enemies.ENEMY, "WITHER_SKELETON"),
|
||||
STRAY_SKELETON("StraySkeleton", Enemies.ENEMY, "STRAY"),
|
||||
ZOMBIE_VILLAGER("ZombieVillager", Enemies.FRIENDLY, "ZOMBIE_VILLAGER"),
|
||||
SKELETON_HORSE("SkeletonHorse", Enemies.FRIENDLY, "SKELETON_HORSE"),
|
||||
ZOMBIE_HORSE("ZombieHorse", Enemies.FRIENDLY, "ZOMBIE_HORSE"),
|
||||
DONKEY("Donkey", Enemies.FRIENDLY, "DONKEY"),
|
||||
MULE("Mule", Enemies.FRIENDLY, "MULE"),
|
||||
EVOKER("Evoker", Enemies.ENEMY, "EVOKER"),
|
||||
VEX("Vex", Enemies.ENEMY, "VEX"),
|
||||
VINDICATOR("Vindicator", Enemies.ENEMY, "VINDICATOR"),
|
||||
LLAMA("Llama", Enemies.NEUTRAL, "LLAMA"),
|
||||
HUSK("Husk", Enemies.ENEMY, "HUSK"),
|
||||
ILLUSIONER("Illusioner", Enemies.ENEMY, "ILLUSIONER"),
|
||||
PARROT("Parrot", Enemies.NEUTRAL, "PARROT"),
|
||||
TURTLE("Turtle", Enemies.NEUTRAL, "TURTLE"),
|
||||
PHANTOM("Phantom", Enemies.ENEMY, "PHANTOM"),
|
||||
COD("Cod", Enemies.NEUTRAL, "", "COD"),
|
||||
SALMON("Salmon", Enemies.NEUTRAL, "", "SALMON"),
|
||||
PUFFERFISH("Pufferfish", Enemies.NEUTRAL, "", "PUFFERFISH"),
|
||||
TROPICAL_FISH("TropicalFish", Enemies.NEUTRAL, "", "TROPICAL_FISH"),
|
||||
DROWNED("Drowned", Enemies.ENEMY, "DROWNED"),
|
||||
DOLPHIN("Dolphin", Enemies.NEUTRAL, "DOLPHIN"),
|
||||
CAT("Cat", Enemies.FRIENDLY, "CAT"),
|
||||
FOX("Fox", Enemies.FRIENDLY, "es", "FOX"),
|
||||
PANDA("Panda", Enemies.NEUTRAL, "PANDA"),
|
||||
PILLAGER("Pillager", Enemies.ENEMY, "PILLAGER"),
|
||||
RAVAGER("Ravager", Enemies.ENEMY, "RAVAGER"),
|
||||
TRADER_LLAMA("TraderLlama", Enemies.FRIENDLY, "TRADER_LLAMA"),
|
||||
WANDERING_TRADER("WanderingTrader", Enemies.FRIENDLY, "WANDERING_TRADER"),
|
||||
BEE("Bee", Enemies.NEUTRAL, "BEE"),
|
||||
STRAY("Stray", Enemies.ENEMY, "STRAY"),
|
||||
HOGLIN("Hoglin", Enemies.ADULT_ENEMY, "HOGLIN"),
|
||||
PIGLIN("Piglin", Enemies.ADULT_ENEMY, "PIGLIN"),
|
||||
STRIDER("Strider", Enemies.FRIENDLY, "STRIDER"),
|
||||
ZOGLIN("Zoglin", Enemies.ENEMY, "ZOGLIN"),
|
||||
PIGLIN_BRUTE("PiglinBrute", Enemies.ADULT_ENEMY, "PIGLIN_BRUTE"),
|
||||
;
|
||||
|
||||
private Mob(String n, Enemies en, String s, EntityType type)
|
||||
{
|
||||
this.suffix = s;
|
||||
this.name = n;
|
||||
this.type = en;
|
||||
this.bukkitType = type;
|
||||
}
|
||||
public static final Logger logger = Logger.getLogger("Essentials");
|
||||
private static final Map<String, Mob> hashMap = new HashMap<>();
|
||||
private static final Map<EntityType, Mob> bukkitMap = new HashMap<>();
|
||||
|
||||
private Mob(String n, Enemies en, EntityType type)
|
||||
{
|
||||
this.name = n;
|
||||
this.type = en;
|
||||
this.bukkitType = type;
|
||||
}
|
||||
public String suffix = "s";
|
||||
final public String name;
|
||||
final public Enemies type;
|
||||
final private EntityType bukkitType;
|
||||
private static final Map<String, Mob> hashMap = new HashMap<String, Mob>();
|
||||
private static final Map<EntityType, Mob> bukkitMap = new HashMap<EntityType, Mob>();
|
||||
static {
|
||||
for (final Mob mob : Mob.values()) {
|
||||
hashMap.put(mob.name.toLowerCase(Locale.ENGLISH), mob);
|
||||
if (mob.bukkitType != null) {
|
||||
bukkitMap.put(mob.bukkitType, mob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
for (Mob mob : Mob.values())
|
||||
{
|
||||
hashMap.put(mob.name.toLowerCase(Locale.ENGLISH), mob);
|
||||
bukkitMap.put(mob.bukkitType, mob);
|
||||
}
|
||||
}
|
||||
final public String name;
|
||||
final public Enemies type;
|
||||
final private EntityType bukkitType;
|
||||
public String suffix = "s";
|
||||
|
||||
public static Set<String> getMobList()
|
||||
{
|
||||
return Collections.unmodifiableSet(hashMap.keySet());
|
||||
}
|
||||
Mob(final String n, final Enemies en, final String s, final EntityType type) {
|
||||
this.suffix = s;
|
||||
this.name = n;
|
||||
this.type = en;
|
||||
this.bukkitType = type;
|
||||
}
|
||||
|
||||
public Entity spawn(final World world, final Server server, final Location loc) throws MobException
|
||||
{
|
||||
final Entity entity = world.spawn(loc, (Class<? extends Entity>)this.bukkitType.getEntityClass());
|
||||
if (entity == null)
|
||||
{
|
||||
logger.log(Level.WARNING, _("unableToSpawnMob"));
|
||||
throw new MobException();
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
Mob(final String n, final Enemies en, final EntityType type) {
|
||||
this.name = n;
|
||||
this.type = en;
|
||||
this.bukkitType = type;
|
||||
}
|
||||
|
||||
Mob(final String n, final Enemies en, final String s, final String typeName) {
|
||||
this.suffix = s;
|
||||
this.name = n;
|
||||
this.type = en;
|
||||
bukkitType = EnumUtil.getEntityType(typeName);
|
||||
}
|
||||
|
||||
public enum Enemies
|
||||
{
|
||||
FRIENDLY("friendly"),
|
||||
NEUTRAL("neutral"),
|
||||
ENEMY("enemy");
|
||||
Mob(final String n, final Enemies en, final String typeName) {
|
||||
this.name = n;
|
||||
this.type = en;
|
||||
bukkitType = EnumUtil.getEntityType(typeName);
|
||||
}
|
||||
|
||||
private Enemies(final String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
final protected String type;
|
||||
}
|
||||
public static Set<String> getMobList() {
|
||||
return Collections.unmodifiableSet(hashMap.keySet());
|
||||
}
|
||||
|
||||
public EntityType getType()
|
||||
{
|
||||
return bukkitType;
|
||||
}
|
||||
public static Mob fromName(final String name) {
|
||||
return hashMap.get(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public static Mob fromName(final String name)
|
||||
{
|
||||
return hashMap.get(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
public static Mob fromBukkitType(final EntityType type) {
|
||||
return bukkitMap.get(type);
|
||||
}
|
||||
|
||||
public static Mob fromBukkitType(final EntityType type)
|
||||
{
|
||||
return bukkitMap.get(type);
|
||||
}
|
||||
public Entity spawn(final World world, final Server server, final Location loc) throws MobException {
|
||||
final Entity entity = world.spawn(loc, this.bukkitType.getEntityClass());
|
||||
if (entity == null) {
|
||||
logger.log(Level.WARNING, tl("unableToSpawnMob"));
|
||||
throw new MobException();
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
public EntityType getType() {
|
||||
return bukkitType;
|
||||
}
|
||||
|
||||
public static class MobException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
public enum Enemies {
|
||||
FRIENDLY("friendly"),
|
||||
NEUTRAL("neutral"),
|
||||
ENEMY("enemy"),
|
||||
ADULT_ENEMY("adult_enemy");
|
||||
|
||||
final protected String type;
|
||||
|
||||
Enemies(final String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
public static class MobException extends Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import net.ess3.nms.refl.ReflUtil;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Fox;
|
||||
import org.bukkit.entity.Llama;
|
||||
import org.bukkit.entity.MushroomCow;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
import org.bukkit.entity.Panda;
|
||||
import org.bukkit.entity.Parrot;
|
||||
import org.bukkit.entity.TropicalFish;
|
||||
import org.bukkit.entity.Villager;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import static com.earth2me.essentials.utils.EnumUtil.getEntityType;
|
||||
|
||||
public final class MobCompat {
|
||||
|
||||
// Constants for mob interfaces added in later versions
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final Class RAIDER = ReflUtil.getClassCached("org.bukkit.entity.Raider");
|
||||
|
||||
// Constants for mobs added in later versions
|
||||
public static final EntityType LLAMA = getEntityType("LLAMA");
|
||||
public static final EntityType PARROT = getEntityType("PARROT");
|
||||
public static final EntityType TROPICAL_FISH = getEntityType("TROPICAL_FISH");
|
||||
public static final EntityType PANDA = getEntityType("PANDA");
|
||||
public static final EntityType TRADER_LLAMA = getEntityType("TRADER_LLAMA");
|
||||
public static final EntityType SHULKER = getEntityType("SHULKER");
|
||||
public static final EntityType STRAY = getEntityType("STRAY");
|
||||
public static final EntityType FOX = getEntityType("FOX");
|
||||
public static final EntityType PHANTOM = getEntityType("PHANTOM");
|
||||
|
||||
// Constants for mobs that have changed since earlier versions
|
||||
public static final EntityType CAT = getEntityType("CAT", "OCELOT");
|
||||
public static final EntityType ZOMBIFIED_PIGLIN = getEntityType("ZOMBIFIED_PIGLIN", "PIG_ZOMBIE");
|
||||
|
||||
private MobCompat() {
|
||||
}
|
||||
|
||||
// Older cats are Ocelots, whereas 1.14+ cats are Cats
|
||||
public static void setCatType(final Entity entity, final CatType type) {
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_14_R01)) {
|
||||
((Ocelot) entity).setCatType(Ocelot.Type.valueOf(type.ocelotTypeName));
|
||||
} else {
|
||||
final Class cat = ReflUtil.getClassCached("org.bukkit.entity.Cat");
|
||||
final Class catType = ReflUtil.getClassCached("org.bukkit.entity.Cat$Type");
|
||||
final Method setCatType = ReflUtil.getMethodCached(cat, "setCatType", catType);
|
||||
try {
|
||||
setCatType.invoke(entity, EnumUtil.valueOf(catType, type.catTypeName));
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Older villagers have professions and careers, 1.14+ villagers only have professions
|
||||
public static void setVillagerProfession(final Entity entity, final VillagerProfession profession) {
|
||||
if (!(entity instanceof Villager)) {
|
||||
return;
|
||||
}
|
||||
final Villager villager = (Villager) entity;
|
||||
villager.setProfession(profession.asEnum());
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_14_R01)) {
|
||||
final Class villagerCareer = ReflUtil.getClassCached("org.bukkit.entity.Villager$Career");
|
||||
final Method setCareer = ReflUtil.getMethodCached(Villager.class, "setCareer", villagerCareer);
|
||||
try {
|
||||
setCareer.invoke(entity, EnumUtil.valueOf(villagerCareer, profession.oldCareer));
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Only 1.14+ villagers have biome variants
|
||||
public static void setVillagerType(final Entity entity, final String type) {
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_14_R01)) {
|
||||
return;
|
||||
}
|
||||
if (entity instanceof Villager) {
|
||||
((Villager) entity).setVillagerType(Villager.Type.valueOf(type));
|
||||
}
|
||||
}
|
||||
|
||||
// Llamas only exist in 1.11+
|
||||
public static void setLlamaColor(final Entity entity, final String color) {
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_11_R01)) {
|
||||
return;
|
||||
}
|
||||
if (entity instanceof Llama) {
|
||||
((Llama) entity).setColor(Llama.Color.valueOf(color));
|
||||
}
|
||||
}
|
||||
|
||||
// Parrots only exist in 1.12+
|
||||
public static void setParrotVariant(final Entity entity, final String variant) {
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_12_0_R01)) {
|
||||
return;
|
||||
}
|
||||
if (entity instanceof Parrot) {
|
||||
((Parrot) entity).setVariant(Parrot.Variant.valueOf(variant));
|
||||
}
|
||||
}
|
||||
|
||||
// Tropical fish only exist in 1.13+
|
||||
public static void setTropicalFishPattern(final Entity entity, final String pattern) {
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_12_0_R01)) {
|
||||
return;
|
||||
}
|
||||
if (entity instanceof TropicalFish) {
|
||||
((TropicalFish) entity).setPattern(TropicalFish.Pattern.valueOf(pattern));
|
||||
}
|
||||
}
|
||||
|
||||
// Mushroom cow variant API only exists in 1.14+
|
||||
public static void setMooshroomVariant(final Entity entity, final String variant) {
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_14_R01)) {
|
||||
return;
|
||||
}
|
||||
if (entity instanceof MushroomCow) {
|
||||
((MushroomCow) entity).setVariant(MushroomCow.Variant.valueOf(variant));
|
||||
}
|
||||
}
|
||||
|
||||
// Pandas only exists in 1.14+
|
||||
public static void setPandaGene(final Entity entity, final String gene, final boolean mainGene) {
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_14_R01)) {
|
||||
return;
|
||||
}
|
||||
if (entity instanceof Panda) {
|
||||
final Panda panda = (Panda) entity;
|
||||
final Panda.Gene pandaGene = Panda.Gene.valueOf(gene);
|
||||
if (mainGene) {
|
||||
panda.setMainGene(pandaGene);
|
||||
} else {
|
||||
panda.setHiddenGene(pandaGene);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Foxes only exist in 1.14+
|
||||
public static void setFoxType(final Entity entity, final String type) {
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_14_R01)) {
|
||||
return;
|
||||
}
|
||||
if (entity instanceof Fox) {
|
||||
((Fox) entity).setFoxType(Fox.Type.valueOf(type));
|
||||
}
|
||||
}
|
||||
|
||||
public enum CatType {
|
||||
// These are (loosely) Mojang names for the cats
|
||||
SIAMESE("SIAMESE", "SIAMESE_CAT"),
|
||||
WHITE("WHITE", "SIAMESE_CAT"),
|
||||
RED("RED", "RED_CAT"),
|
||||
TABBY("TABBY", "RED_CAT"),
|
||||
TUXEDO("BLACK", "BLACK_CAT"),
|
||||
BRITISH_SHORTHAIR("BRITISH_SHORTHAIR", "SIAMESE_CAT"),
|
||||
CALICO("CALICO", "RED_CAT"),
|
||||
PERSIAN("PERSIAN", "RED_CAT"),
|
||||
RAGDOLL("RAGDOLL", "SIAMESE_CAT"),
|
||||
JELLIE("JELLIE", "SIAMESE_CAT"),
|
||||
BLACK("ALL_BLACK", "BLACK_CAT"),
|
||||
;
|
||||
|
||||
private final String catTypeName;
|
||||
private final String ocelotTypeName;
|
||||
|
||||
CatType(final String catTypeName, final String ocelotTypeName) {
|
||||
this.catTypeName = catTypeName;
|
||||
this.ocelotTypeName = ocelotTypeName;
|
||||
}
|
||||
}
|
||||
|
||||
public enum VillagerProfession {
|
||||
// These are 1.14+ villager professions mapped to their respective pre-V&P profession and career
|
||||
NONE("FARMER", "FARMER", "NONE"),
|
||||
ARMORER("BLACKSMITH", "ARMORER"),
|
||||
BUTCHER("FARMER", "BUTCHER"),
|
||||
CARTOGRAPHER("LIBRARIAN", "CARTOGRAPHER"),
|
||||
CLERIC("PRIEST", "CLERIC"),
|
||||
FARMER("FARMER", "FARMER"),
|
||||
FISHERMAN("FARMER", "FISHERMAN"),
|
||||
FLETCHER("FARMER", "FLETCHER"),
|
||||
LEATHERWORKER("BUTCHER", "LEATHERWORKER"),
|
||||
LIBRARIAN("LIBRARIAN", "LIBRARIAN"),
|
||||
MASON(null, null, "MASON"),
|
||||
NITWIT("NITWIT", "NITWIT"),
|
||||
SHEPHERD("FARMER", "SHEPHERD"),
|
||||
TOOLSMITH("BLACKSMITH", "TOOL_SMITH", "TOOLSMITH"),
|
||||
WEAPONSMITH("BLACKSMITH", "WEAPON_SMITH", "WEAPONSMITH"),
|
||||
;
|
||||
|
||||
private final String oldProfession;
|
||||
private final String oldCareer;
|
||||
private final String newProfession;
|
||||
|
||||
VillagerProfession(final String oldProfession, final String career) {
|
||||
this.oldProfession = oldProfession;
|
||||
this.oldCareer = career;
|
||||
this.newProfession = career;
|
||||
}
|
||||
|
||||
VillagerProfession(final String oldProfession, final String oldCareer, final String newProfession) {
|
||||
this.oldProfession = oldProfession;
|
||||
this.oldCareer = oldCareer;
|
||||
this.newProfession = newProfession;
|
||||
}
|
||||
|
||||
private Villager.Profession asEnum() {
|
||||
return EnumUtil.valueOf(Villager.Profession.class, newProfession, oldProfession);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Ageable;
|
||||
@@ -13,327 +12,393 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
import org.bukkit.entity.Phantom;
|
||||
import org.bukkit.entity.Pig;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Raider;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.entity.TropicalFish;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Colorable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public enum MobData
|
||||
{
|
||||
BABY_AGEABLE("baby", Ageable.class, Data.BABY, true),
|
||||
BABY_PIG("piglet", EntityType.PIG, Data.BABY, false),
|
||||
BABY_WOLF("puppy", EntityType.WOLF, Data.BABY, false),
|
||||
BABY_CHICKEN("chick", EntityType.CHICKEN, Data.BABY, false),
|
||||
BABY_HORSE("colt", EntityType.HORSE, Data.BABY, false),
|
||||
BABY_OCELOT("kitten", EntityType.OCELOT, Data.BABY, false),
|
||||
BABY_SHEEP("lamb", EntityType.SHEEP, Data.BABY, false),
|
||||
BABY_COW("calf", EntityType.COW.getEntityClass(), Data.BABY, false),
|
||||
BABY_VILLAGER("child", EntityType.VILLAGER, Data.BABY, false),
|
||||
TAMED_TAMEABLE("tamed", Tameable.class, Data.TAMED, true),
|
||||
TAME_TAMEABLE("tame", Tameable.class, Data.TAMED, false),
|
||||
RANDOM_SHEEP("random", EntityType.SHEEP, Data.COLORABLE, true),
|
||||
COLORABLE_SHEEP("", StringUtil.joinList(DyeColor.values()).toLowerCase(Locale.ENGLISH), EntityType.SHEEP, Data.COLORABLE, true),
|
||||
DONKEY_HORSE("donkey", EntityType.HORSE, Horse.Variant.DONKEY, true),
|
||||
MULE_HORSE("mule", EntityType.HORSE, Horse.Variant.MULE, true),
|
||||
SKELETON_HORSE("skeleton", EntityType.HORSE, Horse.Variant.SKELETON_HORSE, true),
|
||||
UNDEAD_HORSE("undead", EntityType.HORSE, Horse.Variant.UNDEAD_HORSE, true),
|
||||
ZOMBIE_HORSE("zombie", EntityType.HORSE, Horse.Variant.UNDEAD_HORSE, false),
|
||||
POLKA_HORSE("polka", EntityType.HORSE, Horse.Style.BLACK_DOTS, true),
|
||||
SOOTY_HORSE("sooty", EntityType.HORSE, Horse.Style.BLACK_DOTS, false),
|
||||
BLAZE_HORSE("blaze", EntityType.HORSE, Horse.Style.WHITE, true),
|
||||
SOCKS_HORSE("socks", EntityType.HORSE, Horse.Style.WHITE, false),
|
||||
LEOPARD_HORSE("leopard", EntityType.HORSE, Horse.Style.WHITE_DOTS, true),
|
||||
APPALOOSA_HORSE("appaloosa", EntityType.HORSE, Horse.Style.WHITE_DOTS, false),
|
||||
PAINT_HORSE("paint", EntityType.HORSE, Horse.Style.WHITEFIELD, true),
|
||||
MILKY_HORSE("milky", EntityType.HORSE, Horse.Style.WHITEFIELD, false),
|
||||
SPLOTCHY_HORSE("splotchy", EntityType.HORSE, Horse.Style.WHITEFIELD, false),
|
||||
BLACK_HORSE("black", EntityType.HORSE, Horse.Color.BLACK, true),
|
||||
CHESTNUT_HORSE("chestnut", EntityType.HORSE, Horse.Color.CHESTNUT, true),
|
||||
LIVER_HORSE("liver", EntityType.HORSE, Horse.Color.CHESTNUT, false),
|
||||
CREAMY_HORSE("creamy", EntityType.HORSE, Horse.Color.CREAMY, true),
|
||||
FLAXEN_HORSE("flaxen", EntityType.HORSE, Horse.Color.CREAMY, false),
|
||||
GRAY_HORSE("gray", EntityType.HORSE, Horse.Color.GRAY, true),
|
||||
DAPPLE_HORSE("dapple", EntityType.HORSE, Horse.Color.GRAY, false),
|
||||
BUCKSKIN_HORSE("buckskin", EntityType.HORSE, Horse.Color.DARK_BROWN, true),
|
||||
DARKBROWN_HORSE("darkbrown", EntityType.HORSE, Horse.Color.DARK_BROWN, false),
|
||||
DARK_HORSE("dark", EntityType.HORSE, Horse.Color.DARK_BROWN, false),
|
||||
DBROWN_HORSE("dbrown", EntityType.HORSE, Horse.Color.DARK_BROWN, false),
|
||||
BAY_HORSE("bay", EntityType.HORSE, Horse.Color.BROWN, true),
|
||||
BROWN_HORSE("brown", EntityType.HORSE, Horse.Color.BROWN, false),
|
||||
CHEST_HORSE("chest", EntityType.HORSE, Data.CHEST, true),
|
||||
SADDLE_HORSE("saddle", EntityType.HORSE, Data.HORSESADDLE, true),
|
||||
GOLD_ARMOR_HORSE("goldarmor", EntityType.HORSE, Material.GOLD_BARDING, true),
|
||||
DIAMOND_ARMOR_HORSE("diamondarmor", EntityType.HORSE, Material.DIAMOND_BARDING, true),
|
||||
ARMOR_HORSE("armor", EntityType.HORSE, Material.IRON_BARDING, true),
|
||||
SIAMESE_CAT("siamese", EntityType.OCELOT, Ocelot.Type.SIAMESE_CAT, true),
|
||||
WHITE_CAT("white", EntityType.OCELOT, Ocelot.Type.SIAMESE_CAT, false),
|
||||
RED_CAT("red", EntityType.OCELOT, Ocelot.Type.RED_CAT, true),
|
||||
ORANGE_CAT("orange", EntityType.OCELOT, Ocelot.Type.RED_CAT, false),
|
||||
TABBY_CAT("tabby", EntityType.OCELOT, Ocelot.Type.RED_CAT, false),
|
||||
BLACK_CAT("black", EntityType.OCELOT, Ocelot.Type.BLACK_CAT, true),
|
||||
TUXEDO_CAT("tuxedo", EntityType.OCELOT, Ocelot.Type.BLACK_CAT, false),
|
||||
VILLAGER_ZOMBIE("villager", EntityType.ZOMBIE.getEntityClass(), Data.VILLAGER, true),
|
||||
BABY_ZOMBIE("baby", EntityType.ZOMBIE.getEntityClass(), Data.BABYZOMBIE, true),
|
||||
DIAMOND_SWORD_ZOMBIE("diamondsword", EntityType.ZOMBIE.getEntityClass(), Material.DIAMOND_SWORD, true),
|
||||
GOLD_SWORD_ZOMBIE("goldsword", EntityType.ZOMBIE.getEntityClass(), Material.GOLD_SWORD, true),
|
||||
IRON_SWORD_ZOMBIE("ironsword", EntityType.ZOMBIE.getEntityClass(), Material.IRON_SWORD, true),
|
||||
STONE_SWORD_ZOMBIE("stonesword", EntityType.ZOMBIE.getEntityClass(), Material.STONE_SWORD, false),
|
||||
SWORD_ZOMBIE("sword", EntityType.ZOMBIE.getEntityClass(), Material.STONE_SWORD, true),
|
||||
DIAMOND_SWORD_SKELETON("diamondsword", EntityType.SKELETON, Material.DIAMOND_SWORD, true),
|
||||
GOLD_SWORD_SKELETON("goldsword", EntityType.SKELETON, Material.GOLD_SWORD, true),
|
||||
IRON_SWORD_SKELETON("ironsword", EntityType.SKELETON, Material.IRON_SWORD, true),
|
||||
STONE_SWORD_SKELETON("stonesword", EntityType.SKELETON, Material.STONE_SWORD, false),
|
||||
SWORD_SKELETON("sword", EntityType.SKELETON, Material.STONE_SWORD, true),
|
||||
BOW_SKELETON("bow", EntityType.SKELETON, Material.BOW, true),
|
||||
WHITHER_SKELETON("wither", EntityType.SKELETON, Data.WITHER, true),
|
||||
POWERED_CREEPER("powered", EntityType.CREEPER, Data.ELECTRIFIED, true),
|
||||
ELECTRIC_CREEPER("electric", EntityType.CREEPER, Data.ELECTRIFIED, false),
|
||||
CHARGED_CREEPER("charged", EntityType.CREEPER, Data.ELECTRIFIED, false),
|
||||
SADDLE_PIG("saddle", EntityType.PIG, Data.PIGSADDLE, true),
|
||||
ANGRY_WOLF("angry", EntityType.WOLF, Data.ANGRY, true),
|
||||
RABID_WOLF("rabid", EntityType.WOLF, Data.ANGRY, false),
|
||||
FARMER_VILLAGER("farmer", EntityType.VILLAGER, Villager.Profession.FARMER, true),
|
||||
LIBRARIAN_VILLAGER("librarian", EntityType.VILLAGER, Villager.Profession.LIBRARIAN, true),
|
||||
PRIEST_VILLAGER("priest", EntityType.VILLAGER, Villager.Profession.PRIEST, true),
|
||||
FATHER_VILLAGER("father", EntityType.VILLAGER, Villager.Profession.PRIEST, false),
|
||||
SMITH_VILLAGER("smith", EntityType.VILLAGER, Villager.Profession.BLACKSMITH, true),
|
||||
BUTCHER_VILLAGER("butcher", EntityType.VILLAGER, Villager.Profession.BUTCHER, true),
|
||||
SIZE_SLIME("", "<1-100>", EntityType.SLIME.getEntityClass(), Data.SIZE, true),
|
||||
NUM_EXPERIENCE_ORB("", "<1-2000000000>", EntityType.EXPERIENCE_ORB, Data.EXP, true);
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public enum MobData {
|
||||
|
||||
public enum Data
|
||||
{
|
||||
BABY,
|
||||
CHEST,
|
||||
BABYZOMBIE,
|
||||
VILLAGER,
|
||||
HORSESADDLE,
|
||||
PIGSADDLE,
|
||||
ELECTRIFIED,
|
||||
WITHER,
|
||||
ANGRY,
|
||||
TAMED,
|
||||
COLORABLE,
|
||||
EXP,
|
||||
SIZE;
|
||||
}
|
||||
public static final Logger logger = Logger.getLogger("Essentials");
|
||||
BABY_AGEABLE("baby", Ageable.class, Data.BABY, true),
|
||||
ADULT_AGEABLE("adult", Ageable.class, Data.ADULT, true),
|
||||
BABY_CAT("kitten", MobCompat.CAT, Data.BABY, false),
|
||||
BABY_PIG("piglet", EntityType.PIG, Data.BABY, false),
|
||||
BABY_WOLF("puppy", EntityType.WOLF, Data.BABY, false),
|
||||
BABY_CHICKEN("chick", EntityType.CHICKEN, Data.BABY, false),
|
||||
BABY_HORSE("colt", EntityType.HORSE, Data.BABY, false),
|
||||
BABY_OCELOT("kitten", EntityType.OCELOT, Data.BABY, false),
|
||||
BABY_SHEEP("lamb", EntityType.SHEEP, Data.BABY, false),
|
||||
BABY_COW("calf", EntityType.COW.getEntityClass(), Data.BABY, false),
|
||||
BABY_VILLAGER("child", EntityType.VILLAGER, Data.BABY, false),
|
||||
TAMED_TAMEABLE("tamed", Tameable.class, Data.TAMED, true),
|
||||
TAME_TAMEABLE("tame", Tameable.class, Data.TAMED, false),
|
||||
RANDOM_SHEEP("random", EntityType.SHEEP, Data.COLORABLE, true),
|
||||
COLORABLE_SHEEP("", Arrays.stream(DyeColor.values()).map(color -> color.name().toLowerCase(Locale.ENGLISH)).collect(Collectors.toList()), EntityType.SHEEP, Data.COLORABLE, true),
|
||||
POLKA_HORSE("polka", EntityType.HORSE, Horse.Style.BLACK_DOTS, true),
|
||||
SOOTY_HORSE("sooty", EntityType.HORSE, Horse.Style.BLACK_DOTS, false),
|
||||
BLAZE_HORSE("blaze", EntityType.HORSE, Horse.Style.WHITE, true),
|
||||
SOCKS_HORSE("socks", EntityType.HORSE, Horse.Style.WHITE, false),
|
||||
LEOPARD_HORSE("leopard", EntityType.HORSE, Horse.Style.WHITE_DOTS, true),
|
||||
APPALOOSA_HORSE("appaloosa", EntityType.HORSE, Horse.Style.WHITE_DOTS, false),
|
||||
PAINT_HORSE("paint", EntityType.HORSE, Horse.Style.WHITEFIELD, true),
|
||||
MILKY_HORSE("milky", EntityType.HORSE, Horse.Style.WHITEFIELD, false),
|
||||
SPLOTCHY_HORSE("splotchy", EntityType.HORSE, Horse.Style.WHITEFIELD, false),
|
||||
BLACK_HORSE("black", EntityType.HORSE, Horse.Color.BLACK, true),
|
||||
CHESTNUT_HORSE("chestnut", EntityType.HORSE, Horse.Color.CHESTNUT, true),
|
||||
LIVER_HORSE("liver", EntityType.HORSE, Horse.Color.CHESTNUT, false),
|
||||
CREAMY_HORSE("creamy", EntityType.HORSE, Horse.Color.CREAMY, true),
|
||||
FLAXEN_HORSE("flaxen", EntityType.HORSE, Horse.Color.CREAMY, false),
|
||||
GRAY_HORSE("gray", EntityType.HORSE, Horse.Color.GRAY, true),
|
||||
DAPPLE_HORSE("dapple", EntityType.HORSE, Horse.Color.GRAY, false),
|
||||
BUCKSKIN_HORSE("buckskin", EntityType.HORSE, Horse.Color.DARK_BROWN, true),
|
||||
DARKBROWN_HORSE("darkbrown", EntityType.HORSE, Horse.Color.DARK_BROWN, false),
|
||||
DARK_HORSE("dark", EntityType.HORSE, Horse.Color.DARK_BROWN, false),
|
||||
DBROWN_HORSE("dbrown", EntityType.HORSE, Horse.Color.DARK_BROWN, false),
|
||||
BAY_HORSE("bay", EntityType.HORSE, Horse.Color.BROWN, true),
|
||||
BROWN_HORSE("brown", EntityType.HORSE, Horse.Color.BROWN, false),
|
||||
SADDLE_HORSE("saddle", EntityType.HORSE, Data.HORSESADDLE, true),
|
||||
GOLD_ARMOR_HORSE("goldarmor", EntityType.HORSE, EnumUtil.getMaterial("GOLDEN_HORSE_ARMOR", "GOLD_BARDING"), true),
|
||||
DIAMOND_ARMOR_HORSE("diamondarmor", EntityType.HORSE, EnumUtil.getMaterial("DIAMOND_HORSE_ARMOR", "DIAMOND_BARDING"), true),
|
||||
ARMOR_HORSE("armor", EntityType.HORSE, EnumUtil.getMaterial("IRON_HORSE_ARMOR", "IRON_BARDING"), true),
|
||||
SIAMESE_CAT("siamese", MobCompat.CAT, MobCompat.CatType.SIAMESE, true),
|
||||
WHITE_CAT("white", MobCompat.CAT, MobCompat.CatType.WHITE, false),
|
||||
RED_CAT("red", MobCompat.CAT, MobCompat.CatType.RED, true),
|
||||
ORANGE_CAT("orange", MobCompat.CAT, MobCompat.CatType.RED, false),
|
||||
TABBY_CAT("tabby", MobCompat.CAT, MobCompat.CatType.TABBY, true),
|
||||
BLACK_CAT("black", MobCompat.CAT, MobCompat.CatType.BLACK, true),
|
||||
TUXEDO_CAT("tuxedo", MobCompat.CAT, MobCompat.CatType.TUXEDO, true),
|
||||
BRITISH_SHORTHAIR_CAT("britishshorthair", MobCompat.CAT, MobCompat.CatType.BRITISH_SHORTHAIR, true),
|
||||
CALICO_CAT("calico", MobCompat.CAT, MobCompat.CatType.CALICO, true),
|
||||
PERSIAN_CAT("persian", MobCompat.CAT, MobCompat.CatType.PERSIAN, true),
|
||||
RAGDOLL_CAT("ragdoll", MobCompat.CAT, MobCompat.CatType.RAGDOLL, true),
|
||||
JELLIE_CAT("jellie", MobCompat.CAT, MobCompat.CatType.JELLIE, true),
|
||||
ALL_BLACK_CAT("allblack", MobCompat.CAT, MobCompat.CatType.BLACK, true),
|
||||
BABY_ZOMBIE("baby", EntityType.ZOMBIE.getEntityClass(), Data.BABYZOMBIE, true),
|
||||
ADULT_ZOMBIE("adult", EntityType.ZOMBIE.getEntityClass(), Data.ADULTZOMBIE, true),
|
||||
DIAMOND_SWORD_ZOMBIE("diamondsword", EntityType.ZOMBIE.getEntityClass(), Material.DIAMOND_SWORD, true),
|
||||
GOLD_SWORD_ZOMBIE("goldsword", EntityType.ZOMBIE.getEntityClass(), EnumUtil.getMaterial("GOLDEN_SWORD", "GOLD_SWORD"), true),
|
||||
IRON_SWORD_ZOMBIE("ironsword", EntityType.ZOMBIE.getEntityClass(), Material.IRON_SWORD, true),
|
||||
STONE_SWORD_ZOMBIE("stonesword", EntityType.ZOMBIE.getEntityClass(), Material.STONE_SWORD, false),
|
||||
SWORD_ZOMBIE("sword", EntityType.ZOMBIE.getEntityClass(), Material.STONE_SWORD, true),
|
||||
DIAMOND_SWORD_SKELETON("diamondsword", EntityType.SKELETON, Material.DIAMOND_SWORD, true),
|
||||
GOLD_SWORD_SKELETON("goldsword", EntityType.SKELETON, EnumUtil.getMaterial("GOLDEN_SWORD", "GOLD_SWORD"), true),
|
||||
IRON_SWORD_SKELETON("ironsword", EntityType.SKELETON, Material.IRON_SWORD, true),
|
||||
STONE_SWORD_SKELETON("stonesword", EntityType.SKELETON, Material.STONE_SWORD, false),
|
||||
SWORD_SKELETON("sword", EntityType.SKELETON, Material.STONE_SWORD, true),
|
||||
BOW_SKELETON("bow", EntityType.SKELETON, Material.BOW, true),
|
||||
POWERED_CREEPER("powered", EntityType.CREEPER, Data.ELECTRIFIED, true),
|
||||
ELECTRIC_CREEPER("electric", EntityType.CREEPER, Data.ELECTRIFIED, false),
|
||||
CHARGED_CREEPER("charged", EntityType.CREEPER, Data.ELECTRIFIED, false),
|
||||
SADDLE_PIG("saddle", EntityType.PIG, Data.PIGSADDLE, true),
|
||||
ANGRY_WOLF("angry", EntityType.WOLF, Data.ANGRY, true),
|
||||
RABID_WOLF("rabid", EntityType.WOLF, Data.ANGRY, false),
|
||||
VILLAGER("villager", EntityType.VILLAGER, MobCompat.VillagerProfession.NONE, true),
|
||||
ARMORER_VILLAGER("armorer", EntityType.VILLAGER, MobCompat.VillagerProfession.ARMORER, true),
|
||||
BUTCHER_VILLAGER("butcher", EntityType.VILLAGER, MobCompat.VillagerProfession.BUTCHER, true),
|
||||
CARTOGRAPHER_VILLAGER("cartographer", EntityType.VILLAGER, MobCompat.VillagerProfession.CARTOGRAPHER, true),
|
||||
CLERIC_VILLAGER("cleric", EntityType.VILLAGER, MobCompat.VillagerProfession.CLERIC, true),
|
||||
FARMER_VILLAGER("farmer", EntityType.VILLAGER, MobCompat.VillagerProfession.FARMER, true),
|
||||
FISHERMAN_VILLAGER("fisherman", EntityType.VILLAGER, MobCompat.VillagerProfession.FISHERMAN, true),
|
||||
FLETCHER_VILLAGER("fletcher", EntityType.VILLAGER, MobCompat.VillagerProfession.FLETCHER, true),
|
||||
LEATHERWORKER_VILLAGER("leatherworker", EntityType.VILLAGER, MobCompat.VillagerProfession.LEATHERWORKER, true),
|
||||
LIBRARIAN_VILLAGER("librarian", EntityType.VILLAGER, MobCompat.VillagerProfession.LIBRARIAN, true),
|
||||
MASON_VILLAGER("mason", EntityType.VILLAGER, MobCompat.VillagerProfession.MASON, true),
|
||||
NITWIT_VILLAGER("nitwit", EntityType.VILLAGER, MobCompat.VillagerProfession.NITWIT, true),
|
||||
SHEPHERD_VILLAGER("shepherd", EntityType.VILLAGER, MobCompat.VillagerProfession.SHEPHERD, true),
|
||||
TOOLSMITH_VILLAGER("toolsmith", EntityType.VILLAGER, MobCompat.VillagerProfession.TOOLSMITH, true),
|
||||
WEAPONSMITH_VILLAGER("weaponsmith", EntityType.VILLAGER, MobCompat.VillagerProfession.WEAPONSMITH, true),
|
||||
DESERT_VILLAGER("desert", EntityType.VILLAGER, "villagertype:DESERT", true),
|
||||
JUNGLE_VILLAGER("jungle", EntityType.VILLAGER, "villagertype:JUNGLE", true),
|
||||
PLAINS_VILLAGER("plains", EntityType.VILLAGER, "villagertype:PLAINS", true),
|
||||
SAVANNA_VILLAGER("savanna", EntityType.VILLAGER, "villagertype:SAVANNA", true),
|
||||
SNOWY_VILLAGER("snowy", EntityType.VILLAGER, "villagertype:SNOWY", true),
|
||||
SWAMP_VILLAGER("swamp", EntityType.VILLAGER, "villagertype:SWAMP", true),
|
||||
TAIGA_VILLAGER("taiga", EntityType.VILLAGER, "villagertype:TAIGA", true),
|
||||
SIZE_SLIME("", Collections.singletonList("<1-100>"), EntityType.SLIME.getEntityClass(), Data.SIZE, true),
|
||||
NUM_EXPERIENCE_ORB("", Collections.singletonList("<1-2000000000>"), EntityType.EXPERIENCE_ORB, Data.EXP, true),
|
||||
RED_PARROT("red", MobCompat.PARROT, "parrot:RED", true),
|
||||
GREEN_PARROT("green", MobCompat.PARROT, "parrot:GREEN", true),
|
||||
BLUE_PARROT("blue", MobCompat.PARROT, "parrot:BLUE", true),
|
||||
CYAN_PARROT("cyan", MobCompat.PARROT, "parrot:CYAN", true),
|
||||
GRAY_PARROT("gray", MobCompat.PARROT, "parrot:GRAY", true),
|
||||
KOB_TROPICAL_FISH("kob", MobCompat.TROPICAL_FISH, "tropicalfish:KOB", true),
|
||||
SUNSTREAK_TROPICAL_FISH("sunstreak", MobCompat.TROPICAL_FISH, "tropicalfish:SUNSTREAK", true),
|
||||
SNOOPER_TROPICAL_FISH("snooper", MobCompat.TROPICAL_FISH, "tropicalfish:SNOOPER", true),
|
||||
DASHER_TROPICAL_FISH("dasher", MobCompat.TROPICAL_FISH, "tropicalfish:DASHER", true),
|
||||
BRINELY_TROPICAL_FISH("brinely", MobCompat.TROPICAL_FISH, "tropicalfish:BRINELY", true),
|
||||
SPOTTY_TROPICAL_FISH("spotty", MobCompat.TROPICAL_FISH, "tropicalfish:SPOTTY", true),
|
||||
FLOPPER_TROPICAL_FISH("flopper", MobCompat.TROPICAL_FISH, "tropicalfish:FLOPPER", true),
|
||||
STRIPEY_TROPICAL_FISH("stripey", MobCompat.TROPICAL_FISH, "tropicalfish:STRIPEY", true),
|
||||
GLITTER_TROPICAL_FISH("glitter", MobCompat.TROPICAL_FISH, "tropicalfish:GLITTER", true),
|
||||
BLOCKFISH_TROPICAL_FISH("blockfish", MobCompat.TROPICAL_FISH, "tropicalfish:BLOCKFISH", true),
|
||||
BETTY_TROPICAL_FISH("betty", MobCompat.TROPICAL_FISH, "tropicalfish:BETTY", true),
|
||||
CLAYFISH_TROPICAL_FISH("clayfish", MobCompat.TROPICAL_FISH, "tropicalfish:CLAYFISH", true),
|
||||
BROWN_MUSHROOM_COW("brown", EntityType.MUSHROOM_COW, "mooshroom:BROWN", true),
|
||||
RED_MUSHROOM_COW("red", EntityType.MUSHROOM_COW, "mooshroom:RED", true),
|
||||
AGGRESSIVE_PANDA_MAIN("aggressive", MobCompat.PANDA, "pandamain:AGGRESSIVE", true),
|
||||
LAZY_PANDA_MAIN("lazy", MobCompat.PANDA, "pandamain:LAZY", true),
|
||||
WORRIED_PANDA_MAIN("worried", MobCompat.PANDA, "pandamain:WORRIED", true),
|
||||
PLAYFUL_PANDA_MAIN("playful", MobCompat.PANDA, "pandamain:PLAYFUL", true),
|
||||
BROWN_PANDA_MAIN("brown", MobCompat.PANDA, "pandamain:BROWN", true),
|
||||
WEAK_PANDA_MAIN("weak", MobCompat.PANDA, "pandamain:WEAK", true),
|
||||
AGGRESSIVE_PANDA_HIDDEN("aggressive_hidden", MobCompat.PANDA, "pandahidden:AGGRESSIVE", true),
|
||||
LAZY_PANDA_HIDDEN("lazy_hidden", MobCompat.PANDA, "pandahidden:LAZY", true),
|
||||
WORRIED_PANDA_HIDDEN("worried_hidden", MobCompat.PANDA, "pandahidden:WORRIED", true),
|
||||
PLAYFUL_PANDA_HIDDEN("playful_hidden", MobCompat.PANDA, "pandahidden:PLAYFUL", true),
|
||||
BROWN_PANDA_HIDDEN("brown_hidden", MobCompat.PANDA, "pandahidden:BROWN", true),
|
||||
WEAK_PANDA_HIDDEN("weak_hidden", MobCompat.PANDA, "pandahidden:WEAK", true),
|
||||
CREAMY_LLAMA("creamy", MobCompat.LLAMA, "llama:CREAMY", true),
|
||||
WHITE_LLAMA("white", MobCompat.LLAMA, "llama:WHITE", true),
|
||||
BROWN_LLAMA("brown", MobCompat.LLAMA, "llama:BROWN", true),
|
||||
GRAY_LLAMA("gray", MobCompat.LLAMA, "llama:GRAY", true),
|
||||
CREAMY_TRADER_LLAMA("creamy", MobCompat.TRADER_LLAMA, "llama:CREAMY", true),
|
||||
WHITE_TRADER_LLAMA("white", MobCompat.TRADER_LLAMA, "llama:WHITE", true),
|
||||
BROWN_TRADER_LLAMA("brown", MobCompat.TRADER_LLAMA, "llama:BROWN", true),
|
||||
GRAY_TRADER_LLAMA("gray", MobCompat.TRADER_LLAMA, "llama:GRAY", true),
|
||||
RANDOM_SHULKER("random", MobCompat.SHULKER, Data.COLORABLE, true),
|
||||
COLORABLE_SHULKER("", Arrays.stream(DyeColor.values()).map(color -> color.name().toLowerCase(Locale.ENGLISH)).collect(Collectors.toList()), MobCompat.SHULKER, Data.COLORABLE, true),
|
||||
RED_FOX("red", MobCompat.FOX, "fox:RED", true),
|
||||
SNOW_FOX("snow", MobCompat.FOX, "fox:SNOW", true),
|
||||
SIZE_PHANTOM("", Collections.singletonList("<1-100>"), MobCompat.PHANTOM, Data.SIZE, true),
|
||||
RAID_LEADER("leader", MobCompat.RAIDER, Data.RAID_LEADER, true),
|
||||
TROPICAL_FISH_BODY_COLOR("fish_body_color", Arrays.stream(DyeColor.values()).map(color -> color.name().toLowerCase(Locale.ENGLISH) + "body").collect(Collectors.toList()), MobCompat.TROPICAL_FISH, Data.FISH_BODY_COLOR, true),
|
||||
TROPICAL_FISH_PATTERN_COLOR("fish_pattern_color", Arrays.stream(DyeColor.values()).map(color -> color.name().toLowerCase(Locale.ENGLISH) + "pattern").collect(Collectors.toList()), MobCompat.TROPICAL_FISH, Data.FISH_PATTERN_COLOR, true),
|
||||
;
|
||||
|
||||
private MobData(String n, Object type, Object value, boolean isPublic)
|
||||
{
|
||||
this.nickname = n;
|
||||
this.matched = n;
|
||||
this.helpMessage = n;
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
public static final Logger logger = Logger.getLogger("Essentials");
|
||||
final private String nickname;
|
||||
final private List<String> suggestions;
|
||||
final private Object type;
|
||||
final private Object value;
|
||||
final private boolean isPublic;
|
||||
private String matched;
|
||||
|
||||
private MobData(String n, String h, Object type, Object value, boolean isPublic)
|
||||
{
|
||||
this.nickname = n;
|
||||
this.matched = n;
|
||||
this.helpMessage = h;
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
final private String nickname;
|
||||
final private String helpMessage;
|
||||
final private Object type;
|
||||
final private Object value;
|
||||
final private boolean isPublic;
|
||||
private String matched;
|
||||
MobData(final String n, final Object type, final Object value, final boolean isPublic) {
|
||||
this.nickname = n;
|
||||
this.matched = n;
|
||||
this.suggestions = Collections.singletonList(n);
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
|
||||
public static LinkedHashMap<String, MobData> getPossibleData(final Entity spawned, boolean publicOnly)
|
||||
{
|
||||
LinkedHashMap<String, MobData> mobList = new LinkedHashMap<String, MobData>();
|
||||
for (MobData data : MobData.values())
|
||||
{
|
||||
if (data.type instanceof EntityType && spawned.getType().equals(data.type) && ((publicOnly && data.isPublic) || !publicOnly))
|
||||
{
|
||||
mobList.put(data.nickname.toLowerCase(Locale.ENGLISH), data);
|
||||
}
|
||||
else if (data.type instanceof Class && ((Class)data.type).isAssignableFrom(spawned.getClass()) && ((publicOnly && data.isPublic) || !publicOnly))
|
||||
{
|
||||
mobList.put(data.nickname.toLowerCase(Locale.ENGLISH), data);
|
||||
}
|
||||
}
|
||||
MobData(final String n, final List<String> s, final Object type, final Object value, final boolean isPublic) {
|
||||
this.nickname = n;
|
||||
this.matched = n;
|
||||
this.suggestions = s;
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
|
||||
return mobList;
|
||||
}
|
||||
public static LinkedHashMap<String, MobData> getPossibleData(final Entity spawned, final boolean publicOnly) {
|
||||
final LinkedHashMap<String, MobData> mobList = new LinkedHashMap<>();
|
||||
for (final MobData data : MobData.values()) {
|
||||
if (data.type == null || (publicOnly && !data.isPublic)) {
|
||||
continue;
|
||||
}
|
||||
if (data.type instanceof EntityType && spawned.getType().equals(data.type)) {
|
||||
mobList.put(data.nickname.toLowerCase(Locale.ENGLISH), data);
|
||||
} else if (data.type instanceof Class && ((Class) data.type).isAssignableFrom(spawned.getClass())) {
|
||||
mobList.put(data.nickname.toLowerCase(Locale.ENGLISH), data);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getValidHelp(final Entity spawned)
|
||||
{
|
||||
List<String> output = new ArrayList<String>();
|
||||
LinkedHashMap<String, MobData> posData = getPossibleData(spawned, true);
|
||||
return mobList;
|
||||
}
|
||||
|
||||
for (MobData data : posData.values())
|
||||
{
|
||||
output.add(data.helpMessage);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
public static List<String> getValidHelp(final Entity spawned) {
|
||||
final List<String> output = new ArrayList<>();
|
||||
final LinkedHashMap<String, MobData> posData = getPossibleData(spawned, true);
|
||||
|
||||
public static MobData fromData(final Entity spawned, final String name)
|
||||
{
|
||||
if (name.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
for (final MobData data : posData.values()) {
|
||||
output.add(StringUtil.joinList(data.suggestions));
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
LinkedHashMap<String, MobData> posData = getPossibleData(spawned, false);
|
||||
for (String data : posData.keySet())
|
||||
{
|
||||
if (name.contains(data))
|
||||
{
|
||||
return posData.get(data);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static MobData fromData(final Entity spawned, final String name) {
|
||||
if (name.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getMatched()
|
||||
{
|
||||
return this.matched;
|
||||
}
|
||||
final LinkedHashMap<String, MobData> posData = getPossibleData(spawned, false);
|
||||
for (final MobData data : posData.values()) {
|
||||
for (final String suggestion : data.suggestions) {
|
||||
if (name.contains(suggestion)) {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setData(final Entity spawned, final Player target, final String rawData) throws Exception
|
||||
{
|
||||
if (this.value.equals(Data.ANGRY))
|
||||
{
|
||||
((Wolf)spawned).setAngry(true);
|
||||
}
|
||||
else if (this.value.equals(Data.BABY))
|
||||
{
|
||||
((Ageable)spawned).setBaby();
|
||||
}
|
||||
else if (this.value.equals(Data.BABYZOMBIE))
|
||||
{
|
||||
((Zombie)spawned).setBaby(true);
|
||||
}
|
||||
else if (this.value.equals(Data.CHEST))
|
||||
{
|
||||
((Horse)spawned).setTamed(true);
|
||||
((Horse)spawned).setCarryingChest(true);
|
||||
}
|
||||
else if (this.value.equals(Data.ELECTRIFIED))
|
||||
{
|
||||
((Creeper)spawned).setPowered(true);
|
||||
}
|
||||
else if (this.value.equals(Data.HORSESADDLE))
|
||||
{
|
||||
final Horse horse = ((Horse)spawned);
|
||||
horse.setTamed(true);
|
||||
horse.setOwner(target);
|
||||
horse.getInventory().setSaddle(new ItemStack(Material.SADDLE, 1));
|
||||
}
|
||||
else if (this.value.equals(Data.PIGSADDLE))
|
||||
{
|
||||
((Pig)spawned).setSaddle(true);
|
||||
}
|
||||
else if (this.value.equals(Data.TAMED))
|
||||
{
|
||||
final Tameable tameable = ((Tameable)spawned);
|
||||
tameable.setTamed(true);
|
||||
tameable.setOwner(target);
|
||||
}
|
||||
else if (this.value.equals(Data.VILLAGER))
|
||||
{
|
||||
((Zombie)spawned).setVillager(this.value.equals(Data.VILLAGER));
|
||||
}
|
||||
else if (this.value.equals(Data.WITHER))
|
||||
{
|
||||
((Skeleton)spawned).setSkeletonType(Skeleton.SkeletonType.WITHER);
|
||||
}
|
||||
else if (this.value.equals(Data.COLORABLE))
|
||||
{
|
||||
final String color = rawData.toUpperCase(Locale.ENGLISH);
|
||||
try
|
||||
{
|
||||
if (color.equals("RANDOM"))
|
||||
{
|
||||
final Random rand = new Random();
|
||||
((Colorable)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
|
||||
}
|
||||
else if (!color.isEmpty())
|
||||
{
|
||||
((Colorable)spawned).setColor(DyeColor.valueOf(color));
|
||||
}
|
||||
this.matched = rawData;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Exception(_("sheepMalformedColor"), e);
|
||||
}
|
||||
}
|
||||
else if (this.value.equals(Data.EXP))
|
||||
{
|
||||
try
|
||||
{
|
||||
((ExperienceOrb)spawned).setExperience(Integer.parseInt(rawData));
|
||||
this.matched = rawData;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new Exception(_("invalidNumber"), e);
|
||||
}
|
||||
}
|
||||
else if (this.value.equals(Data.SIZE))
|
||||
{
|
||||
try
|
||||
{
|
||||
((Slime)spawned).setSize(Integer.parseInt(rawData));
|
||||
this.matched = rawData;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new Exception(_("slimeMalformedSize"), e);
|
||||
}
|
||||
}
|
||||
else if (this.value instanceof Horse.Color)
|
||||
{
|
||||
((Horse)spawned).setColor((Horse.Color)this.value);
|
||||
}
|
||||
else if (this.value instanceof Horse.Style)
|
||||
{
|
||||
((Horse)spawned).setStyle((Horse.Style)this.value);
|
||||
}
|
||||
else if (this.value instanceof Horse.Variant)
|
||||
{
|
||||
((Horse)spawned).setVariant((Horse.Variant)this.value);
|
||||
}
|
||||
else if (this.value instanceof Ocelot.Type)
|
||||
{
|
||||
((Ocelot)spawned).setCatType((Ocelot.Type)this.value);
|
||||
}
|
||||
else if (this.value instanceof Villager.Profession)
|
||||
{
|
||||
((Villager)spawned).setProfession((Villager.Profession)this.value);
|
||||
}
|
||||
else if (this.value instanceof Material)
|
||||
{
|
||||
if (this.type.equals(EntityType.HORSE))
|
||||
{
|
||||
((Horse)spawned).setTamed(true);
|
||||
((Horse)spawned).getInventory().setArmor(new ItemStack((Material)this.value, 1));
|
||||
}
|
||||
else if (this.type.equals(EntityType.ZOMBIE.getEntityClass()) || this.type.equals(EntityType.SKELETON))
|
||||
{
|
||||
final EntityEquipment invent = ((LivingEntity)spawned).getEquipment();
|
||||
invent.setItemInHand(new ItemStack((Material)this.value, 1));
|
||||
invent.setItemInHandDropChance(0.1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
public String getMatched() {
|
||||
return this.matched;
|
||||
}
|
||||
|
||||
public void setData(final Entity spawned, final Player target, final String rawData) throws Exception {
|
||||
if (this.value.equals(Data.ANGRY)) {
|
||||
((Wolf) spawned).setAngry(true);
|
||||
} else if (this.value.equals(Data.ADULT)) {
|
||||
((Ageable) spawned).setAdult();
|
||||
} else if (this.value.equals(Data.BABY)) {
|
||||
((Ageable) spawned).setBaby();
|
||||
} else if (this.value.equals(Data.ADULTZOMBIE)) {
|
||||
((Zombie) spawned).setBaby(false);
|
||||
} else if (this.value.equals(Data.BABYZOMBIE)) {
|
||||
((Zombie) spawned).setBaby(true);
|
||||
} else if (this.value.equals(Data.ELECTRIFIED)) {
|
||||
((Creeper) spawned).setPowered(true);
|
||||
} else if (this.value.equals(Data.HORSESADDLE)) {
|
||||
final Horse horse = (Horse) spawned;
|
||||
horse.setTamed(true);
|
||||
horse.setOwner(target);
|
||||
horse.getInventory().setSaddle(new ItemStack(Material.SADDLE, 1));
|
||||
} else if (this.value.equals(Data.PIGSADDLE)) {
|
||||
((Pig) spawned).setSaddle(true);
|
||||
} else if (this.value.equals(Data.TAMED)) {
|
||||
final Tameable tameable = (Tameable) spawned;
|
||||
tameable.setTamed(true);
|
||||
tameable.setOwner(target);
|
||||
} else if (this.value.equals(Data.COLORABLE)) {
|
||||
final String color = rawData.toUpperCase(Locale.ENGLISH);
|
||||
try {
|
||||
if (color.equals("RANDOM")) {
|
||||
final Random rand = new Random();
|
||||
((Colorable) spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
|
||||
} else if (!color.isEmpty()) {
|
||||
((Colorable) spawned).setColor(DyeColor.valueOf(color));
|
||||
}
|
||||
this.matched = rawData;
|
||||
} catch (final Exception e) {
|
||||
throw new Exception(tl("sheepMalformedColor"), e);
|
||||
}
|
||||
} else if (this.value.equals(Data.EXP)) {
|
||||
try {
|
||||
((ExperienceOrb) spawned).setExperience(Integer.parseInt(rawData));
|
||||
this.matched = rawData;
|
||||
} catch (final NumberFormatException e) {
|
||||
throw new Exception(tl("invalidNumber"), e);
|
||||
}
|
||||
} else if (this.value.equals(Data.SIZE)) {
|
||||
try {
|
||||
final int size = Integer.parseInt(rawData);
|
||||
if (spawned instanceof Slime) {
|
||||
((Slime) spawned).setSize(size);
|
||||
} else if (spawned.getType() == MobCompat.PHANTOM) {
|
||||
((Phantom) spawned).setSize(size);
|
||||
}
|
||||
this.matched = rawData;
|
||||
} catch (final NumberFormatException e) {
|
||||
throw new Exception(tl("slimeMalformedSize"), e);
|
||||
}
|
||||
} else if (this.value instanceof Horse.Color) {
|
||||
((Horse) spawned).setColor((Horse.Color) this.value);
|
||||
} else if (this.value instanceof Horse.Style) {
|
||||
((Horse) spawned).setStyle((Horse.Style) this.value);
|
||||
} else if (this.value instanceof MobCompat.CatType) {
|
||||
MobCompat.setCatType(spawned, (MobCompat.CatType) this.value);
|
||||
} else if (this.value instanceof MobCompat.VillagerProfession) {
|
||||
MobCompat.setVillagerProfession(spawned, (MobCompat.VillagerProfession) this.value);
|
||||
} else if (this.value instanceof Material) {
|
||||
if (this.type.equals(EntityType.HORSE)) {
|
||||
((Horse) spawned).setTamed(true);
|
||||
((Horse) spawned).getInventory().setArmor(new ItemStack((Material) this.value, 1));
|
||||
} else if (this.type.equals(EntityType.ZOMBIE.getEntityClass()) || this.type.equals(EntityType.SKELETON)) {
|
||||
final EntityEquipment invent = ((LivingEntity) spawned).getEquipment();
|
||||
InventoryWorkaround.setItemInMainHand(invent, new ItemStack((Material) this.value, 1));
|
||||
InventoryWorkaround.setItemInMainHandDropChance(invent, 0.1f);
|
||||
}
|
||||
} else if (this.value.equals(Data.RAID_LEADER)) {
|
||||
((Raider) spawned).setPatrolLeader(true);
|
||||
} else if (this.value.equals(Data.FISH_BODY_COLOR)) {
|
||||
for (final String match : TROPICAL_FISH_BODY_COLOR.suggestions) {
|
||||
if (rawData.contains(match)) {
|
||||
this.matched = match;
|
||||
final String color = match.substring(0, match.indexOf("body")).toUpperCase(Locale.ENGLISH);
|
||||
((TropicalFish) spawned).setBodyColor(DyeColor.valueOf(color));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (this.value.equals(Data.FISH_PATTERN_COLOR)) {
|
||||
for (final String match : TROPICAL_FISH_PATTERN_COLOR.suggestions) {
|
||||
if (rawData.contains(match)) {
|
||||
this.matched = match;
|
||||
final String color = match.substring(0, match.indexOf("pattern")).toUpperCase(Locale.ENGLISH);
|
||||
((TropicalFish) spawned).setPatternColor(DyeColor.valueOf(color));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (this.value instanceof String) {
|
||||
final String[] split = ((String) this.value).split(":");
|
||||
switch (split[0]) {
|
||||
case "parrot":
|
||||
MobCompat.setParrotVariant(spawned, split[1]);
|
||||
break;
|
||||
case "tropicalfish":
|
||||
MobCompat.setTropicalFishPattern(spawned, split[1]);
|
||||
break;
|
||||
case "mooshroom":
|
||||
MobCompat.setMooshroomVariant(spawned, split[1]);
|
||||
break;
|
||||
case "pandamain":
|
||||
MobCompat.setPandaGene(spawned, split[1], true);
|
||||
break;
|
||||
case "pandahidden":
|
||||
MobCompat.setPandaGene(spawned, split[1], false);
|
||||
break;
|
||||
case "llama":
|
||||
MobCompat.setLlamaColor(spawned, split[1]);
|
||||
break;
|
||||
case "villagertype":
|
||||
MobCompat.setVillagerType(spawned, split[1]);
|
||||
break;
|
||||
case "fox":
|
||||
MobCompat.setFoxType(spawned, split[1]);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
logger.warning("Unknown mob data type: " + this.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public enum Data {
|
||||
ADULT,
|
||||
BABY,
|
||||
CHEST,
|
||||
ADULTZOMBIE,
|
||||
BABYZOMBIE,
|
||||
HORSESADDLE,
|
||||
PIGSADDLE,
|
||||
ELECTRIFIED,
|
||||
ANGRY,
|
||||
TAMED,
|
||||
COLORABLE,
|
||||
EXP,
|
||||
SIZE,
|
||||
RAID_LEADER,
|
||||
FISH_BODY_COLOR,
|
||||
FISH_PATTERN_COLOR,
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,38 +1,34 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import lombok.Delegate;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.permissions.ServerOperator;
|
||||
|
||||
public class PlayerExtension {
|
||||
protected Player base;
|
||||
|
||||
public class PlayerExtension
|
||||
{
|
||||
@Delegate(types =
|
||||
{
|
||||
Player.class, Entity.class, CommandSender.class, ServerOperator.class,
|
||||
HumanEntity.class, ConfigurationSerializable.class, LivingEntity.class,
|
||||
Permissible.class
|
||||
})
|
||||
protected Player base;
|
||||
public PlayerExtension(final Player base) {
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
public PlayerExtension(final Player base)
|
||||
{
|
||||
this.base = base;
|
||||
}
|
||||
public final Player getBase() {
|
||||
return base;
|
||||
}
|
||||
|
||||
public final Player getBase()
|
||||
{
|
||||
return base;
|
||||
}
|
||||
public final Player setBase(final Player base) {
|
||||
return this.base = base;
|
||||
}
|
||||
|
||||
public final Player setBase(final Player base)
|
||||
{
|
||||
return this.base = base;
|
||||
}
|
||||
public Server getServer() {
|
||||
return base.getServer();
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return base.getWorld();
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return base.getLocation();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -9,143 +11,118 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class PlayerList
|
||||
{
|
||||
// Cosmetic list formatting
|
||||
public static String listUsers(final IEssentials ess, final List<User> users, final String seperator)
|
||||
{
|
||||
final StringBuilder groupString = new StringBuilder();
|
||||
Collections.sort(users);
|
||||
boolean needComma = false;
|
||||
for (User user : users)
|
||||
{
|
||||
if (needComma)
|
||||
{
|
||||
groupString.append(seperator);
|
||||
}
|
||||
needComma = true;
|
||||
if (user.isAfk())
|
||||
{
|
||||
groupString.append(_("listAfkTag"));
|
||||
}
|
||||
if (user.isHidden())
|
||||
{
|
||||
groupString.append(_("listHiddenTag"));
|
||||
}
|
||||
user.setDisplayNick();
|
||||
groupString.append(user.getDisplayName());
|
||||
groupString.append("\u00a7f");
|
||||
}
|
||||
return groupString.toString();
|
||||
}
|
||||
public final class PlayerList {
|
||||
|
||||
// Produce a user summary: There are 5 out of maximum 10 players online.
|
||||
public static String listSummary(final IEssentials ess, final boolean showHidden)
|
||||
{
|
||||
Server server = ess.getServer();
|
||||
int playerHidden = 0;
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
if (ess.getUser(onlinePlayer).isHidden())
|
||||
{
|
||||
playerHidden++;
|
||||
}
|
||||
}
|
||||
String online;
|
||||
if (showHidden && playerHidden > 0)
|
||||
{
|
||||
online = _("listAmountHidden", server.getOnlinePlayers().length - playerHidden, playerHidden, server.getMaxPlayers());
|
||||
}
|
||||
else
|
||||
{
|
||||
online = _("listAmount", server.getOnlinePlayers().length - playerHidden, server.getMaxPlayers());
|
||||
}
|
||||
return online;
|
||||
}
|
||||
private PlayerList() {
|
||||
}
|
||||
|
||||
// Build the basic player list, divided by groups.
|
||||
public static Map<String, List<User>> getPlayerLists(final IEssentials ess, final boolean showHidden)
|
||||
{
|
||||
Server server = ess.getServer();
|
||||
final Map<String, List<User>> playerList = new HashMap<String, List<User>>();
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final User onlineUser = ess.getUser(onlinePlayer);
|
||||
if (onlineUser.isHidden() && !showHidden)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final String group = FormatUtil.stripFormat(FormatUtil.stripEssentialsFormat(onlineUser.getGroup().toLowerCase()));
|
||||
List<User> list = playerList.get(group);
|
||||
if (list == null)
|
||||
{
|
||||
list = new ArrayList<User>();
|
||||
playerList.put(group, list);
|
||||
}
|
||||
list.add(onlineUser);
|
||||
}
|
||||
return playerList;
|
||||
}
|
||||
// Cosmetic list formatting
|
||||
public static String listUsers(final IEssentials ess, final List<User> users, final String seperator) {
|
||||
final StringBuilder groupString = new StringBuilder();
|
||||
Collections.sort(users);
|
||||
boolean needComma = false;
|
||||
for (final User user : users) {
|
||||
if (needComma) {
|
||||
groupString.append(seperator);
|
||||
}
|
||||
needComma = true;
|
||||
if (user.isAfk()) {
|
||||
groupString.append(tl("listAfkTag"));
|
||||
}
|
||||
if (user.isHidden()) {
|
||||
groupString.append(tl("listHiddenTag"));
|
||||
}
|
||||
user.setDisplayNick();
|
||||
groupString.append(user.getDisplayName());
|
||||
if (ess.getSettings().realNamesOnList() && !ChatColor.stripColor(user.getDisplayName()).equals(user.getName())) {
|
||||
groupString.append(" (").append(user.getName()).append(")");
|
||||
}
|
||||
groupString.append("\u00a7f");
|
||||
}
|
||||
return groupString.toString();
|
||||
}
|
||||
|
||||
// Handle the merging of groups
|
||||
public static List<User> getMergedList(final IEssentials ess, final Map<String, List<User>> playerList, final String groupName)
|
||||
{
|
||||
final Set<String> configGroups = ess.getSettings().getListGroupConfig().keySet();
|
||||
final List<User> users = new ArrayList<User>();
|
||||
for (String configGroup : configGroups)
|
||||
{
|
||||
if (configGroup.equalsIgnoreCase(groupName))
|
||||
{
|
||||
String[] groupValues = ess.getSettings().getListGroupConfig().get(configGroup).toString().trim().split(" ");
|
||||
for (String groupValue : groupValues)
|
||||
{
|
||||
groupValue = groupValue.toLowerCase(Locale.ENGLISH);
|
||||
if (groupValue == null || groupValue.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
List<User> u = playerList.get(groupValue.trim());
|
||||
if (u == null || u.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
playerList.remove(groupValue);
|
||||
users.addAll(u);
|
||||
}
|
||||
}
|
||||
}
|
||||
return users;
|
||||
}
|
||||
// Produce a user summary: There are 5 out of maximum 10 players online.
|
||||
public static String listSummary(final IEssentials ess, final User user, final boolean showHidden) {
|
||||
final Server server = ess.getServer();
|
||||
int playerHidden = 0;
|
||||
int hiddenCount = 0;
|
||||
for (final User onlinePlayer : ess.getOnlineUsers()) {
|
||||
if (onlinePlayer.isHidden() || (user != null && !user.getBase().canSee(onlinePlayer.getBase()))) {
|
||||
playerHidden++;
|
||||
if (showHidden || user != null && user.getBase().canSee(onlinePlayer.getBase())) {
|
||||
hiddenCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
final String online;
|
||||
if (hiddenCount > 0) {
|
||||
online = tl("listAmountHidden", ess.getOnlinePlayers().size() - playerHidden, hiddenCount, server.getMaxPlayers());
|
||||
} else {
|
||||
online = tl("listAmount", ess.getOnlinePlayers().size() - playerHidden, server.getMaxPlayers());
|
||||
}
|
||||
return online;
|
||||
}
|
||||
|
||||
// Output a playerlist of just a single group, /list <groupname>
|
||||
public static String listGroupUsers(final IEssentials ess, final Map<String, List<User>> playerList, final String groupName) throws Exception
|
||||
{
|
||||
final List<User> users = getMergedList(ess, playerList, groupName);
|
||||
final List<User> groupUsers = playerList.get(groupName);
|
||||
if (groupUsers != null && !groupUsers.isEmpty())
|
||||
{
|
||||
users.addAll(groupUsers);
|
||||
}
|
||||
if (users == null || users.isEmpty())
|
||||
{
|
||||
throw new Exception(_("groupDoesNotExist"));
|
||||
}
|
||||
final StringBuilder displayGroupName = new StringBuilder();
|
||||
displayGroupName.append(Character.toTitleCase(groupName.charAt(0)));
|
||||
displayGroupName.append(groupName.substring(1));
|
||||
return outputFormat(displayGroupName.toString(), listUsers(ess, users, ", "));
|
||||
}
|
||||
// Build the basic player list, divided by groups.
|
||||
public static Map<String, List<User>> getPlayerLists(final IEssentials ess, final IUser sender, final boolean showHidden) {
|
||||
final Map<String, List<User>> playerList = new HashMap<>();
|
||||
for (final User onlineUser : ess.getOnlineUsers()) {
|
||||
if ((sender == null && !showHidden && onlineUser.isHidden()) || (sender != null && !showHidden && !sender.getBase().canSee(onlineUser.getBase()))) {
|
||||
continue;
|
||||
}
|
||||
final String group = FormatUtil.stripFormat(FormatUtil.stripEssentialsFormat(onlineUser.getGroup().toLowerCase()));
|
||||
final List<User> list = playerList.computeIfAbsent(group, k -> new ArrayList<>());
|
||||
list.add(onlineUser);
|
||||
}
|
||||
return playerList;
|
||||
}
|
||||
|
||||
// Build the output string
|
||||
public static String outputFormat(final String group, final String message)
|
||||
{
|
||||
final StringBuilder outputString = new StringBuilder();
|
||||
outputString.append(_("listGroupTag", FormatUtil.replaceFormat(group)));
|
||||
outputString.append(message);
|
||||
return outputString.toString();
|
||||
}
|
||||
// Handle the merging of groups
|
||||
public static List<User> getMergedList(final IEssentials ess, final Map<String, List<User>> playerList, final String groupName) {
|
||||
final Set<String> configGroups = ess.getSettings().getListGroupConfig().keySet();
|
||||
final List<User> users = new ArrayList<>();
|
||||
for (final String configGroup : configGroups) {
|
||||
if (configGroup.equalsIgnoreCase(groupName)) {
|
||||
final String[] groupValues = ess.getSettings().getListGroupConfig().get(configGroup).toString().trim().split(" ");
|
||||
for (String groupValue : groupValues) {
|
||||
groupValue = groupValue.toLowerCase(Locale.ENGLISH);
|
||||
if (groupValue.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
final List<User> u = playerList.get(groupValue.trim());
|
||||
if (u == null || u.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
playerList.remove(groupValue);
|
||||
users.addAll(u);
|
||||
}
|
||||
}
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
||||
// Output a playerlist of just a single group, /list <groupname>
|
||||
public static String listGroupUsers(final IEssentials ess, final Map<String, List<User>> playerList, final String groupName) throws Exception {
|
||||
final List<User> users = getMergedList(ess, playerList, groupName);
|
||||
final List<User> groupUsers = playerList.get(groupName);
|
||||
if (groupUsers != null && !groupUsers.isEmpty()) {
|
||||
users.addAll(groupUsers);
|
||||
}
|
||||
if (users.isEmpty()) {
|
||||
throw new Exception(tl("groupDoesNotExist"));
|
||||
}
|
||||
final String displayGroupName = Character.toTitleCase(groupName.charAt(0)) +
|
||||
groupName.substring(1);
|
||||
return outputFormat(displayGroupName, listUsers(ess, users, ", "));
|
||||
}
|
||||
|
||||
// Build the output string
|
||||
public static String outputFormat(final String group, final String message) {
|
||||
return tl("listGroupTag", FormatUtil.replaceFormat(group)) +
|
||||
message;
|
||||
}
|
||||
}
|
||||
@@ -4,19 +4,15 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlayerTarget implements ITarget {
|
||||
private final String name;
|
||||
|
||||
public class PlayerTarget implements ITarget
|
||||
{
|
||||
private final String name;
|
||||
public PlayerTarget(final Player entity) {
|
||||
this.name = entity.getName();
|
||||
}
|
||||
|
||||
public PlayerTarget(Player entity)
|
||||
{
|
||||
this.name = entity.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation()
|
||||
{
|
||||
return Bukkit.getServer().getPlayerExact(name).getLocation();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return Bukkit.getServer().getPlayerExact(name).getLocation();
|
||||
}
|
||||
}
|
||||
@@ -1,160 +1,152 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public final class Potions {
|
||||
private static final Map<String, PotionEffectType> POTIONS = new HashMap<>();
|
||||
private static final Map<String, PotionEffectType> ALIASPOTIONS = new HashMap<>();
|
||||
|
||||
public class Potions
|
||||
{
|
||||
private static final Map<String, PotionEffectType> POTIONS = new HashMap<String, PotionEffectType>();
|
||||
private static final Map<String, PotionEffectType> ALIASPOTIONS = new HashMap<String, PotionEffectType>();
|
||||
static {
|
||||
|
||||
static
|
||||
{
|
||||
POTIONS.put("speed", PotionEffectType.SPEED);
|
||||
ALIASPOTIONS.put("fast", PotionEffectType.SPEED);
|
||||
ALIASPOTIONS.put("runfast", PotionEffectType.SPEED);
|
||||
ALIASPOTIONS.put("sprint", PotionEffectType.SPEED);
|
||||
ALIASPOTIONS.put("swift", PotionEffectType.SPEED);
|
||||
|
||||
POTIONS.put("speed", PotionEffectType.SPEED);
|
||||
ALIASPOTIONS.put("fast", PotionEffectType.SPEED);
|
||||
ALIASPOTIONS.put("runfast", PotionEffectType.SPEED);
|
||||
ALIASPOTIONS.put("sprint", PotionEffectType.SPEED);
|
||||
ALIASPOTIONS.put("swift", PotionEffectType.SPEED);
|
||||
POTIONS.put("slowness", PotionEffectType.SLOW);
|
||||
ALIASPOTIONS.put("slow", PotionEffectType.SLOW);
|
||||
ALIASPOTIONS.put("sluggish", PotionEffectType.SLOW);
|
||||
|
||||
POTIONS.put("slowness", PotionEffectType.SLOW);
|
||||
ALIASPOTIONS.put("slow", PotionEffectType.SLOW);
|
||||
ALIASPOTIONS.put("sluggish", PotionEffectType.SLOW);
|
||||
POTIONS.put("haste", PotionEffectType.FAST_DIGGING);
|
||||
ALIASPOTIONS.put("superpick", PotionEffectType.FAST_DIGGING);
|
||||
ALIASPOTIONS.put("quickmine", PotionEffectType.FAST_DIGGING);
|
||||
ALIASPOTIONS.put("digspeed", PotionEffectType.FAST_DIGGING);
|
||||
ALIASPOTIONS.put("digfast", PotionEffectType.FAST_DIGGING);
|
||||
ALIASPOTIONS.put("sharp", PotionEffectType.FAST_DIGGING);
|
||||
|
||||
POTIONS.put("haste", PotionEffectType.FAST_DIGGING);
|
||||
ALIASPOTIONS.put("superpick", PotionEffectType.FAST_DIGGING);
|
||||
ALIASPOTIONS.put("quickmine", PotionEffectType.FAST_DIGGING);
|
||||
ALIASPOTIONS.put("digspeed", PotionEffectType.FAST_DIGGING);
|
||||
ALIASPOTIONS.put("digfast", PotionEffectType.FAST_DIGGING);
|
||||
ALIASPOTIONS.put("sharp", PotionEffectType.FAST_DIGGING);
|
||||
POTIONS.put("fatigue", PotionEffectType.SLOW_DIGGING);
|
||||
ALIASPOTIONS.put("slow", PotionEffectType.SLOW_DIGGING);
|
||||
ALIASPOTIONS.put("dull", PotionEffectType.SLOW_DIGGING);
|
||||
|
||||
POTIONS.put("fatigue", PotionEffectType.SLOW_DIGGING);
|
||||
ALIASPOTIONS.put("slow", PotionEffectType.SLOW_DIGGING);
|
||||
ALIASPOTIONS.put("dull", PotionEffectType.SLOW_DIGGING);
|
||||
POTIONS.put("strength", PotionEffectType.INCREASE_DAMAGE);
|
||||
ALIASPOTIONS.put("strong", PotionEffectType.INCREASE_DAMAGE);
|
||||
ALIASPOTIONS.put("bull", PotionEffectType.INCREASE_DAMAGE);
|
||||
ALIASPOTIONS.put("attack", PotionEffectType.INCREASE_DAMAGE);
|
||||
|
||||
POTIONS.put("strength", PotionEffectType.INCREASE_DAMAGE);
|
||||
ALIASPOTIONS.put("strong", PotionEffectType.INCREASE_DAMAGE);
|
||||
ALIASPOTIONS.put("bull", PotionEffectType.INCREASE_DAMAGE);
|
||||
ALIASPOTIONS.put("attack", PotionEffectType.INCREASE_DAMAGE);
|
||||
POTIONS.put("heal", PotionEffectType.HEAL);
|
||||
ALIASPOTIONS.put("healthy", PotionEffectType.HEAL);
|
||||
ALIASPOTIONS.put("instaheal", PotionEffectType.HEAL);
|
||||
|
||||
POTIONS.put("heal", PotionEffectType.HEAL);
|
||||
ALIASPOTIONS.put("healthy", PotionEffectType.HEAL);
|
||||
ALIASPOTIONS.put("instaheal", PotionEffectType.HEAL);
|
||||
POTIONS.put("harm", PotionEffectType.HARM);
|
||||
ALIASPOTIONS.put("harming", PotionEffectType.HARM);
|
||||
ALIASPOTIONS.put("injure", PotionEffectType.HARM);
|
||||
ALIASPOTIONS.put("damage", PotionEffectType.HARM);
|
||||
ALIASPOTIONS.put("inflict", PotionEffectType.HARM);
|
||||
|
||||
POTIONS.put("harm", PotionEffectType.HARM);
|
||||
ALIASPOTIONS.put("harming", PotionEffectType.HARM);
|
||||
ALIASPOTIONS.put("injure", PotionEffectType.HARM);
|
||||
ALIASPOTIONS.put("damage", PotionEffectType.HARM);
|
||||
ALIASPOTIONS.put("inflict", PotionEffectType.HARM);
|
||||
POTIONS.put("jump", PotionEffectType.JUMP);
|
||||
ALIASPOTIONS.put("leap", PotionEffectType.JUMP);
|
||||
|
||||
POTIONS.put("jump", PotionEffectType.JUMP);
|
||||
ALIASPOTIONS.put("leap", PotionEffectType.JUMP);
|
||||
POTIONS.put("nausea", PotionEffectType.CONFUSION);
|
||||
ALIASPOTIONS.put("sick", PotionEffectType.CONFUSION);
|
||||
ALIASPOTIONS.put("sickness", PotionEffectType.CONFUSION);
|
||||
ALIASPOTIONS.put("confusion", PotionEffectType.CONFUSION);
|
||||
|
||||
POTIONS.put("nausea", PotionEffectType.CONFUSION);
|
||||
ALIASPOTIONS.put("sick", PotionEffectType.CONFUSION);
|
||||
ALIASPOTIONS.put("sickness", PotionEffectType.CONFUSION);
|
||||
ALIASPOTIONS.put("confusion", PotionEffectType.CONFUSION);
|
||||
POTIONS.put("regeneration", PotionEffectType.REGENERATION);
|
||||
ALIASPOTIONS.put("regen", PotionEffectType.REGENERATION);
|
||||
|
||||
POTIONS.put("regeneration", PotionEffectType.REGENERATION);
|
||||
ALIASPOTIONS.put("regen", PotionEffectType.REGENERATION);
|
||||
POTIONS.put("resistance", PotionEffectType.DAMAGE_RESISTANCE);
|
||||
ALIASPOTIONS.put("dmgresist", PotionEffectType.DAMAGE_RESISTANCE);
|
||||
ALIASPOTIONS.put("armor", PotionEffectType.DAMAGE_RESISTANCE);
|
||||
|
||||
POTIONS.put("resistance", PotionEffectType.DAMAGE_RESISTANCE);
|
||||
ALIASPOTIONS.put("dmgresist", PotionEffectType.DAMAGE_RESISTANCE);
|
||||
ALIASPOTIONS.put("armor", PotionEffectType.DAMAGE_RESISTANCE);
|
||||
POTIONS.put("fireresist", PotionEffectType.FIRE_RESISTANCE);
|
||||
ALIASPOTIONS.put("fireresistance", PotionEffectType.FIRE_RESISTANCE);
|
||||
ALIASPOTIONS.put("resistfire", PotionEffectType.FIRE_RESISTANCE);
|
||||
|
||||
POTIONS.put("fireresist", PotionEffectType.FIRE_RESISTANCE);
|
||||
ALIASPOTIONS.put("fireresistance", PotionEffectType.FIRE_RESISTANCE);
|
||||
ALIASPOTIONS.put("resistfire", PotionEffectType.FIRE_RESISTANCE);
|
||||
POTIONS.put("waterbreath", PotionEffectType.WATER_BREATHING);
|
||||
ALIASPOTIONS.put("waterbreathing", PotionEffectType.WATER_BREATHING);
|
||||
|
||||
POTIONS.put("waterbreath", PotionEffectType.WATER_BREATHING);
|
||||
ALIASPOTIONS.put("waterbreathing", PotionEffectType.WATER_BREATHING);
|
||||
POTIONS.put("invisibility", PotionEffectType.INVISIBILITY);
|
||||
ALIASPOTIONS.put("invisible", PotionEffectType.INVISIBILITY);
|
||||
ALIASPOTIONS.put("invis", PotionEffectType.INVISIBILITY);
|
||||
ALIASPOTIONS.put("vanish", PotionEffectType.INVISIBILITY);
|
||||
ALIASPOTIONS.put("disappear", PotionEffectType.INVISIBILITY);
|
||||
|
||||
POTIONS.put("invisibility", PotionEffectType.INVISIBILITY);
|
||||
ALIASPOTIONS.put("invisible", PotionEffectType.INVISIBILITY);
|
||||
ALIASPOTIONS.put("invis", PotionEffectType.INVISIBILITY);
|
||||
ALIASPOTIONS.put("vanish", PotionEffectType.INVISIBILITY);
|
||||
ALIASPOTIONS.put("disappear", PotionEffectType.INVISIBILITY);
|
||||
POTIONS.put("blindness", PotionEffectType.BLINDNESS);
|
||||
ALIASPOTIONS.put("blind", PotionEffectType.BLINDNESS);
|
||||
|
||||
POTIONS.put("blindness", PotionEffectType.BLINDNESS);
|
||||
ALIASPOTIONS.put("blind", PotionEffectType.BLINDNESS);
|
||||
POTIONS.put("nightvision", PotionEffectType.NIGHT_VISION);
|
||||
ALIASPOTIONS.put("vision", PotionEffectType.NIGHT_VISION);
|
||||
|
||||
POTIONS.put("nightvision", PotionEffectType.NIGHT_VISION);
|
||||
ALIASPOTIONS.put("vision", PotionEffectType.NIGHT_VISION);
|
||||
POTIONS.put("hunger", PotionEffectType.HUNGER);
|
||||
ALIASPOTIONS.put("hungry", PotionEffectType.HUNGER);
|
||||
ALIASPOTIONS.put("starve", PotionEffectType.HUNGER);
|
||||
|
||||
POTIONS.put("hunger", PotionEffectType.HUNGER);
|
||||
ALIASPOTIONS.put("hungry", PotionEffectType.HUNGER);
|
||||
ALIASPOTIONS.put("starve", PotionEffectType.HUNGER);
|
||||
POTIONS.put("weakness", PotionEffectType.WEAKNESS);
|
||||
ALIASPOTIONS.put("weak", PotionEffectType.WEAKNESS);
|
||||
|
||||
POTIONS.put("weakness", PotionEffectType.WEAKNESS);
|
||||
ALIASPOTIONS.put("weak", PotionEffectType.WEAKNESS);
|
||||
POTIONS.put("poison", PotionEffectType.POISON);
|
||||
ALIASPOTIONS.put("venom", PotionEffectType.POISON);
|
||||
|
||||
POTIONS.put("poison", PotionEffectType.POISON);
|
||||
ALIASPOTIONS.put("venom", PotionEffectType.POISON);
|
||||
POTIONS.put("wither", PotionEffectType.WITHER);
|
||||
ALIASPOTIONS.put("decay", PotionEffectType.WITHER);
|
||||
|
||||
POTIONS.put("wither", PotionEffectType.WITHER);
|
||||
ALIASPOTIONS.put("decay", PotionEffectType.WITHER);
|
||||
POTIONS.put("healthboost", PotionEffectType.HEALTH_BOOST);
|
||||
ALIASPOTIONS.put("boost", PotionEffectType.HEALTH_BOOST);
|
||||
|
||||
POTIONS.put("absorption", PotionEffectType.ABSORPTION);
|
||||
ALIASPOTIONS.put("absorb", PotionEffectType.ABSORPTION);
|
||||
|
||||
try // 1.6 update
|
||||
{
|
||||
POTIONS.put("healthboost", PotionEffectType.HEALTH_BOOST);
|
||||
ALIASPOTIONS.put("boost", PotionEffectType.HEALTH_BOOST);
|
||||
POTIONS.put("saturation", PotionEffectType.SATURATION);
|
||||
ALIASPOTIONS.put("food", PotionEffectType.SATURATION);
|
||||
|
||||
POTIONS.put("absorption", PotionEffectType.ABSORPTION);
|
||||
ALIASPOTIONS.put("absorb", PotionEffectType.ABSORPTION);
|
||||
POTIONS.put("waterbreathing", PotionEffectType.WATER_BREATHING);
|
||||
ALIASPOTIONS.put("underwaterbreathing", PotionEffectType.WATER_BREATHING);
|
||||
ALIASPOTIONS.put("waterbreath", PotionEffectType.WATER_BREATHING);
|
||||
ALIASPOTIONS.put("underwaterbreath", PotionEffectType.WATER_BREATHING);
|
||||
ALIASPOTIONS.put("air", PotionEffectType.WATER_BREATHING);
|
||||
|
||||
POTIONS.put("saturation", PotionEffectType.SATURATION);
|
||||
ALIASPOTIONS.put("food", PotionEffectType.SATURATION);
|
||||
}
|
||||
catch (java.lang.NoSuchFieldError e)
|
||||
{
|
||||
Essentials.wrongVersion();
|
||||
}
|
||||
|
||||
try // 1.7 update
|
||||
{
|
||||
POTIONS.put("waterbreathing", PotionEffectType.WATER_BREATHING);
|
||||
ALIASPOTIONS.put("underwaterbreathing", PotionEffectType.WATER_BREATHING);
|
||||
ALIASPOTIONS.put("waterbreath", PotionEffectType.WATER_BREATHING);
|
||||
ALIASPOTIONS.put("underwaterbreath", PotionEffectType.WATER_BREATHING);
|
||||
ALIASPOTIONS.put("air", PotionEffectType.WATER_BREATHING);
|
||||
}
|
||||
catch (java.lang.NoSuchFieldError e)
|
||||
{
|
||||
Essentials.wrongVersion();
|
||||
}
|
||||
}
|
||||
// 1.9
|
||||
try {
|
||||
POTIONS.put("glowing", PotionEffectType.GLOWING);
|
||||
ALIASPOTIONS.put("glow", PotionEffectType.GLOWING);
|
||||
|
||||
public static PotionEffectType getByName(String name)
|
||||
{
|
||||
PotionEffectType peffect;
|
||||
if (NumberUtil.isInt(name))
|
||||
{
|
||||
peffect = PotionEffectType.getById(Integer.parseInt(name));
|
||||
}
|
||||
else
|
||||
{
|
||||
peffect = PotionEffectType.getByName(name.toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
if (peffect == null)
|
||||
{
|
||||
peffect = POTIONS.get(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
if (peffect == null)
|
||||
{
|
||||
peffect = ALIASPOTIONS.get(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
return peffect;
|
||||
}
|
||||
POTIONS.put("levitation", PotionEffectType.LEVITATION);
|
||||
ALIASPOTIONS.put("levitate", PotionEffectType.LEVITATION);
|
||||
|
||||
public static Set<Entry<String, PotionEffectType>> entrySet()
|
||||
{
|
||||
return POTIONS.entrySet();
|
||||
}
|
||||
POTIONS.put("luck", PotionEffectType.LUCK);
|
||||
POTIONS.put("unluck", PotionEffectType.UNLUCK);
|
||||
} catch (final Throwable ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private Potions() {
|
||||
}
|
||||
|
||||
public static PotionEffectType getByName(final String name) {
|
||||
PotionEffectType peffect;
|
||||
if (NumberUtil.isInt(name)) {
|
||||
peffect = PotionEffectType.getById(Integer.parseInt(name));
|
||||
} else {
|
||||
peffect = PotionEffectType.getByName(name.toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
if (peffect == null) {
|
||||
peffect = POTIONS.get(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
if (peffect == null) {
|
||||
peffect = ALIASPOTIONS.get(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
return peffect;
|
||||
}
|
||||
|
||||
public static Set<Entry<String, PotionEffectType>> entrySet() {
|
||||
return POTIONS.entrySet();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.utils.LocationUtil;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.ess3.api.InvalidWorldException;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
public class RandomTeleport implements IConf {
|
||||
private static final Random RANDOM = new Random();
|
||||
private static final int HIGHEST_BLOCK_Y_OFFSET = VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_15_R01) ? 1 : 0;
|
||||
private final IEssentials essentials;
|
||||
private final EssentialsConf config;
|
||||
private final ConcurrentLinkedQueue<Location> cachedLocations = new ConcurrentLinkedQueue<>();
|
||||
|
||||
public RandomTeleport(final IEssentials essentials) {
|
||||
this.essentials = essentials;
|
||||
final File file = new File(essentials.getDataFolder(), "tpr.yml");
|
||||
config = new EssentialsConf(file);
|
||||
config.setTemplateName("/tpr.yml");
|
||||
config.options().copyHeader(true);
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
config.load();
|
||||
cachedLocations.clear();
|
||||
}
|
||||
|
||||
public Location getCenter() {
|
||||
try {
|
||||
final Location center = config.getLocation("center", essentials.getServer());
|
||||
if (center != null) {
|
||||
return center;
|
||||
}
|
||||
} catch (final InvalidWorldException ignored) {
|
||||
}
|
||||
final Location center = essentials.getServer().getWorlds().get(0).getWorldBorder().getCenter();
|
||||
center.setY(center.getWorld().getHighestBlockYAt(center) + 1);
|
||||
setCenter(center);
|
||||
return center;
|
||||
}
|
||||
|
||||
public void setCenter(final Location center) {
|
||||
config.setProperty("center", center);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public double getMinRange() {
|
||||
return config.getDouble("min-range", 0d);
|
||||
}
|
||||
|
||||
public void setMinRange(final double minRange) {
|
||||
config.setProperty("min-range", minRange);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public double getMaxRange() {
|
||||
return config.getDouble("max-range", getCenter().getWorld().getWorldBorder().getSize() / 2);
|
||||
}
|
||||
|
||||
public void setMaxRange(final double maxRange) {
|
||||
config.setProperty("max-range", maxRange);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public Set<Biome> getExcludedBiomes() {
|
||||
final List<String> biomeNames = config.getStringList("excluded-biomes");
|
||||
final Set<Biome> excludedBiomes = new HashSet<>();
|
||||
for (final String biomeName : biomeNames) {
|
||||
try {
|
||||
excludedBiomes.add(Biome.valueOf(biomeName.toUpperCase()));
|
||||
} catch (final IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
return excludedBiomes;
|
||||
}
|
||||
|
||||
public int getFindAttempts() {
|
||||
return config.getInt("find-attempts", 10);
|
||||
}
|
||||
|
||||
public int getCacheThreshold() {
|
||||
return config.getInt("cache-threshold", 10);
|
||||
}
|
||||
|
||||
public boolean getPreCache() {
|
||||
return config.getBoolean("pre-cache", false);
|
||||
}
|
||||
|
||||
public Queue<Location> getCachedLocations() {
|
||||
return cachedLocations;
|
||||
}
|
||||
|
||||
// Get a random location; cached if possible. Otherwise on demand.
|
||||
public CompletableFuture<Location> getRandomLocation(final Location center, final double minRange, final double maxRange) {
|
||||
final int findAttempts = this.getFindAttempts();
|
||||
final Queue<Location> cachedLocations = this.getCachedLocations();
|
||||
// Try to build up the cache if it is below the threshold
|
||||
if (cachedLocations.size() < this.getCacheThreshold()) {
|
||||
cacheRandomLocations(center, minRange, maxRange);
|
||||
}
|
||||
final CompletableFuture<Location> future = new CompletableFuture<>();
|
||||
// Return a random location immediately if one is available, otherwise try to find one now
|
||||
if (cachedLocations.isEmpty()) {
|
||||
attemptRandomLocation(findAttempts, center, minRange, maxRange).thenAccept(future::complete);
|
||||
} else {
|
||||
future.complete(cachedLocations.poll());
|
||||
}
|
||||
return future;
|
||||
}
|
||||
|
||||
// Prompts caching random valid locations, up to a maximum number of attempts
|
||||
public void cacheRandomLocations(final Location center, final double minRange, final double maxRange) {
|
||||
essentials.getServer().getScheduler().scheduleSyncDelayedTask(essentials, () -> {
|
||||
for (int i = 0; i < this.getFindAttempts(); ++i) {
|
||||
calculateRandomLocation(center, minRange, maxRange).thenAccept(location -> {
|
||||
if (isValidRandomLocation(location)) {
|
||||
this.getCachedLocations().add(location);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Recursively attempt to find a random location. After a maximum number of attempts, the center is returned.
|
||||
private CompletableFuture<Location> attemptRandomLocation(final int attempts, final Location center, final double minRange, final double maxRange) {
|
||||
final CompletableFuture<Location> future = new CompletableFuture<>();
|
||||
if (attempts > 0) {
|
||||
calculateRandomLocation(center, minRange, maxRange).thenAccept(location -> {
|
||||
if (isValidRandomLocation(location)) {
|
||||
future.complete(location);
|
||||
} else {
|
||||
attemptRandomLocation(attempts - 1, center, minRange, maxRange).thenAccept(future::complete);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
future.complete(center);
|
||||
}
|
||||
return future;
|
||||
}
|
||||
|
||||
// Calculates a random location asynchronously.
|
||||
private CompletableFuture<Location> calculateRandomLocation(final Location center, final double minRange, final double maxRange) {
|
||||
final CompletableFuture<Location> future = new CompletableFuture<>();
|
||||
// Find an equally distributed offset by randomly rotating a point inside a rectangle about the origin
|
||||
final double rectX = RANDOM.nextDouble() * (maxRange - minRange) + minRange;
|
||||
final double rectZ = RANDOM.nextDouble() * (maxRange + minRange) - minRange;
|
||||
final double offsetX;
|
||||
final double offsetZ;
|
||||
final int transform = RANDOM.nextInt(4);
|
||||
if (transform == 0) {
|
||||
offsetX = rectX;
|
||||
offsetZ = rectZ;
|
||||
} else if (transform == 1) {
|
||||
offsetX = -rectZ;
|
||||
offsetZ = rectX;
|
||||
} else if (transform == 2) {
|
||||
offsetX = -rectX;
|
||||
offsetZ = -rectZ;
|
||||
} else {
|
||||
offsetX = rectZ;
|
||||
offsetZ = -rectX;
|
||||
}
|
||||
final Location location = new Location(
|
||||
center.getWorld(),
|
||||
center.getX() + offsetX,
|
||||
center.getWorld().getMaxHeight(),
|
||||
center.getZ() + offsetZ,
|
||||
360 * RANDOM.nextFloat() - 180,
|
||||
0
|
||||
);
|
||||
PaperLib.getChunkAtAsync(location).thenAccept(chunk -> {
|
||||
if (World.Environment.NETHER.equals(center.getWorld().getEnvironment())) {
|
||||
location.setY(getNetherYAt(location));
|
||||
} else {
|
||||
location.setY(center.getWorld().getHighestBlockYAt(location) + HIGHEST_BLOCK_Y_OFFSET);
|
||||
}
|
||||
future.complete(location);
|
||||
});
|
||||
return future;
|
||||
}
|
||||
|
||||
// Returns an appropriate elevation for a given location in the nether, or -1 if none is found
|
||||
private double getNetherYAt(final Location location) {
|
||||
for (int y = 32; y < location.getWorld().getMaxHeight() / 2; ++y) {
|
||||
if (!LocationUtil.isBlockUnsafe(location.getWorld(), location.getBlockX(), y, location.getBlockZ())) {
|
||||
return y;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private boolean isValidRandomLocation(final Location location) {
|
||||
return location.getBlockY() > 0 && !this.getExcludedBiomes().contains(location.getBlock().getBiome());
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,308 +1,278 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Mob.MobException;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import com.earth2me.essentials.utils.LocationUtil;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.PigZombie;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
public class SpawnMob
|
||||
{
|
||||
public static String mobList(final User user)
|
||||
{
|
||||
final Set<String> mobList = Mob.getMobList();
|
||||
final Set<String> availableList = new HashSet<String>();
|
||||
for (String mob : mobList)
|
||||
{
|
||||
if (user.isAuthorized("essentials.spawnmob." + mob.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
availableList.add(mob);
|
||||
}
|
||||
}
|
||||
if (availableList.isEmpty())
|
||||
{
|
||||
availableList.add(_("none"));
|
||||
}
|
||||
return StringUtil.joinList(availableList);
|
||||
}
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public static List<String> mobParts(final String mobString)
|
||||
{
|
||||
String[] mobParts = mobString.split(",");
|
||||
public final class SpawnMob {
|
||||
|
||||
List<String> mobs = new ArrayList<String>();
|
||||
private static final Material GOLDEN_HELMET = EnumUtil.getMaterial("GOLDEN_HELMET", "GOLD_HELMET");
|
||||
private static final Material GOLDEN_CHESTPLATE = EnumUtil.getMaterial("GOLDEN_CHESTPLATE", "GOLD_CHESTPLATE");
|
||||
private static final Material GOLDEN_LEGGINGS = EnumUtil.getMaterial("GOLDEN_LEGGINGS", "GOLD_LEGGINGS");
|
||||
private static final Material GOLDEN_BOOTS = EnumUtil.getMaterial("GOLDEN_BOOTS", "GOLD_BOOTS");
|
||||
private static final Material GOLDEN_SWORD = EnumUtil.getMaterial("GOLDEN_SWORD", "GOLD_SWORD");
|
||||
|
||||
for (String mobPart : mobParts)
|
||||
{
|
||||
String[] mobDatas = mobPart.split(":");
|
||||
mobs.add(mobDatas[0]);
|
||||
}
|
||||
return mobs;
|
||||
}
|
||||
private SpawnMob() {
|
||||
}
|
||||
|
||||
public static List<String> mobData(final String mobString)
|
||||
{
|
||||
String[] mobParts = mobString.split(",");
|
||||
public static String mobList(final User user) {
|
||||
final Set<String> mobList = Mob.getMobList();
|
||||
final Set<String> availableList = new HashSet<>();
|
||||
for (final String mob : mobList) {
|
||||
if (user.isAuthorized("essentials.spawnmob." + mob.toLowerCase(Locale.ENGLISH))) {
|
||||
availableList.add(mob);
|
||||
}
|
||||
}
|
||||
if (availableList.isEmpty()) {
|
||||
availableList.add(tl("none"));
|
||||
}
|
||||
return StringUtil.joinList(availableList);
|
||||
}
|
||||
|
||||
List<String> mobData = new ArrayList<String>();
|
||||
public static List<String> mobParts(final String mobString) {
|
||||
final String[] mobParts = mobString.split(",");
|
||||
|
||||
for (String mobPart : mobParts)
|
||||
{
|
||||
String[] mobDatas = mobPart.split(":");
|
||||
if (mobDatas.length == 1)
|
||||
{
|
||||
if (mobPart.contains(":"))
|
||||
{
|
||||
mobData.add("");
|
||||
}
|
||||
else
|
||||
{
|
||||
mobData.add(null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mobData.add(mobDatas[1]);
|
||||
}
|
||||
}
|
||||
final List<String> mobs = new ArrayList<>();
|
||||
|
||||
return mobData;
|
||||
}
|
||||
for (final String mobPart : mobParts) {
|
||||
final String[] mobDatas = mobPart.split(":");
|
||||
mobs.add(mobDatas[0]);
|
||||
}
|
||||
return mobs;
|
||||
}
|
||||
|
||||
// This method spawns a mob where the user is looking, owned by user
|
||||
public static void spawnmob(final IEssentials ess, final Server server, final User user, final List<String> parts, final List<String> data, int mobCount) throws Exception
|
||||
{
|
||||
final Block block = LocationUtil.getTarget(user.getBase()).getBlock();
|
||||
if (block == null)
|
||||
{
|
||||
throw new Exception(_("unableToSpawnMob"));
|
||||
}
|
||||
spawnmob(ess, server, user.getSource(), user, block.getLocation(), parts, data, mobCount);
|
||||
}
|
||||
public static List<String> mobData(final String mobString) {
|
||||
final String[] mobParts = mobString.split(",");
|
||||
|
||||
// This method spawns a mob at target, owned by target
|
||||
public static void spawnmob(final IEssentials ess, final Server server, final CommandSource sender, final User target, final List<String> parts, final List<String> data, int mobCount) throws Exception
|
||||
{
|
||||
spawnmob(ess, server, sender, target, target.getLocation(), parts, data, mobCount);
|
||||
}
|
||||
final List<String> mobData = new ArrayList<>();
|
||||
|
||||
// This method spawns a mob at loc, owned by target
|
||||
public static void spawnmob(final IEssentials ess, final Server server, final CommandSource sender, final User target, final Location loc, final List<String> parts, final List<String> data, int mobCount) throws Exception
|
||||
{
|
||||
final Location sloc = LocationUtil.getSafeDestination(loc);
|
||||
for (final String mobPart : mobParts) {
|
||||
final String[] mobDatas = mobPart.split(":");
|
||||
if (mobDatas.length == 1) {
|
||||
if (mobPart.contains(":")) {
|
||||
mobData.add("");
|
||||
} else {
|
||||
mobData.add(null);
|
||||
}
|
||||
} else {
|
||||
mobData.add(mobDatas[1]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < parts.size(); i++)
|
||||
{
|
||||
Mob mob = Mob.fromName(parts.get(i));
|
||||
checkSpawnable(ess, sender, mob);
|
||||
}
|
||||
return mobData;
|
||||
}
|
||||
|
||||
final int serverLimit = ess.getSettings().getSpawnMobLimit();
|
||||
int effectiveLimit = serverLimit / parts.size();
|
||||
// This method spawns a mob where the user is looking, owned by user
|
||||
public static void spawnmob(final IEssentials ess, final Server server, final User user, final List<String> parts, final List<String> data, final int mobCount) throws Exception {
|
||||
final Block block = LocationUtil.getTarget(user.getBase()).getBlock();
|
||||
if (block == null) {
|
||||
throw new Exception(tl("unableToSpawnMob"));
|
||||
}
|
||||
spawnmob(ess, server, user.getSource(), user, block.getLocation(), parts, data, mobCount);
|
||||
}
|
||||
|
||||
if (effectiveLimit < 1)
|
||||
{
|
||||
effectiveLimit = 1;
|
||||
while (parts.size() > serverLimit)
|
||||
{
|
||||
parts.remove(serverLimit);
|
||||
}
|
||||
}
|
||||
// This method spawns a mob at target, owned by target
|
||||
public static void spawnmob(final IEssentials ess, final Server server, final CommandSource sender, final User target, final List<String> parts, final List<String> data, final int mobCount) throws Exception {
|
||||
spawnmob(ess, server, sender, target, target.getLocation(), parts, data, mobCount);
|
||||
}
|
||||
|
||||
if (mobCount > effectiveLimit)
|
||||
{
|
||||
mobCount = effectiveLimit;
|
||||
sender.sendMessage(_("mobSpawnLimit"));
|
||||
}
|
||||
// This method spawns a mob at loc, owned by target
|
||||
public static void spawnmob(final IEssentials ess, final Server server, final CommandSource sender, final User target, final Location loc, final List<String> parts, final List<String> data, int mobCount) throws Exception {
|
||||
final Location sloc = LocationUtil.getSafeDestination(loc);
|
||||
|
||||
Mob mob = Mob.fromName(parts.get(0)); // Get the first mob
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < mobCount; i++)
|
||||
{
|
||||
spawnMob(ess, server, sender, target, sloc, parts, data);
|
||||
}
|
||||
sender.sendMessage(mobCount * parts.size() + " " + mob.name.toLowerCase(Locale.ENGLISH) + mob.suffix + " " + _("spawned"));
|
||||
}
|
||||
catch (MobException e1)
|
||||
{
|
||||
throw new Exception(_("unableToSpawnMob"), e1);
|
||||
}
|
||||
catch (NumberFormatException e2)
|
||||
{
|
||||
throw new Exception(_("numberRequired"), e2);
|
||||
}
|
||||
catch (NullPointerException np)
|
||||
{
|
||||
throw new Exception(_("soloMob"), np);
|
||||
}
|
||||
}
|
||||
for (final String part : parts) {
|
||||
final Mob mob = Mob.fromName(part);
|
||||
checkSpawnable(ess, sender, mob);
|
||||
}
|
||||
|
||||
private static void spawnMob(final IEssentials ess, final Server server, final CommandSource sender, final User target, final Location sloc, List<String> parts, List<String> data) throws Exception
|
||||
{
|
||||
Mob mob;
|
||||
Entity spawnedMob = null;
|
||||
Entity spawnedMount;
|
||||
final int serverLimit = ess.getSettings().getSpawnMobLimit();
|
||||
int effectiveLimit = serverLimit / parts.size();
|
||||
|
||||
for (int i = 0; i < parts.size(); i++)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
mob = Mob.fromName(parts.get(i));
|
||||
spawnedMob = mob.spawn(sloc.getWorld(), server, sloc);
|
||||
defaultMobData(mob.getType(), spawnedMob);
|
||||
if (effectiveLimit < 1) {
|
||||
effectiveLimit = 1;
|
||||
while (parts.size() > serverLimit) {
|
||||
parts.remove(serverLimit);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.get(i) != null)
|
||||
{
|
||||
changeMobData(sender, mob.getType(), spawnedMob, data.get(i).toLowerCase(Locale.ENGLISH), target);
|
||||
}
|
||||
}
|
||||
if (mobCount > effectiveLimit) {
|
||||
mobCount = effectiveLimit;
|
||||
sender.sendMessage(tl("mobSpawnLimit"));
|
||||
}
|
||||
|
||||
int next = (i + 1);
|
||||
if (next < parts.size()) //If it's the last mob in the list, don't set the mount
|
||||
{
|
||||
Mob mMob = Mob.fromName(parts.get(next));
|
||||
spawnedMount = mMob.spawn(sloc.getWorld(), server, sloc);
|
||||
defaultMobData(mMob.getType(), spawnedMount);
|
||||
final Mob mob = Mob.fromName(parts.get(0)); // Get the first mob
|
||||
try {
|
||||
for (int i = 0; i < mobCount; i++) {
|
||||
spawnMob(ess, server, sender, target, sloc, parts, data);
|
||||
}
|
||||
sender.sendMessage(mobCount * parts.size() + " " + mob.name.toLowerCase(Locale.ENGLISH) + mob.suffix + " " + tl("spawned"));
|
||||
} catch (final MobException e1) {
|
||||
throw new Exception(tl("unableToSpawnMob"), e1);
|
||||
} catch (final NumberFormatException e2) {
|
||||
throw new Exception(tl("numberRequired"), e2);
|
||||
} catch (final NullPointerException np) {
|
||||
throw new Exception(tl("soloMob"), np);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.get(next) != null)
|
||||
{
|
||||
changeMobData(sender, mMob.getType(), spawnedMount, data.get(next).toLowerCase(Locale.ENGLISH), target);
|
||||
}
|
||||
private static void spawnMob(final IEssentials ess, final Server server, final CommandSource sender, final User target, final Location sloc, final List<String> parts, final List<String> data) throws Exception {
|
||||
Mob mob;
|
||||
Entity spawnedMob = null;
|
||||
Entity spawnedMount;
|
||||
|
||||
spawnedMob.setPassenger(spawnedMount);
|
||||
for (int i = 0; i < parts.size(); i++) {
|
||||
if (i == 0) {
|
||||
mob = Mob.fromName(parts.get(i));
|
||||
spawnedMob = mob.spawn(sloc.getWorld(), server, sloc);
|
||||
defaultMobData(mob.getType(), spawnedMob);
|
||||
|
||||
spawnedMob = spawnedMount;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (data.get(i) != null) {
|
||||
changeMobData(sender, mob.getType(), spawnedMob, data.get(i).toLowerCase(Locale.ENGLISH), target);
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkSpawnable(IEssentials ess, CommandSource sender, Mob mob) throws Exception
|
||||
{
|
||||
if (mob == null)
|
||||
{
|
||||
throw new Exception(_("invalidMob"));
|
||||
}
|
||||
final int next = i + 1;
|
||||
// If it's the last mob in the list, don't set the mount
|
||||
if (next < parts.size()) {
|
||||
final Mob mMob = Mob.fromName(parts.get(next));
|
||||
spawnedMount = mMob.spawn(sloc.getWorld(), server, sloc);
|
||||
defaultMobData(mMob.getType(), spawnedMount);
|
||||
|
||||
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new Exception(_("disabledToSpawnMob"));
|
||||
}
|
||||
if (data.get(next) != null) {
|
||||
changeMobData(sender, mMob.getType(), spawnedMount, data.get(next).toLowerCase(Locale.ENGLISH), target);
|
||||
}
|
||||
|
||||
if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.spawnmob." + mob.name.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new Exception(_("noPermToSpawnMob"));
|
||||
}
|
||||
}
|
||||
spawnedMob.setPassenger(spawnedMount);
|
||||
|
||||
private static void changeMobData(final CommandSource sender, final EntityType type, final Entity spawned, final String inputData, final User target) throws Exception
|
||||
{
|
||||
String data = inputData;
|
||||
spawnedMob = spawnedMount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (data.isEmpty())
|
||||
{
|
||||
sender.sendMessage(_("mobDataList", StringUtil.joinList(MobData.getValidHelp(spawned))));
|
||||
}
|
||||
private static void checkSpawnable(final IEssentials ess, final CommandSource sender, final Mob mob) throws Exception {
|
||||
if (mob == null || mob.getType() == null) {
|
||||
throw new Exception(tl("invalidMob"));
|
||||
}
|
||||
|
||||
if (spawned instanceof Zombie || type == EntityType.SKELETON)
|
||||
{
|
||||
if (inputData.contains("armor") || inputData.contains("armour"))
|
||||
{
|
||||
final EntityEquipment invent = ((LivingEntity)spawned).getEquipment();
|
||||
if (inputData.contains("noarmor") || inputData.contains("noarmour"))
|
||||
{
|
||||
invent.clear();
|
||||
}
|
||||
else if (inputData.contains("diamond"))
|
||||
{
|
||||
invent.setBoots(new ItemStack(Material.DIAMOND_BOOTS, 1));
|
||||
invent.setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS, 1));
|
||||
invent.setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE, 1));
|
||||
invent.setHelmet(new ItemStack(Material.DIAMOND_HELMET, 1));
|
||||
}
|
||||
else if (inputData.contains("gold"))
|
||||
{
|
||||
invent.setBoots(new ItemStack(Material.GOLD_BOOTS, 1));
|
||||
invent.setLeggings(new ItemStack(Material.GOLD_LEGGINGS, 1));
|
||||
invent.setChestplate(new ItemStack(Material.GOLD_CHESTPLATE, 1));
|
||||
invent.setHelmet(new ItemStack(Material.GOLD_HELMET, 1));
|
||||
}
|
||||
else if (inputData.contains("leather"))
|
||||
{
|
||||
invent.setBoots(new ItemStack(Material.LEATHER_BOOTS, 1));
|
||||
invent.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS, 1));
|
||||
invent.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE, 1));
|
||||
invent.setHelmet(new ItemStack(Material.LEATHER_HELMET, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
invent.setBoots(new ItemStack(Material.IRON_BOOTS, 1));
|
||||
invent.setLeggings(new ItemStack(Material.IRON_LEGGINGS, 1));
|
||||
invent.setChestplate(new ItemStack(Material.IRON_CHESTPLATE, 1));
|
||||
invent.setHelmet(new ItemStack(Material.IRON_HELMET, 1));
|
||||
}
|
||||
invent.setBootsDropChance(0f);
|
||||
invent.setLeggingsDropChance(0f);
|
||||
invent.setChestplateDropChance(0f);
|
||||
invent.setHelmetDropChance(0f);
|
||||
}
|
||||
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH))) {
|
||||
throw new Exception(tl("disabledToSpawnMob"));
|
||||
}
|
||||
|
||||
}
|
||||
if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.spawnmob." + mob.name.toLowerCase(Locale.ENGLISH))) {
|
||||
throw new Exception(tl("noPermToSpawnMob"));
|
||||
}
|
||||
}
|
||||
|
||||
MobData newData = MobData.fromData(spawned, data);
|
||||
while (newData != null)
|
||||
{
|
||||
newData.setData(spawned, target.getBase(), data);
|
||||
data = data.replace(newData.getMatched(), "");
|
||||
newData = MobData.fromData(spawned, data);
|
||||
}
|
||||
}
|
||||
private static void changeMobData(final CommandSource sender, final EntityType type, final Entity spawned, final String inputData, final User target) throws Exception {
|
||||
String data = inputData;
|
||||
|
||||
private static void defaultMobData(final EntityType type, final Entity spawned)
|
||||
{
|
||||
if (type == EntityType.SKELETON)
|
||||
{
|
||||
final EntityEquipment invent = ((LivingEntity)spawned).getEquipment();
|
||||
invent.setItemInHand(new ItemStack(Material.BOW, 1));
|
||||
invent.setItemInHandDropChance(0.1f);
|
||||
if (data.isEmpty()) {
|
||||
sender.sendMessage(tl("mobDataList", StringUtil.joinList(MobData.getValidHelp(spawned))));
|
||||
}
|
||||
|
||||
invent.setBoots(new ItemStack(Material.GOLD_BOOTS, 1));
|
||||
invent.setBootsDropChance(0.0f);
|
||||
}
|
||||
if (spawned instanceof Zombie) {
|
||||
((Zombie) spawned).setBaby(false);
|
||||
} else if (spawned instanceof Ageable) {
|
||||
((Ageable) spawned).setAdult();
|
||||
}
|
||||
|
||||
if (type == EntityType.PIG_ZOMBIE)
|
||||
{
|
||||
final EntityEquipment invent = ((LivingEntity)spawned).getEquipment();
|
||||
invent.setItemInHand(new ItemStack(Material.GOLD_SWORD, 1));
|
||||
invent.setItemInHandDropChance(0.1f);
|
||||
if (spawned instanceof Zombie || type == EntityType.SKELETON) {
|
||||
if (inputData.contains("armor") || inputData.contains("armour")) {
|
||||
final EntityEquipment invent = ((LivingEntity) spawned).getEquipment();
|
||||
if (inputData.contains("noarmor") || inputData.contains("noarmour")) {
|
||||
invent.clear();
|
||||
} else if (inputData.contains("diamond")) {
|
||||
invent.setBoots(new ItemStack(Material.DIAMOND_BOOTS, 1));
|
||||
invent.setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS, 1));
|
||||
invent.setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE, 1));
|
||||
invent.setHelmet(new ItemStack(Material.DIAMOND_HELMET, 1));
|
||||
} else if (inputData.contains("gold")) {
|
||||
invent.setBoots(new ItemStack(GOLDEN_BOOTS, 1));
|
||||
invent.setLeggings(new ItemStack(GOLDEN_LEGGINGS, 1));
|
||||
invent.setChestplate(new ItemStack(GOLDEN_CHESTPLATE, 1));
|
||||
invent.setHelmet(new ItemStack(GOLDEN_HELMET, 1));
|
||||
} else if (inputData.contains("leather")) {
|
||||
invent.setBoots(new ItemStack(Material.LEATHER_BOOTS, 1));
|
||||
invent.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS, 1));
|
||||
invent.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE, 1));
|
||||
invent.setHelmet(new ItemStack(Material.LEATHER_HELMET, 1));
|
||||
} else if (inputData.contains("iron")) {
|
||||
invent.setBoots(new ItemStack(Material.IRON_BOOTS, 1));
|
||||
invent.setLeggings(new ItemStack(Material.IRON_LEGGINGS, 1));
|
||||
invent.setChestplate(new ItemStack(Material.IRON_CHESTPLATE, 1));
|
||||
invent.setHelmet(new ItemStack(Material.IRON_HELMET, 1));
|
||||
}
|
||||
invent.setBootsDropChance(0f);
|
||||
invent.setLeggingsDropChance(0f);
|
||||
invent.setChestplateDropChance(0f);
|
||||
invent.setHelmetDropChance(0f);
|
||||
}
|
||||
|
||||
invent.setBoots(new ItemStack(Material.GOLD_BOOTS, 1));
|
||||
invent.setBootsDropChance(0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
if (type == EntityType.ZOMBIE)
|
||||
{
|
||||
final EntityEquipment invent = ((LivingEntity)spawned).getEquipment();
|
||||
invent.setBoots(new ItemStack(Material.GOLD_BOOTS, 1));
|
||||
invent.setBootsDropChance(0.0f);
|
||||
}
|
||||
MobData newData = MobData.fromData(spawned, data);
|
||||
while (newData != null) {
|
||||
newData.setData(spawned, target.getBase(), data);
|
||||
data = data.replace(newData.getMatched(), "");
|
||||
newData = MobData.fromData(spawned, data);
|
||||
}
|
||||
}
|
||||
|
||||
if (type == EntityType.HORSE)
|
||||
{
|
||||
((Horse)spawned).setJumpStrength(1.2);
|
||||
}
|
||||
}
|
||||
private static void defaultMobData(final EntityType type, final Entity spawned) {
|
||||
if (type == EntityType.SKELETON) {
|
||||
final EntityEquipment invent = ((LivingEntity) spawned).getEquipment();
|
||||
InventoryWorkaround.setItemInMainHand(invent, new ItemStack(Material.BOW, 1));
|
||||
InventoryWorkaround.setItemInMainHandDropChance(invent, 0.1f);
|
||||
}
|
||||
|
||||
if (type == MobCompat.ZOMBIFIED_PIGLIN) {
|
||||
final PigZombie zombie = (PigZombie) spawned;
|
||||
setVillager(zombie, false);
|
||||
|
||||
final EntityEquipment invent = zombie.getEquipment();
|
||||
InventoryWorkaround.setItemInMainHand(invent, new ItemStack(GOLDEN_SWORD, 1));
|
||||
InventoryWorkaround.setItemInMainHandDropChance(invent, 0.1f);
|
||||
}
|
||||
|
||||
if (type == EntityType.ZOMBIE) {
|
||||
final Zombie zombie = (Zombie) spawned;
|
||||
setVillager(zombie, false);
|
||||
}
|
||||
|
||||
if (type == EntityType.HORSE) {
|
||||
((Horse) spawned).setJumpStrength(1.2);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static void setVillager(final Zombie zombie, final boolean villager) {
|
||||
try {
|
||||
zombie.setVillager(villager);
|
||||
} catch (final Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,56 +7,45 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
public class TNTExplodeListener implements Listener, Runnable {
|
||||
private final transient IEssentials ess;
|
||||
private transient boolean enabled = false;
|
||||
private transient int timer = -1;
|
||||
|
||||
public class TNTExplodeListener implements Listener, Runnable
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
private transient boolean enabled = false;
|
||||
private transient int timer = -1;
|
||||
public TNTExplodeListener(final IEssentials ess) {
|
||||
super();
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public TNTExplodeListener(final IEssentials ess)
|
||||
{
|
||||
super();
|
||||
this.ess = ess;
|
||||
}
|
||||
public void enable() {
|
||||
if (!enabled) {
|
||||
enabled = true;
|
||||
timer = ess.scheduleSyncDelayedTask(this, 200);
|
||||
return;
|
||||
}
|
||||
if (timer != -1) {
|
||||
ess.getScheduler().cancelTask(timer);
|
||||
timer = ess.scheduleSyncDelayedTask(this, 200);
|
||||
}
|
||||
}
|
||||
|
||||
public void enable()
|
||||
{
|
||||
if (!enabled)
|
||||
{
|
||||
enabled = true;
|
||||
timer = ess.scheduleSyncDelayedTask(this, 200);
|
||||
return;
|
||||
}
|
||||
if (timer != -1)
|
||||
{
|
||||
ess.getScheduler().cancelTask(timer);
|
||||
timer = ess.scheduleSyncDelayedTask(this, 200);
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onEntityExplode(final EntityExplodeEvent event) {
|
||||
if (!enabled) {
|
||||
return;
|
||||
}
|
||||
if (event.getEntity() instanceof LivingEntity) {
|
||||
return;
|
||||
}
|
||||
if (event.blockList().size() < 1) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
event.getLocation().getWorld().createExplosion(event.getLocation(), 0F);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onEntityExplode(final EntityExplodeEvent event)
|
||||
{
|
||||
if (!enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (event.getEntity() instanceof LivingEntity)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (event.blockList().size() < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
event.getLocation().getWorld().createExplosion(event.getLocation(), 0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
enabled = false;
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
@@ -1,292 +1,403 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import com.earth2me.essentials.utils.LocationUtil;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.ITeleport;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.api.events.UserWarpEvent;
|
||||
import net.ess3.api.events.teleport.PreTeleportEvent;
|
||||
import net.ess3.api.events.teleport.TeleportWarmupEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
public class Teleport implements net.ess3.api.ITeleport
|
||||
{
|
||||
private final IUser teleportOwner;
|
||||
private final IEssentials ess;
|
||||
private TimedTeleport timedTeleport;
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public Teleport(IUser user, IEssentials ess)
|
||||
{
|
||||
this.teleportOwner = user;
|
||||
this.ess = ess;
|
||||
}
|
||||
/**
|
||||
* @deprecated This API is not asynchronous. Use {@link com.earth2me.essentials.AsyncTeleport AsyncTeleport}
|
||||
*/
|
||||
@Deprecated
|
||||
public class Teleport implements ITeleport {
|
||||
private final IUser teleportOwner;
|
||||
private final IEssentials ess;
|
||||
private TimedTeleport timedTeleport;
|
||||
|
||||
public void cooldown(boolean check) throws Exception
|
||||
{
|
||||
final Calendar time = new GregorianCalendar();
|
||||
if (teleportOwner.getLastTeleportTimestamp() > 0)
|
||||
{
|
||||
// Take the current time, and remove the delay from it.
|
||||
final double cooldown = ess.getSettings().getTeleportCooldown();
|
||||
final Calendar earliestTime = new GregorianCalendar();
|
||||
earliestTime.add(Calendar.SECOND, -(int)cooldown);
|
||||
earliestTime.add(Calendar.MILLISECOND, -(int)((cooldown * 1000.0) % 1000.0));
|
||||
// This value contains the most recent time a teleportPlayer could have been used that would allow another use.
|
||||
final long earliestLong = earliestTime.getTimeInMillis();
|
||||
private TeleportType tpType;
|
||||
|
||||
// When was the last teleportPlayer used?
|
||||
final Long lastTime = teleportOwner.getLastTeleportTimestamp();
|
||||
@Deprecated
|
||||
public Teleport(final IUser user, final IEssentials ess) {
|
||||
this.teleportOwner = user;
|
||||
this.ess = ess;
|
||||
tpType = TeleportType.NORMAL;
|
||||
}
|
||||
|
||||
if (lastTime > time.getTimeInMillis())
|
||||
{
|
||||
// This is to make sure time didn't get messed up on last teleportPlayer use.
|
||||
// If this happens, let's give the user the benifit of the doubt.
|
||||
teleportOwner.setLastTeleportTimestamp(time.getTimeInMillis());
|
||||
return;
|
||||
}
|
||||
else if (lastTime > earliestLong && !teleportOwner.isAuthorized("essentials.teleport.cooldown.bypass"))
|
||||
{
|
||||
time.setTimeInMillis(lastTime);
|
||||
time.add(Calendar.SECOND, (int)cooldown);
|
||||
time.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
|
||||
throw new Exception(_("timeBeforeTeleport", DateUtil.formatDateDiff(time.getTimeInMillis())));
|
||||
}
|
||||
}
|
||||
// if justCheck is set, don't update lastTeleport; we're just checking
|
||||
if (!check)
|
||||
{
|
||||
teleportOwner.setLastTeleportTimestamp(time.getTimeInMillis());
|
||||
}
|
||||
}
|
||||
@Deprecated
|
||||
public void cooldown(final boolean check) throws Exception {
|
||||
final Calendar time = new GregorianCalendar();
|
||||
if (teleportOwner.getLastTeleportTimestamp() > 0) {
|
||||
// Take the current time, and remove the delay from it.
|
||||
final double cooldown = ess.getSettings().getTeleportCooldown();
|
||||
final Calendar earliestTime = new GregorianCalendar();
|
||||
earliestTime.add(Calendar.SECOND, -(int) cooldown);
|
||||
earliestTime.add(Calendar.MILLISECOND, -(int) ((cooldown * 1000.0) % 1000.0));
|
||||
// This value contains the most recent time a teleportPlayer could have been used that would allow another use.
|
||||
final long earliestLong = earliestTime.getTimeInMillis();
|
||||
|
||||
private void warnUser(final IUser user, final double delay)
|
||||
{
|
||||
Calendar c = new GregorianCalendar();
|
||||
c.add(Calendar.SECOND, (int)delay);
|
||||
c.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
|
||||
user.sendMessage(_("dontMoveMessage", DateUtil.formatDateDiff(c.getTimeInMillis())));
|
||||
}
|
||||
// When was the last teleportPlayer used?
|
||||
final long lastTime = teleportOwner.getLastTeleportTimestamp();
|
||||
|
||||
//The now function is used when you want to skip tp delay when teleporting someone to a location or player.
|
||||
@Override
|
||||
public void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception
|
||||
{
|
||||
if (cooldown)
|
||||
{
|
||||
cooldown(false);
|
||||
}
|
||||
final ITarget target = new LocationTarget(loc);
|
||||
now(teleportOwner, target, cause);
|
||||
}
|
||||
if (lastTime > time.getTimeInMillis()) {
|
||||
// This is to make sure time didn't get messed up on last teleportPlayer use.
|
||||
// If this happens, let's give the user the benifit of the doubt.
|
||||
teleportOwner.setLastTeleportTimestamp(time.getTimeInMillis());
|
||||
return;
|
||||
} else if (lastTime > earliestLong
|
||||
&& cooldownApplies()) {
|
||||
time.setTimeInMillis(lastTime);
|
||||
time.add(Calendar.SECOND, (int) cooldown);
|
||||
time.add(Calendar.MILLISECOND, (int) ((cooldown * 1000.0) % 1000.0));
|
||||
throw new Exception(tl("timeBeforeTeleport", DateUtil.formatDateDiff(time.getTimeInMillis())));
|
||||
}
|
||||
}
|
||||
// if justCheck is set, don't update lastTeleport; we're just checking
|
||||
if (!check) {
|
||||
teleportOwner.setLastTeleportTimestamp(time.getTimeInMillis());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void now(Player entity, boolean cooldown, TeleportCause cause) throws Exception
|
||||
{
|
||||
if (cooldown)
|
||||
{
|
||||
cooldown(false);
|
||||
}
|
||||
final ITarget target = new PlayerTarget(entity);
|
||||
now(teleportOwner, target, cause);
|
||||
teleportOwner.sendMessage(_("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ()));
|
||||
}
|
||||
@Deprecated
|
||||
private boolean cooldownApplies() {
|
||||
boolean applies = true;
|
||||
final String globalBypassPerm = "essentials.teleport.cooldown.bypass";
|
||||
switch (tpType) {
|
||||
case NORMAL:
|
||||
applies = !teleportOwner.isAuthorized(globalBypassPerm);
|
||||
break;
|
||||
case BACK:
|
||||
applies = !(teleportOwner.isAuthorized(globalBypassPerm) &&
|
||||
teleportOwner.isAuthorized("essentials.teleport.cooldown.bypass.back"));
|
||||
break;
|
||||
case TPA:
|
||||
applies = !(teleportOwner.isAuthorized(globalBypassPerm) &&
|
||||
teleportOwner.isAuthorized("essentials.teleport.cooldown.bypass.tpa"));
|
||||
break;
|
||||
}
|
||||
return applies;
|
||||
}
|
||||
|
||||
protected void now(IUser teleportee, ITarget target, TeleportCause cause) throws Exception
|
||||
{
|
||||
cancel(false);
|
||||
teleportee.setLastLocation();
|
||||
final Location loc = target.getLocation();
|
||||
@Deprecated
|
||||
private void warnUser(final IUser user, final double delay) {
|
||||
final Calendar c = new GregorianCalendar();
|
||||
c.add(Calendar.SECOND, (int) delay);
|
||||
c.add(Calendar.MILLISECOND, (int) ((delay * 1000.0) % 1000.0));
|
||||
user.sendMessage(tl("dontMoveMessage", DateUtil.formatDateDiff(c.getTimeInMillis())));
|
||||
}
|
||||
|
||||
if (LocationUtil.isBlockUnsafe(loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
|
||||
{
|
||||
if (ess.getSettings().isTeleportSafetyEnabled())
|
||||
{
|
||||
if (teleportee.getBase().isInsideVehicle())
|
||||
{
|
||||
teleportee.getBase().leaveVehicle();
|
||||
}
|
||||
teleportee.getBase().teleport(LocationUtil.getSafeDestination(teleportee, loc), cause);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("unsafeTeleportDestination", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (teleportee.getBase().isInsideVehicle())
|
||||
{
|
||||
teleportee.getBase().leaveVehicle();
|
||||
}
|
||||
teleportee.getBase().teleport(LocationUtil.getRoundedDestination(loc), cause);
|
||||
}
|
||||
}
|
||||
//The now function is used when you want to skip tp delay when teleporting someone to a location or player.
|
||||
@Override
|
||||
@Deprecated
|
||||
public void now(final Location loc, final boolean cooldown, final TeleportCause cause) throws Exception {
|
||||
if (cooldown) {
|
||||
cooldown(false);
|
||||
}
|
||||
final ITarget target = new LocationTarget(loc);
|
||||
now(teleportOwner, target, cause);
|
||||
}
|
||||
|
||||
//The teleportPlayer function is used when you want to normally teleportPlayer someone to a location or player.
|
||||
//This method is nolonger used internally and will be removed.
|
||||
@Deprecated
|
||||
@Override
|
||||
public void teleport(Location loc, Trade chargeFor) throws Exception
|
||||
{
|
||||
teleport(loc, chargeFor, TeleportCause.PLUGIN);
|
||||
}
|
||||
@Override
|
||||
@Deprecated
|
||||
public void now(final Player entity, final boolean cooldown, final TeleportCause cause) throws Exception {
|
||||
if (cooldown) {
|
||||
cooldown(false);
|
||||
}
|
||||
final ITarget target = new PlayerTarget(entity);
|
||||
now(teleportOwner, target, cause);
|
||||
teleportOwner.sendMessage(tl("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Location loc, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
teleport(teleportOwner, new LocationTarget(loc), chargeFor, cause);
|
||||
}
|
||||
@Deprecated
|
||||
protected void now(final IUser teleportee, final ITarget target, final TeleportCause cause) throws Exception {
|
||||
cancel(false);
|
||||
Location loc = target.getLocation();
|
||||
|
||||
//This is used when teleporting to a player
|
||||
@Override
|
||||
public void teleport(Player entity, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
ITarget target = new PlayerTarget(entity);
|
||||
teleport(teleportOwner, target, chargeFor, cause);
|
||||
teleportOwner.sendMessage(_("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ()));
|
||||
}
|
||||
final PreTeleportEvent event = new PreTeleportEvent(teleportee, cause, target);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//This is used when teleporting to stored location
|
||||
@Override
|
||||
public void teleportPlayer(IUser teleportee, Location loc, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
teleport(teleportee, new LocationTarget(loc), chargeFor, cause);
|
||||
}
|
||||
if (teleportee.isAuthorized("essentials.back.onteleport")) {
|
||||
teleportee.setLastLocation();
|
||||
}
|
||||
|
||||
//This is used on /tphere
|
||||
@Override
|
||||
public void teleportPlayer(IUser teleportee, Player entity, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
ITarget target = new PlayerTarget(entity);
|
||||
teleport(teleportee, target, chargeFor, cause);
|
||||
teleportee.sendMessage(_("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ()));
|
||||
teleportOwner.sendMessage(_("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ()));
|
||||
}
|
||||
if (!teleportee.getBase().isEmpty()) {
|
||||
if (!ess.getSettings().isTeleportPassengerDismount()) {
|
||||
throw new Exception(tl("passengerTeleportFail"));
|
||||
}
|
||||
teleportee.getBase().eject();
|
||||
}
|
||||
|
||||
private void teleport(IUser teleportee, ITarget target, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
if (LocationUtil.isBlockUnsafeForUser(teleportee, loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) {
|
||||
if (ess.getSettings().isTeleportSafetyEnabled()) {
|
||||
if (ess.getSettings().isForceDisableTeleportSafety()) {
|
||||
PaperLib.teleportAsync(teleportee.getBase(), loc, cause);
|
||||
} else {
|
||||
PaperLib.teleportAsync(teleportee.getBase(), LocationUtil.getSafeDestination(ess, teleportee, loc), cause);
|
||||
}
|
||||
} else {
|
||||
throw new Exception(tl("unsafeTeleportDestination", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
}
|
||||
} else {
|
||||
if (ess.getSettings().isForceDisableTeleportSafety()) {
|
||||
PaperLib.teleportAsync(teleportee.getBase(), loc, cause);
|
||||
} else {
|
||||
if (ess.getSettings().isTeleportToCenterLocation()) {
|
||||
loc = LocationUtil.getRoundedDestination(loc);
|
||||
}
|
||||
PaperLib.teleportAsync(teleportee.getBase(), loc, cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Trade cashCharge = chargeFor;
|
||||
//The teleportPlayer function is used when you want to normally teleportPlayer someone to a location or player.
|
||||
//This method is nolonger used internally and will be removed.
|
||||
@Deprecated
|
||||
@Override
|
||||
public void teleport(final Location loc, final Trade chargeFor) throws Exception {
|
||||
teleport(loc, chargeFor, TeleportCause.PLUGIN);
|
||||
}
|
||||
|
||||
if (chargeFor != null)
|
||||
{
|
||||
chargeFor.isAffordableFor(teleportOwner);
|
||||
|
||||
//This code is to make sure that commandcosts are checked in the initial world, and not in the resulting world.
|
||||
if (!chargeFor.getCommandCost(teleportOwner).equals(BigDecimal.ZERO))
|
||||
{
|
||||
//By converting a command cost to a regular cost, the command cost permission isn't checked when executing the charge after teleport.
|
||||
cashCharge = new Trade(chargeFor.getCommandCost(teleportOwner), ess);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
@Deprecated
|
||||
public void teleport(final Location loc, final Trade chargeFor, final TeleportCause cause) throws Exception {
|
||||
teleport(teleportOwner, new LocationTarget(loc), chargeFor, cause);
|
||||
}
|
||||
|
||||
cooldown(true);
|
||||
if (delay <= 0 || teleportOwner.isAuthorized("essentials.teleport.timer.bypass")
|
||||
|| teleportee.isAuthorized("essentials.teleport.timer.bypass"))
|
||||
{
|
||||
cooldown(false);
|
||||
now(teleportee, target, cause);
|
||||
if (cashCharge != null)
|
||||
{
|
||||
cashCharge.charge(teleportOwner);
|
||||
}
|
||||
return;
|
||||
}
|
||||
//This is used when teleporting to a player
|
||||
@Override
|
||||
@Deprecated
|
||||
public void teleport(final Player entity, final Trade chargeFor, final TeleportCause cause) throws Exception {
|
||||
final ITarget target = new PlayerTarget(entity);
|
||||
teleportOwner.sendMessage(tl("teleportToPlayer", entity.getDisplayName()));
|
||||
teleport(teleportOwner, target, chargeFor, cause);
|
||||
}
|
||||
|
||||
cancel(false);
|
||||
warnUser(teleportee, delay);
|
||||
initTimer((long)(delay * 1000.0), teleportee, target, cashCharge, cause, false);
|
||||
}
|
||||
//This is used when teleporting to stored location
|
||||
@Override
|
||||
@Deprecated
|
||||
public void teleportPlayer(final IUser teleportee, final Location loc, final Trade chargeFor, final TeleportCause cause) throws Exception {
|
||||
teleport(teleportee, new LocationTarget(loc), chargeFor, cause);
|
||||
}
|
||||
|
||||
//The respawn function is a wrapper used to handle tp fallback, on /jail and /home
|
||||
@Override
|
||||
public void respawn(final Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
if (chargeFor != null)
|
||||
{
|
||||
chargeFor.isAffordableFor(teleportOwner);
|
||||
}
|
||||
cooldown(true);
|
||||
if (delay <= 0 || teleportOwner.isAuthorized("essentials.teleport.timer.bypass"))
|
||||
{
|
||||
cooldown(false);
|
||||
respawnNow(teleportOwner, cause);
|
||||
if (chargeFor != null)
|
||||
{
|
||||
chargeFor.charge(teleportOwner);
|
||||
}
|
||||
return;
|
||||
}
|
||||
//This is used on /tphere
|
||||
@Override
|
||||
@Deprecated
|
||||
public void teleportPlayer(final IUser teleportee, final Player entity, final Trade chargeFor, final TeleportCause cause) throws Exception {
|
||||
final ITarget target = new PlayerTarget(entity);
|
||||
teleport(teleportee, target, chargeFor, cause);
|
||||
teleportee.sendMessage(tl("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ()));
|
||||
teleportOwner.sendMessage(tl("teleporting", target.getLocation().getWorld().getName(), target.getLocation().getBlockX(), target.getLocation().getBlockY(), target.getLocation().getBlockZ()));
|
||||
}
|
||||
|
||||
cancel(false);
|
||||
warnUser(teleportOwner, delay);
|
||||
initTimer((long)(delay * 1000.0), teleportOwner, null, chargeFor, cause, true);
|
||||
}
|
||||
@Deprecated
|
||||
private void teleport(final IUser teleportee, final ITarget target, final Trade chargeFor, final TeleportCause cause) throws Exception {
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
|
||||
protected void respawnNow(IUser teleportee, TeleportCause cause) throws Exception
|
||||
{
|
||||
final Player player = teleportee.getBase();
|
||||
Location bed = player.getBedSpawnLocation();
|
||||
if (bed != null)
|
||||
{
|
||||
now(teleportee, new LocationTarget(bed), cause);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().info("Could not find bed spawn, forcing respawn event.");
|
||||
}
|
||||
final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, player.getWorld().getSpawnLocation(), false);
|
||||
ess.getServer().getPluginManager().callEvent(pre);
|
||||
now(teleportee, new LocationTarget(pre.getRespawnLocation()), cause);
|
||||
}
|
||||
}
|
||||
final TeleportWarmupEvent event = new TeleportWarmupEvent(teleportee, cause, target, delay);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
delay = event.getDelay();
|
||||
|
||||
//The warp function is a wrapper used to teleportPlayer a player to a /warp
|
||||
@Override
|
||||
public void warp(IUser teleportee, String warp, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
Location loc = ess.getWarps().getWarp(warp);
|
||||
teleportee.sendMessage(_("warpingTo", warp, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
teleport(teleportee, new LocationTarget(loc), chargeFor, cause);
|
||||
}
|
||||
Trade cashCharge = chargeFor;
|
||||
|
||||
//The back function is a wrapper used to teleportPlayer a player /back to their previous location.
|
||||
@Override
|
||||
public void back(Trade chargeFor) throws Exception
|
||||
{
|
||||
final Location loc = teleportOwner.getLastLocation();
|
||||
teleportOwner.sendMessage(_("backUsageMsg", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
teleport(teleportOwner, new LocationTarget(loc), chargeFor, TeleportCause.COMMAND);
|
||||
}
|
||||
if (chargeFor != null) {
|
||||
chargeFor.isAffordableFor(teleportOwner);
|
||||
|
||||
//This function is used to throw a user back after a jail sentence
|
||||
@Override
|
||||
public void back() throws Exception
|
||||
{
|
||||
now(teleportOwner, new LocationTarget(teleportOwner.getLastLocation()), TeleportCause.COMMAND);
|
||||
}
|
||||
//This code is to make sure that commandcosts are checked in the initial world, and not in the resulting world.
|
||||
if (!chargeFor.getCommandCost(teleportOwner).equals(BigDecimal.ZERO)) {
|
||||
//By converting a command cost to a regular cost, the command cost permission isn't checked when executing the charge after teleport.
|
||||
cashCharge = new Trade(chargeFor.getCommandCost(teleportOwner), ess);
|
||||
}
|
||||
}
|
||||
|
||||
//If we need to cancelTimer a pending teleportPlayer call this method
|
||||
private void cancel(boolean notifyUser)
|
||||
{
|
||||
if (timedTeleport != null)
|
||||
{
|
||||
timedTeleport.cancelTimer(notifyUser);
|
||||
timedTeleport = null;
|
||||
}
|
||||
}
|
||||
cooldown(true);
|
||||
if (delay <= 0 || teleportOwner.isAuthorized("essentials.teleport.timer.bypass") || teleportee.isAuthorized("essentials.teleport.timer.bypass")) {
|
||||
cooldown(false);
|
||||
now(teleportee, target, cause);
|
||||
if (cashCharge != null) {
|
||||
cashCharge.charge(teleportOwner);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private void initTimer(long delay, IUser teleportUser, ITarget target, Trade chargeFor, TeleportCause cause, boolean respawn)
|
||||
{
|
||||
timedTeleport = new TimedTeleport(teleportOwner, ess, this, delay, teleportUser, target, chargeFor, cause, respawn);
|
||||
}
|
||||
cancel(false);
|
||||
warnUser(teleportee, delay);
|
||||
initTimer((long) (delay * 1000.0), teleportee, target, cashCharge, cause, false);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void teleportOther(final IUser teleporter, final IUser teleportee, final ITarget target, final Trade chargeFor, final TeleportCause cause) throws Exception {
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
|
||||
final TeleportWarmupEvent event = new TeleportWarmupEvent(teleporter, teleportee, cause, target, delay);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
delay = event.getDelay();
|
||||
|
||||
Trade cashCharge = chargeFor;
|
||||
|
||||
if (teleporter != null && chargeFor != null) {
|
||||
chargeFor.isAffordableFor(teleporter);
|
||||
|
||||
//This code is to make sure that commandcosts are checked in the initial world, and not in the resulting world.
|
||||
if (!chargeFor.getCommandCost(teleporter).equals(BigDecimal.ZERO)) {
|
||||
//By converting a command cost to a regular cost, the command cost permission isn't checked when executing the charge after teleport.
|
||||
cashCharge = new Trade(chargeFor.getCommandCost(teleporter), ess);
|
||||
}
|
||||
}
|
||||
|
||||
cooldown(true);
|
||||
if (delay <= 0 || teleporter == null
|
||||
|| teleporter.isAuthorized("essentials.teleport.timer.bypass")
|
||||
|| teleportOwner.isAuthorized("essentials.teleport.timer.bypass")
|
||||
|| teleportee.isAuthorized("essentials.teleport.timer.bypass")) {
|
||||
cooldown(false);
|
||||
now(teleportee, target, cause);
|
||||
if (teleporter != null && cashCharge != null) {
|
||||
cashCharge.charge(teleporter);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
cancel(false);
|
||||
warnUser(teleportee, delay);
|
||||
initTimer((long) (delay * 1000.0), teleportee, target, cashCharge, cause, false);
|
||||
}
|
||||
|
||||
//The respawn function is a wrapper used to handle tp fallback, on /jail and /home
|
||||
@Override
|
||||
@Deprecated
|
||||
public void respawn(final Trade chargeFor, final TeleportCause cause) throws Exception {
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
|
||||
final TeleportWarmupEvent event = new TeleportWarmupEvent(teleportOwner, cause, null, delay);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
delay = event.getDelay();
|
||||
|
||||
if (chargeFor != null) {
|
||||
chargeFor.isAffordableFor(teleportOwner);
|
||||
}
|
||||
cooldown(true);
|
||||
if (delay <= 0 || teleportOwner.isAuthorized("essentials.teleport.timer.bypass")) {
|
||||
cooldown(false);
|
||||
respawnNow(teleportOwner, cause);
|
||||
if (chargeFor != null) {
|
||||
chargeFor.charge(teleportOwner);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
cancel(false);
|
||||
warnUser(teleportOwner, delay);
|
||||
initTimer((long) (delay * 1000.0), teleportOwner, null, chargeFor, cause, true);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
void respawnNow(final IUser teleportee, final TeleportCause cause) throws Exception {
|
||||
final Player player = teleportee.getBase();
|
||||
final Location bed = player.getBedSpawnLocation();
|
||||
if (bed != null) {
|
||||
now(teleportee, new LocationTarget(bed), cause);
|
||||
} else {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().info("Could not find bed spawn, forcing respawn event.");
|
||||
}
|
||||
final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, player.getWorld().getSpawnLocation(), false);
|
||||
ess.getServer().getPluginManager().callEvent(pre);
|
||||
now(teleportee, new LocationTarget(pre.getRespawnLocation()), cause);
|
||||
}
|
||||
}
|
||||
|
||||
//The warp function is a wrapper used to teleportPlayer a player to a /warp
|
||||
@Override
|
||||
@Deprecated
|
||||
public void warp(final IUser teleportee, String warp, final Trade chargeFor, final TeleportCause cause) throws Exception {
|
||||
final UserWarpEvent event = new UserWarpEvent(teleportee, warp, chargeFor);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
warp = event.getWarp();
|
||||
final Location loc = ess.getWarps().getWarp(warp);
|
||||
teleportee.sendMessage(tl("warpingTo", warp, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
if (!teleportee.equals(teleportOwner)) {
|
||||
teleportOwner.sendMessage(tl("warpingTo", warp, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
}
|
||||
teleport(teleportee, new LocationTarget(loc), chargeFor, cause);
|
||||
}
|
||||
|
||||
//The back function is a wrapper used to teleportPlayer a player /back to their previous location.
|
||||
@Override
|
||||
@Deprecated
|
||||
public void back(final Trade chargeFor) throws Exception {
|
||||
back(teleportOwner, chargeFor);
|
||||
}
|
||||
|
||||
//This function is a wrapper over the other back function for cases where another player performs back for them
|
||||
@Override
|
||||
@Deprecated
|
||||
public void back(final IUser teleporter, final Trade chargeFor) throws Exception {
|
||||
tpType = TeleportType.BACK;
|
||||
final Location loc = teleportOwner.getLastLocation();
|
||||
teleportOwner.sendMessage(tl("backUsageMsg", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
teleportOther(teleporter, teleportOwner, new LocationTarget(loc), chargeFor, TeleportCause.COMMAND);
|
||||
}
|
||||
|
||||
//This function is used to throw a user back after a jail sentence
|
||||
@Override
|
||||
@Deprecated
|
||||
public void back() throws Exception {
|
||||
now(teleportOwner, new LocationTarget(teleportOwner.getLastLocation()), TeleportCause.COMMAND);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setTpType(final TeleportType tpType) {
|
||||
this.tpType = tpType;
|
||||
}
|
||||
|
||||
//If we need to cancelTimer a pending teleportPlayer call this method
|
||||
@Deprecated
|
||||
private void cancel(final boolean notifyUser) {
|
||||
if (timedTeleport != null) {
|
||||
timedTeleport.cancelTimer(notifyUser);
|
||||
timedTeleport = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void initTimer(final long delay, final IUser teleportUser, final ITarget target, final Trade chargeFor, final TeleportCause cause, final boolean respawn) {
|
||||
timedTeleport = new TimedTeleport(teleportOwner, ess, this, delay, teleportUser, target, chargeFor, cause, respawn);
|
||||
}
|
||||
|
||||
public enum TeleportType {
|
||||
TPA,
|
||||
BACK,
|
||||
NORMAL
|
||||
}
|
||||
}
|
||||
@@ -1,162 +1,140 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class TimedTeleport implements Runnable
|
||||
{
|
||||
private static final double MOVE_CONSTANT = 0.3;
|
||||
private final IUser teleportOwner;
|
||||
private final IEssentials ess;
|
||||
private final Teleport teleport;
|
||||
private final String timer_teleportee;
|
||||
private int timer_task = -1;
|
||||
private final long timer_started; // time this task was initiated
|
||||
private final long timer_delay; // how long to delay the teleportPlayer
|
||||
private double timer_health;
|
||||
// note that I initially stored a clone of the location for reference, but...
|
||||
// when comparing locations, I got incorrect mismatches (rounding errors, looked like)
|
||||
// so, the X/Y/Z values are stored instead and rounded off
|
||||
private final long timer_initX;
|
||||
private final long timer_initY;
|
||||
private final long timer_initZ;
|
||||
private final ITarget timer_teleportTarget;
|
||||
private final boolean timer_respawn;
|
||||
private final boolean timer_canMove;
|
||||
private final Trade timer_chargeFor;
|
||||
private final TeleportCause timer_cause;
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public TimedTeleport(IUser user, IEssentials ess, Teleport teleport, long delay, IUser teleportUser, ITarget target, Trade chargeFor, TeleportCause cause, boolean respawn)
|
||||
{
|
||||
@Deprecated
|
||||
public class TimedTeleport implements Runnable {
|
||||
private static final double MOVE_CONSTANT = 0.3;
|
||||
private final IUser teleportOwner;
|
||||
private final IEssentials ess;
|
||||
private final Teleport teleport;
|
||||
private final UUID timer_teleportee;
|
||||
private final long timer_started; // time this task was initiated
|
||||
private final long timer_delay; // how long to delay the teleportPlayer
|
||||
// note that I initially stored a clone of the location for reference, but...
|
||||
// when comparing locations, I got incorrect mismatches (rounding errors, looked like)
|
||||
// so, the X/Y/Z values are stored instead and rounded off
|
||||
private final long timer_initX;
|
||||
private final long timer_initY;
|
||||
private final long timer_initZ;
|
||||
private final ITarget timer_teleportTarget;
|
||||
private final boolean timer_respawn;
|
||||
private final boolean timer_canMove;
|
||||
private final Trade timer_chargeFor;
|
||||
private final TeleportCause timer_cause;
|
||||
private int timer_task;
|
||||
private double timer_health;
|
||||
|
||||
this.teleportOwner = user;
|
||||
this.ess = ess;
|
||||
this.teleport = teleport;
|
||||
this.timer_started = System.currentTimeMillis();
|
||||
this.timer_delay = delay;
|
||||
this.timer_health = teleportUser.getBase().getHealth();
|
||||
this.timer_initX = Math.round(teleportUser.getBase().getLocation().getX() * MOVE_CONSTANT);
|
||||
this.timer_initY = Math.round(teleportUser.getBase().getLocation().getY() * MOVE_CONSTANT);
|
||||
this.timer_initZ = Math.round(teleportUser.getBase().getLocation().getZ() * MOVE_CONSTANT);
|
||||
this.timer_teleportee = teleportUser.getName();
|
||||
this.timer_teleportTarget = target;
|
||||
this.timer_chargeFor = chargeFor;
|
||||
this.timer_cause = cause;
|
||||
this.timer_respawn = respawn;
|
||||
this.timer_canMove = user.isAuthorized("essentials.teleport.timer.move");
|
||||
TimedTeleport(final IUser user, final IEssentials ess, final Teleport teleport, final long delay, final IUser teleportUser, final ITarget target, final Trade chargeFor, final TeleportCause cause, final boolean respawn) {
|
||||
this.teleportOwner = user;
|
||||
this.ess = ess;
|
||||
this.teleport = teleport;
|
||||
this.timer_started = System.currentTimeMillis();
|
||||
this.timer_delay = delay;
|
||||
this.timer_health = teleportUser.getBase().getHealth();
|
||||
this.timer_initX = Math.round(teleportUser.getBase().getLocation().getX() * MOVE_CONSTANT);
|
||||
this.timer_initY = Math.round(teleportUser.getBase().getLocation().getY() * MOVE_CONSTANT);
|
||||
this.timer_initZ = Math.round(teleportUser.getBase().getLocation().getZ() * MOVE_CONSTANT);
|
||||
this.timer_teleportee = teleportUser.getBase().getUniqueId();
|
||||
this.timer_teleportTarget = target;
|
||||
this.timer_chargeFor = chargeFor;
|
||||
this.timer_cause = cause;
|
||||
this.timer_respawn = respawn;
|
||||
this.timer_canMove = user.isAuthorized("essentials.teleport.timer.move");
|
||||
|
||||
timer_task = ess.scheduleSyncRepeatingTask(this, 20, 20);
|
||||
}
|
||||
timer_task = ess.runTaskTimerAsynchronously(this, 20, 20).getTaskId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if (teleportOwner == null || !teleportOwner.getBase().isOnline() || teleportOwner.getBase().getLocation() == null)
|
||||
{
|
||||
cancelTimer(false);
|
||||
return;
|
||||
}
|
||||
if (teleportOwner == null || !teleportOwner.getBase().isOnline() || teleportOwner.getBase().getLocation() == null) {
|
||||
cancelTimer(false);
|
||||
return;
|
||||
}
|
||||
|
||||
IUser teleportUser = ess.getUser(this.timer_teleportee);
|
||||
final IUser teleportUser = ess.getUser(this.timer_teleportee);
|
||||
|
||||
if (teleportUser == null || !teleportUser.getBase().isOnline())
|
||||
{
|
||||
cancelTimer(false);
|
||||
return;
|
||||
}
|
||||
if (teleportUser == null || !teleportUser.getBase().isOnline()) {
|
||||
cancelTimer(false);
|
||||
return;
|
||||
}
|
||||
|
||||
final Location currLocation = teleportUser.getBase().getLocation();
|
||||
if (currLocation == null)
|
||||
{
|
||||
cancelTimer(false);
|
||||
return;
|
||||
}
|
||||
final Location currLocation = teleportUser.getBase().getLocation();
|
||||
if (currLocation == null) {
|
||||
cancelTimer(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!timer_canMove
|
||||
&& (Math.round(currLocation.getX() * MOVE_CONSTANT) != timer_initX
|
||||
|| Math.round(currLocation.getY() * MOVE_CONSTANT) != timer_initY
|
||||
|| Math.round(currLocation.getZ() * MOVE_CONSTANT) != timer_initZ
|
||||
|| teleportUser.getBase().getHealth() < timer_health))
|
||||
{
|
||||
// user moved, cancelTimer teleportPlayer
|
||||
cancelTimer(true);
|
||||
return;
|
||||
}
|
||||
if (!timer_canMove && (Math.round(currLocation.getX() * MOVE_CONSTANT) != timer_initX || Math.round(currLocation.getY() * MOVE_CONSTANT) != timer_initY || Math.round(currLocation.getZ() * MOVE_CONSTANT) != timer_initZ || teleportUser.getBase().getHealth() < timer_health)) {
|
||||
// user moved, cancelTimer teleportPlayer
|
||||
cancelTimer(true);
|
||||
return;
|
||||
}
|
||||
|
||||
timer_health = teleportUser.getBase().getHealth(); // in case user healed, then later gets injured
|
||||
final long now = System.currentTimeMillis();
|
||||
if (now > timer_started + timer_delay)
|
||||
{
|
||||
try
|
||||
{
|
||||
teleport.cooldown(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
teleportOwner.sendMessage(_("cooldownWithMessage", ex.getMessage()));
|
||||
if (teleportOwner != teleportUser)
|
||||
{
|
||||
teleportUser.sendMessage(_("cooldownWithMessage", ex.getMessage()));
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
cancelTimer(false);
|
||||
teleportUser.sendMessage(_("teleportationCommencing"));
|
||||
if (timer_chargeFor != null)
|
||||
{
|
||||
timer_chargeFor.isAffordableFor(teleportOwner);
|
||||
}
|
||||
if (timer_respawn)
|
||||
{
|
||||
teleport.respawnNow(teleportUser, timer_cause);
|
||||
}
|
||||
else
|
||||
{
|
||||
teleport.now(teleportUser, timer_teleportTarget, timer_cause);
|
||||
}
|
||||
if (timer_chargeFor != null)
|
||||
{
|
||||
timer_chargeFor.charge(teleportOwner);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ess.showError(teleportOwner.getSource(), ex, "\\ teleport");
|
||||
}
|
||||
class DelayedTeleportTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
||||
timer_health = teleportUser.getBase().getHealth(); // in case user healed, then later gets injured
|
||||
final long now = System.currentTimeMillis();
|
||||
if (now > timer_started + timer_delay) {
|
||||
try {
|
||||
teleport.cooldown(false);
|
||||
} catch (final Exception ex) {
|
||||
teleportOwner.sendMessage(tl("cooldownWithMessage", ex.getMessage()));
|
||||
if (teleportOwner != teleportUser) {
|
||||
teleportUser.sendMessage(tl("cooldownWithMessage", ex.getMessage()));
|
||||
}
|
||||
}
|
||||
try {
|
||||
cancelTimer(false);
|
||||
teleportUser.sendMessage(tl("teleportationCommencing"));
|
||||
|
||||
//If we need to cancelTimer a pending teleportPlayer call this method
|
||||
public void cancelTimer(boolean notifyUser)
|
||||
{
|
||||
if (timer_task == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
ess.getServer().getScheduler().cancelTask(timer_task);
|
||||
if (notifyUser)
|
||||
{
|
||||
teleportOwner.sendMessage(_("pendingTeleportCancelled"));
|
||||
if (timer_teleportee != null && !timer_teleportee.equals(teleportOwner.getName()))
|
||||
{
|
||||
ess.getUser(timer_teleportee).sendMessage(_("pendingTeleportCancelled"));
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
timer_task = -1;
|
||||
}
|
||||
}
|
||||
if (timer_chargeFor != null) {
|
||||
timer_chargeFor.isAffordableFor(teleportOwner);
|
||||
}
|
||||
if (timer_respawn) {
|
||||
teleport.respawnNow(teleportUser, timer_cause);
|
||||
} else {
|
||||
teleport.now(teleportUser, timer_teleportTarget, timer_cause);
|
||||
}
|
||||
if (timer_chargeFor != null) {
|
||||
timer_chargeFor.charge(teleportOwner);
|
||||
}
|
||||
|
||||
} catch (final Exception ex) {
|
||||
ess.showError(teleportOwner.getSource(), ex, "\\ teleport");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ess.scheduleSyncDelayedTask(new DelayedTeleportTask());
|
||||
}
|
||||
|
||||
//If we need to cancelTimer a pending teleportPlayer call this method
|
||||
void cancelTimer(final boolean notifyUser) {
|
||||
if (timer_task == -1) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
ess.getServer().getScheduler().cancelTask(timer_task);
|
||||
if (notifyUser) {
|
||||
teleportOwner.sendMessage(tl("pendingTeleportCancelled"));
|
||||
if (timer_teleportee != null && !timer_teleportee.equals(teleportOwner.getBase().getUniqueId())) {
|
||||
ess.getUser(timer_teleportee).sendMessage(tl("pendingTeleportCancelled"));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
timer_task = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,15 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import com.earth2me.essentials.craftbukkit.SetExpFix;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
@@ -11,441 +18,374 @@ import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Trade
|
||||
{
|
||||
private final transient String command;
|
||||
private final transient Trade fallbackTrade;
|
||||
private final transient BigDecimal money;
|
||||
private final transient ItemStack itemStack;
|
||||
private final transient Integer exp;
|
||||
private final transient com.earth2me.essentials.IEssentials ess;
|
||||
public class Trade {
|
||||
private static FileWriter fw = null;
|
||||
private final transient String command;
|
||||
private final transient Trade fallbackTrade;
|
||||
private final transient BigDecimal money;
|
||||
private final transient ItemStack itemStack;
|
||||
private final transient Integer exp;
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public Trade(final String command, final IEssentials ess) {
|
||||
this(command, null, null, null, null, ess);
|
||||
}
|
||||
|
||||
public enum TradeType
|
||||
{
|
||||
MONEY,
|
||||
EXP,
|
||||
ITEM
|
||||
}
|
||||
public Trade(final String command, final Trade fallback, final IEssentials ess) {
|
||||
this(command, fallback, null, null, null, ess);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Trade(final double money, final com.earth2me.essentials.IEssentials ess) {
|
||||
this(null, null, BigDecimal.valueOf(money), null, null, (IEssentials) ess);
|
||||
}
|
||||
|
||||
public enum OverflowType
|
||||
{
|
||||
ABORT,
|
||||
DROP,
|
||||
RETURN
|
||||
}
|
||||
public Trade(final BigDecimal money, final IEssentials ess) {
|
||||
this(null, null, money, null, null, ess);
|
||||
}
|
||||
|
||||
public Trade(final String command, final IEssentials ess)
|
||||
{
|
||||
this(command, null, null, null, null, ess);
|
||||
}
|
||||
public Trade(final ItemStack items, final IEssentials ess) {
|
||||
this(null, null, null, items, null, ess);
|
||||
}
|
||||
|
||||
public Trade(final String command, final Trade fallback, final IEssentials ess)
|
||||
{
|
||||
this(command, fallback, null, null, null, ess);
|
||||
}
|
||||
public Trade(final int exp, final IEssentials ess) {
|
||||
this(null, null, null, null, exp, ess);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Trade(final double money, final com.earth2me.essentials.IEssentials ess)
|
||||
{
|
||||
this(null, null, BigDecimal.valueOf(money), null, null, ess);
|
||||
}
|
||||
private Trade(final String command, final Trade fallback, final BigDecimal money, final ItemStack item, final Integer exp, final IEssentials ess) {
|
||||
this.command = command;
|
||||
this.fallbackTrade = fallback;
|
||||
this.money = money;
|
||||
this.itemStack = item;
|
||||
this.exp = exp;
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public Trade(final BigDecimal money, final IEssentials ess)
|
||||
{
|
||||
this(null, null, money, null, null, ess);
|
||||
}
|
||||
public static void log(final String type, final String subtype, final String event, final String sender, final Trade charge, final String receiver, final Trade pay, final Location loc, final IEssentials ess) {
|
||||
//isEcoLogUpdateEnabled() - This refers to log entries with no location, ie API updates #EasterEgg
|
||||
//isEcoLogEnabled() - This refers to log entries with with location, ie /pay /sell and eco signs.
|
||||
|
||||
public Trade(final ItemStack items, final IEssentials ess)
|
||||
{
|
||||
this(null, null, null, items, null, ess);
|
||||
}
|
||||
if ((loc == null && !ess.getSettings().isEcoLogUpdateEnabled()) || (loc != null && !ess.getSettings().isEcoLogEnabled())) {
|
||||
return;
|
||||
}
|
||||
if (fw == null) {
|
||||
try {
|
||||
fw = new FileWriter(new File(ess.getDataFolder(), "trade.log"), true);
|
||||
} catch (final IOException ex) {
|
||||
Logger.getLogger("Essentials").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
final 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());
|
||||
}
|
||||
if (charge.getExperience() != null) {
|
||||
sb.append(charge.getExperience()).append(",");
|
||||
sb.append("exp").append(",");
|
||||
sb.append("\"\"");
|
||||
}
|
||||
}
|
||||
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 (pay.getExperience() != null) {
|
||||
sb.append(pay.getExperience()).append(",");
|
||||
sb.append("exp").append(",");
|
||||
sb.append("\"\"");
|
||||
}
|
||||
}
|
||||
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 (final IOException ex) {
|
||||
Logger.getLogger("Essentials").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public Trade(final int exp, final IEssentials ess)
|
||||
{
|
||||
this(null, null, null, null, exp, ess);
|
||||
}
|
||||
public static void closeLog() {
|
||||
if (fw != null) {
|
||||
try {
|
||||
fw.close();
|
||||
} catch (final IOException ex) {
|
||||
Logger.getLogger("Essentials").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
fw = null;
|
||||
}
|
||||
}
|
||||
|
||||
private Trade(final String command, final Trade fallback, final BigDecimal money, final ItemStack item, final Integer exp, final com.earth2me.essentials.IEssentials ess)
|
||||
{
|
||||
this.command = command;
|
||||
this.fallbackTrade = fallback;
|
||||
this.money = money;
|
||||
this.itemStack = item;
|
||||
this.exp = exp;
|
||||
this.ess = ess;
|
||||
}
|
||||
public void isAffordableFor(final IUser user) throws ChargeException {
|
||||
final CompletableFuture<Boolean> future = new CompletableFuture<>();
|
||||
isAffordableFor(user, future);
|
||||
if (future.isCompletedExceptionally()) {
|
||||
try {
|
||||
future.get();
|
||||
} catch (final InterruptedException e) { //If this happens, we have bigger problems...
|
||||
e.printStackTrace();
|
||||
} catch (final ExecutionException e) {
|
||||
throw (ChargeException) e.getCause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void isAffordableFor(final IUser user) throws ChargeException
|
||||
{
|
||||
public void isAffordableFor(final IUser user, final CompletableFuture<Boolean> future) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "checking if " + user.getName() + " can afford charge.");
|
||||
}
|
||||
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "checking if " + user.getName() + " can afford charge.");
|
||||
}
|
||||
if (getMoney() != null && getMoney().signum() > 0 && !user.canAfford(getMoney())) {
|
||||
future.completeExceptionally(new ChargeException(tl("notEnoughMoney", NumberUtil.displayCurrency(getMoney(), ess))));
|
||||
return;
|
||||
}
|
||||
|
||||
if (getMoney() != null
|
||||
&& getMoney().signum() > 0
|
||||
&& !user.canAfford(getMoney()))
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
if (getItemStack() != null && !user.getBase().getInventory().containsAtLeast(itemStack, itemStack.getAmount())) {
|
||||
future.completeExceptionally(new ChargeException(tl("missingItems", getItemStack().getAmount(), ess.getItemDb().name(getItemStack()))));
|
||||
return;
|
||||
}
|
||||
|
||||
if (getItemStack() != null
|
||||
&& !user.getBase().getInventory().containsAtLeast(itemStack, itemStack.getAmount()))
|
||||
{
|
||||
throw new ChargeException(_("missingItems", getItemStack().getAmount(), ess.getItemDb().name(getItemStack())));
|
||||
}
|
||||
final BigDecimal money;
|
||||
if (command != null && !command.isEmpty() && (money = getCommandCost(user)).signum() > 0 && !user.canAfford(money)) {
|
||||
future.completeExceptionally(new ChargeException(tl("notEnoughMoney", NumberUtil.displayCurrency(money, ess))));
|
||||
return;
|
||||
}
|
||||
|
||||
BigDecimal money;
|
||||
if (command != null && !command.isEmpty()
|
||||
&& (money = getCommandCost(user)).signum() > 0
|
||||
&& !user.canAfford(money))
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
if (exp != null && exp > 0 && SetExpFix.getTotalExperience(user.getBase()) < exp) {
|
||||
future.completeExceptionally(new ChargeException(tl("notEnoughExperience")));
|
||||
}
|
||||
}
|
||||
|
||||
if (exp != null && exp > 0
|
||||
&& SetExpFix.getTotalExperience(user.getBase()) < exp)
|
||||
{
|
||||
throw new ChargeException(_("notEnoughExperience"));
|
||||
}
|
||||
}
|
||||
public boolean pay(final IUser user) throws MaxMoneyException {
|
||||
return pay(user, OverflowType.ABORT) == null;
|
||||
}
|
||||
|
||||
public boolean pay(final IUser user) throws MaxMoneyException
|
||||
{
|
||||
return pay(user, OverflowType.ABORT) == null;
|
||||
}
|
||||
public Map<Integer, ItemStack> pay(final IUser user, final OverflowType type) throws MaxMoneyException {
|
||||
if (getMoney() != null && getMoney().signum() > 0) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "paying user " + user.getName() + " via trade " + getMoney().toPlainString());
|
||||
}
|
||||
user.giveMoney(getMoney());
|
||||
}
|
||||
if (getItemStack() != null) {
|
||||
// This stores the would be overflow
|
||||
final Map<Integer, ItemStack> overFlow = InventoryWorkaround.addAllItems(user.getBase().getInventory(), getItemStack());
|
||||
|
||||
public Map<Integer, ItemStack> pay(final IUser user, final OverflowType type) throws MaxMoneyException
|
||||
{
|
||||
if (getMoney() != null && getMoney().signum() > 0)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "paying user " + user.getName() + " via trade " + getMoney().toPlainString());
|
||||
}
|
||||
user.giveMoney(getMoney());
|
||||
}
|
||||
if (getItemStack() != null)
|
||||
{
|
||||
// This stores the would be overflow
|
||||
Map<Integer, ItemStack> overFlow = InventoryWorkaround.addAllItems(user.getBase().getInventory(), getItemStack());
|
||||
if (overFlow != null) {
|
||||
switch (type) {
|
||||
case ABORT:
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "abort paying " + user.getName() + " itemstack " + getItemStack().toString() + " due to lack of inventory space ");
|
||||
}
|
||||
|
||||
if (overFlow != null)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case ABORT:
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "abort paying " + user.getName() + " itemstack " + getItemStack().toString() + " due to lack of inventory space ");
|
||||
}
|
||||
return overFlow;
|
||||
|
||||
return overFlow;
|
||||
case RETURN:
|
||||
// Pay the user the items, and return overflow
|
||||
final Map<Integer, ItemStack> returnStack = InventoryWorkaround.addItems(user.getBase().getInventory(), getItemStack());
|
||||
user.getBase().updateInventory();
|
||||
|
||||
case RETURN:
|
||||
// Pay the user the items, and return overflow
|
||||
final Map<Integer, ItemStack> returnStack = InventoryWorkaround.addItems(user.getBase().getInventory(), getItemStack());
|
||||
user.getBase().updateInventory();
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "paying " + user.getName() + " partial itemstack " + getItemStack().toString() + " with overflow " + returnStack.get(0).toString());
|
||||
}
|
||||
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "paying " + user.getName() + " partial itemstack " + getItemStack().toString() + " with overflow " + returnStack.get(0).toString());
|
||||
}
|
||||
return returnStack;
|
||||
case DROP:
|
||||
// Pay the users the items directly, and drop the rest, will always return no overflow.
|
||||
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItems(user.getBase().getInventory(), getItemStack());
|
||||
final Location loc = user.getBase().getLocation();
|
||||
for (final ItemStack loStack : leftOver.values()) {
|
||||
final int maxStackSize = loStack.getType().getMaxStackSize();
|
||||
final int stacks = loStack.getAmount() / maxStackSize;
|
||||
final int leftover = loStack.getAmount() % maxStackSize;
|
||||
final Item[] itemStacks = new Item[stacks + (leftover > 0 ? 1 : 0)];
|
||||
for (int i = 0; i < stacks; i++) {
|
||||
final ItemStack stack = loStack.clone();
|
||||
stack.setAmount(maxStackSize);
|
||||
itemStacks[i] = loc.getWorld().dropItem(loc, stack);
|
||||
}
|
||||
if (leftover > 0) {
|
||||
final ItemStack stack = loStack.clone();
|
||||
stack.setAmount(leftover);
|
||||
itemStacks[stacks] = loc.getWorld().dropItem(loc, stack);
|
||||
}
|
||||
}
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "paying " + user.getName() + " partial itemstack " + getItemStack().toString() + " and dropping overflow " + leftOver.get(0).toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "paying " + user.getName() + " itemstack " + getItemStack().toString());
|
||||
}
|
||||
user.getBase().updateInventory();
|
||||
}
|
||||
if (getExperience() != null) {
|
||||
SetExpFix.setTotalExperience(user.getBase(), SetExpFix.getTotalExperience(user.getBase()) + getExperience());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return returnStack;
|
||||
public void charge(final IUser user) throws ChargeException {
|
||||
final CompletableFuture<Boolean> future = new CompletableFuture<>();
|
||||
charge(user, future);
|
||||
if (future.isCompletedExceptionally()) {
|
||||
try {
|
||||
future.get();
|
||||
} catch (final InterruptedException e) { //If this happens, we have bigger problems...
|
||||
e.printStackTrace();
|
||||
} catch (final ExecutionException e) {
|
||||
throw (ChargeException) e.getCause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case DROP:
|
||||
// Pay the users the items directly, and drop the rest, will always return no overflow.
|
||||
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItems(user.getBase().getInventory(), getItemStack());
|
||||
final Location loc = user.getBase().getLocation();
|
||||
for (ItemStack loStack : leftOver.values())
|
||||
{
|
||||
final int maxStackSize = loStack.getType().getMaxStackSize();
|
||||
final int stacks = loStack.getAmount() / maxStackSize;
|
||||
final int leftover = loStack.getAmount() % maxStackSize;
|
||||
final Item[] itemStacks = new Item[stacks + (leftover > 0 ? 1 : 0)];
|
||||
for (int i = 0; i < stacks; i++)
|
||||
{
|
||||
final ItemStack stack = loStack.clone();
|
||||
stack.setAmount(maxStackSize);
|
||||
itemStacks[i] = loc.getWorld().dropItem(loc, stack);
|
||||
}
|
||||
if (leftover > 0)
|
||||
{
|
||||
final ItemStack stack = loStack.clone();
|
||||
stack.setAmount(leftover);
|
||||
itemStacks[stacks] = loc.getWorld().dropItem(loc, stack);
|
||||
}
|
||||
}
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "paying " + user.getName() + " partial itemstack " + getItemStack().toString() + " and dropping overflow " + leftOver.get(0).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "paying " + user.getName() + " itemstack " + getItemStack().toString());
|
||||
}
|
||||
user.getBase().updateInventory();
|
||||
}
|
||||
if (getExperience() != null)
|
||||
{
|
||||
SetExpFix.setTotalExperience(user.getBase(), SetExpFix.getTotalExperience(user.getBase()) + getExperience());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public void charge(final IUser user, final CompletableFuture<Boolean> future) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "attempting to charge user " + user.getName());
|
||||
}
|
||||
if (getMoney() != null) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " money " + getMoney().toPlainString());
|
||||
}
|
||||
if (!user.canAfford(getMoney()) && getMoney().signum() > 0) {
|
||||
future.completeExceptionally(new ChargeException(tl("notEnoughMoney", NumberUtil.displayCurrency(getMoney(), ess))));
|
||||
return;
|
||||
}
|
||||
user.takeMoney(getMoney());
|
||||
}
|
||||
if (getItemStack() != null) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " itemstack " + getItemStack().toString());
|
||||
}
|
||||
if (!user.getBase().getInventory().containsAtLeast(getItemStack(), getItemStack().getAmount())) {
|
||||
future.completeExceptionally(new ChargeException(tl("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " "))));
|
||||
return;
|
||||
}
|
||||
user.getBase().getInventory().removeItem(getItemStack());
|
||||
user.getBase().updateInventory();
|
||||
}
|
||||
if (command != null) {
|
||||
final BigDecimal cost = getCommandCost(user);
|
||||
if (!user.canAfford(cost) && cost.signum() > 0) {
|
||||
future.completeExceptionally(new ChargeException(tl("notEnoughMoney", NumberUtil.displayCurrency(cost, ess))));
|
||||
return;
|
||||
}
|
||||
user.takeMoney(cost);
|
||||
}
|
||||
if (getExperience() != null) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " exp " + getExperience());
|
||||
}
|
||||
final int experience = SetExpFix.getTotalExperience(user.getBase());
|
||||
if (experience < getExperience() && getExperience() > 0) {
|
||||
future.completeExceptionally(new ChargeException(tl("notEnoughExperience")));
|
||||
return;
|
||||
}
|
||||
SetExpFix.setTotalExperience(user.getBase(), experience - getExperience());
|
||||
}
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "charge user " + user.getName() + " completed");
|
||||
}
|
||||
}
|
||||
|
||||
public void charge(final IUser user) throws ChargeException
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "attempting to charge user " + user.getName());
|
||||
}
|
||||
if (getMoney() != null)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " money " + getMoney().toPlainString());
|
||||
}
|
||||
if (!user.canAfford(getMoney()) && getMoney().signum() > 0)
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(getMoney());
|
||||
}
|
||||
if (getItemStack() != null)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " itemstack " + getItemStack().toString());
|
||||
}
|
||||
if (!user.getBase().getInventory().containsAtLeast(getItemStack(), getItemStack().getAmount()))
|
||||
{
|
||||
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
|
||||
}
|
||||
user.getBase().getInventory().removeItem(getItemStack());
|
||||
user.getBase().updateInventory();
|
||||
}
|
||||
if (command != null)
|
||||
{
|
||||
final BigDecimal cost = getCommandCost(user);
|
||||
if (!user.canAfford(cost) && cost.signum() > 0)
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(cost);
|
||||
}
|
||||
if (getExperience() != null)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " exp " + getExperience());
|
||||
}
|
||||
final int experience = SetExpFix.getTotalExperience(user.getBase());
|
||||
if (experience < getExperience() && getExperience() > 0)
|
||||
{
|
||||
throw new ChargeException(_("notEnoughExperience"));
|
||||
}
|
||||
SetExpFix.setTotalExperience(user.getBase(), experience - getExperience());
|
||||
}
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "charge user " + user.getName() + " completed");
|
||||
}
|
||||
}
|
||||
public BigDecimal getMoney() {
|
||||
return money;
|
||||
}
|
||||
|
||||
public BigDecimal getMoney()
|
||||
{
|
||||
return money;
|
||||
}
|
||||
public ItemStack getItemStack() {
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return itemStack;
|
||||
}
|
||||
public Integer getExperience() {
|
||||
return exp;
|
||||
}
|
||||
|
||||
public Integer getExperience()
|
||||
{
|
||||
return exp;
|
||||
}
|
||||
public TradeType getType() {
|
||||
if (getExperience() != null) {
|
||||
return TradeType.EXP;
|
||||
}
|
||||
|
||||
public TradeType getType()
|
||||
{
|
||||
if (getExperience() != null)
|
||||
{
|
||||
return TradeType.EXP;
|
||||
}
|
||||
if (getItemStack() != null) {
|
||||
return TradeType.ITEM;
|
||||
}
|
||||
|
||||
if (getItemStack() != null)
|
||||
{
|
||||
return TradeType.ITEM;
|
||||
}
|
||||
return TradeType.MONEY;
|
||||
}
|
||||
|
||||
return TradeType.MONEY;
|
||||
}
|
||||
public BigDecimal getCommandCost(final IUser user) {
|
||||
BigDecimal cost = BigDecimal.ZERO;
|
||||
if (command != null && !command.isEmpty()) {
|
||||
cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
|
||||
if (cost.signum() == 0 && fallbackTrade != null) {
|
||||
cost = fallbackTrade.getCommandCost(user);
|
||||
}
|
||||
|
||||
public BigDecimal getCommandCost(final IUser user)
|
||||
{
|
||||
BigDecimal cost = BigDecimal.ZERO;
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
|
||||
if (cost.signum() == 0 && fallbackTrade != null)
|
||||
{
|
||||
cost = fallbackTrade.getCommandCost(user);
|
||||
}
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "calculated command (" + command + ") cost for " + user.getName() + " as " + cost);
|
||||
}
|
||||
}
|
||||
if (cost.signum() != 0 && (user.isAuthorized("essentials.nocommandcost.all") || user.isAuthorized("essentials.nocommandcost." + command))) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "calculated command (" + command + ") cost for " + user.getName() + " as " + cost);
|
||||
}
|
||||
}
|
||||
if (cost.signum() != 0 && (user.isAuthorized("essentials.nocommandcost.all")
|
||||
|| user.isAuthorized("essentials.nocommandcost." + command)))
|
||||
{
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
private static FileWriter fw = null;
|
||||
public enum TradeType {
|
||||
MONEY,
|
||||
EXP,
|
||||
ITEM
|
||||
}
|
||||
|
||||
public static void log(String type, String subtype, String event, String sender, Trade charge, String receiver, Trade pay, Location loc, IEssentials ess)
|
||||
{
|
||||
//isEcoLogUpdateEnabled() - This refers to log entries with no location, ie API updates #EasterEgg
|
||||
//isEcoLogEnabled() - This refers to log entries with with location, ie /pay /sell and eco signs.
|
||||
|
||||
if ((loc == null && !ess.getSettings().isEcoLogUpdateEnabled())
|
||||
|| (loc != null && !ess.getSettings().isEcoLogEnabled()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (fw == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
fw = new FileWriter(new File(ess.getDataFolder(), "trade.log"), true);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.getLogger("Essentials").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());
|
||||
}
|
||||
if (charge.getExperience() != null)
|
||||
{
|
||||
sb.append(charge.getExperience()).append(",");
|
||||
sb.append("exp").append(",");
|
||||
sb.append("\"\"");
|
||||
}
|
||||
}
|
||||
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 (pay.getExperience() != null)
|
||||
{
|
||||
sb.append(pay.getExperience()).append(",");
|
||||
sb.append("exp").append(",");
|
||||
sb.append("\"\"");
|
||||
}
|
||||
}
|
||||
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("Essentials").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void closeLog()
|
||||
{
|
||||
if (fw != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
fw.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.getLogger("Essentials").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
fw = null;
|
||||
}
|
||||
}
|
||||
public enum OverflowType {
|
||||
ABORT,
|
||||
DROP,
|
||||
RETURN
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class UUIDMap {
|
||||
private static final ScheduledExecutorService writeScheduler = Executors.newScheduledThreadPool(1);
|
||||
private static boolean pendingWrite;
|
||||
private static boolean loading = false;
|
||||
private final transient net.ess3.api.IEssentials ess;
|
||||
private final File userList;
|
||||
private final transient Pattern splitPattern = Pattern.compile(",");
|
||||
private final Runnable writeTaskRunnable;
|
||||
|
||||
public UUIDMap(final net.ess3.api.IEssentials ess) {
|
||||
this.ess = ess;
|
||||
userList = new File(ess.getDataFolder(), "usermap.csv");
|
||||
pendingWrite = false;
|
||||
writeTaskRunnable = () -> {
|
||||
if (pendingWrite) {
|
||||
try {
|
||||
new WriteRunner(ess.getDataFolder(), userList, ess.getUserMap().getNames()).run();
|
||||
} catch (final Throwable t) { // bad code to prevent task from being suppressed
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
writeScheduler.scheduleWithFixedDelay(writeTaskRunnable, 5, 5, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public void loadAllUsers(final ConcurrentSkipListMap<String, UUID> names, final ConcurrentSkipListMap<UUID, ArrayList<String>> history) {
|
||||
try {
|
||||
if (!userList.exists()) {
|
||||
userList.createNewFile();
|
||||
}
|
||||
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "Reading usermap from disk");
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
names.clear();
|
||||
history.clear();
|
||||
loading = true;
|
||||
|
||||
try (final BufferedReader reader = new BufferedReader(new FileReader(userList))) {
|
||||
while (true) {
|
||||
final String line = reader.readLine();
|
||||
if (line == null) {
|
||||
break;
|
||||
} else {
|
||||
final String[] values = splitPattern.split(line);
|
||||
if (values.length == 2) {
|
||||
final String name = values[0];
|
||||
final UUID uuid = UUID.fromString(values[1]);
|
||||
names.put(name, uuid);
|
||||
if (!history.containsKey(uuid)) {
|
||||
final ArrayList<String> list = new ArrayList<>();
|
||||
list.add(name);
|
||||
history.put(uuid, list);
|
||||
} else {
|
||||
final ArrayList<String> list = history.get(uuid);
|
||||
if (!list.contains(name)) {
|
||||
list.add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
loading = false;
|
||||
} catch (final IOException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeUUIDMap() {
|
||||
pendingWrite = true;
|
||||
}
|
||||
|
||||
public void forceWriteUUIDMap() {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.INFO, "Forcing usermap write to disk");
|
||||
}
|
||||
pendingWrite = true;
|
||||
writeTaskRunnable.run();
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
writeScheduler.submit(writeTaskRunnable);
|
||||
writeScheduler.shutdown();
|
||||
}
|
||||
|
||||
private static final class WriteRunner implements Runnable {
|
||||
private final File location;
|
||||
private final File endFile;
|
||||
private final Map<String, UUID> names;
|
||||
|
||||
private WriteRunner(final File location, final File endFile, final Map<String, UUID> names) {
|
||||
this.location = location;
|
||||
this.endFile = endFile;
|
||||
this.names = new HashMap<>(names);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
pendingWrite = false;
|
||||
if (loading || names.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
File configFile = null;
|
||||
|
||||
try {
|
||||
configFile = File.createTempFile("usermap", ".tmp.csv", location);
|
||||
|
||||
final BufferedWriter bWriter = new BufferedWriter(new FileWriter(configFile));
|
||||
for (final Map.Entry<String, UUID> entry : names.entrySet()) {
|
||||
bWriter.write(entry.getKey() + "," + entry.getValue().toString());
|
||||
bWriter.newLine();
|
||||
}
|
||||
|
||||
bWriter.close();
|
||||
Files.move(configFile, endFile);
|
||||
} catch (final IOException ex) {
|
||||
try {
|
||||
if (configFile != null && configFile.exists()) {
|
||||
Files.move(configFile, new File(endFile.getParentFile(), "usermap.bak.csv"));
|
||||
}
|
||||
} catch (final Exception ex2) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, ex2.getMessage(), ex2);
|
||||
}
|
||||
Bukkit.getLogger().log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,134 +1,313 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class UserMap extends CacheLoader<String, User> implements IConf
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
private final transient Cache<String, User> users;
|
||||
private final transient ConcurrentSkipListSet<String> keys = new ConcurrentSkipListSet<String>();
|
||||
public class UserMap extends CacheLoader<String, User> implements IConf {
|
||||
private static boolean legacy = false;
|
||||
private static Method getLegacy;
|
||||
private final transient IEssentials ess;
|
||||
private final transient ConcurrentSkipListSet<UUID> keys = new ConcurrentSkipListSet<>();
|
||||
private final transient ConcurrentSkipListMap<String, UUID> names = new ConcurrentSkipListMap<>();
|
||||
private final transient ConcurrentSkipListMap<UUID, ArrayList<String>> history = new ConcurrentSkipListMap<>();
|
||||
private final UUIDMap uuidMap;
|
||||
private final transient Cache<String, User> users;
|
||||
private final Pattern validUserPattern = Pattern.compile("^[a-zA-Z0-9_]{2,16}$");
|
||||
|
||||
public UserMap(final IEssentials ess)
|
||||
{
|
||||
super();
|
||||
this.ess = ess;
|
||||
users = CacheBuilder.newBuilder().maximumSize(ess.getSettings().getMaxUserCacheCount()).softValues().build(this);
|
||||
loadAllUsersAsync(ess);
|
||||
}
|
||||
public UserMap(final IEssentials ess) {
|
||||
super();
|
||||
this.ess = ess;
|
||||
uuidMap = new UUIDMap(ess);
|
||||
//RemovalListener<UUID, User> remListener = new UserMapRemovalListener();
|
||||
//users = CacheBuilder.newBuilder().maximumSize(ess.getSettings().getMaxUserCacheCount()).softValues().removalListener(remListener).build(this);
|
||||
final CacheBuilder<Object, Object> cacheBuilder = CacheBuilder.newBuilder();
|
||||
final int maxCount = ess.getSettings().getMaxUserCacheCount();
|
||||
try {
|
||||
cacheBuilder.maximumSize(maxCount);
|
||||
} catch (final NoSuchMethodError nsme) {
|
||||
legacy = true;
|
||||
legacyMaximumSize(cacheBuilder, maxCount);
|
||||
}
|
||||
cacheBuilder.softValues();
|
||||
if (!legacy) {
|
||||
users = cacheBuilder.build(this);
|
||||
} else {
|
||||
users = legacyBuild(cacheBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadAllUsersAsync(final IEssentials ess)
|
||||
{
|
||||
ess.runTaskAsynchronously(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final File userdir = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdir.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
keys.clear();
|
||||
users.invalidateAll();
|
||||
for (String string : userdir.list())
|
||||
{
|
||||
if (!string.endsWith(".yml"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final String name = string.substring(0, string.length() - 4);
|
||||
keys.add(StringUtil.sanitizeFileName(name));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
private void loadAllUsersAsync(final IEssentials ess) {
|
||||
ess.runTaskAsynchronously(() -> {
|
||||
synchronized (users) {
|
||||
final File userdir = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdir.exists()) {
|
||||
return;
|
||||
}
|
||||
keys.clear();
|
||||
users.invalidateAll();
|
||||
for (final String string : userdir.list()) {
|
||||
if (!string.endsWith(".yml")) {
|
||||
continue;
|
||||
}
|
||||
final String name = string.substring(0, string.length() - 4);
|
||||
try {
|
||||
keys.add(UUID.fromString(name));
|
||||
} catch (final IllegalArgumentException ex) {
|
||||
//Ignore these users till they rejoin.
|
||||
}
|
||||
}
|
||||
uuidMap.loadAllUsers(names, history);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean userExists(final String name)
|
||||
{
|
||||
return keys.contains(StringUtil.sanitizeFileName(name));
|
||||
}
|
||||
public boolean userExists(final UUID uuid) {
|
||||
return keys.contains(uuid);
|
||||
}
|
||||
|
||||
public User getUser(final String name)
|
||||
{
|
||||
try
|
||||
{
|
||||
String sanitizedName = StringUtil.sanitizeFileName(name);
|
||||
return users.get(sanitizedName);
|
||||
}
|
||||
catch (ExecutionException ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch (UncheckedExecutionException ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public User getUser(final String name) {
|
||||
try {
|
||||
final String sanitizedName = StringUtil.safeString(name);
|
||||
if (names.containsKey(sanitizedName)) {
|
||||
final UUID uuid = names.get(sanitizedName);
|
||||
return getUser(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User load(final String sanitizedName) throws Exception
|
||||
{
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
String sanitizedPlayer = StringUtil.sanitizeFileName(player.getName());
|
||||
if (sanitizedPlayer.equalsIgnoreCase(sanitizedName))
|
||||
{
|
||||
keys.add(sanitizedName);
|
||||
return new User(player, ess);
|
||||
}
|
||||
}
|
||||
final File userFile = getUserFile2(sanitizedName);
|
||||
if (userFile.exists())
|
||||
{
|
||||
keys.add(sanitizedName);
|
||||
return new User(new OfflinePlayer(sanitizedName, ess), ess);
|
||||
}
|
||||
throw new Exception("User not found!");
|
||||
}
|
||||
final File userFile = getUserFileFromString(sanitizedName);
|
||||
if (userFile.exists()) {
|
||||
ess.getLogger().info("Importing user " + name + " to usermap.");
|
||||
final User user = new User(new OfflinePlayer(sanitizedName, ess.getServer()), ess);
|
||||
trackUUID(user.getBase().getUniqueId(), user.getName(), true);
|
||||
return user;
|
||||
}
|
||||
return null;
|
||||
} catch (final UncheckedExecutionException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
loadAllUsersAsync(ess);
|
||||
}
|
||||
public User getUser(final UUID uuid) {
|
||||
try {
|
||||
if (!legacy) {
|
||||
return ((LoadingCache<String, User>) users).get(uuid.toString());
|
||||
} else {
|
||||
return legacyCacheGet(uuid);
|
||||
}
|
||||
} catch (final ExecutionException | UncheckedExecutionException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeUser(final String name)
|
||||
{
|
||||
keys.remove(StringUtil.sanitizeFileName(name));
|
||||
users.invalidate(StringUtil.sanitizeFileName(name));
|
||||
users.invalidate(name);
|
||||
}
|
||||
public void trackUUID(final UUID uuid, final String name, final boolean replace) {
|
||||
if (uuid != null) {
|
||||
keys.add(uuid);
|
||||
if (name != null && name.length() > 0) {
|
||||
final String keyName = ess.getSettings().isSafeUsermap() ? StringUtil.safeString(name) : name;
|
||||
if (!names.containsKey(keyName)) {
|
||||
names.put(keyName, uuid);
|
||||
uuidMap.writeUUIDMap();
|
||||
} else if (!names.get(keyName).equals(uuid)) {
|
||||
if (replace) {
|
||||
ess.getLogger().info("Found new UUID for " + name + ". Replacing " + names.get(keyName).toString() + " with " + uuid.toString());
|
||||
names.put(keyName, uuid);
|
||||
uuidMap.writeUUIDMap();
|
||||
} else {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().info("Found old UUID for " + name + " (" + uuid.toString() + "). Not adding to usermap.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Set<String> getAllUniqueUsers()
|
||||
{
|
||||
return Collections.unmodifiableSet(keys);
|
||||
}
|
||||
@Override
|
||||
public User load(final String stringUUID) throws Exception {
|
||||
final UUID uuid = UUID.fromString(stringUUID);
|
||||
Player player = ess.getServer().getPlayer(uuid);
|
||||
if (player != null) {
|
||||
final User user = new User(player, ess);
|
||||
trackUUID(uuid, user.getName(), true);
|
||||
return user;
|
||||
}
|
||||
|
||||
public int getUniqueUsers()
|
||||
{
|
||||
return keys.size();
|
||||
}
|
||||
final File userFile = getUserFileFromID(uuid);
|
||||
|
||||
public File getUserFile(final String name)
|
||||
{
|
||||
return getUserFile2(StringUtil.sanitizeFileName(name));
|
||||
}
|
||||
if (userFile.exists()) {
|
||||
player = new OfflinePlayer(uuid, ess.getServer());
|
||||
final User user = new User(player, ess);
|
||||
((OfflinePlayer) player).setName(user.getLastAccountName());
|
||||
trackUUID(uuid, user.getName(), false);
|
||||
return user;
|
||||
}
|
||||
|
||||
private File getUserFile2(final String name)
|
||||
{
|
||||
final File userFolder = new File(ess.getDataFolder(), "userdata");
|
||||
return new File(userFolder, name + ".yml");
|
||||
}
|
||||
throw new Exception("User not found!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
getUUIDMap().forceWriteUUIDMap();
|
||||
loadAllUsersAsync(ess);
|
||||
}
|
||||
|
||||
public void invalidateAll() {
|
||||
users.invalidateAll();
|
||||
}
|
||||
|
||||
public void removeUser(final String name) {
|
||||
if (names == null) {
|
||||
ess.getLogger().warning("Name collection is null, cannot remove user.");
|
||||
return;
|
||||
}
|
||||
final UUID uuid = names.get(name);
|
||||
if (uuid != null) {
|
||||
keys.remove(uuid);
|
||||
users.invalidate(uuid.toString());
|
||||
}
|
||||
names.remove(name);
|
||||
names.remove(StringUtil.safeString(name));
|
||||
}
|
||||
|
||||
public Set<UUID> getAllUniqueUsers() {
|
||||
return Collections.unmodifiableSet(keys);
|
||||
}
|
||||
|
||||
public int getUniqueUsers() {
|
||||
return keys.size();
|
||||
}
|
||||
|
||||
protected ConcurrentSkipListMap<String, UUID> getNames() {
|
||||
return names;
|
||||
}
|
||||
|
||||
protected ConcurrentSkipListMap<UUID, ArrayList<String>> getHistory() {
|
||||
return history;
|
||||
}
|
||||
|
||||
public List<String> getUserHistory(final UUID uuid) {
|
||||
return history.get(uuid);
|
||||
}
|
||||
|
||||
public UUIDMap getUUIDMap() {
|
||||
return uuidMap;
|
||||
}
|
||||
// class UserMapRemovalListener implements RemovalListener
|
||||
// {
|
||||
// @Override
|
||||
// public void onRemoval(final RemovalNotification notification)
|
||||
// {
|
||||
// Object value = notification.getValue();
|
||||
// if (value != null)
|
||||
// {
|
||||
// ((User)value).cleanup();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
private File getUserFileFromID(final UUID uuid) {
|
||||
final File userFolder = new File(ess.getDataFolder(), "userdata");
|
||||
return new File(userFolder, uuid.toString() + ".yml");
|
||||
}
|
||||
|
||||
public File getUserFileFromString(final String name) {
|
||||
final File userFolder = new File(ess.getDataFolder(), "userdata");
|
||||
return new File(userFolder, StringUtil.sanitizeFileName(name) + ".yml");
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public User getUserFromBukkit(String name) {
|
||||
name = StringUtil.safeString(name);
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().warning("Using potentially blocking Bukkit UUID lookup for: " + name);
|
||||
}
|
||||
// Don't attempt to look up entirely invalid usernames
|
||||
if (name == null || !validUserPattern.matcher(name).matches()) {
|
||||
return null;
|
||||
}
|
||||
final org.bukkit.OfflinePlayer offlinePlayer = ess.getServer().getOfflinePlayer(name);
|
||||
if (offlinePlayer == null) {
|
||||
return null;
|
||||
}
|
||||
final UUID uuid;
|
||||
try {
|
||||
uuid = offlinePlayer.getUniqueId();
|
||||
} catch (final UnsupportedOperationException | NullPointerException e) {
|
||||
return null;
|
||||
}
|
||||
// This is how Bukkit generates fake UUIDs
|
||||
if (UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)).equals(uuid)) {
|
||||
return null;
|
||||
} else {
|
||||
names.put(name, uuid);
|
||||
return getUser(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
private User legacyCacheGet(final UUID uuid) {
|
||||
if (getLegacy == null) {
|
||||
final Class<?> usersClass = users.getClass();
|
||||
for (final Method m : usersClass.getDeclaredMethods()) {
|
||||
if (m.getName().equals("get")) {
|
||||
getLegacy = m;
|
||||
getLegacy.setAccessible(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
return (User) getLegacy.invoke(users, uuid.toString());
|
||||
} catch (final IllegalAccessException | InvocationTargetException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void legacyMaximumSize(final CacheBuilder builder, final int maxCount) {
|
||||
try {
|
||||
final Method maxSizeLegacy = builder.getClass().getDeclaredMethod("maximumSize", Integer.TYPE);
|
||||
maxSizeLegacy.setAccessible(true);
|
||||
maxSizeLegacy.invoke(builder, maxCount);
|
||||
} catch (final NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Cache<String, User> legacyBuild(final CacheBuilder builder) {
|
||||
Method build = null;
|
||||
for (final Method method : builder.getClass().getDeclaredMethods()) {
|
||||
if (method.getName().equals("build")) {
|
||||
build = method;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Cache<String, User> legacyUsers;
|
||||
try {
|
||||
assert build != null;
|
||||
build.setAccessible(true);
|
||||
legacyUsers = (Cache<String, User>) build.invoke(builder, this);
|
||||
} catch (final IllegalAccessException | InvocationTargetException e) {
|
||||
legacyUsers = null;
|
||||
}
|
||||
return legacyUsers;
|
||||
}
|
||||
}
|
||||
@@ -1,180 +1,177 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.commands.WarpNotFoundException;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.ess3.api.InvalidNameException;
|
||||
import net.ess3.api.InvalidWorldException;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class Warps implements IConf, net.ess3.api.IWarps
|
||||
{
|
||||
private static final Logger logger = Logger.getLogger("Essentials");
|
||||
private final Map<StringIgnoreCase, EssentialsConf> warpPoints = new HashMap<StringIgnoreCase, EssentialsConf>();
|
||||
private final File warpsFolder;
|
||||
private final Server server;
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public Warps(Server server, File dataFolder)
|
||||
{
|
||||
this.server = server;
|
||||
warpsFolder = new File(dataFolder, "warps");
|
||||
if (!warpsFolder.exists())
|
||||
{
|
||||
warpsFolder.mkdirs();
|
||||
}
|
||||
reloadConfig();
|
||||
}
|
||||
public class Warps implements IConf, net.ess3.api.IWarps {
|
||||
private static final Logger logger = Logger.getLogger("Essentials");
|
||||
private final Map<StringIgnoreCase, EssentialsConf> warpPoints = new HashMap<>();
|
||||
private final File warpsFolder;
|
||||
private final Server server;
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return warpPoints.isEmpty();
|
||||
}
|
||||
public Warps(final Server server, final File dataFolder) {
|
||||
this.server = server;
|
||||
warpsFolder = new File(dataFolder, "warps");
|
||||
if (!warpsFolder.exists()) {
|
||||
warpsFolder.mkdirs();
|
||||
}
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getList()
|
||||
{
|
||||
final List<String> keys = new ArrayList<String>();
|
||||
for (StringIgnoreCase stringIgnoreCase : warpPoints.keySet())
|
||||
{
|
||||
keys.add(stringIgnoreCase.getString());
|
||||
}
|
||||
Collections.sort(keys, String.CASE_INSENSITIVE_ORDER);
|
||||
return keys;
|
||||
}
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return warpPoints.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getWarp(String warp) throws WarpNotFoundException, InvalidWorldException
|
||||
{
|
||||
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(warp));
|
||||
if (conf == null)
|
||||
{
|
||||
throw new WarpNotFoundException();
|
||||
}
|
||||
return conf.getLocation(null, server);
|
||||
}
|
||||
@Override
|
||||
public Collection<String> getList() {
|
||||
final List<String> keys = new ArrayList<>();
|
||||
for (final StringIgnoreCase stringIgnoreCase : warpPoints.keySet()) {
|
||||
keys.add(stringIgnoreCase.getString());
|
||||
}
|
||||
keys.sort(String.CASE_INSENSITIVE_ORDER);
|
||||
return keys;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWarp(String name, Location loc) throws Exception
|
||||
{
|
||||
String filename = StringUtil.sanitizeFileName(name);
|
||||
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(name));
|
||||
if (conf == null)
|
||||
{
|
||||
File confFile = new File(warpsFolder, filename + ".yml");
|
||||
if (confFile.exists())
|
||||
{
|
||||
throw new Exception(_("similarWarpExist"));
|
||||
}
|
||||
conf = new EssentialsConf(confFile);
|
||||
warpPoints.put(new StringIgnoreCase(name), conf);
|
||||
}
|
||||
conf.setProperty(null, loc);
|
||||
conf.setProperty("name", name);
|
||||
try
|
||||
{
|
||||
conf.saveWithError();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
throw new IOException(_("invalidWarpName"));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Location getWarp(final String warp) throws WarpNotFoundException, InvalidWorldException {
|
||||
final EssentialsConf conf = warpPoints.get(new StringIgnoreCase(warp));
|
||||
if (conf == null) {
|
||||
throw new WarpNotFoundException();
|
||||
}
|
||||
return conf.getLocation(null, server);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeWarp(String name) throws Exception
|
||||
{
|
||||
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(name));
|
||||
if (conf == null)
|
||||
{
|
||||
throw new Exception(_("warpNotExist"));
|
||||
}
|
||||
if (!conf.getFile().delete())
|
||||
{
|
||||
throw new Exception(_("warpDeleteError"));
|
||||
}
|
||||
warpPoints.remove(new StringIgnoreCase(name));
|
||||
}
|
||||
@Override
|
||||
public void setWarp(final String name, final Location loc) throws Exception {
|
||||
setWarp(null, name, loc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void reloadConfig()
|
||||
{
|
||||
warpPoints.clear();
|
||||
File[] listOfFiles = warpsFolder.listFiles();
|
||||
if (listOfFiles.length >= 1)
|
||||
{
|
||||
for (int i = 0; i < listOfFiles.length; i++)
|
||||
{
|
||||
String filename = listOfFiles[i].getName();
|
||||
if (listOfFiles[i].isFile() && filename.endsWith(".yml"))
|
||||
{
|
||||
try
|
||||
{
|
||||
EssentialsConf conf = new EssentialsConf(listOfFiles[i]);
|
||||
conf.load();
|
||||
String name = conf.getString("name");
|
||||
if (name != null)
|
||||
{
|
||||
warpPoints.put(new StringIgnoreCase(name), conf);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.WARNING, _("loadWarpError", filename), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setWarp(final IUser user, final String name, final Location loc) throws Exception {
|
||||
final String filename = StringUtil.sanitizeFileName(name);
|
||||
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(name));
|
||||
if (conf == null) {
|
||||
final File confFile = new File(warpsFolder, filename + ".yml");
|
||||
if (confFile.exists()) {
|
||||
throw new Exception(tl("similarWarpExist"));
|
||||
}
|
||||
conf = new EssentialsConf(confFile);
|
||||
warpPoints.put(new StringIgnoreCase(name), conf);
|
||||
}
|
||||
conf.setProperty(null, loc);
|
||||
conf.setProperty("name", name);
|
||||
if (user != null) conf.setProperty("lastowner", user.getBase().getUniqueId().toString());
|
||||
try {
|
||||
conf.saveWithError();
|
||||
} catch (final IOException ex) {
|
||||
throw new IOException(tl("invalidWarpName"));
|
||||
}
|
||||
}
|
||||
|
||||
//This is here for future 3.x api support. Not implemented here becasue storage is handled differently
|
||||
@Override
|
||||
public File getWarpFile(String name) throws InvalidNameException
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
@Override
|
||||
public UUID getLastOwner(final String warp) throws WarpNotFoundException {
|
||||
final EssentialsConf conf = warpPoints.get(new StringIgnoreCase(warp));
|
||||
if (conf == null) {
|
||||
throw new WarpNotFoundException();
|
||||
}
|
||||
UUID uuid = null;
|
||||
try {
|
||||
uuid = UUID.fromString(conf.getString("lastowner"));
|
||||
} catch (final Exception ignored) {
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount()
|
||||
{
|
||||
return getList().size();
|
||||
}
|
||||
@Override
|
||||
public void removeWarp(final String name) throws Exception {
|
||||
final EssentialsConf conf = warpPoints.get(new StringIgnoreCase(name));
|
||||
if (conf == null) {
|
||||
throw new Exception(tl("warpNotExist"));
|
||||
}
|
||||
if (!conf.getFile().delete()) {
|
||||
throw new Exception(tl("warpDeleteError"));
|
||||
}
|
||||
warpPoints.remove(new StringIgnoreCase(name));
|
||||
}
|
||||
|
||||
private static class StringIgnoreCase
|
||||
{
|
||||
private final String string;
|
||||
@Override
|
||||
public final void reloadConfig() {
|
||||
warpPoints.clear();
|
||||
final File[] listOfFiles = warpsFolder.listFiles();
|
||||
if (listOfFiles.length >= 1) {
|
||||
for (final File listOfFile : listOfFiles) {
|
||||
final String filename = listOfFile.getName();
|
||||
if (listOfFile.isFile() && filename.endsWith(".yml")) {
|
||||
try {
|
||||
final EssentialsConf conf = new EssentialsConf(listOfFile);
|
||||
conf.load();
|
||||
final String name = conf.getString("name");
|
||||
if (name != null) {
|
||||
warpPoints.put(new StringIgnoreCase(name), conf);
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
logger.log(Level.WARNING, tl("loadWarpError", filename), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public StringIgnoreCase(String string)
|
||||
{
|
||||
this.string = string;
|
||||
}
|
||||
/**
|
||||
* @deprecated This method relates to the abandoned 3.x storage refactor and is not implemented.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public File getWarpFile(final String name) throws InvalidNameException {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return getString().toLowerCase(Locale.ENGLISH).hashCode();
|
||||
}
|
||||
@Override
|
||||
public int getCount() {
|
||||
return getList().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (o instanceof StringIgnoreCase)
|
||||
{
|
||||
return getString().equalsIgnoreCase(((StringIgnoreCase)o).getString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private static class StringIgnoreCase {
|
||||
private final String string;
|
||||
|
||||
public String getString()
|
||||
{
|
||||
return string;
|
||||
}
|
||||
}
|
||||
StringIgnoreCase(final String string) {
|
||||
this.string = string;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getString().toLowerCase(Locale.ENGLISH).hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o instanceof StringIgnoreCase) {
|
||||
return getString().equalsIgnoreCase(((StringIgnoreCase) o).getString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return string;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,177 +1,155 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Logger;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Locale;
|
||||
|
||||
public class Worth implements IConf
|
||||
{
|
||||
private static final Logger logger = Logger.getLogger("Essentials");
|
||||
private final EssentialsConf config;
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public Worth(File dataFolder)
|
||||
{
|
||||
config = new EssentialsConf(new File(dataFolder, "worth.yml"));
|
||||
config.setTemplateName("/worth.yml");
|
||||
config.load();
|
||||
}
|
||||
public class Worth implements IConf {
|
||||
private final EssentialsConf config;
|
||||
|
||||
public BigDecimal getPrice(ItemStack itemStack)
|
||||
{
|
||||
String itemname = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
BigDecimal result;
|
||||
public Worth(final File dataFolder) {
|
||||
config = new EssentialsConf(new File(dataFolder, "worth.yml"));
|
||||
config.setTemplateName("/worth.yml");
|
||||
config.load();
|
||||
}
|
||||
|
||||
//First check for matches with item name
|
||||
result = config.getBigDecimal("worth." + itemname + "." + itemStack.getDurability(), BigDecimal.ONE.negate());
|
||||
if (result.signum() < 0)
|
||||
{
|
||||
final ConfigurationSection itemNameMatch = config.getConfigurationSection("worth." + itemname);
|
||||
if (itemNameMatch != null && itemNameMatch.getKeys(false).size() == 1)
|
||||
{
|
||||
result = config.getBigDecimal("worth." + itemname + ".0", BigDecimal.ONE.negate());
|
||||
}
|
||||
}
|
||||
if (result.signum() < 0)
|
||||
{
|
||||
result = config.getBigDecimal("worth." + itemname + ".*", BigDecimal.ONE.negate());
|
||||
}
|
||||
if (result.signum() < 0)
|
||||
{
|
||||
result = config.getBigDecimal("worth." + itemname, BigDecimal.ONE.negate());
|
||||
}
|
||||
/**
|
||||
* Get the value of an item stack from the config.
|
||||
*
|
||||
* @param ess The Essentials instance.
|
||||
* @param itemStack The item stack to look up in the config.
|
||||
* @return The price from the config.
|
||||
*/
|
||||
public BigDecimal getPrice(final IEssentials ess, final ItemStack itemStack) {
|
||||
BigDecimal result;
|
||||
|
||||
//Now we should check for item ID
|
||||
if (result.signum() < 0)
|
||||
{
|
||||
result = config.getBigDecimal("worth." + itemStack.getTypeId() + "." + itemStack.getDurability(), BigDecimal.ONE.negate());
|
||||
}
|
||||
if (result.signum() < 0)
|
||||
{
|
||||
final ConfigurationSection itemNumberMatch = config.getConfigurationSection("worth." + itemStack.getTypeId());
|
||||
if (itemNumberMatch != null && itemNumberMatch.getKeys(false).size() == 1)
|
||||
{
|
||||
result = config.getBigDecimal("worth." + itemStack.getTypeId() + ".0", BigDecimal.ONE.negate());
|
||||
}
|
||||
}
|
||||
if (result.signum() < 0)
|
||||
{
|
||||
result = config.getBigDecimal("worth." + itemStack.getTypeId() + ".*", BigDecimal.ONE.negate());
|
||||
}
|
||||
if (result.signum() < 0)
|
||||
{
|
||||
result = config.getBigDecimal("worth." + itemStack.getTypeId(), BigDecimal.ONE.negate());
|
||||
}
|
||||
final String itemname = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
|
||||
//This is to match the old worth syntax
|
||||
if (result.signum() < 0)
|
||||
{
|
||||
result = config.getBigDecimal("worth-" + itemStack.getTypeId(), BigDecimal.ONE.negate());
|
||||
}
|
||||
if (result.signum() < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// Check for matches with data value from stack
|
||||
// Note that we always default to BigDecimal.ONE.negate(), equivalent to -1
|
||||
result = config.getBigDecimal("worth." + itemname + "." + itemStack.getDurability(), BigDecimal.ONE.negate());
|
||||
|
||||
public int getAmount(IEssentials ess, User user, ItemStack is, String[] args, boolean isBulkSell) throws Exception
|
||||
{
|
||||
if (is == null || is.getType() == Material.AIR)
|
||||
{
|
||||
throw new Exception(_("itemSellAir"));
|
||||
}
|
||||
int id = is.getTypeId();
|
||||
int amount = 0;
|
||||
// Check for matches with data value 0
|
||||
if (result.signum() < 0) {
|
||||
final ConfigurationSection itemNameMatch = config.getConfigurationSection("worth." + itemname);
|
||||
if (itemNameMatch != null && itemNameMatch.getKeys(false).size() == 1) {
|
||||
result = config.getBigDecimal("worth." + itemname + ".0", BigDecimal.ONE.negate());
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
amount = Integer.parseInt(args[1].replaceAll("[^0-9]", ""));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
throw new NotEnoughArgumentsException(ex);
|
||||
}
|
||||
if (args[1].startsWith("-"))
|
||||
{
|
||||
amount = -amount;
|
||||
}
|
||||
}
|
||||
// Check for matches with data value wildcard
|
||||
if (result.signum() < 0) {
|
||||
result = config.getBigDecimal("worth." + itemname + ".*", BigDecimal.ONE.negate());
|
||||
}
|
||||
|
||||
boolean stack = args.length > 1 && args[1].endsWith("s");
|
||||
boolean requireStack = ess.getSettings().isTradeInStacks(id);
|
||||
// Check for matches with item name alone
|
||||
if (result.signum() < 0) {
|
||||
result = config.getBigDecimal("worth." + itemname, BigDecimal.ONE.negate());
|
||||
}
|
||||
|
||||
if (requireStack && !stack)
|
||||
{
|
||||
throw new Exception(_("itemMustBeStacked"));
|
||||
}
|
||||
if (result.signum() < 0) {
|
||||
return null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int max = 0;
|
||||
for (ItemStack s : user.getInventory().getContents())
|
||||
{
|
||||
if (s == null || !s.isSimilar(is))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
max += s.getAmount();
|
||||
}
|
||||
/**
|
||||
* Get the amount of items to be sold from a player's inventory.
|
||||
*
|
||||
* @param ess The Essentials instance.
|
||||
* @param user The user attempting to sell the item.
|
||||
* @param is A stack of the item to search the inventory for.
|
||||
* @param args The amount to try to sell.
|
||||
* @param isBulkSell Whether or not to try and bulk sell all items.
|
||||
* @return The amount of items to sell from the player's inventory.
|
||||
* @throws Exception Thrown if trying to sell air or an invalid amount.
|
||||
*/
|
||||
public int getAmount(final IEssentials ess, final User user, final ItemStack is, final String[] args, final boolean isBulkSell) throws Exception {
|
||||
if (is == null || is.getType() == Material.AIR) {
|
||||
throw new Exception(tl("itemSellAir"));
|
||||
}
|
||||
|
||||
if (stack)
|
||||
{
|
||||
amount *= is.getType().getMaxStackSize();
|
||||
}
|
||||
if (amount < 1)
|
||||
{
|
||||
amount += max;
|
||||
}
|
||||
int amount = 0;
|
||||
|
||||
if (requireStack)
|
||||
{
|
||||
amount -= amount % is.getType().getMaxStackSize();
|
||||
}
|
||||
if (amount > max || amount < 1)
|
||||
{
|
||||
if (!isBulkSell)
|
||||
{
|
||||
user.sendMessage(_("itemNotEnough2"));
|
||||
user.sendMessage(_("itemNotEnough3"));
|
||||
throw new Exception(_("itemNotEnough1"));
|
||||
}
|
||||
else
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
if (args.length > 1) {
|
||||
try {
|
||||
amount = Integer.parseInt(args[1].replaceAll("[^0-9]", ""));
|
||||
} catch (final NumberFormatException ex) {
|
||||
throw new NotEnoughArgumentsException(ex);
|
||||
}
|
||||
if (args[1].startsWith("-")) {
|
||||
amount = -amount;
|
||||
}
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
final boolean stack = args.length > 1 && args[1].endsWith("s");
|
||||
final boolean requireStack = ess.getSettings().isTradeInStacks(is.getType());
|
||||
|
||||
public void setPrice(ItemStack itemStack, double price)
|
||||
{
|
||||
if (itemStack.getType().getData() == null)
|
||||
{
|
||||
config.setProperty("worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""), price);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Bukkit-bug: getDurability still contains the correct value, while getData().getData() is 0.
|
||||
config.setProperty("worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "") + "." + itemStack.getDurability(), price);
|
||||
}
|
||||
config.removeProperty("worth-" + itemStack.getTypeId());
|
||||
config.save();
|
||||
}
|
||||
if (requireStack && !stack) {
|
||||
throw new Exception(tl("itemMustBeStacked"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
config.load();
|
||||
}
|
||||
int max = 0;
|
||||
for (final ItemStack s : user.getBase().getInventory().getContents()) {
|
||||
if (s == null || !s.isSimilar(is)) {
|
||||
continue;
|
||||
}
|
||||
max += s.getAmount();
|
||||
}
|
||||
|
||||
if (stack) {
|
||||
amount *= is.getType().getMaxStackSize();
|
||||
}
|
||||
if (amount < 1) {
|
||||
amount += max;
|
||||
}
|
||||
|
||||
if (requireStack) {
|
||||
amount -= amount % is.getType().getMaxStackSize();
|
||||
}
|
||||
if (amount > max || amount < 1) {
|
||||
if (!isBulkSell) {
|
||||
user.sendMessage(tl("itemNotEnough2"));
|
||||
user.sendMessage(tl("itemNotEnough3"));
|
||||
throw new Exception(tl("itemNotEnough1"));
|
||||
} else {
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the price of an item and save it to the config.
|
||||
*
|
||||
* @param ess The Essentials instance.
|
||||
* @param itemStack A stack of the item to save.
|
||||
* @param price The new price of the item.
|
||||
*/
|
||||
public void setPrice(final IEssentials ess, final ItemStack itemStack, final double price) {
|
||||
String path = "worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
|
||||
// Spigot 1.13+ throws an exception if a 1.13+ plugin even *attempts* to do set data.
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_13_0_R01) && itemStack.getType().getData() == null) {
|
||||
// Bukkit-bug: getDurability still contains the correct value, while getData().getData() is 0.
|
||||
path = path + "." + itemStack.getDurability();
|
||||
}
|
||||
|
||||
config.setProperty(path, price);
|
||||
config.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
config.load();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,126 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.Trade;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* Manages EssentialsX's teleport functionality for a player.
|
||||
* Use this if you want to access EssentialsX's async/safe teleport functionality and teleport warmups and cooldowns.
|
||||
*/
|
||||
public interface IAsyncTeleport {
|
||||
|
||||
/**
|
||||
* Used to skip teleportPlayer delay when teleporting someone to a location or player.
|
||||
*
|
||||
* @param loc - Where should the player end up
|
||||
* @param cooldown - If cooldown should be enforced
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void now(Location loc, boolean cooldown, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
|
||||
/**
|
||||
* Used to skip teleportPlayer delay when teleporting someone to a location or player.
|
||||
*
|
||||
* @param entity - Where should the player end up
|
||||
* @param cooldown - If cooldown should be enforced
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void now(Player entity, boolean cooldown, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
|
||||
/**
|
||||
* Teleport a player to a specific location
|
||||
*
|
||||
* @param loc - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause.
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void teleport(Location loc, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
|
||||
/**
|
||||
* Teleport a player to a specific player
|
||||
*
|
||||
* @param entity - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void teleport(Player entity, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
|
||||
/**
|
||||
* Teleport a player to a specific location
|
||||
*
|
||||
* @param otherUser - Which user will be teleported
|
||||
* @param loc - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void teleportPlayer(IUser otherUser, Location loc, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
|
||||
/**
|
||||
* Teleport a player to a specific player
|
||||
*
|
||||
* @param otherUser - Which user will be teleported
|
||||
* @param entity - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void teleportPlayer(IUser otherUser, Player entity, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
|
||||
/**
|
||||
* Teleport wrapper used to handle tp fallback on /jail and /home
|
||||
*
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void respawn(final Trade chargeFor, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
|
||||
/**
|
||||
* Teleport wrapper used to handle /warp teleports
|
||||
*
|
||||
* @param otherUser - Which user will be teleported
|
||||
* @param warp - The name of the warp the user will be teleported too.
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void warp(IUser otherUser, String warp, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause, CompletableFuture<Boolean> future);
|
||||
|
||||
/**
|
||||
* Teleport wrapper used to handle /back teleports
|
||||
*
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void back(Trade chargeFor, CompletableFuture<Boolean> future);
|
||||
|
||||
/**
|
||||
* Teleport wrapper used to handle /back teleports that
|
||||
* are executed by a different player with this
|
||||
* instance of teleport as a target.
|
||||
*
|
||||
* @param teleporter - The user performing the /back command.
|
||||
* This value may be {@code null} to indicate console.
|
||||
* @param chargeFor - What the {@code teleporter} will be charged if teleportPlayer is successful
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void back(IUser teleporter, Trade chargeFor, CompletableFuture<Boolean> future);
|
||||
|
||||
/**
|
||||
* Teleport wrapper used to handle throwing user home after a jail sentence
|
||||
*
|
||||
* @param future - Future which is completed with the success status of the execution
|
||||
*/
|
||||
void back(CompletableFuture<Boolean> future);
|
||||
|
||||
}
|
||||
@@ -1,13 +1,21 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
public interface II18n
|
||||
{
|
||||
/**
|
||||
* Gets the current locale setting
|
||||
* @return the current locale, if not set it will return the default locale
|
||||
*/
|
||||
Locale getCurrentLocale();
|
||||
/**
|
||||
* Provides access to the current locale in use.
|
||||
*
|
||||
* @deprecated External plugins should prefer to use either the player's client language ({@link Player#getLocale()} or
|
||||
* {@link net.ess3.api.II18n} in case of future additions.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface II18n {
|
||||
/**
|
||||
* Gets the current locale setting
|
||||
*
|
||||
* @return the current locale, if not set it will return the default locale
|
||||
*/
|
||||
Locale getCurrentLocale();
|
||||
}
|
||||
@@ -1,20 +1,171 @@
|
||||
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.List;
|
||||
import com.earth2me.essentials.utils.MaterialUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public interface IItemDb
|
||||
{
|
||||
ItemStack get(final String name, final int quantity) throws Exception;
|
||||
/**
|
||||
* Provides access to the current item alias registry.
|
||||
*
|
||||
* @deprecated External plugins should use {@link net.ess3.api.IItemDb} instead, which includes access to {@link net.ess3.api.IItemDb.ItemResolver}
|
||||
* APIs.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IItemDb {
|
||||
|
||||
ItemStack get(final String name) throws Exception;
|
||||
|
||||
public String names(ItemStack item);
|
||||
|
||||
public String name(ItemStack item);
|
||||
|
||||
List<ItemStack> getMatching(User user, String[] args) throws Exception;
|
||||
/**
|
||||
* Create a stack from the given name with the given quantity.
|
||||
*
|
||||
* @param name Item name to look up in the database
|
||||
* @param quantity Quantity of the item stack
|
||||
* @return The requested item stack
|
||||
* @throws Exception if the item stack cannot be created
|
||||
*/
|
||||
default ItemStack get(final String name, final int quantity) throws Exception {
|
||||
final ItemStack stack = get(name.toLowerCase(Locale.ENGLISH));
|
||||
stack.setAmount(quantity);
|
||||
return stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a stack from the given name with the maximum stack size for that material.
|
||||
* <p>
|
||||
* Note that this will always check against resolver functions from other plugins as well.
|
||||
* To avoid this behaviour, use net.ess3.api.IItemDb#get(String name, boolean useResolvers).
|
||||
*
|
||||
* @param name Item name to look up in the database
|
||||
* @return The requested item stack with the maximum stack size
|
||||
* @throws Exception if the item stack cannot be created
|
||||
*/
|
||||
ItemStack get(final String name) throws Exception;
|
||||
|
||||
/**
|
||||
* Get a comma-separated string list of up to 15 aliases for the given stack.
|
||||
*
|
||||
* @param item Item stack whose names to find
|
||||
* @return Comma-separated list of up to 15 item names
|
||||
*/
|
||||
default String names(final ItemStack item) {
|
||||
List<String> nameList = nameList(item);
|
||||
|
||||
if (nameList.size() > 15) {
|
||||
nameList = nameList.subList(0, 14);
|
||||
}
|
||||
return StringUtil.joinList(", ", nameList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a List of all aliases for the given item stack.
|
||||
*
|
||||
* @param item Item stack whose names to find
|
||||
* @return List of all names
|
||||
*/
|
||||
List<String> nameList(ItemStack item);
|
||||
|
||||
/**
|
||||
* Get the primary name for the given item stack.
|
||||
*
|
||||
* @param item Item stack whose name to find
|
||||
* @return Primary name of the item
|
||||
*/
|
||||
String name(ItemStack item);
|
||||
|
||||
/**
|
||||
* Get all stacks in a given User's inventory that matches the given arguments.
|
||||
*
|
||||
* @param user The user with the player inventory to search
|
||||
* @param args Either an item name, or one of the following:
|
||||
* hand (default), inventory/invent/all, blocks
|
||||
* @return A List of all matching ItemStacks
|
||||
* @throws Exception if the given args are invalid or no blocks are found
|
||||
*/
|
||||
List<ItemStack> getMatching(User user, String[] args) throws Exception;
|
||||
|
||||
/**
|
||||
* Converts the given {@link ItemStack} to a string representation that can be saved.
|
||||
* This is typically used for /createkit but can be used by other plugins for various purposes too.
|
||||
* Note that this will try registered resolvers first - to avoid this, use {@link net.ess3.api.IItemDb#serialize(ItemStack, boolean)} instead.
|
||||
*
|
||||
* @param is The stack to serialize
|
||||
* @return A string representing the given stack
|
||||
*/
|
||||
String serialize(ItemStack is);
|
||||
|
||||
/**
|
||||
* Return names recognised by the database, intended for tab-completion.
|
||||
*
|
||||
* @return Collection of all item names
|
||||
*/
|
||||
Collection<String> listNames();
|
||||
|
||||
/**
|
||||
* Get the material matching the given legacy ID. Used for conversion from item IDs to
|
||||
* modern names.
|
||||
*
|
||||
* @param id Legacy ID of material to find
|
||||
* @return Updated material
|
||||
*/
|
||||
@Deprecated
|
||||
default Material getFromLegacyId(final int id) {
|
||||
return getFromLegacy(id, (byte) 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the legacy ID for the given material.
|
||||
*
|
||||
* @param material Material to look up
|
||||
* @return Legacy ID of given material
|
||||
* @throws Exception if the ID cannot be looked up
|
||||
* @deprecated Item IDs are no longer supported.
|
||||
*/
|
||||
@Deprecated
|
||||
int getLegacyId(Material material) throws Exception;
|
||||
|
||||
/**
|
||||
* Convert colon syntax (eg. "13", "1:5") legacy IDs to Material. Used for conversion from
|
||||
* item IDs to modern names.
|
||||
*
|
||||
* @param item Legacy ID in colon syntax.
|
||||
* @return Material if an appropriate material exists, else null.
|
||||
*/
|
||||
default Material getFromLegacy(final String item) {
|
||||
final String[] split = item.split(":");
|
||||
|
||||
if (!NumberUtil.isInt(split[0])) return null;
|
||||
|
||||
final int id = Integer.parseInt(split[0]);
|
||||
byte damage = 0;
|
||||
|
||||
if (split.length > 1 && NumberUtil.isInt(split[1])) {
|
||||
damage = Byte.parseByte(split[1]);
|
||||
}
|
||||
|
||||
return getFromLegacy(id, damage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert legacy ID and damage value to Material. Used for conversion from item IDs to
|
||||
* modern names.
|
||||
*
|
||||
* @param id Legacy ID
|
||||
* @param damage Damage value
|
||||
* @return Material
|
||||
*/
|
||||
default Material getFromLegacy(final int id, final byte damage) {
|
||||
return MaterialUtil.convertFromLegacy(id, damage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the item database is loaded and ready for use.
|
||||
*
|
||||
* @return Whether items have finished loading
|
||||
*/
|
||||
boolean isReady();
|
||||
}
|
||||
@@ -1,53 +1,77 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.util.Collection;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface IJails extends IReload
|
||||
{
|
||||
/**
|
||||
* Gets the location of the jail with the given name
|
||||
* @param jailName The name of the jail
|
||||
* @return the location of the jail
|
||||
* @throws Exception if the jail does not exist
|
||||
*/
|
||||
Location getJail(String jailName) throws Exception;
|
||||
/**
|
||||
* Provides access to the storage of jail locations. Maintainers should add methods to <i>this interface</i>.
|
||||
*
|
||||
* @deprecated External plugins should use {@link net.ess3.api.IJails} instead of this interface in case future APIs are added.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IJails extends IReload {
|
||||
/**
|
||||
* Gets the location of the jail with the given name
|
||||
*
|
||||
* @param jailName The name of the jail
|
||||
* @return the location of the jail
|
||||
* @throws Exception if the jail does not exist
|
||||
*/
|
||||
Location getJail(String jailName) throws Exception;
|
||||
|
||||
/**
|
||||
* Gets a list of jails by names
|
||||
* @return a list of jails, if there are none the list will be empty
|
||||
* @throws Exception
|
||||
*/
|
||||
Collection<String> getList() throws Exception;
|
||||
/**
|
||||
* Gets a list of jails by names
|
||||
*
|
||||
* @return a list of jails, if there are none the list will be empty
|
||||
* @throws Exception
|
||||
*/
|
||||
Collection<String> getList() throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the number of jails
|
||||
* @return the size of the list of jails
|
||||
*/
|
||||
int getCount();
|
||||
/**
|
||||
* Gets the number of jails
|
||||
*
|
||||
* @return the size of the list of jails
|
||||
*/
|
||||
int getCount();
|
||||
|
||||
/**
|
||||
* Remove the jail with the given name
|
||||
* @param jail the jail to remove
|
||||
* @throws Exception if the jail does not exist
|
||||
*/
|
||||
void removeJail(String jail) throws Exception;
|
||||
/**
|
||||
* Remove the jail with the given name
|
||||
*
|
||||
* @param jail the jail to remove
|
||||
* @throws Exception if the jail does not exist
|
||||
*/
|
||||
void removeJail(String jail) throws Exception;
|
||||
|
||||
/**
|
||||
* Attempts to send the given user to the given jail
|
||||
* @param user the user to send to jail
|
||||
* @param jail the jail to send the user to
|
||||
* @throws Exception if the user is offline or jail does not exist
|
||||
*/
|
||||
void sendToJail(IUser user, String jail) throws Exception;
|
||||
/**
|
||||
* Attempts to send the given user to the given jail
|
||||
*
|
||||
* @param user the user to send to jail
|
||||
* @param jail the jail to send the user to
|
||||
* @throws Exception if the user is offline or jail does not exist
|
||||
* @deprecated Use {@link IJails#sendToJail(IUser, String, CompletableFuture)}
|
||||
*/
|
||||
@Deprecated
|
||||
void sendToJail(IUser user, String jail) throws Exception;
|
||||
|
||||
/**
|
||||
* Set a new jail with the given name and location
|
||||
* @param jailName the name of the jail being set
|
||||
* @param loc the location of the jail being set
|
||||
* @throws Exception
|
||||
*/
|
||||
void setJail(String jailName, Location loc) throws Exception;
|
||||
/**
|
||||
* Attempts to send the given user to the given jail
|
||||
*
|
||||
* @param user the user to send to jail
|
||||
* @param jail the jail to send the user to
|
||||
* @param future Future which is completed with the success status of the execution
|
||||
* @throws Exception if the user is offline or jail does not exist
|
||||
*/
|
||||
void sendToJail(IUser user, String jail, CompletableFuture<Boolean> future) throws Exception;
|
||||
|
||||
/**
|
||||
* Set a new jail with the given name and location
|
||||
*
|
||||
* @param jailName the name of the jail being set
|
||||
* @param loc the location of the jail being set
|
||||
* @throws Exception
|
||||
*/
|
||||
void setJail(String jailName, Location loc) throws Exception;
|
||||
}
|
||||
@@ -1,7 +1,15 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
|
||||
public interface IReload
|
||||
{
|
||||
void onReload();
|
||||
/**
|
||||
* Represents a storage object that is reloadable.
|
||||
*
|
||||
* @deprecated This is a remnant of the abandoned 3.x storage system. Neither future 2.x code nor external plugins
|
||||
* should use this interface.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IReload {
|
||||
/**
|
||||
* Reloads the given storage object.
|
||||
*/
|
||||
void onReload();
|
||||
}
|
||||
@@ -6,107 +6,138 @@ import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
/**
|
||||
* @deprecated This API is not asynchronous and is no longer maintained. Use {@link com.earth2me.essentials.api.IAsyncTeleport IAsyncTeleport}.
|
||||
*/
|
||||
public interface ITeleport {
|
||||
/**
|
||||
* Used to skip teleportPlayer delay when teleporting someone to a location or player.
|
||||
*
|
||||
* @param loc - Where should the player end up
|
||||
* @param cooldown - If cooldown should be enforced
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void now(Location loc, boolean cooldown, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
|
||||
public interface ITeleport
|
||||
{
|
||||
/**
|
||||
* Used to skip teleportPlayer delay when teleporting someone to a location or player.
|
||||
*
|
||||
* @param loc - Where should the player end up
|
||||
* @param cooldown - If cooldown should be enforced
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
void now(Location loc, boolean cooldown, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
/**
|
||||
* Used to skip teleportPlayer delay when teleporting someone to a location or player.
|
||||
*
|
||||
* @param entity - Where should the player end up
|
||||
* @param cooldown - If cooldown should be enforced
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void now(Player entity, boolean cooldown, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
|
||||
/**
|
||||
* Used to skip teleportPlayer delay when teleporting someone to a location or player.
|
||||
*
|
||||
* @param entity - Where should the player end up
|
||||
* @param cooldown - If cooldown should be enforced
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
void now(Player entity, boolean cooldown, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
/**
|
||||
* Teleport a player to a specific location
|
||||
*
|
||||
* @param loc - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void teleport(Location loc, Trade chargeFor) throws Exception;
|
||||
|
||||
@Deprecated
|
||||
void teleport(Location loc, Trade chargeFor) throws Exception;
|
||||
/**
|
||||
* Teleport a player to a specific location
|
||||
*
|
||||
* @param loc - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void teleport(Location loc, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
|
||||
/**
|
||||
* Teleport a player to a specific location
|
||||
*
|
||||
* @param loc - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
void teleport(Location loc, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
/**
|
||||
* Teleport a player to a specific player
|
||||
*
|
||||
* @param entity - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void teleport(Player entity, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
|
||||
/**
|
||||
* Teleport a player to a specific player
|
||||
*
|
||||
* @param entity - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
void teleport(Player entity, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
/**
|
||||
* Teleport a player to a specific location
|
||||
*
|
||||
* @param otherUser - Which user will be teleported
|
||||
* @param loc - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void teleportPlayer(IUser otherUser, Location loc, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
|
||||
/**
|
||||
* Teleport a player to a specific location
|
||||
*
|
||||
* @param otherUser - Which user will be teleported
|
||||
* @param loc - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
void teleportPlayer(IUser otherUser, Location loc, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
/**
|
||||
* Teleport a player to a specific player
|
||||
*
|
||||
* @param otherUser - Which user will be teleported
|
||||
* @param entity - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void teleportPlayer(IUser otherUser, Player entity, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
|
||||
/**
|
||||
* Teleport a player to a specific player
|
||||
*
|
||||
* @param otherUser - Which user will be teleported
|
||||
* @param entity - Where should the player end up
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
void teleportPlayer(IUser otherUser, Player entity, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
/**
|
||||
* Teleport wrapper used to handle tp fallback on /jail and /home
|
||||
*
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void respawn(final Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
|
||||
/**
|
||||
* Teleport wrapper used to handle tp fallback on /jail and /home
|
||||
*
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
public void respawn(final Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
/**
|
||||
* Teleport wrapper used to handle /warp teleports
|
||||
*
|
||||
* @param otherUser - Which user will be teleported
|
||||
* @param warp - The name of the warp the user will be teleported too.
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void warp(IUser otherUser, String warp, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
|
||||
/**
|
||||
* Teleport wrapper used to handle /warp teleports
|
||||
*
|
||||
* @param otherUser - Which user will be teleported
|
||||
* @param warp - The name of the warp the user will be teleported too.
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @param cause - The reported teleportPlayer cause
|
||||
* @throws Exception
|
||||
*/
|
||||
public void warp(IUser otherUser, String warp, Trade chargeFor, PlayerTeleportEvent.TeleportCause cause) throws Exception;
|
||||
/**
|
||||
* Teleport wrapper used to handle /back teleports
|
||||
*
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void back(Trade chargeFor) throws Exception;
|
||||
|
||||
/**
|
||||
* Teleport wrapper used to handle /back teleports
|
||||
*
|
||||
* @param chargeFor - What the user will be charged if teleportPlayer is successful
|
||||
* @throws Exception
|
||||
*/
|
||||
public void back(Trade chargeFor) throws Exception;
|
||||
/**
|
||||
* Teleport wrapper used to handle /back teleports that
|
||||
* are executed by a different player with this
|
||||
* instance of teleport as a target.
|
||||
*
|
||||
* @param teleporter - The user performing the /back command.
|
||||
* This value may be {@code null} to indicate console.
|
||||
* @param chargeFor - What the {@code teleporter} will be charged if teleportPlayer is successful
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void back(IUser teleporter, Trade chargeFor) throws Exception;
|
||||
|
||||
/**
|
||||
* Teleport wrapper used to handle throwing user home after a jail sentence
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void back() throws Exception;
|
||||
/**
|
||||
* Teleport wrapper used to handle throwing user home after a jail sentence
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
void back() throws Exception;
|
||||
|
||||
}
|
||||
@@ -1,68 +1,90 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.IConf;
|
||||
import com.earth2me.essentials.IUser;
|
||||
import com.earth2me.essentials.commands.WarpNotFoundException;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface IWarps extends IConf
|
||||
{
|
||||
/**
|
||||
* Get a warp by name
|
||||
*
|
||||
* @param warp - Warp name
|
||||
* @return - Location the warp is set to
|
||||
* @throws WarpNotFoundException When the warp is not found
|
||||
* @throws InvalidWorldException When the world the warp is in is not found
|
||||
*/
|
||||
Location getWarp(String warp) throws WarpNotFoundException, net.ess3.api.InvalidWorldException;
|
||||
/**
|
||||
* Provides access to the storage of warp locations. Maintainers should add methods to <i>this interface</i>.
|
||||
*
|
||||
* @deprecated External plugins should use {@link net.ess3.api.IWarps} instead of this interface, in case future APIs are added.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IWarps extends IConf {
|
||||
/**
|
||||
* Get a warp by name
|
||||
*
|
||||
* @param warp - Warp name
|
||||
* @return - Location the warp is set to
|
||||
* @throws WarpNotFoundException When the warp is not found
|
||||
* @throws net.ess3.api.InvalidWorldException When the world the warp is in is not found
|
||||
*/
|
||||
Location getWarp(String warp) throws WarpNotFoundException, net.ess3.api.InvalidWorldException;
|
||||
|
||||
/**
|
||||
* Gets a list of warps
|
||||
*
|
||||
* @return - A {@link Collection} of warps
|
||||
*/
|
||||
Collection<String> getList();
|
||||
/**
|
||||
* Gets a list of warps
|
||||
*
|
||||
* @return - A {@link Collection} of warps
|
||||
*/
|
||||
Collection<String> getList();
|
||||
|
||||
/**
|
||||
* Gets the number of warps
|
||||
*
|
||||
* @return the size of the list of warps
|
||||
*/
|
||||
int getCount();
|
||||
/**
|
||||
* Gets the number of warps
|
||||
*
|
||||
* @return the size of the list of warps
|
||||
*/
|
||||
int getCount();
|
||||
|
||||
/**
|
||||
* Delete a warp from the warp DB
|
||||
*
|
||||
* @param name - Name of warp
|
||||
* @throws Exception
|
||||
*/
|
||||
void removeWarp(String name) throws Exception;
|
||||
/**
|
||||
* Delete a warp from the warp DB
|
||||
*
|
||||
* @param name - Name of warp
|
||||
* @throws Exception
|
||||
*/
|
||||
void removeWarp(String name) throws Exception;
|
||||
|
||||
/**
|
||||
* Set a warp
|
||||
*
|
||||
* @param name - Name of warp
|
||||
* @param loc - Location of warp
|
||||
* @throws Exception
|
||||
*/
|
||||
void setWarp(String name, Location loc) throws Exception;
|
||||
/**
|
||||
* Set a warp
|
||||
*
|
||||
* @param name - Name of warp
|
||||
* @param loc - Location of warp
|
||||
* @throws Exception
|
||||
*/
|
||||
void setWarp(String name, Location loc) throws Exception;
|
||||
|
||||
/**
|
||||
* Check to see if the file is empty
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isEmpty();
|
||||
/**
|
||||
* Set a warp
|
||||
*
|
||||
* @param user - User of warp
|
||||
* @param name - Name of warp
|
||||
* @param loc - Location of warp
|
||||
* @throws Exception
|
||||
*/
|
||||
void setWarp(IUser user, String name, Location loc) throws Exception;
|
||||
|
||||
/**
|
||||
* Get a warp file note: this is not yet implemented, as 3.x uses different storage methods
|
||||
*
|
||||
* @param name - name of file
|
||||
* @return - an instance of the file
|
||||
* @throws InvalidNameException - When the file is not found
|
||||
*/
|
||||
File getWarpFile(String name) throws net.ess3.api.InvalidNameException;
|
||||
/**
|
||||
* Gets Lastowner UUID
|
||||
*
|
||||
* @param warp - Name of warp
|
||||
* @throws WarpNotFoundException
|
||||
*/
|
||||
UUID getLastOwner(String warp) throws WarpNotFoundException;
|
||||
|
||||
/**
|
||||
* Check to see if the file is empty
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isEmpty();
|
||||
|
||||
/**
|
||||
* @deprecated This method relates to the abandoned 3.x storage refactor and is not implemented.
|
||||
*/
|
||||
@Deprecated
|
||||
File getWarpFile(String name) throws net.ess3.api.InvalidNameException;
|
||||
}
|
||||
@@ -1,16 +1,17 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
/**
|
||||
* @deprecated This exception relates to the abandoned 3.x storage refactor and is not implemented.
|
||||
*/
|
||||
@Deprecated
|
||||
public class InvalidNameException extends Exception {
|
||||
/**
|
||||
* NOTE: This is not implemented yet, just here for future 3.x api support Allow serialization of the
|
||||
* InvalidNameException exception
|
||||
*/
|
||||
private static final long serialVersionUID = 1485321420293663139L;
|
||||
|
||||
public class InvalidNameException extends Exception
|
||||
{
|
||||
/**
|
||||
* NOTE: This is not implemented yet, just here for future 3.x api support
|
||||
* Allow serialization of the InvalidNameException exception
|
||||
*/
|
||||
private static final long serialVersionUID = 1485321420293663139L;
|
||||
|
||||
public InvalidNameException(Throwable thrwbl)
|
||||
{
|
||||
super(thrwbl);
|
||||
}
|
||||
public InvalidNameException(final Throwable thrwbl) {
|
||||
super(thrwbl);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
/**
|
||||
* @deprecated This exception is unused. Use {@link net.ess3.api.InvalidWorldException} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public class InvalidWorldException extends Exception {
|
||||
private final String world;
|
||||
|
||||
public class InvalidWorldException extends Exception
|
||||
{
|
||||
private final String world;
|
||||
public InvalidWorldException(final String world) {
|
||||
super(tl("invalidWorld"));
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public InvalidWorldException(final String world)
|
||||
{
|
||||
super(_("invalidWorld"));
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public String getWorld()
|
||||
{
|
||||
return this.world;
|
||||
}
|
||||
public String getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
|
||||
public class NoLoanPermittedException extends net.ess3.api.NoLoanPermittedException
|
||||
{
|
||||
/**
|
||||
* Thrown when a user does not have the balance for a transaction and cannot take a loan.
|
||||
*/
|
||||
public class NoLoanPermittedException extends net.ess3.api.NoLoanPermittedException {
|
||||
|
||||
}
|
||||
@@ -1,12 +1,18 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class UserDoesNotExistException extends Exception
|
||||
{
|
||||
public UserDoesNotExistException(String name)
|
||||
{
|
||||
super(_("userDoesNotExist", name));
|
||||
}
|
||||
/**
|
||||
* Thrown when the requested user does not exist.
|
||||
*/
|
||||
public class UserDoesNotExistException extends Exception {
|
||||
public UserDoesNotExistException(final String name) {
|
||||
super(tl("userDoesNotExist", name));
|
||||
}
|
||||
|
||||
public UserDoesNotExistException(final UUID uuid) {
|
||||
super(tl("uuidDoesNotExist", uuid.toString()));
|
||||
}
|
||||
}
|
||||
@@ -1,71 +1,101 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import net.ess3.api.events.AfkStatusChangeEvent;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Commandafk extends EssentialsCommand
|
||||
{
|
||||
public Commandafk()
|
||||
{
|
||||
super("afk");
|
||||
}
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && user.isAuthorized("essentials.afk.others"))
|
||||
{
|
||||
User afkUser = getPlayer(server, user, args, 0);
|
||||
toggleAfk(afkUser);
|
||||
}
|
||||
else
|
||||
{
|
||||
toggleAfk(user);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSource sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0)
|
||||
{
|
||||
User afkUser = getPlayer(server, args, 0, true, false);
|
||||
toggleAfk(afkUser);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
}
|
||||
public class Commandafk extends EssentialsCommand {
|
||||
public Commandafk() {
|
||||
super("afk");
|
||||
}
|
||||
|
||||
private void toggleAfk(User user)
|
||||
{
|
||||
user.setDisplayNick();
|
||||
String msg = "";
|
||||
if (!user.toggleAfk())
|
||||
{
|
||||
//user.sendMessage(_("markedAsNotAway"));
|
||||
if (!user.isHidden())
|
||||
{
|
||||
msg = _("userIsNotAway", user.getDisplayName());
|
||||
}
|
||||
user.updateActivity(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
//user.sendMessage(_("markedAsAway"));
|
||||
if (!user.isHidden())
|
||||
{
|
||||
msg = _("userIsAway", user.getDisplayName());
|
||||
}
|
||||
}
|
||||
if (!msg.isEmpty())
|
||||
{
|
||||
ess.broadcastMessage(user, msg);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length > 0 && user.isAuthorized("essentials.afk.others")) {
|
||||
User afkUser = user; // if no player found, but message specified, set command executor to target user
|
||||
String message;
|
||||
try {
|
||||
afkUser = getPlayer(server, user, args, 0);
|
||||
message = args.length > 1 ? getFinalArg(args, 1) : null;
|
||||
} catch (final PlayerNotFoundException e) {
|
||||
message = getFinalArg(args, 0);
|
||||
}
|
||||
toggleAfk(user, afkUser, message);
|
||||
} else {
|
||||
final String message = args.length > 0 ? getFinalArg(args, 0) : null;
|
||||
toggleAfk(user, user, message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length > 0) {
|
||||
final User afkUser = getPlayer(server, args, 0, true, false);
|
||||
final String message = args.length > 1 ? getFinalArg(args, 1) : null;
|
||||
toggleAfk(null, afkUser, message);
|
||||
} else {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleAfk(final User sender, final User user, final String message) throws Exception {
|
||||
if (message != null && sender != null) {
|
||||
if (sender.isMuted()) {
|
||||
final String dateDiff = sender.getMuteTimeout() > 0 ? DateUtil.formatDateDiff(sender.getMuteTimeout()) : null;
|
||||
if (dateDiff == null) {
|
||||
throw new Exception(sender.hasMuteReason() ? tl("voiceSilencedReason", sender.getMuteReason()) : tl("voiceSilenced"));
|
||||
}
|
||||
throw new Exception(sender.hasMuteReason() ? tl("voiceSilencedReasonTime", dateDiff, sender.getMuteReason()) : tl("voiceSilencedTime", dateDiff));
|
||||
}
|
||||
if (!sender.isAuthorized("essentials.afk.message")) {
|
||||
throw new Exception(tl("noPermToAFKMessage"));
|
||||
}
|
||||
}
|
||||
user.setDisplayNick();
|
||||
String msg = "";
|
||||
String selfmsg = "";
|
||||
if (!user.toggleAfk(AfkStatusChangeEvent.Cause.COMMAND)) {
|
||||
if (!user.isHidden()) {
|
||||
msg = tl("userIsNotAway", user.getDisplayName());
|
||||
selfmsg = tl("userIsNotAwaySelf", user.getDisplayName());
|
||||
}
|
||||
user.updateActivity(false, AfkStatusChangeEvent.Cause.COMMAND);
|
||||
} else {
|
||||
if (!user.isHidden()) {
|
||||
if (message != null) {
|
||||
msg = tl("userIsAwayWithMessage", user.getDisplayName(), message);
|
||||
selfmsg = tl("userIsAwaySelfWithMessage", user.getDisplayName(), message);
|
||||
} else {
|
||||
msg = tl("userIsAway", user.getDisplayName());
|
||||
selfmsg = tl("userIsAwaySelf", user.getDisplayName());
|
||||
}
|
||||
}
|
||||
user.setAfkMessage(message);
|
||||
}
|
||||
if (!msg.isEmpty() && ess.getSettings().broadcastAfkMessage()) {
|
||||
// exclude user from receiving general AFK announcement in favor of personal message
|
||||
ess.broadcastMessage(user, msg, u -> u == user);
|
||||
}
|
||||
if (!selfmsg.isEmpty()) {
|
||||
user.sendMessage(selfmsg);
|
||||
}
|
||||
user.setDisplayNick(); // Set this again after toggling
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1 && sender.isAuthorized("essentials.afk.others", ess)) {
|
||||
return getPlayers(server, sender);
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,23 +7,19 @@ import org.bukkit.Server;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
||||
// This command has a in theme message that only shows if you supply a parameter #EasterEgg
|
||||
public class Commandantioch extends EssentialsCommand
|
||||
{
|
||||
public Commandantioch()
|
||||
{
|
||||
super("antioch");
|
||||
}
|
||||
public class Commandantioch extends EssentialsCommand {
|
||||
public Commandantioch() {
|
||||
super("antioch");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0)
|
||||
{
|
||||
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.");
|
||||
}
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length > 0) {
|
||||
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.");
|
||||
}
|
||||
|
||||
final Location loc = LocationUtil.getTarget(user.getBase());
|
||||
loc.getWorld().spawn(loc, TNTPrimed.class);
|
||||
}
|
||||
final Location loc = LocationUtil.getTarget(user.getBase());
|
||||
loc.getWorld().spawn(loc, TNTPrimed.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandanvil extends EssentialsCommand {
|
||||
|
||||
public Commandanvil() {
|
||||
super("anvil");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception {
|
||||
if (ess.getContainerProvider() == null) {
|
||||
user.sendMessage(tl("unsupportedBrand"));
|
||||
return;
|
||||
}
|
||||
|
||||
ess.getContainerProvider().openAnvil(user.getBase());
|
||||
}
|
||||
}
|
||||
@@ -1,33 +1,86 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Commandback extends EssentialsCommand
|
||||
{
|
||||
public Commandback()
|
||||
{
|
||||
super("back");
|
||||
}
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (user.getLastLocation() == null)
|
||||
{
|
||||
throw new Exception(_("noLocationFound"));
|
||||
}
|
||||
if (user.getWorld() != user.getLastLocation().getWorld() && ess.getSettings().isWorldTeleportPermissions()
|
||||
&& !user.isAuthorized("essentials.worlds." + user.getLastLocation().getWorld().getName()))
|
||||
{
|
||||
throw new Exception(_("noPerm", "essentials.worlds." + user.getLastLocation().getWorld().getName()));
|
||||
}
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.getTeleport().back(charge);
|
||||
throw new NoChargeException();
|
||||
}
|
||||
public class Commandback extends EssentialsCommand {
|
||||
public Commandback() {
|
||||
super("back");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
final CommandSource sender = user.getSource();
|
||||
if (args.length > 0 && user.isAuthorized("essentials.back.others")) {
|
||||
parseOthers(server, sender, args, commandLabel);
|
||||
return;
|
||||
}
|
||||
|
||||
teleportBack(sender, user, commandLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length == 0) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
parseOthers(server, sender, args, commandLabel);
|
||||
}
|
||||
|
||||
private void parseOthers(final Server server, final CommandSource sender, final String[] args, final String commandLabel) throws Exception {
|
||||
final User player = getPlayer(server, args, 0, true, false);
|
||||
sender.sendMessage(tl("backOther", player.getName()));
|
||||
teleportBack(sender, player, commandLabel);
|
||||
}
|
||||
|
||||
private void teleportBack(final CommandSource sender, final User user, final String commandLabel) throws Exception {
|
||||
if (user.getLastLocation() == null) {
|
||||
throw new Exception(tl("noLocationFound"));
|
||||
}
|
||||
|
||||
final String lastWorldName = user.getLastLocation().getWorld().getName();
|
||||
|
||||
User requester = null;
|
||||
if (sender.isPlayer()) {
|
||||
requester = ess.getUser(sender.getPlayer());
|
||||
|
||||
if (user.getWorld() != user.getLastLocation().getWorld() && this.ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + lastWorldName)) {
|
||||
throw new Exception(tl("noPerm", "essentials.worlds." + lastWorldName));
|
||||
}
|
||||
|
||||
if (!requester.isAuthorized("essentials.back.into." + lastWorldName)) {
|
||||
throw new Exception(tl("noPerm", "essentials.back.into." + lastWorldName));
|
||||
}
|
||||
}
|
||||
|
||||
if (requester == null) {
|
||||
user.getAsyncTeleport().back(null, null, getNewExceptionFuture(sender, commandLabel));
|
||||
} else if (!requester.equals(user)) {
|
||||
final Trade charge = new Trade(this.getName(), this.ess);
|
||||
charge.isAffordableFor(requester);
|
||||
user.getAsyncTeleport().back(requester, charge, getNewExceptionFuture(sender, commandLabel));
|
||||
} else {
|
||||
final Trade charge = new Trade(this.getName(), this.ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.getAsyncTeleport().back(charge, getNewExceptionFuture(sender, commandLabel));
|
||||
}
|
||||
throw new NoChargeException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final User user, final String commandLabel, final String[] args) {
|
||||
if (user.isAuthorized("essentials.back.others") && args.length == 1) {
|
||||
return getPlayers(server, user);
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,31 +2,26 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Backup;
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandbackup extends EssentialsCommand
|
||||
{
|
||||
public Commandbackup()
|
||||
{
|
||||
super("backup");
|
||||
}
|
||||
public class Commandbackup extends EssentialsCommand {
|
||||
public Commandbackup() {
|
||||
super("backup");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final Backup backup = ess.getBackup();
|
||||
if (backup == null)
|
||||
{
|
||||
throw new Exception(_("backupDisabled"));
|
||||
}
|
||||
final String command = ess.getSettings().getBackupCommand();
|
||||
if (command == null || "".equals(command) || "save-all".equalsIgnoreCase(command))
|
||||
{
|
||||
throw new Exception(_("backupDisabled"));
|
||||
}
|
||||
backup.run();
|
||||
sender.sendMessage(_("backupStarted"));
|
||||
}
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
final Backup backup = ess.getBackup();
|
||||
if (backup == null) {
|
||||
throw new Exception(tl("backupDisabled"));
|
||||
}
|
||||
final String command = ess.getSettings().getBackupCommand();
|
||||
if (command == null || "".equals(command) || "save-all".equalsIgnoreCase(command)) {
|
||||
throw new Exception(tl("backupDisabled"));
|
||||
}
|
||||
backup.run();
|
||||
sender.sendMessage(tl("backupStarted"));
|
||||
}
|
||||
}
|
||||
@@ -1,49 +1,48 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import java.math.BigDecimal;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Commandbalance extends EssentialsCommand
|
||||
{
|
||||
public Commandbalance()
|
||||
{
|
||||
super("balance");
|
||||
}
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
public class Commandbalance extends EssentialsCommand {
|
||||
public Commandbalance() {
|
||||
super("balance");
|
||||
}
|
||||
|
||||
User target = getPlayer(server, args, 0, true, true);
|
||||
sender.sendMessage(_("balanceOther", target.isHidden() ? target.getName() : target.getDisplayName(), NumberUtil.displayCurrency(target.getMoney(), ess)));
|
||||
}
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length == 0) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length == 1 && user.isAuthorized("essentials.balance.others"))
|
||||
{
|
||||
final User target = getPlayer(server, args, 0, true, true);
|
||||
final BigDecimal bal = target.getMoney();
|
||||
user.sendMessage(_("balanceOther", target.isHidden() ? target.getName() : target.getDisplayName(), NumberUtil.displayCurrency(bal, ess)));
|
||||
}
|
||||
else if (args.length < 2)
|
||||
{
|
||||
final BigDecimal bal = user.getMoney();
|
||||
user.sendMessage(_("balance", NumberUtil.displayCurrency(bal, ess)));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
}
|
||||
final User target = getPlayer(server, args, 0, false, true);
|
||||
sender.sendMessage(tl("balanceOther", target.isHidden() ? target.getName() : target.getDisplayName(), NumberUtil.displayCurrency(target.getMoney(), ess)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length == 1 && user.isAuthorized("essentials.balance.others")) {
|
||||
final User target = getPlayer(server, args, 0, true, true);
|
||||
user.sendMessage(tl("balanceOther", target.isHidden() ? target.getName() : target.getDisplayName(), NumberUtil.displayCurrency(target.getMoney(), ess)));
|
||||
} else if (args.length < 2) {
|
||||
user.sendMessage(tl("balance", NumberUtil.displayCurrency(user.getMoney(), ess)));
|
||||
} else {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1 && sender.isAuthorized("essentials.balance.others", ess)) {
|
||||
return getPlayers(server, sender);
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,198 +1,176 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.textreader.SimpleTextInput;
|
||||
import com.earth2me.essentials.textreader.TextPager;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DateFormat;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandbalancetop extends EssentialsCommand
|
||||
{
|
||||
public Commandbalancetop()
|
||||
{
|
||||
super("balancetop");
|
||||
}
|
||||
private static final int CACHETIME = 2 * 60 * 1000;
|
||||
public static final int MINUSERS = 50;
|
||||
private static final SimpleTextInput cache = new SimpleTextInput();
|
||||
private static long cacheage = 0;
|
||||
private static final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
public class Commandbalancetop extends EssentialsCommand {
|
||||
public static final int MINUSERS = 50;
|
||||
private static final int CACHETIME = 2 * 60 * 1000;
|
||||
private static final SimpleTextInput cache = new SimpleTextInput();
|
||||
private static final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
private static long cacheage = 0;
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
int page = 0;
|
||||
boolean force = false;
|
||||
if (args.length > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
page = Integer.parseInt(args[0]);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("force")
|
||||
&& (!sender.isPlayer() || ess.getUser(sender.getPlayer()).isAuthorized("essentials.balancetop.force")))
|
||||
{
|
||||
force = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public Commandbalancetop() {
|
||||
super("balancetop");
|
||||
}
|
||||
|
||||
if (!force && lock.readLock().tryLock())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (cacheage > System.currentTimeMillis() - CACHETIME)
|
||||
{
|
||||
outputCache(sender, page);
|
||||
return;
|
||||
}
|
||||
if (ess.getUserMap().getUniqueUsers() > MINUSERS)
|
||||
{
|
||||
sender.sendMessage(_("orderBalances", ess.getUserMap().getUniqueUsers()));
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
ess.runTaskAsynchronously(new Viewer(sender, page, force));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ess.getUserMap().getUniqueUsers() > MINUSERS)
|
||||
{
|
||||
sender.sendMessage(_("orderBalances", ess.getUserMap().getUniqueUsers()));
|
||||
}
|
||||
ess.runTaskAsynchronously(new Viewer(sender, page, force));
|
||||
}
|
||||
private static void outputCache(final CommandSource sender, final int page) {
|
||||
final Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeInMillis(cacheage);
|
||||
final DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
sender.sendMessage(tl("balanceTop", format.format(cal.getTime())));
|
||||
new TextPager(cache).showPage(Integer.toString(page), null, "balancetop", sender);
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
int page = 0;
|
||||
boolean force = false;
|
||||
if (args.length > 0) {
|
||||
try {
|
||||
page = Integer.parseInt(args[0]);
|
||||
} catch (final NumberFormatException ex) {
|
||||
if (args[0].equalsIgnoreCase("force") && (!sender.isPlayer() || ess.getUser(sender.getPlayer()).isAuthorized("essentials.balancetop.force"))) {
|
||||
force = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void outputCache(final CommandSource sender, int page)
|
||||
{
|
||||
final Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeInMillis(cacheage);
|
||||
final DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
sender.sendMessage(_("balanceTop", format.format(cal.getTime())));
|
||||
new TextPager(cache).showPage(Integer.toString(page), null, "balancetop", sender);
|
||||
}
|
||||
if (!force && lock.readLock().tryLock()) {
|
||||
try {
|
||||
if (cacheage > System.currentTimeMillis() - CACHETIME) {
|
||||
outputCache(sender, page);
|
||||
return;
|
||||
}
|
||||
if (ess.getUserMap().getUniqueUsers() > MINUSERS) {
|
||||
sender.sendMessage(tl("orderBalances", ess.getUserMap().getUniqueUsers()));
|
||||
}
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
} else {
|
||||
if (ess.getUserMap().getUniqueUsers() > MINUSERS) {
|
||||
sender.sendMessage(tl("orderBalances", ess.getUserMap().getUniqueUsers()));
|
||||
}
|
||||
}
|
||||
ess.runTaskAsynchronously(new Viewer(sender, commandLabel, page, force));
|
||||
|
||||
}
|
||||
|
||||
private class Calculator implements Runnable
|
||||
{
|
||||
private final transient Viewer viewer;
|
||||
private final boolean force;
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
final List<String> options = Lists.newArrayList("1");
|
||||
if (!sender.isPlayer() || ess.getUser(sender.getPlayer()).isAuthorized("essentials.balancetop.force")) {
|
||||
options.add("force");
|
||||
}
|
||||
return options;
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
public Calculator(final Viewer viewer, final boolean force)
|
||||
{
|
||||
this.viewer = viewer;
|
||||
this.force = force;
|
||||
}
|
||||
private class Calculator implements Runnable {
|
||||
private final transient Viewer viewer;
|
||||
private final boolean force;
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
lock.writeLock().lock();
|
||||
try
|
||||
{
|
||||
if (force || cacheage <= System.currentTimeMillis() - CACHETIME)
|
||||
{
|
||||
cache.getLines().clear();
|
||||
final Map<String, BigDecimal> balances = new HashMap<String, BigDecimal>();
|
||||
BigDecimal totalMoney = BigDecimal.ZERO;
|
||||
if (ess.getSettings().isEcoDisabled())
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().info("Internal economy functions disabled, aborting baltop.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (String u : ess.getUserMap().getAllUniqueUsers())
|
||||
{
|
||||
final User user = ess.getUserMap().getUser(u);
|
||||
if (user != null)
|
||||
{
|
||||
final BigDecimal userMoney = user.getMoney();
|
||||
user.updateMoneyCache(userMoney);
|
||||
totalMoney = totalMoney.add(userMoney);
|
||||
final String name = user.isHidden() ? user.getName() : user.getDisplayName();
|
||||
balances.put(name, userMoney);
|
||||
}
|
||||
}
|
||||
}
|
||||
Calculator(final Viewer viewer, final boolean force) {
|
||||
this.viewer = viewer;
|
||||
this.force = force;
|
||||
}
|
||||
|
||||
final List<Map.Entry<String, BigDecimal>> sortedEntries = new ArrayList<Map.Entry<String, BigDecimal>>(balances.entrySet());
|
||||
Collections.sort(sortedEntries, new Comparator<Map.Entry<String, BigDecimal>>()
|
||||
{
|
||||
@Override
|
||||
public int compare(final Entry<String, BigDecimal> entry1, final Entry<String, BigDecimal> entry2)
|
||||
{
|
||||
return entry2.getValue().compareTo(entry1.getValue());
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void run() {
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
if (force || cacheage <= System.currentTimeMillis() - CACHETIME) {
|
||||
cache.getLines().clear();
|
||||
final Map<String, BigDecimal> balances = new HashMap<>();
|
||||
BigDecimal totalMoney = BigDecimal.ZERO;
|
||||
if (ess.getSettings().isEcoDisabled()) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().info("Internal economy functions disabled, aborting baltop.");
|
||||
}
|
||||
} else {
|
||||
for (final UUID u : ess.getUserMap().getAllUniqueUsers()) {
|
||||
final User user = ess.getUserMap().getUser(u);
|
||||
if (user != null) {
|
||||
if (!ess.getSettings().isNpcsInBalanceRanking() && user.isNPC()) {
|
||||
// Don't list NPCs in output
|
||||
continue;
|
||||
}
|
||||
if (!user.isAuthorized("essentials.balancetop.exclude")) {
|
||||
final BigDecimal userMoney = user.getMoney();
|
||||
user.updateMoneyCache(userMoney);
|
||||
totalMoney = totalMoney.add(userMoney);
|
||||
final String name = user.isHidden() ? user.getName() : user.getDisplayName();
|
||||
balances.put(name, userMoney);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cache.getLines().add(_("serverTotal", NumberUtil.displayCurrency(totalMoney, ess)));
|
||||
int pos = 1;
|
||||
for (Map.Entry<String, BigDecimal> entry : sortedEntries)
|
||||
{
|
||||
cache.getLines().add(pos + ". " + entry.getKey() + ", " + NumberUtil.displayCurrency(entry.getValue(), ess));
|
||||
pos++;
|
||||
}
|
||||
cacheage = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
ess.runTaskAsynchronously(viewer);
|
||||
}
|
||||
}
|
||||
final List<Map.Entry<String, BigDecimal>> sortedEntries = new ArrayList<>(balances.entrySet());
|
||||
sortedEntries.sort((entry1, entry2) -> entry2.getValue().compareTo(entry1.getValue()));
|
||||
|
||||
cache.getLines().add(tl("serverTotal", NumberUtil.displayCurrency(totalMoney, ess)));
|
||||
int pos = 1;
|
||||
for (final Map.Entry<String, BigDecimal> entry : sortedEntries) {
|
||||
cache.getLines().add(tl("balanceTopLine", pos, entry.getKey(), NumberUtil.displayCurrency(entry.getValue(), ess)));
|
||||
pos++;
|
||||
}
|
||||
cacheage = System.currentTimeMillis();
|
||||
}
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
ess.runTaskAsynchronously(viewer);
|
||||
}
|
||||
}
|
||||
|
||||
private class Viewer implements Runnable
|
||||
{
|
||||
private final transient CommandSource sender;
|
||||
private final transient int page;
|
||||
private final transient boolean force;
|
||||
private class Viewer implements Runnable {
|
||||
private final transient CommandSource sender;
|
||||
private final transient int page;
|
||||
private final transient boolean force;
|
||||
private final transient String commandLabel;
|
||||
|
||||
public Viewer(final CommandSource sender, final int page, final boolean force)
|
||||
{
|
||||
this.sender = sender;
|
||||
this.page = page;
|
||||
this.force = force;
|
||||
}
|
||||
Viewer(final CommandSource sender, final String commandLabel, final int page, final boolean force) {
|
||||
this.sender = sender;
|
||||
this.page = page;
|
||||
this.force = force;
|
||||
this.commandLabel = commandLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
lock.readLock().lock();
|
||||
try
|
||||
{
|
||||
if (!force && cacheage > System.currentTimeMillis() - CACHETIME)
|
||||
{
|
||||
outputCache(sender, page);
|
||||
return;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
ess.runTaskAsynchronously(new Calculator(new Viewer(sender, page, false), force));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
if (!force && cacheage > System.currentTimeMillis() - CACHETIME) {
|
||||
outputCache(sender, page);
|
||||
return;
|
||||
}
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
ess.runTaskAsynchronously(new Calculator(new Viewer(sender, commandLabel, page, false), force));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,77 +2,72 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.Console;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.OfflinePlayer;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.BanList;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Commandban extends EssentialsCommand
|
||||
{
|
||||
public Commandban()
|
||||
{
|
||||
super("ban");
|
||||
}
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
boolean nomatch = false;
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
User user;
|
||||
try
|
||||
{
|
||||
user = getPlayer(server, args, 0, true, true);
|
||||
}
|
||||
catch (PlayerNotFoundException e)
|
||||
{
|
||||
nomatch = true;
|
||||
user = ess.getUser(new OfflinePlayer(args[0], ess));
|
||||
}
|
||||
if (!user.isOnline())
|
||||
{
|
||||
if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.ban.offline"))
|
||||
{
|
||||
throw new Exception(_("banExemptOffline"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user.isAuthorized("essentials.ban.exempt") && sender.isPlayer())
|
||||
{
|
||||
throw new Exception(_("banExempt"));
|
||||
}
|
||||
}
|
||||
public class Commandban extends EssentialsCommand {
|
||||
public Commandban() {
|
||||
super("ban");
|
||||
}
|
||||
|
||||
final String senderName = sender.isPlayer() ? sender.getPlayer().getDisplayName() : Console.NAME;
|
||||
String banReason;
|
||||
if (args.length > 1)
|
||||
{
|
||||
banReason = FormatUtil.replaceFormat(getFinalArg(args, 1).replace("\\n", "\n").replace("|", "\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
banReason = _("defaultBanReason");
|
||||
}
|
||||
@Override
|
||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
boolean nomatch = false;
|
||||
if (args.length < 1) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
User user;
|
||||
try {
|
||||
user = getPlayer(server, args, 0, true, true);
|
||||
} catch (final PlayerNotFoundException e) {
|
||||
nomatch = true;
|
||||
user = ess.getUser(new OfflinePlayer(args[0], ess.getServer()));
|
||||
}
|
||||
if (!user.getBase().isOnline()) {
|
||||
if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.ban.offline")) {
|
||||
throw new Exception(tl("banExemptOffline"));
|
||||
}
|
||||
} else if (user.isAuthorized("essentials.ban.exempt") && sender.isPlayer()) {
|
||||
throw new Exception(tl("banExempt"));
|
||||
}
|
||||
|
||||
user.setBanReason(_("banFormat", banReason, senderName));
|
||||
user.setBanned(true);
|
||||
user.setBanTimeout(0);
|
||||
user.kickPlayer(_("banFormat", banReason, senderName));
|
||||
final String senderName = sender.isPlayer() ? sender.getPlayer().getDisplayName() : Console.NAME;
|
||||
final String banReason;
|
||||
if (args.length > 1) {
|
||||
banReason = FormatUtil.replaceFormat(getFinalArg(args, 1).replace("\\n", "\n").replace("|", "\n"));
|
||||
} else {
|
||||
banReason = tl("defaultBanReason");
|
||||
}
|
||||
|
||||
server.getLogger().log(Level.INFO, _("playerBanned", senderName, user.getName(), banReason));
|
||||
ess.getServer().getBanList(BanList.Type.NAME).addBan(user.getName(), banReason, null, senderName);
|
||||
|
||||
if (nomatch)
|
||||
{
|
||||
sender.sendMessage(_("userUnknown", user.getName()));
|
||||
}
|
||||
final String banDisplay = tl("banFormat", banReason, senderName);
|
||||
|
||||
ess.broadcastMessage("essentials.ban.notify", _("playerBanned", senderName, user.getName(), banReason));
|
||||
}
|
||||
user.getBase().kickPlayer(banDisplay);
|
||||
server.getLogger().log(Level.INFO, tl("playerBanned", senderName, user.getName(), banDisplay));
|
||||
|
||||
if (nomatch) {
|
||||
sender.sendMessage(tl("userUnknown", user.getName()));
|
||||
}
|
||||
|
||||
ess.broadcastMessage("essentials.ban.notify", tl("playerBanned", senderName, user.getName(), banReason));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
return getPlayers(server, sender);
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,56 +2,75 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.Console;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.BanList;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Commandbanip extends EssentialsCommand
|
||||
{
|
||||
public Commandbanip()
|
||||
{
|
||||
super("banip");
|
||||
}
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
public class Commandbanip extends EssentialsCommand {
|
||||
public Commandbanip() {
|
||||
super("banip");
|
||||
}
|
||||
|
||||
final String senderName = sender.isPlayer() ? sender.getPlayer().getDisplayName() : Console.NAME;
|
||||
@Override
|
||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length < 1) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
String ipAddress;
|
||||
if (FormatUtil.validIP(args[0]))
|
||||
{
|
||||
ipAddress = args[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
User player = getPlayer(server, args, 0, true, true);
|
||||
ipAddress = player.getLastLoginAddress();
|
||||
}
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
ipAddress = args[0];
|
||||
}
|
||||
}
|
||||
final String senderName = sender.isPlayer() ? sender.getPlayer().getDisplayName() : Console.NAME;
|
||||
|
||||
if (ipAddress.isEmpty())
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
String ipAddress;
|
||||
if (FormatUtil.validIP(args[0])) {
|
||||
ipAddress = args[0];
|
||||
} else {
|
||||
try {
|
||||
final User player = getPlayer(server, args, 0, true, true);
|
||||
ipAddress = player.getLastLoginAddress();
|
||||
} catch (final PlayerNotFoundException ex) {
|
||||
ipAddress = args[0];
|
||||
}
|
||||
}
|
||||
|
||||
ess.getServer().banIP(ipAddress);
|
||||
server.getLogger().log(Level.INFO, _("playerBanIpAddress", senderName, ipAddress));
|
||||
if (ipAddress.isEmpty()) {
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
|
||||
ess.broadcastMessage("essentials.ban.notify", _("playerBanIpAddress", senderName, ipAddress));
|
||||
}
|
||||
final String banReason;
|
||||
if (args.length > 1) {
|
||||
banReason = FormatUtil.replaceFormat(getFinalArg(args, 1).replace("\\n", "\n").replace("|", "\n"));
|
||||
} else {
|
||||
banReason = tl("defaultBanReason");
|
||||
}
|
||||
|
||||
final String banDisplay = tl("banFormat", banReason, senderName);
|
||||
|
||||
ess.getServer().getBanList(BanList.Type.IP).addBan(ipAddress, banReason, null, senderName);
|
||||
server.getLogger().log(Level.INFO, tl("playerBanIpAddress", senderName, ipAddress, banReason));
|
||||
|
||||
for (final Player player : ess.getServer().getOnlinePlayers()) {
|
||||
if (player.getAddress().getAddress().getHostAddress().equalsIgnoreCase(ipAddress)) {
|
||||
player.kickPlayer(banDisplay);
|
||||
}
|
||||
}
|
||||
|
||||
ess.broadcastMessage("essentials.banip.notify", tl("playerBanIpAddress", senderName, ipAddress, banReason));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
// TODO: Also list IP addresses?
|
||||
return getPlayers(server, sender);
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Mob;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandbeezooka extends EssentialsCommand {
|
||||
|
||||
public Commandbeezooka() {
|
||||
super("beezooka");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_15_R01)) {
|
||||
user.sendMessage(tl("unsupportedFeature"));
|
||||
return;
|
||||
}
|
||||
|
||||
final Entity bee = Mob.BEE.spawn(user.getWorld(), server, user.getBase().getEyeLocation());
|
||||
bee.setVelocity(user.getBase().getEyeLocation().getDirection().multiply(2));
|
||||
|
||||
ess.scheduleSyncDelayedTask(() -> {
|
||||
final Location loc = bee.getLocation();
|
||||
bee.remove();
|
||||
loc.getWorld().createExplosion(loc, 0F);
|
||||
}, 20);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,51 +1,55 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.LocationUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.TreeType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Commandbigtree extends EssentialsCommand
|
||||
{
|
||||
public Commandbigtree()
|
||||
{
|
||||
super("bigtree");
|
||||
}
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
TreeType tree;
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("redwood"))
|
||||
{
|
||||
tree = TreeType.TALL_REDWOOD;
|
||||
}
|
||||
else if (args.length > 0 && args[0].equalsIgnoreCase("tree"))
|
||||
{
|
||||
tree = TreeType.BIG_TREE;
|
||||
}
|
||||
else if (args.length > 0 && args[0].equalsIgnoreCase("jungle"))
|
||||
{
|
||||
tree = TreeType.JUNGLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
public class Commandbigtree extends EssentialsCommand {
|
||||
public Commandbigtree() {
|
||||
super("bigtree");
|
||||
}
|
||||
|
||||
final Location loc = LocationUtil.getTarget(user.getBase());
|
||||
final Location safeLocation = LocationUtil.getSafeDestination(loc);
|
||||
final boolean success = user.getWorld().generateTree(safeLocation, tree);
|
||||
if (success)
|
||||
{
|
||||
user.sendMessage(_("bigTreeSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("bigTreeFailure"));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
final TreeType tree;
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("redwood")) {
|
||||
tree = TreeType.TALL_REDWOOD;
|
||||
} else if (args.length > 0 && args[0].equalsIgnoreCase("tree")) {
|
||||
tree = TreeType.BIG_TREE;
|
||||
} else if (args.length > 0 && args[0].equalsIgnoreCase("jungle")) {
|
||||
tree = TreeType.JUNGLE;
|
||||
} else if (args.length > 0 && args[0].equalsIgnoreCase("darkoak")) {
|
||||
tree = TreeType.DARK_OAK;
|
||||
} else {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
final Location loc = LocationUtil.getTarget(user.getBase()).add(0, 1, 0);
|
||||
if (loc.getBlock().getType().isSolid()) {
|
||||
throw new Exception(tl("bigTreeFailure"));
|
||||
}
|
||||
final boolean success = user.getWorld().generateTree(loc, tree);
|
||||
if (success) {
|
||||
user.sendMessage(tl("bigTreeSuccess"));
|
||||
} else {
|
||||
throw new Exception(tl("bigTreeFailure"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final User user, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
return Lists.newArrayList("redwood", "tree", "jungle", "darkoak");
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,92 +1,97 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Commandbook extends EssentialsCommand
|
||||
{
|
||||
public Commandbook()
|
||||
{
|
||||
super("book");
|
||||
}
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
//TODO: Translate this
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final ItemStack item = user.getItemInHand();
|
||||
final String player = user.getName();
|
||||
if (item.getType() == Material.WRITTEN_BOOK)
|
||||
{
|
||||
BookMeta bmeta = (BookMeta)item.getItemMeta();
|
||||
public class Commandbook extends EssentialsCommand {
|
||||
|
||||
if (args.length > 1 && args[0].equalsIgnoreCase("author"))
|
||||
{
|
||||
if (user.isAuthorized("essentials.book.author") && (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others")))
|
||||
{
|
||||
bmeta.setAuthor(args[1]);
|
||||
item.setItemMeta(bmeta);
|
||||
user.sendMessage(_("bookAuthorSet", getFinalArg(args, 1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("denyChangeAuthor"));
|
||||
}
|
||||
}
|
||||
else if (args.length > 1 && args[0].equalsIgnoreCase("title"))
|
||||
{
|
||||
if (user.isAuthorized("essentials.book.title") && (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others")))
|
||||
{
|
||||
bmeta.setTitle(args[1]);
|
||||
item.setItemMeta(bmeta);
|
||||
user.sendMessage(_("bookTitleSet", getFinalArg(args, 1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("denyChangeTitle"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others"))
|
||||
{
|
||||
ItemStack newItem = new ItemStack(Material.BOOK_AND_QUILL, item.getAmount());
|
||||
newItem.setItemMeta(bmeta);
|
||||
user.setItemInHand(newItem);
|
||||
user.sendMessage(_("editBookContents"));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("denyBookEdit"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (item.getType() == Material.BOOK_AND_QUILL)
|
||||
{
|
||||
BookMeta bmeta = (BookMeta)item.getItemMeta();
|
||||
if (!user.isAuthorized("essentials.book.author"))
|
||||
{
|
||||
bmeta.setAuthor(player);
|
||||
}
|
||||
ItemStack newItem = new ItemStack(Material.WRITTEN_BOOK, item.getAmount());
|
||||
newItem.setItemMeta(bmeta);
|
||||
user.setItemInHand(newItem);
|
||||
user.sendMessage(_("bookLocked"));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("holdBook"));
|
||||
}
|
||||
}
|
||||
private static final Material WRITABLE_BOOK = EnumUtil.getMaterial("WRITABLE_BOOK", "BOOK_AND_QUILL");
|
||||
|
||||
private boolean isAuthor(BookMeta bmeta, String player)
|
||||
{
|
||||
String author = bmeta.getAuthor();
|
||||
return author != null && author.equalsIgnoreCase(player);
|
||||
}
|
||||
public Commandbook() {
|
||||
super("book");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
final ItemStack item = user.getItemInHand();
|
||||
final String player = user.getName();
|
||||
if (item.getType() == Material.WRITTEN_BOOK) {
|
||||
final BookMeta bmeta = (BookMeta) item.getItemMeta();
|
||||
|
||||
if (args.length > 1 && args[0].equalsIgnoreCase("author")) {
|
||||
if (user.isAuthorized("essentials.book.author") && (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others"))) {
|
||||
bmeta.setAuthor(args[1]);
|
||||
item.setItemMeta(bmeta);
|
||||
user.sendMessage(tl("bookAuthorSet", getFinalArg(args, 1)));
|
||||
} else {
|
||||
throw new Exception(tl("denyChangeAuthor"));
|
||||
}
|
||||
} else if (args.length > 1 && args[0].equalsIgnoreCase("title")) {
|
||||
if (user.isAuthorized("essentials.book.title") && (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others"))) {
|
||||
bmeta.setTitle(args[1]);
|
||||
item.setItemMeta(bmeta);
|
||||
user.sendMessage(tl("bookTitleSet", getFinalArg(args, 1)));
|
||||
} else {
|
||||
throw new Exception(tl("denyChangeTitle"));
|
||||
}
|
||||
} else {
|
||||
if (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others")) {
|
||||
final ItemStack newItem = new ItemStack(WRITABLE_BOOK, item.getAmount());
|
||||
newItem.setItemMeta(bmeta);
|
||||
InventoryWorkaround.setItemInMainHand(user.getBase(), newItem);
|
||||
user.sendMessage(tl("editBookContents"));
|
||||
} else {
|
||||
throw new Exception(tl("denyBookEdit"));
|
||||
}
|
||||
}
|
||||
} else if (item.getType() == WRITABLE_BOOK) {
|
||||
final BookMeta bmeta = (BookMeta) item.getItemMeta();
|
||||
if (!user.isAuthorized("essentials.book.author")) {
|
||||
bmeta.setAuthor(player);
|
||||
}
|
||||
final ItemStack newItem = new ItemStack(Material.WRITTEN_BOOK, item.getAmount());
|
||||
newItem.setItemMeta(bmeta);
|
||||
InventoryWorkaround.setItemInMainHand(user.getBase(), newItem);
|
||||
user.sendMessage(tl("bookLocked"));
|
||||
} else {
|
||||
throw new Exception(tl("holdBook"));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isAuthor(final BookMeta bmeta, final String player) {
|
||||
final String author = bmeta.getAuthor();
|
||||
return author != null && author.equalsIgnoreCase(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final User user, final String commandLabel, final String[] args) {
|
||||
// Right now, we aren't testing what's held in the player's hand - we could, but it's not necessarily worth it
|
||||
if (args.length == 1) {
|
||||
final List<String> options = Lists.newArrayList("sign", "unsign"); // sign and unsign aren't real, but work
|
||||
if (user.isAuthorized("essentials.book.author")) {
|
||||
options.add("author");
|
||||
}
|
||||
if (user.isAuthorized("essentials.book.title")) {
|
||||
options.add("title");
|
||||
}
|
||||
return options;
|
||||
} else if (args.length == 2 && args[0].equalsIgnoreCase("author") && user.isAuthorized("essentials.book.author")) {
|
||||
final List<String> options = getPlayers(server, user);
|
||||
options.add("Herobrine"); // #EasterEgg
|
||||
return options;
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,48 +1,37 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandbreak extends EssentialsCommand
|
||||
{
|
||||
public Commandbreak()
|
||||
{
|
||||
super("break");
|
||||
}
|
||||
public class Commandbreak extends EssentialsCommand {
|
||||
public Commandbreak() {
|
||||
super("break");
|
||||
}
|
||||
|
||||
//TODO: Switch to use util class
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final Block block = user.getTargetBlock(null, 20);
|
||||
if (block == null)
|
||||
{
|
||||
throw new NoChargeException();
|
||||
}
|
||||
if (block.getType() == Material.AIR)
|
||||
{
|
||||
throw new NoChargeException();
|
||||
}
|
||||
if (block.getType() == Material.BEDROCK && !user.isAuthorized("essentials.break.bedrock"))
|
||||
{
|
||||
throw new Exception(_("noBreakBedrock"));
|
||||
}
|
||||
//final List<ItemStack> list = (List<ItemStack>)block.getDrops();
|
||||
//final BlockBreakEvent event = new BlockBreakEvent(block, user.getBase(), list);
|
||||
final BlockBreakEvent event = new BlockBreakEvent(block, user.getBase());
|
||||
server.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled())
|
||||
{
|
||||
throw new NoChargeException();
|
||||
}
|
||||
else
|
||||
{
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO: Switch to use util class
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
|
||||
final Block block = user.getTargetBlock(20);
|
||||
if (block.getType() == Material.AIR) {
|
||||
throw new NoChargeException();
|
||||
}
|
||||
if (block.getType() == Material.BEDROCK && !user.isAuthorized("essentials.break.bedrock")) {
|
||||
throw new Exception(tl("noBreakBedrock"));
|
||||
}
|
||||
//final List<ItemStack> list = (List<ItemStack>)block.getDrops();
|
||||
//final BlockBreakEvent event = new BlockBreakEvent(block, user.getBase(), list);
|
||||
final BlockBreakEvent event = new BlockBreakEvent(block, user.getBase());
|
||||
server.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
throw new NoChargeException();
|
||||
} else {
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +1,22 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandbroadcast extends EssentialsCommand
|
||||
{
|
||||
public Commandbroadcast()
|
||||
{
|
||||
super("broadcast");
|
||||
}
|
||||
public class Commandbroadcast extends EssentialsCommand {
|
||||
public Commandbroadcast() {
|
||||
super("broadcast");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
sendBroadcast(user.getDisplayName(), args);
|
||||
}
|
||||
@Override
|
||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length < 1) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
sendBroadcast(sender.getSender().getName(), args);
|
||||
}
|
||||
|
||||
private void sendBroadcast(final String name, final String[] args) throws NotEnoughArgumentsException
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
ess.broadcastMessage(_("broadcast", FormatUtil.replaceFormat(getFinalArg(args, 0)).replace("\\n", "\n"), name));
|
||||
}
|
||||
ess.broadcastMessage(tl("broadcast", FormatUtil.replaceFormat(getFinalArg(args, 0)).replace("\\n", "\n"), sender.getDisplayName()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.textreader.IText;
|
||||
import com.earth2me.essentials.textreader.KeywordReplacer;
|
||||
import com.earth2me.essentials.textreader.SimpleTextInput;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandbroadcastworld extends EssentialsCommand {
|
||||
|
||||
public Commandbroadcastworld() {
|
||||
super("broadcastworld");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length == 0) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
World world = user.getWorld();
|
||||
String message = getFinalArg(args, 0);
|
||||
if (args.length > 1 && ess.getSettings().isAllowWorldInBroadcastworld()) {
|
||||
final World argWorld = ess.getWorld(args[0]);
|
||||
if (argWorld != null) {
|
||||
world = argWorld;
|
||||
message = getFinalArg(args, 1);
|
||||
}
|
||||
}
|
||||
|
||||
sendBroadcast(world, user.getDisplayName(), message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length < 2) {
|
||||
throw new NotEnoughArgumentsException("world");
|
||||
}
|
||||
|
||||
final World world = ess.getWorld(args[0]);
|
||||
if (world == null) {
|
||||
throw new Exception(tl("invalidWorld"));
|
||||
}
|
||||
sendBroadcast(world, sender.getSender().getName(), getFinalArg(args, 1));
|
||||
}
|
||||
|
||||
private void sendBroadcast(final World world, final String name, final String message) throws Exception {
|
||||
if (message.isEmpty()) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
sendToWorld(world, tl("broadcast", FormatUtil.replaceFormat(message).replace("\\n", "\n"), name));
|
||||
}
|
||||
|
||||
private void sendToWorld(final World world, final String message) {
|
||||
IText broadcast = new SimpleTextInput(message);
|
||||
final Collection<Player> players = ess.getOnlinePlayers();
|
||||
|
||||
for (final Player player : players) {
|
||||
if (player.getWorld().equals(world)) {
|
||||
final User user = ess.getUser(player);
|
||||
broadcast = new KeywordReplacer(broadcast, new CommandSource(player), ess, false);
|
||||
for (final String messageText : broadcast.getLines()) {
|
||||
user.sendMessage(messageText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1 && (!sender.isPlayer() || ess.getSettings().isAllowWorldInBroadcastworld())) {
|
||||
final List<String> worlds = Lists.newArrayList();
|
||||
for (final World world : server.getWorlds()) {
|
||||
worlds.add(world.getName());
|
||||
}
|
||||
return worlds;
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +1,38 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Commandburn extends EssentialsCommand
|
||||
{
|
||||
public Commandburn()
|
||||
{
|
||||
super("burn");
|
||||
}
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
public class Commandburn extends EssentialsCommand {
|
||||
public Commandburn() {
|
||||
super("burn");
|
||||
}
|
||||
|
||||
if (args[0].trim().length() < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length < 2) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
User user = getPlayer(server, sender, args, 0);
|
||||
user.setFireTicks(Integer.parseInt(args[1]) * 20);
|
||||
sender.sendMessage(_("burnMsg", user.getDisplayName(), Integer.parseInt(args[1])));
|
||||
}
|
||||
final User user = getPlayer(server, sender, args, 0);
|
||||
user.getBase().setFireTicks(Integer.parseInt(args[1]) * 20);
|
||||
sender.sendMessage(tl("burnMsg", user.getDisplayName(), Integer.parseInt(args[1])));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
return getPlayers(server, sender);
|
||||
} else if (args.length == 2) {
|
||||
return COMMON_DURATIONS;
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 589 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user