mirror of
https://github.com/EssentialsX/Essentials.git
synced 2026-11-05 01:00:13 -05:00
Compare commits
992
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4dcce2544e | ||
|
|
21cb8efb90 | ||
|
|
cd7be1bb86 | ||
|
|
69cd17a1b1 | ||
|
|
afccda6350 | ||
|
|
c0a176825c | ||
|
|
db6512b702 | ||
|
|
46d3f0827a | ||
|
|
b9e5c8827f | ||
|
|
b8e000c7f9 | ||
|
|
5e7af93c77 | ||
|
|
077ad8cd0f | ||
|
|
0bf954e467 | ||
|
|
8a55afc4e1 | ||
|
|
2bc9f2e386 | ||
|
|
920e1a3b1f | ||
|
|
353253b9c5 | ||
|
|
1438230b70 | ||
|
|
240aebde98 | ||
|
|
d4e2ed782e | ||
|
|
f025cd9d2f | ||
|
|
1ff7082892 | ||
|
|
15fa10dd29 | ||
|
|
00b4bdadd4 | ||
|
|
3055dd93a5 | ||
|
|
94dc29cc4d | ||
|
|
22d1db5463 | ||
|
|
f2b4bb00b6 | ||
|
|
d2546ebd36 | ||
|
|
f1930e76d6 | ||
|
|
d722e6a9f0 | ||
|
|
8e6d4b1595 | ||
|
|
72065c81f3 | ||
|
|
2864d0186c | ||
|
|
9c9b2be011 | ||
|
|
2f40264c46 | ||
|
|
5cc24827fc | ||
|
|
da01bdc2b0 | ||
|
|
dfb81dd50f | ||
|
|
567d52459b | ||
|
|
80a96e2a73 | ||
|
|
c2f8467ca9 | ||
|
|
155ca46fef | ||
|
|
0952150235 | ||
|
|
30faa39070 | ||
|
|
3e367912ec | ||
|
|
f8cff25bda | ||
|
|
3e80bf479e | ||
|
|
84afc80873 | ||
|
|
27a943217e | ||
|
|
16834d85c5 | ||
|
|
44d8c85450 | ||
|
|
2a8e44dda8 | ||
|
|
00e3957190 | ||
|
|
a79b76e8d2 | ||
|
|
0a092ff5b3 | ||
|
|
e6aeefb12d | ||
|
|
924b6bd2ba | ||
|
|
f701090c89 | ||
|
|
b9195a561f | ||
|
|
d94e4095da | ||
|
|
fd61cd1750 | ||
|
|
e7ae8bcc47 | ||
|
|
edc4d62004 | ||
|
|
cdff690bb5 | ||
|
|
aa14cc39d9 | ||
|
|
cdf2c8beed | ||
|
|
3e06c06827 | ||
|
|
a2886d76d2 | ||
|
|
cc0a65bace | ||
|
|
d988546ef3 | ||
|
|
b7f2add7b4 | ||
|
|
b07f65c58b | ||
|
|
18e315a048 | ||
|
|
d3967297bb | ||
|
|
ea3631ddc2 | ||
|
|
992e473b72 | ||
|
|
0296f4fcf1 | ||
|
|
2fc16250a3 | ||
|
|
75f7b06a23 | ||
|
|
a7e834e5f9 | ||
|
|
59086932bd | ||
|
|
5611acf12c | ||
|
|
60142d872f | ||
|
|
1cf0ebbd7f | ||
|
|
736a6d273a | ||
|
|
71179e3dfd | ||
|
|
24cdc37987 | ||
|
|
b606f153f4 | ||
|
|
96ab1b4533 | ||
|
|
8718d59286 | ||
|
|
5d372b8149 | ||
|
|
1d62de7e5e | ||
|
|
3691417848 | ||
|
|
029162bba7 | ||
|
|
161a61e0c6 | ||
|
|
587addb73f | ||
|
|
d71bd7fb71 | ||
|
|
699ec273dd | ||
|
|
c1eed8ebcd | ||
|
|
b8d0cf4cc4 | ||
|
|
ff0dd00d79 | ||
|
|
e18d12f109 | ||
|
|
0a09b355b2 | ||
|
|
f9659dae68 | ||
|
|
78a580bc40 | ||
|
|
8c4d6ad4df | ||
|
|
9c9d4e1da5 | ||
|
|
ce50e1448b | ||
|
|
8e885a3a6e | ||
|
|
ecd96a81dd | ||
|
|
427108574e | ||
|
|
62381a7f52 | ||
|
|
b1b09ea542 | ||
|
|
e502a7e6fd | ||
|
|
acf4d0bcf5 | ||
|
|
6c3b13a7a4 | ||
|
|
cababcbfcf | ||
|
|
a032d0f19f | ||
|
|
f808e6fa8e | ||
|
|
842d9f73a4 | ||
|
|
c2893788e7 | ||
|
|
0b8a6c45c6 | ||
|
|
2049e630fb | ||
|
|
6fd82480a3 | ||
|
|
e919897f1b | ||
|
|
0fb5fc6bcc | ||
|
|
a7d61b1b8d | ||
|
|
be9a58457a | ||
|
|
b1cfc8a8ed | ||
|
|
6b9b6ba420 | ||
|
|
79c70b1f65 | ||
|
|
cfe634e8f7 | ||
|
|
8c8c6fe73a | ||
|
|
a4353bc8f2 | ||
|
|
4015351c85 | ||
|
|
e89f1d8a03 | ||
|
|
ff461be45d | ||
|
|
93f5a05f17 | ||
|
|
3eba7fb90f | ||
|
|
25d51cd79e | ||
|
|
a39824abb6 | ||
|
|
2ac4c8e665 | ||
|
|
a84afbaa6e | ||
|
|
41f7b4ec2d | ||
|
|
ce90e9710e | ||
|
|
930eb7ae86 | ||
|
|
cf79a8fdca | ||
|
|
1773a6060d | ||
|
|
5755d647a3 | ||
|
|
5032142a49 | ||
|
|
15e996f485 | ||
|
|
b37c08fd31 | ||
|
|
eaca7f9c09 | ||
|
|
00072501c9 | ||
|
|
b50bb03814 | ||
|
|
f55316281c | ||
|
|
413a7beaa4 | ||
|
|
88140f0610 | ||
|
|
4996171b6e | ||
|
|
d201286fc5 | ||
|
|
12b527be99 | ||
|
|
e666c27d96 | ||
|
|
56cfc47ef6 | ||
|
|
c4e4235f30 | ||
|
|
e045f9d983 | ||
|
|
ba8d060927 | ||
|
|
5f73bf12d7 | ||
|
|
616f92c214 | ||
|
|
298f3dc3b2 | ||
|
|
65741403e0 | ||
|
|
2b6d41ac5f | ||
|
|
a4936355b5 | ||
|
|
02d6eade28 | ||
|
|
089fa8c19b | ||
|
|
7c687831bc | ||
|
|
d43cb95d72 | ||
|
|
d588c3f271 | ||
|
|
eaa93d545d | ||
|
|
e324a21b60 | ||
|
|
b9cfd44588 | ||
|
|
44e9c6ebfc | ||
|
|
a836576211 | ||
|
|
1ad8c95e3e | ||
|
|
2dff343c10 | ||
|
|
fa2a041102 | ||
|
|
86f8f9c83f | ||
|
|
e359e8ab6e | ||
|
|
2f8f3aaa8d | ||
|
|
f5bf5ed251 | ||
|
|
979da6e713 | ||
|
|
6c86fe6117 | ||
|
|
9018fc8324 | ||
|
|
2f57961ce4 | ||
|
|
4478d438d6 | ||
|
|
9261b259a9 | ||
|
|
3f3d8c58bc | ||
|
|
e42f7e4ffa | ||
|
|
8a9353fd09 | ||
|
|
7d5e0352d2 | ||
|
|
05eef76134 | ||
|
|
e6ef67f7bf | ||
|
|
bbd93f333d | ||
|
|
84f7859ca9 | ||
|
|
1c0dffa67c | ||
|
|
5f3fb9b595 | ||
|
|
4ce1e2d9bf | ||
|
|
e40f364c1e | ||
|
|
6bd2d2c4b9 | ||
|
|
47f06e5c1b | ||
|
|
4c4df13c2f | ||
|
|
6ca037ae3e | ||
|
|
47c708fd33 | ||
|
|
c40b23d80e | ||
|
|
f17a790d78 | ||
|
|
bdf67db6ed | ||
|
|
3e203d193c | ||
|
|
a92eb4dee6 | ||
|
|
ed411ee217 | ||
|
|
368d3a4046 | ||
|
|
8aab57e86b | ||
|
|
e198b61eae | ||
|
|
9824cd75b6 | ||
|
|
562274706b | ||
|
|
03a93bfeff | ||
|
|
86749c433c | ||
|
|
17adafecf9 | ||
|
|
dd12e5db66 | ||
|
|
94947ecc21 | ||
|
|
8e50158af8 | ||
|
|
610fae63d2 | ||
|
|
ee072e844b | ||
|
|
0319415f1b | ||
|
|
8fdd32a210 | ||
|
|
32240cd00d | ||
|
|
94f9aedf4b | ||
|
|
fca3ad4df9 | ||
|
|
ba6cc5a9ee | ||
|
|
101ae201d6 | ||
|
|
5c1eea0953 | ||
|
|
733fcc9d87 | ||
|
|
738b895cba | ||
|
|
72aeec58ed | ||
|
|
4d8116cc39 | ||
|
|
54133cd75e | ||
|
|
322fe386f6 | ||
|
|
d2b30bad99 | ||
|
|
264eb318b8 | ||
|
|
cebe291a6f | ||
|
|
30d5468be0 | ||
|
|
fbfd62b73e | ||
|
|
0b9725bf77 | ||
|
|
3c268312a2 | ||
|
|
4c2d220176 | ||
|
|
a855eaf8d0 | ||
|
|
e5c70713b8 | ||
|
|
92267fa7f8 | ||
|
|
3c5f9e1616 | ||
|
|
c2db96edc8 | ||
|
|
4ca09cea2d | ||
|
|
9b39a227c9 | ||
|
|
a7a06963ac | ||
|
|
38655811b7 | ||
|
|
2f562f79aa | ||
|
|
ee608d944a | ||
|
|
9e975568be | ||
|
|
3dbabfa11d | ||
|
|
7a96fd1dce | ||
|
|
5174b6fe93 | ||
|
|
c6617324af | ||
|
|
c7b90f61f7 | ||
|
|
7beab59c1a | ||
|
|
55c9cacaa3 | ||
|
|
58fc3f4338 | ||
|
|
5379b3955f | ||
|
|
bf93bb2026 | ||
|
|
af73c11638 | ||
|
|
1a07815f4b | ||
|
|
52702894af | ||
|
|
73fb2d3735 | ||
|
|
7b482b612e | ||
|
|
bd6614328b | ||
|
|
45cd9597c9 | ||
|
|
b40d663c7e | ||
|
|
6513842d28 | ||
|
|
c8a07ecdb5 | ||
|
|
80f001fdb7 | ||
|
|
ab82f550cf | ||
|
|
6064b9760b | ||
|
|
7802192faa | ||
|
|
cd437f95f1 | ||
|
|
da735b496f | ||
|
|
fc288718b7 | ||
|
|
766f9b4dbd | ||
|
|
a1ac58d17c | ||
|
|
2fbdf7e4d6 | ||
|
|
d5ed474be7 | ||
|
|
1d92cb0e0a | ||
|
|
ab7a19b6e6 | ||
|
|
7b94adfac8 | ||
|
|
33d7776a8e | ||
|
|
d299309c67 | ||
|
|
fcf39ed85b | ||
|
|
0badd09ad3 | ||
|
|
cfc8faa43a | ||
|
|
b0586abc67 | ||
|
|
41235b6ee1 | ||
|
|
141a2bb190 | ||
|
|
fb71ebdfdf | ||
|
|
66ae1d5b94 | ||
|
|
ada077fead | ||
|
|
45367b17a5 | ||
|
|
76717350d6 | ||
|
|
b71a6ac5e1 | ||
|
|
58544c9eea | ||
|
|
f15cb410ce | ||
|
|
b0cec9782d | ||
|
|
1eac05799f | ||
|
|
8fac5f6beb | ||
|
|
a46497255e | ||
|
|
89670bdfd1 | ||
|
|
71e552c0d1 | ||
|
|
efec7c8f95 | ||
|
|
ed668fcac4 | ||
|
|
72015d42fc | ||
|
|
24ec84730e | ||
|
|
dab13931ca | ||
|
|
b1c7004d7e | ||
|
|
69ff8b28d8 | ||
|
|
0395b5d222 | ||
|
|
3b25235755 | ||
|
|
51d61e7a91 | ||
|
|
4d0ce90787 | ||
|
|
4d17b73291 | ||
|
|
f7a34c49fb | ||
|
|
d0a8dc4812 | ||
|
|
0466a60093 | ||
|
|
2c6a81a916 | ||
|
|
656f25dc97 | ||
|
|
329f93a4f6 | ||
|
|
b70f950479 | ||
|
|
38a2e2bcfd | ||
|
|
d9b91e0c34 | ||
|
|
4ae5579068 | ||
|
|
622d710aa9 | ||
|
|
f1a7be09c2 | ||
|
|
0742ca23c1 | ||
|
|
8823ce070e | ||
|
|
d77f6cbbf1 | ||
|
|
909c8b3cb5 | ||
|
|
5b7d29fa55 | ||
|
|
8dfb3c03c7 | ||
|
|
6e8031f477 | ||
|
|
81c545f45b | ||
|
|
65025d47c5 | ||
|
|
4f23e8aaeb | ||
|
|
aea2c00a95 | ||
|
|
eafe0380e1 | ||
|
|
3975ceb2a0 | ||
|
|
0a3ecbcd0e | ||
|
|
9679a90d88 | ||
|
|
c4a704b1a2 | ||
|
|
776900bd7b | ||
|
|
5683ea35fc | ||
|
|
78d4987d5d | ||
|
|
9f852b3a41 | ||
|
|
edca2cbdff | ||
|
|
c578302d7c | ||
|
|
dfce4b31f3 | ||
|
|
669edfc048 | ||
|
|
0a9c88a990 | ||
|
|
4e5e5a9684 | ||
|
|
97eada7dd6 | ||
|
|
a764f8c929 | ||
|
|
5da886593b | ||
|
|
4c5a88929c | ||
|
|
af7e427545 | ||
|
|
4638c5ab55 | ||
|
|
0c2e63baad | ||
|
|
ee61ce35c8 | ||
|
|
6ec5b4a5da | ||
|
|
d63ad6fc0c | ||
|
|
641a4b9dff | ||
|
|
31001d6b1a | ||
|
|
d1a1559dca | ||
|
|
0d56b700bf | ||
|
|
cafdb919e4 | ||
|
|
808f448399 | ||
|
|
10d902e730 | ||
|
|
0436962ee7 | ||
|
|
2bebb0bd61 | ||
|
|
1e04e3f80d | ||
|
|
c32e10caac | ||
|
|
120440d45b | ||
|
|
61b85901a3 | ||
|
|
f0b3acf491 | ||
|
|
f2d624a795 | ||
|
|
9e1d7aca92 | ||
|
|
3b43f7bf03 | ||
|
|
2f18c6edf1 | ||
|
|
79f8699174 | ||
|
|
602681dcc2 | ||
|
|
3e63047c38 | ||
|
|
4f2f166824 | ||
|
|
fc782f286d | ||
|
|
425c548611 | ||
|
|
593f1dd67f | ||
|
|
8cff4348a6 | ||
|
|
40271f2ddf | ||
|
|
aa1205f42d | ||
|
|
2e15de483d | ||
|
|
77b0415c1b | ||
|
|
43b3a9df23 | ||
|
|
8b47b80b0b | ||
|
|
13da8c3adc | ||
|
|
a10190df51 | ||
|
|
ecfa745484 | ||
|
|
20d439578b | ||
|
|
dd7f1bcf25 | ||
|
|
3b855255cf | ||
|
|
23283426e0 | ||
|
|
c958bc78dd | ||
|
|
24ec242ecf | ||
|
|
9068c13e39 | ||
|
|
024aff0af5 | ||
|
|
57c1d75779 | ||
|
|
8c434783a2 | ||
|
|
85ae839211 | ||
|
|
b218d33a24 | ||
|
|
6e0f4674d5 | ||
|
|
62812e1e3a | ||
|
|
63680b4911 | ||
|
|
071254ed8d | ||
|
|
93980629d3 | ||
|
|
f299771044 | ||
|
|
8c013b7680 | ||
|
|
78fe659677 | ||
|
|
98de950ae2 | ||
|
|
96eb9c5db7 | ||
|
|
45c1e347b0 | ||
|
|
0559b935e9 | ||
|
|
409f337973 | ||
|
|
7f5f6b6ac9 | ||
|
|
dc36a50d85 | ||
|
|
74f0babc7d | ||
|
|
5eeaeaee5d | ||
|
|
fa58503c9f | ||
|
|
9fca3728c3 | ||
|
|
56fccb9645 | ||
|
|
cab40d7893 | ||
|
|
faa3a5e027 | ||
|
|
1c0838aa5d | ||
|
|
32fa834f3f | ||
|
|
051af644a7 | ||
|
|
9b9a6a3148 | ||
|
|
711426fe69 | ||
|
|
18c9c812d7 | ||
|
|
bc798977b5 | ||
|
|
853d7cb668 | ||
|
|
3eac027ddb | ||
|
|
1247401a5f | ||
|
|
9846362836 | ||
|
|
16fc88b50c | ||
|
|
fee3d7c0d3 | ||
|
|
5020f6b990 | ||
|
|
a48f6c8c30 | ||
|
|
8d6b864b5b | ||
|
|
deca5e5e73 | ||
|
|
9b731cc39c | ||
|
|
78cd64c388 | ||
|
|
d9e15729fd | ||
|
|
0fbe2da9cb | ||
|
|
d3397279f6 | ||
|
|
705efc6002 | ||
|
|
3a60191a9d | ||
|
|
95e6db6797 | ||
|
|
e37b1946f5 | ||
|
|
6d1e2dd10e | ||
|
|
0668c4214e | ||
|
|
1b4c803ce3 | ||
|
|
8d00da9e98 | ||
|
|
1524a06ac6 | ||
|
|
9ca820d45e | ||
|
|
27102d1c38 | ||
|
|
18b5405c76 | ||
|
|
de541f6654 | ||
|
|
9d398b1d2e | ||
|
|
caeb3279cb | ||
|
|
06247732da | ||
|
|
fc7689354f | ||
|
|
a50b74bb36 | ||
|
|
a21b5fac76 | ||
|
|
3d9022d8fa | ||
|
|
4e10470acd | ||
|
|
3cc1a462f5 | ||
|
|
cd7bf5eff2 | ||
|
|
8da3b490d9 | ||
|
|
00c87c0e60 | ||
|
|
507ecc47b6 | ||
|
|
6ac8abdac8 | ||
|
|
4a29dd4c9c | ||
|
|
6d06636bc2 | ||
|
|
da857895fc | ||
|
|
425a2184c6 | ||
|
|
6919b52f61 | ||
|
|
8eb7428ad1 | ||
|
|
327a57de3c | ||
|
|
01ba8dbc3f | ||
|
|
a97b3abca3 | ||
|
|
d927d04765 | ||
|
|
6dc2e96509 | ||
|
|
26a0cd0761 | ||
|
|
75b7f7ac22 | ||
|
|
d08ea5a650 | ||
|
|
1bd1665faa | ||
|
|
b3847270fa | ||
|
|
055603b09e | ||
|
|
34f5c19f99 | ||
|
|
602bd5b0d4 | ||
|
|
45de85dae2 | ||
|
|
8b9ff2c58a | ||
|
|
1599a36642 | ||
|
|
1e30f23ca6 | ||
|
|
2f74510cce | ||
|
|
08bff3ea5f | ||
|
|
90d2451ce2 | ||
|
|
5b5df254d5 | ||
|
|
a028abe036 | ||
|
|
677534c0b7 | ||
|
|
2d319fe5aa | ||
|
|
bbd2c53dd8 | ||
|
|
d1eb7e5614 | ||
|
|
d9ee666770 | ||
|
|
9f744beb13 | ||
|
|
62a297ec6d | ||
|
|
3f9e19d279 | ||
|
|
c9e64d9e46 | ||
|
|
25759064ff | ||
|
|
cd24ffbada | ||
|
|
cdae0898c7 | ||
|
|
f02691863b | ||
|
|
4c8d0ea2d9 | ||
|
|
ec4f5cc34d | ||
|
|
e8a42e3947 | ||
|
|
e8dd963545 | ||
|
|
1c0a5c49a5 | ||
|
|
bb83dcc828 | ||
|
|
0eefb7f5a1 | ||
|
|
fe95cfe03b | ||
|
|
7a6368a980 | ||
|
|
9e86681722 | ||
|
|
25bd91eb80 | ||
|
|
6504c88bf7 | ||
|
|
6a75d6fe86 | ||
|
|
bc876611d0 | ||
|
|
798ea77736 | ||
|
|
21ef83c0ff | ||
|
|
bd7af593e7 | ||
|
|
f73a5d0e8d | ||
|
|
f7bc04bc34 | ||
|
|
aa43703094 | ||
|
|
381886245b | ||
|
|
08642ada20 | ||
|
|
10cb4c03b7 | ||
|
|
e7d1cb8bb6 | ||
|
|
5a7d733cbf | ||
|
|
e23f491500 | ||
|
|
98b716dfbf | ||
|
|
2ddd31a37d | ||
|
|
2b99ed9a2a | ||
|
|
eeea16a99a | ||
|
|
e52996609a | ||
|
|
932de33349 | ||
|
|
195604997b | ||
|
|
a3a3f81e11 | ||
|
|
d0f3fb4417 | ||
|
|
183602ac28 | ||
|
|
37370f722c | ||
|
|
e2e51c9c95 | ||
|
|
bf1e073ef4 | ||
|
|
767703bfc9 | ||
|
|
0e0a96b6d8 | ||
|
|
3f73272524 | ||
|
|
d72f831519 | ||
|
|
c6f25c0df6 | ||
|
|
17058c220c | ||
|
|
0e99b35ab2 | ||
|
|
e795c6ed0b | ||
|
|
f3345247ed | ||
|
|
1101a3243d | ||
|
|
c7638efc7e | ||
|
|
d90053c8c4 | ||
|
|
6235983ddd | ||
|
|
7a249abc67 | ||
|
|
c2c613b652 | ||
|
|
590357004d | ||
|
|
9dbeb1407c | ||
|
|
1ef8ab70d1 | ||
|
|
c09ada201c | ||
|
|
d7139cb16c | ||
|
|
10f82a6723 | ||
|
|
2aed3af3c4 | ||
|
|
c45d38ca69 | ||
|
|
576642a573 | ||
|
|
9d545dcbf1 | ||
|
|
71d8744840 | ||
|
|
32c689e0f5 | ||
|
|
5b62661404 | ||
|
|
a7df8a1a0a | ||
|
|
b14e7c197f | ||
|
|
97eed50ccc | ||
|
|
b8453ac792 | ||
|
|
fe7f479e63 | ||
|
|
50ea442bf0 | ||
|
|
5d45495371 | ||
|
|
e30d900289 | ||
|
|
2cc96e995b | ||
|
|
47cf1289d7 | ||
|
|
d2506cd928 | ||
|
|
1dbb11ea55 | ||
|
|
b60363b6bd | ||
|
|
00033c11bc | ||
|
|
c588b78adb | ||
|
|
7bd7992b24 | ||
|
|
6f86b7400a | ||
|
|
e13a2c371d | ||
|
|
0cbded9fca | ||
|
|
3e6e71ca41 | ||
|
|
1b2e3b1951 | ||
|
|
e53a480c22 | ||
|
|
7280c1c468 | ||
|
|
b7221516dc | ||
|
|
71aaf81bba | ||
|
|
160c3f428c | ||
|
|
3c3e8d167f | ||
|
|
7ca2b65c4f | ||
|
|
a8cbb5c8f5 | ||
|
|
72028086c0 | ||
|
|
dddf529ff5 | ||
|
|
b3de0aabae | ||
|
|
77c6a3b730 | ||
|
|
bb54dbb688 | ||
|
|
0a74da88d6 | ||
|
|
d0b94938e0 | ||
|
|
a0cba8e63d | ||
|
|
a4d7b5dcf8 | ||
|
|
c503adabc5 | ||
|
|
8a22258945 | ||
|
|
29a190f93a | ||
|
|
5c0b522026 | ||
|
|
c46f14665c | ||
|
|
20c973dab2 | ||
|
|
49cb482ca5 | ||
|
|
033c2e22cd | ||
|
|
2f434291cb | ||
|
|
42d01471d3 | ||
|
|
c5eb1bb105 | ||
|
|
3c9057f68e | ||
|
|
96f0dd5824 | ||
|
|
71358629f4 | ||
|
|
284fef00e7 | ||
|
|
d20519ef8b | ||
|
|
0dc1270aed | ||
|
|
cd0d37f73c | ||
|
|
56fce34539 | ||
|
|
165a76d492 | ||
|
|
9570e5cfd9 | ||
|
|
c6bb10489e | ||
|
|
3d7d4a47d9 | ||
|
|
968c849b13 | ||
|
|
1746569e1a | ||
|
|
209c91d3de | ||
|
|
7d7c1d34cf | ||
|
|
c3ad486f65 | ||
|
|
7bcec32134 | ||
|
|
b19b08dc6e | ||
|
|
264e175d6c | ||
|
|
bcd4fd9bff | ||
|
|
3e88fb44f4 | ||
|
|
518b013a63 | ||
|
|
e752538568 | ||
|
|
970364886c | ||
|
|
07f859e38b | ||
|
|
c806059958 | ||
|
|
14bce8fd82 | ||
|
|
17be04cd99 | ||
|
|
b93847f077 | ||
|
|
6476158462 | ||
|
|
6dd73ff9d0 | ||
|
|
b72083fb18 | ||
|
|
ca11d4d98b | ||
|
|
12cb4fd5f8 | ||
|
|
4df4eba2a5 | ||
|
|
762105d692 | ||
|
|
e4ce814c2f | ||
|
|
87cd693020 | ||
|
|
baadd4b1cb | ||
|
|
adf3755abb | ||
|
|
5c280e7cb7 | ||
|
|
4a149855ab | ||
|
|
cf000b04e4 | ||
|
|
79cd8d6065 | ||
|
|
5b930cdc3b | ||
|
|
c09329e5be | ||
|
|
c513014732 | ||
|
|
bada36be68 | ||
|
|
e5e81eda72 | ||
|
|
45cf2ae960 | ||
|
|
d0d0117411 | ||
|
|
5d79863cfc | ||
|
|
b85756f8b1 | ||
|
|
8776f4c1c0 | ||
|
|
5e8fd3993d | ||
|
|
d3033716ca | ||
|
|
6cf2bb5cd9 | ||
|
|
267495a406 | ||
|
|
a8937f7bf0 | ||
|
|
dfd63a81ac | ||
|
|
dfbc1956c9 | ||
|
|
c0490c0890 | ||
|
|
2da802d4b7 | ||
|
|
adffbab678 | ||
|
|
e11525ab64 | ||
|
|
8dcd591beb | ||
|
|
a40c936bcf | ||
|
|
5c2622b390 | ||
|
|
c7046b696a | ||
|
|
9ac5ce8a75 | ||
|
|
5c55e18d33 | ||
|
|
19d233454e | ||
|
|
1f761ee1cb | ||
|
|
1db5d61945 | ||
|
|
1e34a396cd | ||
|
|
ba96117f55 | ||
|
|
96b217cbe8 | ||
|
|
0dd5c0370e | ||
|
|
bdf32cde9e | ||
|
|
e91ed60441 | ||
|
|
8577202f48 | ||
|
|
7819b9d2f0 | ||
|
|
15c0565923 | ||
|
|
2b25ca2932 | ||
|
|
c7a6677d52 | ||
|
|
c3d5b32986 | ||
|
|
cbfb524195 | ||
|
|
b16a1f7237 | ||
|
|
e28f1b1be3 | ||
|
|
b512a243e7 | ||
|
|
873c9880dd | ||
|
|
e6736e48a5 | ||
|
|
caf598f55b | ||
|
|
619e099a04 | ||
|
|
faba1e3604 | ||
|
|
7cb728b15f | ||
|
|
3e3c7f0d54 | ||
|
|
a45c19a08b | ||
|
|
eb74a1de9c | ||
|
|
8450734cf1 | ||
|
|
016299a1dd | ||
|
|
d27ff9abb6 | ||
|
|
cdf5d45483 | ||
|
|
0b60d4efe2 | ||
|
|
d31e434e4d | ||
|
|
fabc1c3dd9 | ||
|
|
68fbc40605 | ||
|
|
8b7c5cf2ed | ||
|
|
1811631b93 | ||
|
|
7cec1564b9 | ||
|
|
a75eefcdd4 | ||
|
|
6a9027da6d | ||
|
|
e55aa3cea7 | ||
|
|
1ce2c60bf4 | ||
|
|
7ba49afa0b | ||
|
|
6da705c86f | ||
|
|
c3fa56322b | ||
|
|
53cfab229b | ||
|
|
b62217f301 | ||
|
|
d9a8453995 | ||
|
|
e6181928e8 | ||
|
|
c33499797e | ||
|
|
860f6a41ac | ||
|
|
8aa7b1f301 | ||
|
|
6efd3eaa27 | ||
|
|
d2d8d191da | ||
|
|
cea5c81d44 | ||
|
|
504f28df1a | ||
|
|
74a57553f6 | ||
|
|
35576ab64a | ||
|
|
33605517ff | ||
|
|
6da6e4d2e8 | ||
|
|
c0fa03ede2 | ||
|
|
301b609e93 | ||
|
|
b6bbe237ea | ||
|
|
de7ab13c03 | ||
|
|
7a0f4da860 | ||
|
|
1bbbfe1c96 | ||
|
|
25ebe68389 | ||
|
|
7737d19c5a | ||
|
|
622ca4bf8a | ||
|
|
b090afbeb3 | ||
|
|
dce149511e | ||
|
|
21a248e94d | ||
|
|
f1aed4b521 | ||
|
|
7564ebf79e | ||
|
|
b9aecbe1d4 | ||
|
|
49eb451a76 | ||
|
|
64d866a77d | ||
|
|
f75779aa7a | ||
|
|
5622882602 | ||
|
|
b3d3928db8 | ||
|
|
6df3b9008a | ||
|
|
c36ca65e09 | ||
|
|
2e788802fe | ||
|
|
b0552019f5 | ||
|
|
dae69622a5 | ||
|
|
696b930fb2 | ||
|
|
e43a62f992 | ||
|
|
02c1cb05c7 | ||
|
|
b44d738867 | ||
|
|
e1818f7e62 | ||
|
|
e5081db7e4 | ||
|
|
ba346bd797 | ||
|
|
0670ece7f3 | ||
|
|
a8da3eebd7 | ||
|
|
056303b53c | ||
|
|
454f7d30de | ||
|
|
6d1c270976 | ||
|
|
d1001274bb | ||
|
|
3099855562 | ||
|
|
3f26d4ad98 | ||
|
|
bae337cc49 | ||
|
|
3823e7a108 | ||
|
|
1c2221f52f | ||
|
|
1b780a4364 | ||
|
|
ac3e65a829 | ||
|
|
332f19177e | ||
|
|
6ab57b9abe | ||
|
|
862f3aad59 | ||
|
|
e277acf80e | ||
|
|
9f893e68e9 | ||
|
|
833a5b2b55 | ||
|
|
340f0c68eb | ||
|
|
a5e3182dad | ||
|
|
10ae9c3aa2 | ||
|
|
bcf903de92 | ||
|
|
ad08d27504 | ||
|
|
d24f77dbd5 | ||
|
|
a5b38ce1a4 | ||
|
|
5d048d2c1d | ||
|
|
13d3cc3306 | ||
|
|
9f02fb4dd4 | ||
|
|
07baa6e611 | ||
|
|
50bd5869bf | ||
|
|
fa49fc91d2 | ||
|
|
28f478dd04 | ||
|
|
6fb8dad0ec | ||
|
|
9f605e9a88 | ||
|
|
e5b91dae73 | ||
|
|
e1749fecd1 | ||
|
|
358edff798 | ||
|
|
34f13ba89c | ||
|
|
945ba6f8ab | ||
|
|
46f05ee92f | ||
|
|
6d46fc66ce | ||
|
|
ed7fe9213f | ||
|
|
9c68cbae72 | ||
|
|
c0df771539 | ||
|
|
9bd0c33fef | ||
|
|
8042cefd3d | ||
|
|
16a0f44b4d | ||
|
|
1a2acb43ae | ||
|
|
36d07cb539 | ||
|
|
6ca1cdec4f | ||
|
|
e2abf05a27 | ||
|
|
d9e6f2975a | ||
|
|
d8ac3587ac | ||
|
|
85c4fbdf4f | ||
|
|
5a7f38fa29 | ||
|
|
417148f5da | ||
|
|
a85cbdd505 | ||
|
|
b4d91978c7 | ||
|
|
16bde87982 | ||
|
|
270533652b | ||
|
|
03d640260d | ||
|
|
f27b2290dc | ||
|
|
efda9beece | ||
|
|
c7c7e5e4ce | ||
|
|
f61f80164d | ||
|
|
d16fef9f7f | ||
|
|
4425d53664 | ||
|
|
ee5e015a63 | ||
|
|
839ce3d526 | ||
|
|
cc06117210 | ||
|
|
cbd5b6c0f4 | ||
|
|
867e66e774 | ||
|
|
45ffeaffec | ||
|
|
f91b622646 | ||
|
|
40a9c28699 | ||
|
|
081491d0a1 | ||
|
|
8d0230d6a8 | ||
|
|
37e5260cda | ||
|
|
19b8031933 | ||
|
|
99211fd407 | ||
|
|
3d839c2b21 | ||
|
|
e1e7a1cfdb | ||
|
|
0ed7f87ee0 | ||
|
|
579bbc9f2c | ||
|
|
e672de949c | ||
|
|
f72762bcb2 | ||
|
|
7ecc3c25b0 | ||
|
|
adcffba7cf | ||
|
|
e271e60144 | ||
|
|
16be86953f | ||
|
|
1f527cdb9e | ||
|
|
11e8240c5c | ||
|
|
4aecc034c2 | ||
|
|
a111a07bca | ||
|
|
eb71097546 | ||
|
|
c7fcb72d6c | ||
|
|
04af8ef329 | ||
|
|
4cdf803ab7 | ||
|
|
4595c15bee | ||
|
|
1e3d2fbfd2 | ||
|
|
57c25bf151 | ||
|
|
ae030b227a | ||
|
|
4f85751694 | ||
|
|
6b0d0daa2e | ||
|
|
401498a4f7 | ||
|
|
8bb50189bc | ||
|
|
eb665a059a | ||
|
|
3dc29be083 | ||
|
|
82e5447526 | ||
|
|
066f3fd726 | ||
|
|
f0acf733a5 | ||
|
|
96c4dd2ab9 | ||
|
|
df3b9a7ef9 | ||
|
|
70a3a5919e | ||
|
|
688d37ee60 | ||
|
|
3dcf8bc8fc | ||
|
|
7039d613ee | ||
|
|
256c963370 | ||
|
|
7b8c2a4575 | ||
|
|
7f1ba0d6ae | ||
|
|
7e5b79aa14 | ||
|
|
086343ee48 | ||
|
|
a1ad512a80 | ||
|
|
9bb2ef9cbe | ||
|
|
832910d480 | ||
|
|
13da2b2924 | ||
|
|
84ac520353 | ||
|
|
5613975314 | ||
|
|
662d30ae45 | ||
|
|
57bee443b1 | ||
|
|
621618e41f | ||
|
|
6ccb60813a | ||
|
|
b34119901e | ||
|
|
b317aef8c9 | ||
|
|
fdbc6fa94f | ||
|
|
0ffe24903a | ||
|
|
e550a7cc44 | ||
|
|
82165a2af6 | ||
|
|
63a4fe32c1 | ||
|
|
1c44a25a4a | ||
|
|
cf21ecee2e | ||
|
|
5467e502a5 | ||
|
|
6af9ec266b | ||
|
|
faa7e0e7a9 | ||
|
|
aa3606007a | ||
|
|
db5974970d | ||
|
|
ba2539db67 | ||
|
|
21d0661d79 | ||
|
|
9f3eb461a9 | ||
|
|
34b0deba29 | ||
|
|
d9a93d8dff | ||
|
|
747776344b | ||
|
|
f979a79081 | ||
|
|
367e9840cc | ||
|
|
ea590c2ed1 | ||
|
|
d93120257b | ||
|
|
e763b362d9 | ||
|
|
e5eb1ca0cb | ||
|
|
ea2649db5e | ||
|
|
b53fc9cadc | ||
|
|
4b35e1b729 | ||
|
|
40e106db13 | ||
|
|
3dc0659f66 | ||
|
|
e652ed2981 | ||
|
|
28db891aa5 | ||
|
|
b63ae9b771 | ||
|
|
27c84ceaac | ||
|
|
d67ccd03ca | ||
|
|
96b0f27c51 |
No files matched your search
@@ -3,6 +3,5 @@
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="lib/bukkit-0.0.1-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="lib/craftbukkit-0.0.1-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="lib/Permissions3.jar"/>
|
||||
</classpath>
|
||||
+45
-47
@@ -1,47 +1,45 @@
|
||||
.DS_Store
|
||||
/BuildAll/nbproject/private/
|
||||
/EssentialsProtect/nbproject/private/
|
||||
/EssentialsChat/nbproject/private/
|
||||
/EssentialsGroupBridge/nbproject/private/
|
||||
/EssentialsGeoIP/nbproject/private/
|
||||
/EssentialsSpawn/nbproject/private/
|
||||
/EssentialsXMPP/nbproject/private/
|
||||
/EssentialsGroupManager/nbproject/private/
|
||||
/BuildAll/build/
|
||||
/EssentialsGroupBridge/dist/
|
||||
/EssentialsGroupBridge/build/
|
||||
/EssentialsGeoIP/dist/
|
||||
/EssentialsGeoIP/build/
|
||||
/EssentialsGroupManager/build/
|
||||
/EssentialsGroupManager/dist/
|
||||
/BuildAll/dist/
|
||||
/EssentialsChat/build/
|
||||
/EssentialsChat/dist/
|
||||
/EssentialsSpawn/build/
|
||||
/EssentialsSpawn/dist/
|
||||
/EssentialsXMPP/dist/
|
||||
/EssentialsXMPP/build/
|
||||
/EssentialsProtect/dist/
|
||||
/EssentialsProtect/build/
|
||||
/EssentialsPermissionsCommands/nbproject/private/
|
||||
/EssentialsPermissionsCommands/build/
|
||||
/EssentialsPermissionsCommands/dist/
|
||||
/Essentials/nbproject/private/
|
||||
/Essentials/dist/
|
||||
/Essentials/build/
|
||||
/YamlAnnotations/
|
||||
/EssentialsUpdate/nbproject/private/
|
||||
/EssentialsRelease/
|
||||
/EssentialsUpdate/dist/
|
||||
/EssentialsUpdate/build/
|
||||
/WebPush/apikey.php
|
||||
/WebPush/nbproject/private
|
||||
/.idea
|
||||
*.iml
|
||||
/EssentialsSigns/nbproject/private/
|
||||
/Essentials2Compat/nbproject/private/
|
||||
/Essentials2Compat/dist/
|
||||
/Essentials2Compat/build/
|
||||
/EssentialsGroupManager/bin
|
||||
/EssentialsGroupManager/.externalToolBuilders
|
||||
/EssentialsGeoIP/build
|
||||
.DS_Store
|
||||
/BuildAll/nbproject/private/
|
||||
/EssentialsProtect/nbproject/private/
|
||||
/EssentialsChat/nbproject/private/
|
||||
/EssentialsGroupBridge/nbproject/private/
|
||||
/EssentialsGeoIP/nbproject/private/
|
||||
/EssentialsSpawn/nbproject/private/
|
||||
/EssentialsXMPP/nbproject/private/
|
||||
/EssentialsGroupManager/nbproject/private/
|
||||
/BuildAll/build/
|
||||
/EssentialsGroupBridge/dist/
|
||||
/EssentialsGroupBridge/build/
|
||||
/EssentialsGeoIP/dist/
|
||||
/EssentialsGeoIP/build/
|
||||
/EssentialsGroupManager/build/
|
||||
/EssentialsGroupManager/dist/
|
||||
/BuildAll/dist/
|
||||
/EssentialsChat/build/
|
||||
/EssentialsChat/dist/
|
||||
/EssentialsSpawn/build/
|
||||
/EssentialsSpawn/dist/
|
||||
/EssentialsXMPP/dist/
|
||||
/EssentialsXMPP/build/
|
||||
/EssentialsProtect/dist/
|
||||
/EssentialsProtect/build/
|
||||
/EssentialsPermissionsCommands/nbproject/private/
|
||||
/EssentialsPermissionsCommands/build/
|
||||
/EssentialsPermissionsCommands/dist/
|
||||
/Essentials/nbproject/private/
|
||||
/Essentials/dist/
|
||||
/Essentials/build/
|
||||
/YamlAnnotations/
|
||||
/EssentialsUpdate/nbproject/private/
|
||||
/EssentialsRelease/
|
||||
/EssentialsUpdate/dist/
|
||||
/EssentialsUpdate/build/
|
||||
/WebPush/apikey.php
|
||||
/WebPush/nbproject/private
|
||||
/.idea
|
||||
*.iml
|
||||
/EssentialsGroupManager/bin
|
||||
/EssentialsGroupManager/.externalToolBuilders
|
||||
/EssentialsAntiBuild/nbproject/private/
|
||||
/EssentialsAntiBuild/dist/
|
||||
/EssentialsAntiBuild/build/
|
||||
@@ -638,6 +638,13 @@ is divided into following sections:
|
||||
<param name="call.target" value="jar"/>
|
||||
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
|
||||
</antcall>
|
||||
<antcall target="-maybe-call-dep">
|
||||
<param name="call.built.properties" value="${built-jar.properties}"/>
|
||||
<param location="${project.EssentialsAntiBuild}" name="call.subproject"/>
|
||||
<param location="${project.EssentialsAntiBuild}/build.xml" name="call.script"/>
|
||||
<param name="call.target" value="jar"/>
|
||||
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
|
||||
</antcall>
|
||||
<antcall target="-maybe-call-dep">
|
||||
<param name="call.built.properties" value="${built-jar.properties}"/>
|
||||
<param location="${project.EssentialsProtect}" name="call.subproject"/>
|
||||
@@ -1140,6 +1147,13 @@ is divided into following sections:
|
||||
<param name="call.target" value="clean"/>
|
||||
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
|
||||
</antcall>
|
||||
<antcall target="-maybe-call-dep">
|
||||
<param name="call.built.properties" value="${built-clean.properties}"/>
|
||||
<param location="${project.EssentialsAntiBuild}" name="call.subproject"/>
|
||||
<param location="${project.EssentialsAntiBuild}/build.xml" name="call.script"/>
|
||||
<param name="call.target" value="clean"/>
|
||||
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
|
||||
</antcall>
|
||||
<antcall target="-maybe-call-dep">
|
||||
<param name="call.built.properties" value="${built-clean.properties}"/>
|
||||
<param location="${project.EssentialsProtect}" name="call.subproject"/>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
build.xml.data.CRC32=51b33957
|
||||
build.xml.data.CRC32=b4df970c
|
||||
build.xml.script.CRC32=7a797370
|
||||
build.xml.stylesheet.CRC32=28e38971@1.44.1.45
|
||||
build.xml.stylesheet.CRC32=28e38971@1.50.3.46
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=51b33957
|
||||
nbproject/build-impl.xml.script.CRC32=c5170bed
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46
|
||||
nbproject/build-impl.xml.data.CRC32=b4df970c
|
||||
nbproject/build-impl.xml.script.CRC32=1fd6d3cc
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.3.46
|
||||
@@ -66,6 +66,7 @@ jar.compress=true
|
||||
javac.classpath=\
|
||||
${reference.Essentials.jar}:\
|
||||
${reference.EssentialsChat.jar}:\
|
||||
${reference.EssentialsAntiBuild.jar}:\
|
||||
${reference.EssentialsProtect.jar}:\
|
||||
${reference.EssentialsSpawn.jar}:\
|
||||
${reference.EssentialsGeoIP.jar}:\
|
||||
@@ -103,6 +104,7 @@ project.EssentialsChat=../EssentialsChat
|
||||
project.EssentialsGeoIP=../EssentialsGeoIP
|
||||
project.EssentialsGroupBridge=../EssentialsGroupBridge
|
||||
project.EssentialsGroupManager=../EssentialsGroupManager
|
||||
project.EssentialsAntiBuild=../EssentialsAntiBuild
|
||||
project.EssentialsProtect=../EssentialsProtect
|
||||
project.EssentialsSpawn=../EssentialsSpawn
|
||||
project.EssentialsXMPP=../EssentialsXMPP
|
||||
@@ -111,6 +113,7 @@ reference.EssentialsChat.jar=${project.EssentialsChat}/dist/EssentialsChat.jar
|
||||
reference.EssentialsGeoIP.jar=${project.EssentialsGeoIP}/dist/EssentialsGeoIP.jar
|
||||
reference.EssentialsGroupBridge.jar=${project.EssentialsGroupBridge}/dist/EssentialsGroupBridge.jar
|
||||
reference.EssentialsGroupManager.jar=${project.EssentialsGroupManager}/dist/EssentialsGroupManager.jar
|
||||
reference.EssentialsAntiBuild.jar=${project.EssentialsAntiBuild}/dist/EssentialsAntiBuild.jar
|
||||
reference.EssentialsProtect.jar=${project.EssentialsProtect}/dist/EssentialsProtect.jar
|
||||
reference.EssentialsSpawn.jar=${project.EssentialsSpawn}/dist/EssentialsSpawn.jar
|
||||
reference.EssentialsXMPP.jar=${project.EssentialsXMPP}/dist/EssentialsXMPP.jar
|
||||
|
||||
@@ -55,6 +55,14 @@
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
<reference>
|
||||
<foreign-project>EssentialsAntiBuild</foreign-project>
|
||||
<artifact-type>jar</artifact-type>
|
||||
<script>build.xml</script>
|
||||
<target>jar</target>
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
<reference>
|
||||
<foreign-project>EssentialsProtect</foreign-project>
|
||||
<artifact-type>jar</artifact-type>
|
||||
|
||||
@@ -12,9 +12,9 @@ is divided into following sections:
|
||||
- execution
|
||||
- debugging
|
||||
- javadoc
|
||||
- junit compilation
|
||||
- junit execution
|
||||
- junit debugging
|
||||
- test compilation
|
||||
- test execution
|
||||
- test debugging
|
||||
- applet
|
||||
- cleanup
|
||||
|
||||
@@ -181,6 +181,7 @@ is divided into following sections:
|
||||
</and>
|
||||
</condition>
|
||||
<property name="run.jvmargs" value=""/>
|
||||
<property name="run.jvmargs.ide" value=""/>
|
||||
<property name="javac.compilerargs" value=""/>
|
||||
<property name="work.dir" value="${basedir}"/>
|
||||
<condition property="no.deps">
|
||||
@@ -225,6 +226,27 @@ is divided into following sections:
|
||||
<property name="jar.index.metainf" value="${jar.index}"/>
|
||||
<property name="copylibs.rebase" value="true"/>
|
||||
<available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/>
|
||||
<condition property="junit.available">
|
||||
<or>
|
||||
<available classname="org.junit.Test" classpath="${run.test.classpath}"/>
|
||||
<available classname="junit.framework.Test" classpath="${run.test.classpath}"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition property="testng.available">
|
||||
<available classname="org.testng.annotations.Test" classpath="${run.test.classpath}"/>
|
||||
</condition>
|
||||
<condition property="junit+testng.available">
|
||||
<and>
|
||||
<istrue value="${junit.available}"/>
|
||||
<istrue value="${testng.available}"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition else="testng" property="testng.mode" value="mixed">
|
||||
<istrue value="${junit+testng.available}"/>
|
||||
</condition>
|
||||
<condition else="" property="testng.debug.mode" value="-mixed">
|
||||
<istrue value="${junit+testng.available}"/>
|
||||
</condition>
|
||||
</target>
|
||||
<target name="-post-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
@@ -357,11 +379,52 @@ is divided into following sections:
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-junit">
|
||||
<target if="${junit.available}" name="-init-macrodef-junit-init">
|
||||
<condition else="false" property="nb.junit.batch" value="true">
|
||||
<and>
|
||||
<istrue value="${junit.available}"/>
|
||||
<not>
|
||||
<isset property="test.method"/>
|
||||
</not>
|
||||
</and>
|
||||
</condition>
|
||||
<condition else="false" property="nb.junit.single" value="true">
|
||||
<and>
|
||||
<istrue value="${junit.available}"/>
|
||||
<isset property="test.method"/>
|
||||
</and>
|
||||
</condition>
|
||||
</target>
|
||||
<target if="${nb.junit.single}" name="-init-macrodef-junit-single" unless="${nb.junit.batch}">
|
||||
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute default="${includes}" name="includes"/>
|
||||
<attribute default="${excludes}" name="excludes"/>
|
||||
<attribute default="**" name="testincludes"/>
|
||||
<attribute default="" name="testmethods"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<property name="junit.forkmode" value="perTest"/>
|
||||
<junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
|
||||
<test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="test-sys-prop."/>
|
||||
<mapper from="test-sys-prop.*" to="*" type="glob"/>
|
||||
</syspropertyset>
|
||||
<formatter type="brief" usefile="false"/>
|
||||
<formatter type="xml"/>
|
||||
<jvmarg value="-ea"/>
|
||||
<customize/>
|
||||
</junit>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
|
||||
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute default="${includes}" name="includes"/>
|
||||
<attribute default="${excludes}" name="excludes"/>
|
||||
<attribute default="**" name="testincludes"/>
|
||||
<attribute default="" name="testmethods"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<property name="junit.forkmode" value="perTest"/>
|
||||
<junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
|
||||
@@ -370,32 +433,270 @@ is divided into following sections:
|
||||
<filename name="@{testincludes}"/>
|
||||
</fileset>
|
||||
</batchtest>
|
||||
<classpath>
|
||||
<path path="${run.test.classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="test-sys-prop."/>
|
||||
<mapper from="test-sys-prop.*" to="*" type="glob"/>
|
||||
</syspropertyset>
|
||||
<formatter type="brief" usefile="false"/>
|
||||
<formatter type="xml"/>
|
||||
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
|
||||
<jvmarg value="-ea"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<customize/>
|
||||
</junit>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" name="profile-init"/>
|
||||
<target name="-profile-pre-init">
|
||||
<target depends="-init-macrodef-junit-init,-init-macrodef-junit-single, -init-macrodef-junit-batch" if="${junit.available}" name="-init-macrodef-junit"/>
|
||||
<target if="${testng.available}" name="-init-macrodef-testng">
|
||||
<macrodef name="testng" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute default="${includes}" name="includes"/>
|
||||
<attribute default="${excludes}" name="excludes"/>
|
||||
<attribute default="**" name="testincludes"/>
|
||||
<attribute default="" name="testmethods"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<condition else="" property="testng.methods.arg" value="@{testincludes}.@{testmethods}">
|
||||
<isset property="test.method"/>
|
||||
</condition>
|
||||
<union id="test.set">
|
||||
<fileset dir="${test.src.dir}" excludes="@{excludes},**/*.xml,${excludes}" includes="@{includes}">
|
||||
<filename name="@{testincludes}"/>
|
||||
</fileset>
|
||||
</union>
|
||||
<taskdef classname="org.testng.TestNGAntTask" classpath="${run.test.classpath}" name="testng"/>
|
||||
<testng classfilesetref="test.set" failureProperty="tests.failed" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="Essentials" testname="TestNG tests" workingDir="${work.dir}">
|
||||
<xmlfileset dir="${build.test.classes.dir}" includes="@{testincludes}"/>
|
||||
<propertyset>
|
||||
<propertyref prefix="test-sys-prop."/>
|
||||
<mapper from="test-sys-prop.*" to="*" type="glob"/>
|
||||
</propertyset>
|
||||
<customize/>
|
||||
</testng>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-test-impl">
|
||||
<macrodef name="test-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute default="${includes}" name="includes"/>
|
||||
<attribute default="${excludes}" name="excludes"/>
|
||||
<attribute default="**" name="testincludes"/>
|
||||
<attribute default="" name="testmethods"/>
|
||||
<element implicit="true" name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<echo>No tests executed.</echo>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target depends="-init-macrodef-junit" if="${junit.available}" name="-init-macrodef-junit-impl">
|
||||
<macrodef name="test-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute default="${includes}" name="includes"/>
|
||||
<attribute default="${excludes}" name="excludes"/>
|
||||
<attribute default="**" name="testincludes"/>
|
||||
<attribute default="" name="testmethods"/>
|
||||
<element implicit="true" name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<j2seproject3:junit excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
|
||||
<customize/>
|
||||
</j2seproject3:junit>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target depends="-init-macrodef-testng" if="${testng.available}" name="-init-macrodef-testng-impl">
|
||||
<macrodef name="test-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute default="${includes}" name="includes"/>
|
||||
<attribute default="${excludes}" name="excludes"/>
|
||||
<attribute default="**" name="testincludes"/>
|
||||
<attribute default="" name="testmethods"/>
|
||||
<element implicit="true" name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<j2seproject3:testng excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
|
||||
<customize/>
|
||||
</j2seproject3:testng>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target depends="-init-macrodef-test-impl,-init-macrodef-junit-impl,-init-macrodef-testng-impl" name="-init-macrodef-test">
|
||||
<macrodef name="test" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute default="${includes}" name="includes"/>
|
||||
<attribute default="${excludes}" name="excludes"/>
|
||||
<attribute default="**" name="testincludes"/>
|
||||
<attribute default="" name="testmethods"/>
|
||||
<sequential>
|
||||
<j2seproject3:test-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
|
||||
<customize>
|
||||
<classpath>
|
||||
<path path="${run.test.classpath}"/>
|
||||
</classpath>
|
||||
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<jvmarg line="${run.jvmargs.ide}"/>
|
||||
</customize>
|
||||
</j2seproject3:test-impl>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target if="${junit.available}" name="-init-macrodef-junit-debug" unless="${nb.junit.batch}">
|
||||
<macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute default="${includes}" name="includes"/>
|
||||
<attribute default="${excludes}" name="excludes"/>
|
||||
<attribute default="**" name="testincludes"/>
|
||||
<attribute default="" name="testmethods"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<property name="junit.forkmode" value="perTest"/>
|
||||
<junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
|
||||
<test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="test-sys-prop."/>
|
||||
<mapper from="test-sys-prop.*" to="*" type="glob"/>
|
||||
</syspropertyset>
|
||||
<formatter type="brief" usefile="false"/>
|
||||
<formatter type="xml"/>
|
||||
<jvmarg value="-ea"/>
|
||||
<jvmarg line="${debug-args-line}"/>
|
||||
<jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
|
||||
<customize/>
|
||||
</junit>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
|
||||
<macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute default="${includes}" name="includes"/>
|
||||
<attribute default="${excludes}" name="excludes"/>
|
||||
<attribute default="**" name="testincludes"/>
|
||||
<attribute default="" name="testmethods"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<property name="junit.forkmode" value="perTest"/>
|
||||
<junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
|
||||
<batchtest todir="${build.test.results.dir}">
|
||||
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
|
||||
<filename name="@{testincludes}"/>
|
||||
</fileset>
|
||||
</batchtest>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="test-sys-prop."/>
|
||||
<mapper from="test-sys-prop.*" to="*" type="glob"/>
|
||||
</syspropertyset>
|
||||
<formatter type="brief" usefile="false"/>
|
||||
<formatter type="xml"/>
|
||||
<jvmarg value="-ea"/>
|
||||
<jvmarg line="${debug-args-line}"/>
|
||||
<jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
|
||||
<customize/>
|
||||
</junit>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target depends="-init-macrodef-junit-debug,-init-macrodef-junit-debug-batch" if="${junit.available}" name="-init-macrodef-junit-debug-impl">
|
||||
<macrodef name="test-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute default="${includes}" name="includes"/>
|
||||
<attribute default="${excludes}" name="excludes"/>
|
||||
<attribute default="**" name="testincludes"/>
|
||||
<attribute default="" name="testmethods"/>
|
||||
<element implicit="true" name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<j2seproject3:junit-debug excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
|
||||
<customize/>
|
||||
</j2seproject3:junit-debug>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target if="${testng.available}" name="-init-macrodef-testng-debug">
|
||||
<macrodef name="testng-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute default="${main.class}" name="testClass"/>
|
||||
<attribute default="" name="testMethod"/>
|
||||
<element name="customize2" optional="true"/>
|
||||
<sequential>
|
||||
<condition else="-testclass @{testClass}" property="test.class.or.method" value="-methods @{testClass}.@{testMethod}">
|
||||
<isset property="test.method"/>
|
||||
</condition>
|
||||
<condition else="-suitename Essentials -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}">
|
||||
<matches pattern=".*\.xml" string="@{testClass}"/>
|
||||
</condition>
|
||||
<delete dir="${build.test.results.dir}" quiet="true"/>
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
<j2seproject3:debug classname="org.testng.TestNG" classpath="${debug.test.classpath}">
|
||||
<customize>
|
||||
<customize2/>
|
||||
<jvmarg value="-ea"/>
|
||||
<arg line="${testng.debug.mode}"/>
|
||||
<arg line="-d ${build.test.results.dir}"/>
|
||||
<arg line="-listener org.testng.reporters.VerboseReporter"/>
|
||||
<arg line="${testng.cmd.args}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target depends="-init-macrodef-testng-debug" if="${testng.available}" name="-init-macrodef-testng-debug-impl">
|
||||
<macrodef name="testng-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute default="${main.class}" name="testClass"/>
|
||||
<attribute default="" name="testMethod"/>
|
||||
<element implicit="true" name="customize2" optional="true"/>
|
||||
<sequential>
|
||||
<j2seproject3:testng-debug testClass="@{testClass}" testMethod="@{testMethod}">
|
||||
<customize2/>
|
||||
</j2seproject3:testng-debug>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target depends="-init-macrodef-junit-debug-impl" if="${junit.available}" name="-init-macrodef-test-debug-junit">
|
||||
<macrodef name="test-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute default="${includes}" name="includes"/>
|
||||
<attribute default="${excludes}" name="excludes"/>
|
||||
<attribute default="**" name="testincludes"/>
|
||||
<attribute default="" name="testmethods"/>
|
||||
<attribute default="${main.class}" name="testClass"/>
|
||||
<attribute default="" name="testMethod"/>
|
||||
<sequential>
|
||||
<j2seproject3:test-debug-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
|
||||
<customize>
|
||||
<classpath>
|
||||
<path path="${run.test.classpath}"/>
|
||||
</classpath>
|
||||
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<jvmarg line="${run.jvmargs.ide}"/>
|
||||
</customize>
|
||||
</j2seproject3:test-debug-impl>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target depends="-init-macrodef-testng-debug-impl" if="${testng.available}" name="-init-macrodef-test-debug-testng">
|
||||
<macrodef name="test-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute default="${includes}" name="includes"/>
|
||||
<attribute default="${excludes}" name="excludes"/>
|
||||
<attribute default="**" name="testincludes"/>
|
||||
<attribute default="" name="testmethods"/>
|
||||
<attribute default="${main.class}" name="testClass"/>
|
||||
<attribute default="" name="testMethod"/>
|
||||
<sequential>
|
||||
<j2seproject3:testng-debug-impl testClass="@{testClass}" testMethod="@{testMethod}">
|
||||
<customize2>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="test-sys-prop."/>
|
||||
<mapper from="test-sys-prop.*" to="*" type="glob"/>
|
||||
</syspropertyset>
|
||||
</customize2>
|
||||
</j2seproject3:testng-debug-impl>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target depends="-init-macrodef-test-debug-junit,-init-macrodef-test-debug-testng" name="-init-macrodef-test-debug"/>
|
||||
<!--
|
||||
pre NB7.2 profiling section; consider it deprecated
|
||||
-->
|
||||
<target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" if="profiler.info.jvmargs.agent" name="profile-init"/>
|
||||
<target if="profiler.info.jvmargs.agent" name="-profile-pre-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-profile-post-init">
|
||||
<target if="profiler.info.jvmargs.agent" name="-profile-post-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-profile-init-macrodef-profile">
|
||||
<target if="profiler.info.jvmargs.agent" name="-profile-init-macrodef-profile">
|
||||
<macrodef name="resolve">
|
||||
<attribute name="name"/>
|
||||
<attribute name="value"/>
|
||||
@@ -427,10 +728,13 @@ is divided into following sections:
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile" name="-profile-init-check">
|
||||
<target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile" if="profiler.info.jvmargs.agent" name="-profile-init-check">
|
||||
<fail unless="profiler.info.jvm">Must set JVM to use for profiling in profiler.info.jvm</fail>
|
||||
<fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail>
|
||||
</target>
|
||||
<!--
|
||||
end of pre NB7.2 profiling section
|
||||
-->
|
||||
<target depends="-init-debug-args" name="-init-macrodef-nbjpda">
|
||||
<macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute default="${main.class}" name="name"/>
|
||||
@@ -488,6 +792,7 @@ is divided into following sections:
|
||||
<jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
|
||||
<redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<jvmarg line="${run.jvmargs.ide}"/>
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
@@ -504,6 +809,7 @@ is divided into following sections:
|
||||
<macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute default="${main.class}" name="classname"/>
|
||||
<attribute default="${run.classpath}" name="classpath"/>
|
||||
<attribute default="jvm" name="jvm"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<java classname="@{classname}" dir="${work.dir}" fork="true">
|
||||
@@ -511,6 +817,7 @@ is divided into following sections:
|
||||
<jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
|
||||
<redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<jvmarg line="${run.jvmargs.ide}"/>
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
@@ -537,6 +844,9 @@ is divided into following sections:
|
||||
<path path="${run.classpath.without.build.classes.dir}"/>
|
||||
<chainedmapper>
|
||||
<flattenmapper/>
|
||||
<filtermapper>
|
||||
<replacestring from=" " to="%20"/>
|
||||
</filtermapper>
|
||||
<globmapper from="*" to="lib/*"/>
|
||||
</chainedmapper>
|
||||
</pathconvert>
|
||||
@@ -582,7 +892,7 @@ is divided into following sections:
|
||||
<target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline">
|
||||
<property name="ap.cmd.line.internal" value=""/>
|
||||
</target>
|
||||
<target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
|
||||
<target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-test,-init-macrodef-test-debug,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
|
||||
<!--
|
||||
===================
|
||||
COMPILATION SECTION
|
||||
@@ -805,7 +1115,11 @@ is divided into following sections:
|
||||
PROFILING SECTION
|
||||
=================
|
||||
-->
|
||||
<target depends="profile-init,compile" description="Profile a project in the IDE." if="netbeans.home" name="profile">
|
||||
<!--
|
||||
pre NB7.2 profiler integration
|
||||
-->
|
||||
<target depends="profile-init,compile" description="Profile a project in the IDE." if="profiler.info.jvmargs.agent" name="-profile-pre72">
|
||||
<fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
|
||||
<nbprofiledirect>
|
||||
<classpath>
|
||||
<path path="${run.classpath}"/>
|
||||
@@ -813,8 +1127,9 @@ is divided into following sections:
|
||||
</nbprofiledirect>
|
||||
<profile/>
|
||||
</target>
|
||||
<target depends="profile-init,compile-single" description="Profile a selected class in the IDE." if="netbeans.home" name="profile-single">
|
||||
<target depends="profile-init,compile-single" description="Profile a selected class in the IDE." if="profiler.info.jvmargs.agent" name="-profile-single-pre72">
|
||||
<fail unless="profile.class">Must select one file in the IDE or set profile.class</fail>
|
||||
<fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
|
||||
<nbprofiledirect>
|
||||
<classpath>
|
||||
<path path="${run.classpath}"/>
|
||||
@@ -822,12 +1137,8 @@ is divided into following sections:
|
||||
</nbprofiledirect>
|
||||
<profile classname="${profile.class}"/>
|
||||
</target>
|
||||
<!--
|
||||
=========================
|
||||
APPLET PROFILING SECTION
|
||||
=========================
|
||||
-->
|
||||
<target depends="profile-init,compile-single" if="netbeans.home" name="profile-applet">
|
||||
<target depends="profile-init,compile-single" if="profiler.info.jvmargs.agent" name="-profile-applet-pre72">
|
||||
<fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
|
||||
<nbprofiledirect>
|
||||
<classpath>
|
||||
<path path="${run.classpath}"/>
|
||||
@@ -839,12 +1150,8 @@ is divided into following sections:
|
||||
</customize>
|
||||
</profile>
|
||||
</target>
|
||||
<!--
|
||||
=========================
|
||||
TESTS PROFILING SECTION
|
||||
=========================
|
||||
-->
|
||||
<target depends="profile-init,compile-test-single" if="netbeans.home" name="profile-test-single">
|
||||
<target depends="profile-init,compile-test-single" if="profiler.info.jvmargs.agent" name="-profile-test-single-pre72">
|
||||
<fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
|
||||
<nbprofiledirect>
|
||||
<classpath>
|
||||
<path path="${run.test.classpath}"/>
|
||||
@@ -866,6 +1173,42 @@ is divided into following sections:
|
||||
<formatter type="xml"/>
|
||||
</junit>
|
||||
</target>
|
||||
<!--
|
||||
end of pre NB72 profiling section
|
||||
-->
|
||||
<target if="netbeans.home" name="-profile-check">
|
||||
<condition property="profiler.configured">
|
||||
<or>
|
||||
<contains casesensitive="true" string="${run.jvmargs.ide}" substring="-agentpath:"/>
|
||||
<contains casesensitive="true" string="${run.jvmargs.ide}" substring="-javaagent:"/>
|
||||
</or>
|
||||
</condition>
|
||||
</target>
|
||||
<target depends="-profile-check,-profile-pre72" description="Profile a project in the IDE." if="profiler.configured" name="profile" unless="profiler.info.jvmargs.agent">
|
||||
<startprofiler/>
|
||||
<antcall target="run"/>
|
||||
</target>
|
||||
<target depends="-profile-check,-profile-single-pre72" description="Profile a selected class in the IDE." if="profiler.configured" name="profile-single" unless="profiler.info.jvmargs.agent">
|
||||
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>
|
||||
<startprofiler/>
|
||||
<antcall target="run-single"/>
|
||||
</target>
|
||||
<target depends="-profile-test-single-pre72" description="Profile a selected test in the IDE." name="profile-test-single"/>
|
||||
<target depends="-profile-check" description="Profile a selected test in the IDE." if="profiler.configured" name="profile-test" unless="profiler.info.jvmargs">
|
||||
<fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
|
||||
<startprofiler/>
|
||||
<antcall target="test-single"/>
|
||||
</target>
|
||||
<target depends="-profile-check" description="Profile a selected class in the IDE." if="profiler.configured" name="profile-test-with-main">
|
||||
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>
|
||||
<startprofiler/>
|
||||
<antcal target="run-test-with-main"/>
|
||||
</target>
|
||||
<target depends="-profile-check,-profile-applet-pre72" if="profiler.configured" name="profile-applet" unless="profiler.info.jvmargs.agent">
|
||||
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
|
||||
<startprofiler/>
|
||||
<antcall target="run-applet"/>
|
||||
</target>
|
||||
<!--
|
||||
===============
|
||||
JAVADOC SECTION
|
||||
@@ -909,7 +1252,7 @@ is divided into following sections:
|
||||
<target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
|
||||
<!--
|
||||
=========================
|
||||
JUNIT COMPILATION SECTION
|
||||
TEST COMPILATION SECTION
|
||||
=========================
|
||||
-->
|
||||
<target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
|
||||
@@ -952,14 +1295,14 @@ is divided into following sections:
|
||||
<target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
|
||||
<!--
|
||||
=======================
|
||||
JUNIT EXECUTION SECTION
|
||||
TEST EXECUTION SECTION
|
||||
=======================
|
||||
-->
|
||||
<target depends="init" if="have.tests" name="-pre-test-run">
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
</target>
|
||||
<target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
|
||||
<j2seproject3:junit testincludes="**/*Test.java"/>
|
||||
<j2seproject3:test testincludes="**/*Test.java"/>
|
||||
</target>
|
||||
<target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
|
||||
<fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
|
||||
@@ -972,39 +1315,40 @@ is divided into following sections:
|
||||
</target>
|
||||
<target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
|
||||
<fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
|
||||
<j2seproject3:junit excludes="" includes="${test.includes}"/>
|
||||
<j2seproject3:test excludes="" includes="${test.includes}" testincludes="${test.includes}"/>
|
||||
</target>
|
||||
<target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
|
||||
<fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
|
||||
</target>
|
||||
<target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
|
||||
<target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single-method">
|
||||
<fail unless="test.class">Must select some files in the IDE or set test.class</fail>
|
||||
<fail unless="test.method">Must select some method in the IDE or set test.method</fail>
|
||||
<j2seproject3:test excludes="" includes="${javac.includes}" testincludes="${test.class}" testmethods="${test.method}"/>
|
||||
</target>
|
||||
<target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single-method" if="have.tests" name="-post-test-run-single-method">
|
||||
<fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
|
||||
</target>
|
||||
<target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single-method,-post-test-run-single-method" description="Run single unit test." name="test-single-method"/>
|
||||
<!--
|
||||
=======================
|
||||
JUNIT DEBUGGING SECTION
|
||||
TEST DEBUGGING SECTION
|
||||
=======================
|
||||
-->
|
||||
<target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
|
||||
<target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test">
|
||||
<fail unless="test.class">Must select one file in the IDE or set test.class</fail>
|
||||
<property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
|
||||
<delete file="${test.report.file}"/>
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
<j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
|
||||
<customize>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="test-sys-prop."/>
|
||||
<mapper from="test-sys-prop.*" to="*" type="glob"/>
|
||||
</syspropertyset>
|
||||
<arg value="${test.class}"/>
|
||||
<arg value="showoutput=true"/>
|
||||
<arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
|
||||
<arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
<j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testincludes="${javac.includes}"/>
|
||||
</target>
|
||||
<target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test-method">
|
||||
<fail unless="test.class">Must select one file in the IDE or set test.class</fail>
|
||||
<fail unless="test.method">Must select some method in the IDE or set test.method</fail>
|
||||
<j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testMethod="${test.method}" testincludes="${test.class}" testmethods="${test.method}"/>
|
||||
</target>
|
||||
<target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
|
||||
<j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
|
||||
</target>
|
||||
<target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
|
||||
<target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test-method" name="debug-test-method"/>
|
||||
<target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
|
||||
<j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
|
||||
</target>
|
||||
@@ -1076,9 +1420,12 @@ is divided into following sections:
|
||||
<target name="-check-call-dep">
|
||||
<property file="${call.built.properties}" prefix="already.built."/>
|
||||
<condition property="should.call.dep">
|
||||
<not>
|
||||
<isset property="already.built.${call.subproject}"/>
|
||||
</not>
|
||||
<and>
|
||||
<not>
|
||||
<isset property="already.built.${call.subproject}"/>
|
||||
</not>
|
||||
<available file="${call.script}"/>
|
||||
</and>
|
||||
</condition>
|
||||
</target>
|
||||
<target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
|
||||
|
||||
@@ -4,8 +4,8 @@ build.xml.stylesheet.CRC32=28e38971@1.38.2.45
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=a830bc14
|
||||
nbproject/build-impl.xml.script.CRC32=a9f8842a
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46
|
||||
nbproject/build-impl.xml.script.CRC32=7c507372
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46
|
||||
nbproject/profiler-build-impl.xml.data.CRC32=ab78ce15
|
||||
nbproject/profiler-build-impl.xml.script.CRC32=abda56ed
|
||||
nbproject/profiler-build-impl.xml.stylesheet.CRC32=f10cf54c@1.11.1
|
||||
@@ -1,5 +1,5 @@
|
||||
annotation.processing.enabled=true
|
||||
annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.enabled.in.editor=true
|
||||
annotation.processing.processors.list=lombok.core.AnnotationProcessor
|
||||
annotation.processing.run.all.processors=false
|
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||
@@ -124,7 +124,7 @@ javadoc.reference.PermissionsEx.jar=../lib/PermissionsEx-javadoc.jar
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=Essentials Docs.
|
||||
javadoc.windowtitle=
|
||||
jnlp.codebase.type=no.codebase
|
||||
jnlp.descriptor=application
|
||||
jnlp.enabled=false
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.PluginCommandYamlParser;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public class AlternativeCommandsHandler
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
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 AlternativeCommandsHandler(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
for (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);
|
||||
|
||||
for (Command command : commands)
|
||||
{
|
||||
final PluginCommand pc = (PluginCommand)command;
|
||||
final List<String> labels = new ArrayList<String>(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 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 void executed(final String label, final String otherLabel)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials: Alternative command " + label + " found, using " + otherLabel);
|
||||
}
|
||||
disabledList.put(label, otherLabel);
|
||||
}
|
||||
|
||||
public Map<String, String> disabledCommands()
|
||||
{
|
||||
return disabledList;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,23 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IBackup;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Backup implements Runnable, IBackup
|
||||
public class Backup implements Runnable
|
||||
{
|
||||
private static final Logger LOGGER = Bukkit.getLogger();
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient final Server server;
|
||||
private transient final IEssentials ess;
|
||||
private transient final AtomicBoolean running = new AtomicBoolean(false);
|
||||
private transient boolean running = false;
|
||||
private transient int taskId = -1;
|
||||
private transient final AtomicBoolean active = new AtomicBoolean(false);
|
||||
private transient boolean active = false;
|
||||
|
||||
public Backup(final IEssentials ess)
|
||||
{
|
||||
@@ -35,119 +29,112 @@ public class Backup implements Runnable, IBackup
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void startTask()
|
||||
void onPlayerJoin()
|
||||
{
|
||||
if (running.compareAndSet(false, true))
|
||||
startTask();
|
||||
}
|
||||
|
||||
private void startTask()
|
||||
{
|
||||
if (!running)
|
||||
{
|
||||
@Cleanup
|
||||
final ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
final long interval = settings.getData().getGeneral().getBackup().getInterval() * 1200; // minutes -> ticks
|
||||
final long interval = ess.getSettings().getBackupInterval() * 1200; // minutes -> ticks
|
||||
if (interval < 1200)
|
||||
{
|
||||
running.set(false);
|
||||
return;
|
||||
}
|
||||
taskId = ess.scheduleSyncRepeatingTask(this, interval, interval);
|
||||
running = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (!active.compareAndSet(false, true))
|
||||
if (active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@Cleanup
|
||||
final ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
final String command = settings.getData().getGeneral().getBackup().getCommand();
|
||||
if (command == null || command.isEmpty())
|
||||
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 consoleSender = server.getConsoleSender();
|
||||
server.dispatchCommand(consoleSender, "save-all");
|
||||
server.dispatchCommand(consoleSender, "save-off");
|
||||
final CommandSender cs = server.getConsoleSender();
|
||||
server.dispatchCommand(cs, "save-all");
|
||||
server.dispatchCommand(cs, "save-off");
|
||||
|
||||
ess.scheduleAsyncDelayedTask(new BackupRunner(command));
|
||||
}
|
||||
|
||||
|
||||
private class BackupRunner implements Runnable
|
||||
{
|
||||
private final transient String command;
|
||||
|
||||
public BackupRunner(final String command)
|
||||
{
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
@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();
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(child.getInputStream()));
|
||||
try
|
||||
ess.scheduleAsyncDelayedTask(
|
||||
new Runnable()
|
||||
{
|
||||
child.waitFor();
|
||||
String line;
|
||||
do
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
line = reader.readLine();
|
||||
if (line != null)
|
||||
try
|
||||
{
|
||||
LOGGER.log(Level.INFO, line);
|
||||
final ProcessBuilder childBuilder = new ProcessBuilder(command);
|
||||
childBuilder.redirectErrorStream(true);
|
||||
childBuilder.directory(ess.getDataFolder().getParentFile().getParentFile());
|
||||
final Process child = childBuilder.start();
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(child.getInputStream()));
|
||||
try
|
||||
{
|
||||
child.waitFor();
|
||||
String line;
|
||||
do
|
||||
{
|
||||
line = reader.readLine();
|
||||
if (line != null)
|
||||
{
|
||||
LOGGER.log(Level.INFO, line);
|
||||
}
|
||||
}
|
||||
while (line != null);
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
running = false;
|
||||
if (taskId != -1)
|
||||
{
|
||||
server.getScheduler().cancelTask(taskId);
|
||||
}
|
||||
}
|
||||
active = false;
|
||||
LOGGER.log(Level.INFO, _("backupFinished"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
while (line != null);
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
catch (InterruptedException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(new EnableSavingRunner());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class EnableSavingRunner implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
server.dispatchCommand(server.getConsoleSender(), "save-on");
|
||||
if (server.getOnlinePlayers().length == 0)
|
||||
{
|
||||
running.set(false);
|
||||
if (taskId != -1)
|
||||
{
|
||||
server.getScheduler().cancelTask(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
active.set(false);
|
||||
LOGGER.log(Level.INFO, _("backupFinished"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.earth2me.essentials.api;
|
||||
package com.earth2me.essentials;
|
||||
|
||||
|
||||
public class ChargeException extends Exception
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.IReplyTo;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
@@ -14,8 +14,13 @@ public final class Console implements IReplyTo
|
||||
{
|
||||
}
|
||||
|
||||
public static CommandSender getCommandSender(Server server) throws Exception
|
||||
{
|
||||
return server.getConsoleSender();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReplyTo(final CommandSender user)
|
||||
public void setReplyTo(CommandSender user)
|
||||
{
|
||||
replyTo = user;
|
||||
}
|
||||
|
||||
@@ -6,16 +6,18 @@ import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* This utility class is used for converting between the ingame
|
||||
* time in ticks to ingame time as a friendly string.
|
||||
* Note that the time is INGAME.
|
||||
*
|
||||
* This utility class is used for converting between the ingame time in ticks to ingame time as a friendly string. Note
|
||||
* that the time is INGAME.
|
||||
*
|
||||
* http://www.minecraftwiki.net/wiki/Day/night_cycle
|
||||
*
|
||||
*
|
||||
* @author Olof Larsson
|
||||
*/
|
||||
public final class DescParseTickFormat
|
||||
{
|
||||
// ============================================
|
||||
// First some information vars. TODO: Should this be in a config file?
|
||||
// --------------------------------------------
|
||||
public static final Map<String, Integer> nameToTicks = new LinkedHashMap<String, Integer>();
|
||||
public static final Set<String> resetAliases = new HashSet<String>();
|
||||
public static final int ticksAtMidnight = 18000;
|
||||
@@ -153,30 +155,31 @@ public final class DescParseTickFormat
|
||||
int hours = 0;
|
||||
int minutes = 0;
|
||||
|
||||
desc = desc.toLowerCase(Locale.ENGLISH).replaceAll("[^0-9]", "");
|
||||
desc = desc.toLowerCase(Locale.ENGLISH);
|
||||
String parsetime = desc.replaceAll("[^0-9]", "");
|
||||
|
||||
if (desc.length() > 4)
|
||||
if (parsetime.length() > 4)
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
if (desc.length() == 4)
|
||||
if (parsetime.length() == 4)
|
||||
{
|
||||
hours += Integer.parseInt(desc.substring(0, 2));
|
||||
minutes += Integer.parseInt(desc.substring(2, 4));
|
||||
hours += Integer.parseInt(parsetime.substring(0, 2));
|
||||
minutes += Integer.parseInt(parsetime.substring(2, 4));
|
||||
}
|
||||
else if (desc.length() == 3)
|
||||
else if (parsetime.length() == 3)
|
||||
{
|
||||
hours += Integer.parseInt(desc.substring(0, 1));
|
||||
minutes += Integer.parseInt(desc.substring(1, 3));
|
||||
hours += Integer.parseInt(parsetime.substring(0, 1));
|
||||
minutes += Integer.parseInt(parsetime.substring(1, 3));
|
||||
}
|
||||
else if (desc.length() == 2)
|
||||
else if (parsetime.length() == 2)
|
||||
{
|
||||
hours += Integer.parseInt(desc.substring(0, 2));
|
||||
hours += Integer.parseInt(parsetime.substring(0, 2));
|
||||
}
|
||||
else if (desc.length() == 1)
|
||||
else if (parsetime.length() == 1)
|
||||
{
|
||||
hours += Integer.parseInt(desc.substring(0, 1));
|
||||
hours += Integer.parseInt(parsetime.substring(0, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -266,11 +269,11 @@ public final class DescParseTickFormat
|
||||
|
||||
// How many ingame days have passed since the server start?
|
||||
final long days = ticks / ticksPerDay;
|
||||
ticks = ticks - days * ticksPerDay;
|
||||
ticks -= days * ticksPerDay;
|
||||
|
||||
// How many hours on the last day?
|
||||
final long hours = ticks / ticksPerHour;
|
||||
ticks = ticks - hours * ticksPerHour;
|
||||
ticks -= hours * ticksPerHour;
|
||||
|
||||
// How many minutes on the last day?
|
||||
final long minutes = (long)Math.floor(ticks / ticksPerMinute);
|
||||
|
||||
@@ -1,207 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.*;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import com.earth2me.essentials.settings.MoneyHolder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class Economy implements IEconomy
|
||||
{
|
||||
private final IEssentials ess;
|
||||
private final MoneyHolder npcs;
|
||||
|
||||
public Economy(IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
this.npcs = new MoneyHolder(ess);
|
||||
}
|
||||
|
||||
private double getNPCBalance(String name) throws UserDoesNotExistException
|
||||
{
|
||||
npcs.acquireReadLock();
|
||||
try
|
||||
{
|
||||
Map<String, Double> balances = npcs.getData().getBalances();
|
||||
if (balances == null)
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
Double balance = npcs.getData().getBalances().get(name.toLowerCase(Locale.ENGLISH));
|
||||
if (balance == null)
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
return balance;
|
||||
}
|
||||
finally
|
||||
{
|
||||
npcs.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private void setNPCBalance(String name, double balance, boolean checkExistance) throws UserDoesNotExistException
|
||||
{
|
||||
npcs.acquireWriteLock();
|
||||
try
|
||||
{
|
||||
Map<String, Double> balances = npcs.getData().getBalances();
|
||||
if (balances == null)
|
||||
{
|
||||
balances = new HashMap<String, Double>();
|
||||
npcs.getData().setBalances(balances);
|
||||
}
|
||||
if (checkExistance && !balances.containsKey(name.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
balances.put(name.toLowerCase(Locale.ENGLISH), balance);
|
||||
}
|
||||
finally
|
||||
{
|
||||
npcs.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private double getStartingBalance()
|
||||
{
|
||||
double startingBalance = 0;
|
||||
ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
try
|
||||
{
|
||||
startingBalance = settings.getData().getEconomy().getStartingBalance();
|
||||
}
|
||||
finally
|
||||
{
|
||||
settings.unlock();
|
||||
}
|
||||
return startingBalance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReload()
|
||||
{
|
||||
this.npcs.onReload(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMoney(String name) throws UserDoesNotExistException
|
||||
{
|
||||
IUser user = ess.getUser(name);
|
||||
if (user == null)
|
||||
{
|
||||
return getNPCBalance(name);
|
||||
}
|
||||
return user.getMoney();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMoney(String name, double balance) throws NoLoanPermittedException, UserDoesNotExistException
|
||||
{
|
||||
IUser user = ess.getUser(name);
|
||||
if (user == null)
|
||||
{
|
||||
setNPCBalance(name, balance, true);
|
||||
return;
|
||||
}
|
||||
if (balance < 0.0 && !Permissions.ECO_LOAN.isAuthorized(user))
|
||||
{
|
||||
throw new NoLoanPermittedException();
|
||||
}
|
||||
user.setMoney(balance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetBalance(String name) throws NoLoanPermittedException, UserDoesNotExistException
|
||||
{
|
||||
setMoney(name, getStartingBalance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount)
|
||||
{
|
||||
return Util.formatCurrency(amount, ess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerExists(String name)
|
||||
{
|
||||
try
|
||||
{
|
||||
getMoney(name);
|
||||
return true;
|
||||
}
|
||||
catch (UserDoesNotExistException ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNPC(String name) throws UserDoesNotExistException
|
||||
{
|
||||
boolean result = ess.getUser(name) == null;
|
||||
if (result)
|
||||
{
|
||||
getNPCBalance(name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createNPC(String name)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (isNPC(name))
|
||||
{
|
||||
|
||||
setNPCBalance(name, getStartingBalance(), false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (UserDoesNotExistException ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
setNPCBalance(name, getStartingBalance(), false);
|
||||
return true;
|
||||
}
|
||||
catch (UserDoesNotExistException ex1)
|
||||
{
|
||||
//This should never happen!
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNPC(String name) throws UserDoesNotExistException
|
||||
{
|
||||
npcs.acquireWriteLock();
|
||||
try
|
||||
{
|
||||
Map<String, Double> balances = npcs.getData().getBalances();
|
||||
if (balances == null)
|
||||
{
|
||||
balances = new HashMap<String, Double>();
|
||||
npcs.getData().setBalances(balances);
|
||||
}
|
||||
if (balances.containsKey(name.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
balances.remove(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
npcs.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,65 +9,130 @@ import java.util.regex.Pattern;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
|
||||
public final class Enchantments
|
||||
public class Enchantments
|
||||
{
|
||||
|
||||
private Enchantments()
|
||||
{
|
||||
}
|
||||
|
||||
private static final transient Pattern NUMPATTERN = Pattern.compile("\\d+");
|
||||
private static final Map<String, Enchantment> ENCHANTMENTS = new HashMap<String, Enchantment>();
|
||||
private static final Map<String, Enchantment> ALIASENCHANTMENTS = new HashMap<String, Enchantment>();
|
||||
|
||||
static
|
||||
{
|
||||
ENCHANTMENTS.put("alldamage", Enchantment.DAMAGE_ALL);
|
||||
ENCHANTMENTS.put("alldmg", Enchantment.DAMAGE_ALL);
|
||||
ALIASENCHANTMENTS.put("alldmg", Enchantment.DAMAGE_ALL);
|
||||
ENCHANTMENTS.put("sharpness", Enchantment.DAMAGE_ALL);
|
||||
ENCHANTMENTS.put("arthropodsdamage", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ENCHANTMENTS.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("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);
|
||||
|
||||
ENCHANTMENTS.put("durability", Enchantment.DURABILITY);
|
||||
ENCHANTMENTS.put("dura", Enchantment.DURABILITY);
|
||||
ENCHANTMENTS.put("unbreaking", Enchantment.DURABILITY);
|
||||
ALIASENCHANTMENTS.put("d", Enchantment.DURABILITY);
|
||||
|
||||
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);
|
||||
ENCHANTMENTS.put("blockslootbonus", Enchantment.LOOT_BONUS_BLOCKS);
|
||||
ALIASENCHANTMENTS.put("k", Enchantment.KNOCKBACK);
|
||||
|
||||
ALIASENCHANTMENTS.put("blockslootbonus", Enchantment.LOOT_BONUS_BLOCKS);
|
||||
ENCHANTMENTS.put("fortune", Enchantment.LOOT_BONUS_BLOCKS);
|
||||
ENCHANTMENTS.put("mobslootbonus", Enchantment.LOOT_BONUS_MOBS);
|
||||
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);
|
||||
ENCHANTMENTS.put("oxygen", Enchantment.OXYGEN);
|
||||
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);
|
||||
|
||||
ENCHANTMENTS.put("protection", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
ENCHANTMENTS.put("prot", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
ENCHANTMENTS.put("explosionsprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ENCHANTMENTS.put("expprot", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ENCHANTMENTS.put("blastprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ENCHANTMENTS.put("fallprotection", Enchantment.PROTECTION_FALL);
|
||||
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);
|
||||
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);
|
||||
ENCHANTMENTS.put("featherfalling", Enchantment.PROTECTION_FALL);
|
||||
ENCHANTMENTS.put("fireprotection", Enchantment.PROTECTION_FIRE);
|
||||
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);
|
||||
|
||||
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("waterworker", Enchantment.WATER_WORKER);
|
||||
ENCHANTMENTS.put("aquaaffinity", Enchantment.WATER_WORKER);
|
||||
ENCHANTMENTS.put("firearrow", Enchantment.ARROW_FIRE);
|
||||
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);
|
||||
|
||||
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);
|
||||
ENCHANTMENTS.put("arrowkb", Enchantment.ARROW_KNOCKBACK);
|
||||
ENCHANTMENTS.put("infinitearrows", Enchantment.ARROW_INFINITE);
|
||||
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);
|
||||
}
|
||||
|
||||
public static Enchantment getByName(final String name) {
|
||||
public static Enchantment getByName(String name) {
|
||||
Enchantment enchantment;
|
||||
if (NUMPATTERN.matcher(name).matches()) {
|
||||
enchantment = Enchantment.getById(Integer.parseInt(name));
|
||||
@@ -78,6 +143,10 @@ public final class Enchantments
|
||||
{
|
||||
enchantment = ENCHANTMENTS.get(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
if (enchantment == null)
|
||||
{
|
||||
enchantment = ALIASENCHANTMENTS.get(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
return enchantment;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,12 +18,19 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.*;
|
||||
import com.earth2me.essentials.listener.*;
|
||||
import com.earth2me.essentials.api.Economy;
|
||||
import com.earth2me.essentials.api.IJails;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.commands.NoChargeException;
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import com.earth2me.essentials.metrics.Metrics;
|
||||
import com.earth2me.essentials.metrics.MetricsListener;
|
||||
import com.earth2me.essentials.metrics.MetricsStarter;
|
||||
import com.earth2me.essentials.perm.PermissionsHandler;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import com.earth2me.essentials.settings.GroupsHolder;
|
||||
import com.earth2me.essentials.settings.SettingsHolder;
|
||||
import com.earth2me.essentials.user.UserMap;
|
||||
import com.earth2me.essentials.signs.SignBlockListener;
|
||||
import com.earth2me.essentials.signs.SignEntityListener;
|
||||
import com.earth2me.essentials.signs.SignPlayerListener;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
@@ -33,45 +40,50 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
import org.bukkit.plugin.InvalidDescriptionException;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.yaml.snakeyaml.error.YAMLException;
|
||||
|
||||
|
||||
public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
public static final int BUKKIT_VERSION = 1952;
|
||||
public static final int BUKKIT_VERSION = 2352;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient ISettings settings;
|
||||
private final transient TntExplodeListener tntListener = new TntExplodeListener(this);
|
||||
private transient IJails jails;
|
||||
private transient IKits kits;
|
||||
private transient IWarps warps;
|
||||
private transient IWorth worth;
|
||||
private transient List<IReload> reloadList;
|
||||
private transient IBackup backup;
|
||||
private transient IItemDb itemDb;
|
||||
private transient IGroups groups;
|
||||
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);
|
||||
private transient Jails jails;
|
||||
private transient Warps warps;
|
||||
private transient Worth worth;
|
||||
private transient List<IConf> confList;
|
||||
private transient Backup backup;
|
||||
private transient ItemDb itemDb;
|
||||
private transient final Methods paymentMethod = new Methods();
|
||||
//private transient PermissionsHandler permissionsHandler;
|
||||
private transient IUserMap userMap;
|
||||
private transient PermissionsHandler permissionsHandler;
|
||||
private transient AlternativeCommandsHandler alternativeCommandsHandler;
|
||||
private transient UserMap userMap;
|
||||
private transient ExecuteTimer execTimer;
|
||||
private transient I18n i18n;
|
||||
private transient ICommandHandler commandHandler;
|
||||
private transient Economy economy;
|
||||
public transient boolean testing;
|
||||
private transient Metrics metrics;
|
||||
private transient EssentialsTimer timer;
|
||||
private transient List<String> vanishedPlayers = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
public ISettings getSettings()
|
||||
@@ -81,7 +93,6 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
|
||||
public void setupForTesting(final Server server) throws IOException, InvalidDescriptionException
|
||||
{
|
||||
testing = true;
|
||||
final File dataFolder = File.createTempFile("essentialstest", "");
|
||||
if (!dataFolder.delete())
|
||||
{
|
||||
@@ -96,11 +107,11 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
LOGGER.log(Level.INFO, _("usingTempFolderForTesting"));
|
||||
LOGGER.log(Level.INFO, dataFolder.toString());
|
||||
this.initialize(null, server, new PluginDescriptionFile(new FileReader(new File("src" + File.separator + "plugin.yml"))), dataFolder, null, null);
|
||||
settings = new SettingsHolder(this);
|
||||
settings = new Settings(this);
|
||||
i18n.updateLocale("en");
|
||||
userMap = new UserMap(this);
|
||||
//permissionsHandler = new PermissionsHandler(this);
|
||||
economy = new Economy(this);
|
||||
permissionsHandler = new PermissionsHandler(this, false);
|
||||
Economy.setEss(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,19 +126,22 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
for (Plugin plugin : pm.getPlugins())
|
||||
{
|
||||
if (plugin.getDescription().getName().startsWith("Essentials")
|
||||
&& !plugin.getDescription().getVersion().equals(this.getDescription().getVersion()))
|
||||
&& !plugin.getDescription().getVersion().equals(this.getDescription().getVersion())
|
||||
&& !plugin.getDescription().getName().equals("EssentialsAntiCheat"))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("versionMismatch", plugin.getDescription().getName()));
|
||||
}
|
||||
}
|
||||
final Matcher versionMatch = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-R[0-9]+-(?:[0-9]+-g[0-9a-f]+-)?b([0-9]+)jnks.*").matcher(getServer().getVersion());
|
||||
final Matcher versionMatch = Pattern.compile("git-Bukkit-(?:(?:[0-9]+)\\.)+[0-9]+-R[\\.0-9]+-(?:[0-9]+-g[0-9a-f]+-)?b([0-9]+)jnks.*").matcher(getServer().getVersion());
|
||||
if (versionMatch.matches())
|
||||
{
|
||||
final int versionNumber = Integer.parseInt(versionMatch.group(4));
|
||||
if (versionNumber < BUKKIT_VERSION)
|
||||
final int versionNumber = Integer.parseInt(versionMatch.group(1));
|
||||
if (versionNumber < BUKKIT_VERSION && versionNumber > 100)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, " * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! *");
|
||||
LOGGER.log(Level.SEVERE, _("notRecommendedBukkit"));
|
||||
LOGGER.log(Level.SEVERE, _("requiredBukkit", Integer.toString(BUKKIT_VERSION)));
|
||||
LOGGER.log(Level.SEVERE, " * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! *");
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
@@ -141,35 +155,27 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
execTimer.mark("BukkitCheck");
|
||||
try
|
||||
{
|
||||
//final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
|
||||
//upgrade.beforeSettings();
|
||||
//execTimer.mark("Upgrade");
|
||||
reloadList = new ArrayList<IReload>();
|
||||
settings = new SettingsHolder(this);
|
||||
reloadList.add(settings);
|
||||
final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
|
||||
upgrade.beforeSettings();
|
||||
execTimer.mark("Upgrade");
|
||||
confList = new ArrayList<IConf>();
|
||||
settings = new Settings(this);
|
||||
confList.add(settings);
|
||||
execTimer.mark("Settings");
|
||||
//upgrade.afterSettings();
|
||||
//execTimer.mark("Upgrade2");
|
||||
upgrade.afterSettings();
|
||||
execTimer.mark("Upgrade2");
|
||||
i18n.updateLocale(settings.getLocale());
|
||||
userMap = new UserMap(this);
|
||||
reloadList.add(userMap);
|
||||
confList.add(userMap);
|
||||
execTimer.mark("Init(Usermap)");
|
||||
groups = new GroupsHolder(this);
|
||||
reloadList.add((GroupsHolder)groups);
|
||||
warps = new Warps(this);
|
||||
reloadList.add(warps);
|
||||
warps = new Warps(getServer(), this.getDataFolder());
|
||||
confList.add(warps);
|
||||
execTimer.mark("Init(Spawn/Warp)");
|
||||
worth = new Worth(this);
|
||||
reloadList.add(worth);
|
||||
worth = new Worth(this.getDataFolder());
|
||||
confList.add(worth);
|
||||
itemDb = new ItemDb(this);
|
||||
reloadList.add(itemDb);
|
||||
confList.add(itemDb);
|
||||
execTimer.mark("Init(Worth/ItemDB)");
|
||||
kits = new Kits(this);
|
||||
reloadList.add(kits);
|
||||
commandHandler = new EssentialsCommandHandler(Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command", "essentials.", this);
|
||||
reloadList.add(commandHandler);
|
||||
economy = new Economy(this);
|
||||
reloadList.add(economy);
|
||||
reload();
|
||||
}
|
||||
catch (YAMLException exception)
|
||||
@@ -199,10 +205,11 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
return;
|
||||
}
|
||||
backup = new Backup(this);
|
||||
//permissionsHandler = new PermissionsHandler(this);
|
||||
permissionsHandler = new PermissionsHandler(this, settings.useBukkitPermissions());
|
||||
alternativeCommandsHandler = new AlternativeCommandsHandler(this);
|
||||
final EssentialsPluginListener serverListener = new EssentialsPluginListener(this);
|
||||
pm.registerEvents(serverListener, this);
|
||||
reloadList.add(serverListener);
|
||||
confList.add(serverListener);
|
||||
|
||||
final EssentialsPlayerListener playerListener = new EssentialsPlayerListener(this);
|
||||
pm.registerEvents(playerListener, this);
|
||||
@@ -210,29 +217,65 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
final EssentialsBlockListener blockListener = new EssentialsBlockListener(this);
|
||||
pm.registerEvents(blockListener, this);
|
||||
|
||||
final SignBlockListener signBlockListener = new SignBlockListener(this);
|
||||
pm.registerEvents(signBlockListener, this);
|
||||
|
||||
final SignPlayerListener signPlayerListener = new SignPlayerListener(this);
|
||||
pm.registerEvents(signPlayerListener, this);
|
||||
|
||||
final SignEntityListener signEntityListener = new SignEntityListener(this);
|
||||
pm.registerEvents(signEntityListener, this);
|
||||
|
||||
final EssentialsEntityListener entityListener = new EssentialsEntityListener(this);
|
||||
pm.registerEvents(entityListener, this);
|
||||
|
||||
final EssentialsWorldListener worldListener = new EssentialsWorldListener(this);
|
||||
pm.registerEvents(worldListener, this);
|
||||
|
||||
//TODO: Check if this should be here, and not above before reload()
|
||||
jails = new Jails(this);
|
||||
reloadList.add(jails);
|
||||
confList.add(jails);
|
||||
|
||||
pm.registerEvents(tntListener, this);
|
||||
|
||||
timer = new EssentialsTimer(this);
|
||||
getScheduler().scheduleSyncRepeatingTask(this, timer, 100, 100);
|
||||
|
||||
final EssentialsTimer timer = new EssentialsTimer(this);
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100);
|
||||
Economy.setEss(this);
|
||||
execTimer.mark("RegListeners");
|
||||
|
||||
final MetricsStarter metricsStarter = new MetricsStarter(this);
|
||||
if (metricsStarter.getStart() != null && metricsStarter.getStart() == true)
|
||||
{
|
||||
getScheduler().scheduleAsyncDelayedTask(this, metricsStarter, 1);
|
||||
}
|
||||
else if (metricsStarter.getStart() != null && metricsStarter.getStart() == false)
|
||||
{
|
||||
final MetricsListener metricsListener = new MetricsListener(this, metricsStarter);
|
||||
pm.registerEvents(metricsListener, this);
|
||||
}
|
||||
|
||||
final String timeroutput = execTimer.end();
|
||||
if (getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials load {0}", timeroutput);
|
||||
LOGGER.log(Level.INFO, "Essentials load " + timeroutput);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
for (Player p : getServer().getOnlinePlayers())
|
||||
{
|
||||
User user = getUser(p);
|
||||
if (user.isVanished())
|
||||
{
|
||||
user.toggleVanished();
|
||||
p.sendMessage(_("unvanishedReload"));
|
||||
}
|
||||
}
|
||||
i18n.onDisable();
|
||||
Economy.setEss(null);
|
||||
Trade.closeLog();
|
||||
}
|
||||
|
||||
@@ -241,10 +284,10 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
Trade.closeLog();
|
||||
|
||||
for (IReload iReload : reloadList)
|
||||
for (IConf iConf : confList)
|
||||
{
|
||||
iReload.onReload();
|
||||
execTimer.mark("Reload(" + iReload.getClass().getSimpleName() + ")");
|
||||
iConf.reloadConfig();
|
||||
execTimer.mark("Reload(" + iConf.getClass().getSimpleName() + ")");
|
||||
}
|
||||
|
||||
i18n.updateLocale(settings.getLocale());
|
||||
@@ -253,8 +296,132 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender sender, final Command command, final String commandLabel, final String[] args)
|
||||
{
|
||||
return commandHandler.handleCommand(sender, command, commandLabel, args);
|
||||
//return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command", "essentials.", null);
|
||||
return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command", "essentials.", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommandEssentials(final CommandSender sender, final Command command, final String commandLabel, final String[] args, final ClassLoader classLoader, final String commandPath, final String permissionPrefix, final IEssentialsModule module)
|
||||
{
|
||||
// Allow plugins to override the command via onCommand
|
||||
if (!getSettings().isCommandOverridden(command.getName()) && (!commandLabel.startsWith("e") || commandLabel.equalsIgnoreCase(command.getName())))
|
||||
{
|
||||
final PluginCommand pc = alternativeCommandsHandler.getAlternative(commandLabel);
|
||||
if (pc != null)
|
||||
{
|
||||
alternativeCommandsHandler.executed(commandLabel, pc.getLabel());
|
||||
try
|
||||
{
|
||||
return pc.execute(sender, commandLabel, args);
|
||||
}
|
||||
catch (final Exception ex)
|
||||
{
|
||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||
sender.sendMessage(ChatColor.RED + "An internal error occurred while attempting to perform this command");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
User user = null;
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
user = getUser(sender);
|
||||
}
|
||||
|
||||
// New mail notification
|
||||
if (user != null && !getSettings().isCommandDisabled("mail") && !commandLabel.equals("mail") && user.isAuthorized("essentials.mail"))
|
||||
{
|
||||
final List<String> mail = user.getMails();
|
||||
if (mail != null && !mail.isEmpty())
|
||||
{
|
||||
user.sendMessage(_("youHaveNewMail", mail.size()));
|
||||
}
|
||||
}
|
||||
|
||||
// Check for disabled commands
|
||||
if (getSettings().isCommandDisabled(commandLabel))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
IEssentialsCommand cmd;
|
||||
try
|
||||
{
|
||||
cmd = (IEssentialsCommand)classLoader.loadClass(commandPath + command.getName()).newInstance();
|
||||
cmd.setEssentials(this);
|
||||
cmd.setEssentialsModule(module);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
sender.sendMessage(_("commandNotLoaded", commandLabel));
|
||||
LOGGER.log(Level.SEVERE, _("commandNotLoaded", commandLabel), ex);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check authorization
|
||||
if (user != null && !user.isAuthorized(cmd, permissionPrefix))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("deniedAccessCommand", user.getName()));
|
||||
user.sendMessage(_("noAccessCommand"));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Run the command
|
||||
try
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
cmd.run(getServer(), sender, commandLabel, command, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.run(getServer(), user, commandLabel, command, args);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (NoChargeException ex)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
catch (NotEnoughArgumentsException ex)
|
||||
{
|
||||
sender.sendMessage(command.getDescription());
|
||||
sender.sendMessage(command.getUsage().replaceAll("<command>", commandLabel));
|
||||
if (!ex.getMessage().isEmpty())
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
showError(sender, ex, commandLabel);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, _("commandFailed", commandLabel), ex);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showError(final CommandSender sender, final Throwable exception, final String commandLabel)
|
||||
{
|
||||
sender.sendMessage(_("errorWithMessage", exception.getMessage()));
|
||||
if (getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("errorCallingCommand", commandLabel), exception);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BukkitScheduler getScheduler()
|
||||
{
|
||||
return this.getServer().getScheduler();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -264,39 +431,92 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
|
||||
@Override
|
||||
public IKits getKits()
|
||||
{
|
||||
return kits;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWarps getWarps()
|
||||
public Warps getWarps()
|
||||
{
|
||||
return warps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWorth getWorth()
|
||||
public Worth getWorth()
|
||||
{
|
||||
return worth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBackup getBackup()
|
||||
public Backup getBackup()
|
||||
{
|
||||
return backup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IUser getUser(final Player player)
|
||||
public Metrics getMetrics()
|
||||
{
|
||||
return userMap.getUser(player);
|
||||
return metrics;
|
||||
}
|
||||
|
||||
public void setMetrics(Metrics metrics)
|
||||
{
|
||||
this.metrics = metrics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IUser getUser(final String playerName)
|
||||
public User getUser(final Object base)
|
||||
{
|
||||
return userMap.getUser(playerName);
|
||||
if (base instanceof Player)
|
||||
{
|
||||
return getUser((Player)base);
|
||||
}
|
||||
if (base instanceof String)
|
||||
{
|
||||
final User user = userMap.getUser((String)base);
|
||||
if (user != null && user.getBase() instanceof OfflinePlayer)
|
||||
{
|
||||
((OfflinePlayer)user.getBase()).setName((String)base);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private <T extends Player> User getUser(final T base)
|
||||
{
|
||||
if (base == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (base instanceof User)
|
||||
{
|
||||
return (User)base;
|
||||
}
|
||||
|
||||
if (userMap == null)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "Essentials userMap not initialized");
|
||||
return null;
|
||||
}
|
||||
|
||||
User user = userMap.getUser(base.getName());
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
user = new User(base, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.update(base);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getOfflineUser(final String name)
|
||||
{
|
||||
final User user = userMap.getUser(name);
|
||||
if (user != null && user.getBase() instanceof OfflinePlayer)
|
||||
{
|
||||
((OfflinePlayer)user.getBase()).setName(name);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -314,9 +534,9 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addReloadListener(final IReload listener)
|
||||
public void addReloadListener(final IConf listener)
|
||||
{
|
||||
reloadList.add(listener);
|
||||
confList.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -340,8 +560,8 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
|
||||
for (Player player : players)
|
||||
{
|
||||
final IUser user = getUser(player);
|
||||
if (!user.isIgnoringPlayer(sender.getName()))
|
||||
final User user = getUser(player);
|
||||
if (!user.isIgnoredPlayer(sender))
|
||||
{
|
||||
player.sendMessage(message);
|
||||
}
|
||||
@@ -353,47 +573,53 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
@Override
|
||||
public int scheduleAsyncDelayedTask(final Runnable run)
|
||||
{
|
||||
return this.getServer().getScheduler().scheduleAsyncDelayedTask(this, run);
|
||||
return this.getScheduler().scheduleAsyncDelayedTask(this, run);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleSyncDelayedTask(final Runnable run)
|
||||
{
|
||||
return this.getServer().getScheduler().scheduleSyncDelayedTask(this, run);
|
||||
return this.getScheduler().scheduleSyncDelayedTask(this, run);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleSyncDelayedTask(final Runnable run, final long delay)
|
||||
{
|
||||
return this.getServer().getScheduler().scheduleSyncDelayedTask(this, run, delay);
|
||||
return this.getScheduler().scheduleSyncDelayedTask(this, run, delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleSyncRepeatingTask(final Runnable run, final long delay, final long period)
|
||||
{
|
||||
return this.getServer().getScheduler().scheduleSyncRepeatingTask(this, run, delay, period);
|
||||
return this.getScheduler().scheduleSyncRepeatingTask(this, run, delay, period);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TntExplodeListener getTNTListener()
|
||||
public TNTExplodeListener getTNTListener()
|
||||
{
|
||||
return tntListener;
|
||||
}
|
||||
|
||||
/*@Override
|
||||
@Override
|
||||
public PermissionsHandler getPermissionsHandler()
|
||||
{
|
||||
return permissionsHandler;
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDb getItemDb()
|
||||
public AlternativeCommandsHandler getAlternativeCommandsHandler()
|
||||
{
|
||||
return alternativeCommandsHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemDb getItemDb()
|
||||
{
|
||||
return itemDb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IUserMap getUserMap()
|
||||
public UserMap getUserMap()
|
||||
{
|
||||
return userMap;
|
||||
}
|
||||
@@ -405,32 +631,59 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGroups getGroups()
|
||||
public EssentialsTimer getTimer()
|
||||
{
|
||||
return groups;
|
||||
return timer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICommandHandler getCommandHandler()
|
||||
public List<String> getVanishedPlayers()
|
||||
{
|
||||
return commandHandler;
|
||||
return vanishedPlayers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroups(final IGroups groups)
|
||||
{
|
||||
this.groups = groups;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeReloadListener(IReload groups)
|
||||
private static class EssentialsWorldListener implements Listener, Runnable
|
||||
{
|
||||
this.reloadList.remove(groups);
|
||||
}
|
||||
private transient final IEssentials ess;
|
||||
|
||||
@Override
|
||||
public IEconomy getEconomy()
|
||||
{
|
||||
return economy;
|
||||
public EssentialsWorldListener(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onWorldLoad(final WorldLoadEvent event)
|
||||
{
|
||||
ess.getJails().onReload();
|
||||
ess.getWarps().reloadConfig();
|
||||
for (IConf iConf : ((Essentials)ess).confList)
|
||||
{
|
||||
if (iConf instanceof IEssentialsModule)
|
||||
{
|
||||
iConf.reloadConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onWorldUnload(final WorldUnloadEvent event)
|
||||
{
|
||||
ess.getJails().onReload();
|
||||
ess.getWarps().reloadConfig();
|
||||
for (IConf iConf : ((Essentials)ess).confList)
|
||||
{
|
||||
if (iConf instanceof IEssentialsModule)
|
||||
{
|
||||
iConf.reloadConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
ess.reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-16
@@ -1,8 +1,5 @@
|
||||
package com.earth2me.essentials.listener;
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -17,26 +14,21 @@ public class EssentialsBlockListener implements Listener
|
||||
|
||||
public EssentialsBlockListener(final IEssentials ess)
|
||||
{
|
||||
super();
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockPlace(final BlockPlaceEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Do not rely on getItemInHand();
|
||||
// http://leaky.bukkit.org/issues/663
|
||||
final ItemStack itemstack = Util.convertBlockToItem(event.getBlockPlaced());
|
||||
if (itemstack == null)
|
||||
// http://leaky.bukkit.org/issues/663
|
||||
final ItemStack is = Util.convertBlockToItem(event.getBlockPlaced());
|
||||
if (is == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
final boolean unlimitedForUser = user.getData().hasUnlimited(itemstack.getType());
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final boolean unlimitedForUser = user.hasUnlimited(is);
|
||||
if (unlimitedForUser && user.getGameMode() == GameMode.SURVIVAL)
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
@@ -45,7 +37,7 @@ public class EssentialsBlockListener implements Listener
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
user.getInventory().addItem(itemstack);
|
||||
user.getInventory().addItem(is);
|
||||
user.updateInventory();
|
||||
}
|
||||
});
|
||||
@@ -1,316 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.*;
|
||||
import com.earth2me.essentials.commands.EssentialsCommand;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.commands.NoChargeException;
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.PluginCommandYamlParser;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public class EssentialsCommandHandler implements ICommandHandler
|
||||
{
|
||||
private final transient ClassLoader classLoader;
|
||||
private final transient String commandPath;
|
||||
private final transient String permissionPrefix;
|
||||
private final transient IEssentialsModule module;
|
||||
private static final transient Logger LOGGER = Bukkit.getLogger();
|
||||
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 Map<String, IEssentialsCommand> commands = new HashMap<String, IEssentialsCommand>();
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public EssentialsCommandHandler(ClassLoader classLoader, String commandPath, String permissionPrefix, IEssentials ess)
|
||||
{
|
||||
this(classLoader, commandPath, permissionPrefix, null, ess);
|
||||
}
|
||||
|
||||
public EssentialsCommandHandler(ClassLoader classLoader, String commandPath, String permissionPrefix, IEssentialsModule module, IEssentials ess)
|
||||
{
|
||||
this.classLoader = classLoader;
|
||||
this.commandPath = commandPath;
|
||||
this.permissionPrefix = permissionPrefix;
|
||||
this.module = module;
|
||||
this.ess = ess;
|
||||
for (Plugin plugin : ess.getServer().getPluginManager().getPlugins())
|
||||
{
|
||||
if (plugin.isEnabled())
|
||||
{
|
||||
addPlugin(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleCommand(final CommandSender sender, final Command command, final String commandLabel, final String[] args)
|
||||
{
|
||||
boolean disabled = false;
|
||||
boolean overridden = false;
|
||||
ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
try
|
||||
{
|
||||
disabled = settings.getData().getCommands().isDisabled(command.getName());
|
||||
overridden = !disabled || settings.getData().getCommands().isOverridden(command.getName());
|
||||
}
|
||||
finally
|
||||
{
|
||||
settings.unlock();
|
||||
}
|
||||
// Allow plugins to override the command via onCommand
|
||||
if (!overridden && (!commandLabel.startsWith("e") || commandLabel.equalsIgnoreCase(command.getName())))
|
||||
{
|
||||
final PluginCommand pc = getAlternative(commandLabel);
|
||||
if (pc != null)
|
||||
{
|
||||
|
||||
executed(commandLabel, pc.getLabel());
|
||||
try
|
||||
{
|
||||
return pc.execute(sender, commandLabel, args);
|
||||
}
|
||||
catch (final Exception ex)
|
||||
{
|
||||
final ArrayList<StackTraceElement> elements = new ArrayList<StackTraceElement>(Arrays.asList(ex.getStackTrace()));
|
||||
elements.remove(0);
|
||||
final ArrayList<StackTraceElement> toRemove = new ArrayList<StackTraceElement>();
|
||||
for (final StackTraceElement e : elements)
|
||||
{
|
||||
if (e.getClassName().equals("com.earth2me.essentials.Essentials"))
|
||||
{
|
||||
toRemove.add(e);
|
||||
}
|
||||
}
|
||||
elements.removeAll(toRemove);
|
||||
final StackTraceElement[] trace = elements.toArray(new StackTraceElement[elements.size()]);
|
||||
ex.setStackTrace(trace);
|
||||
ex.printStackTrace();
|
||||
sender.sendMessage(ChatColor.RED + "An internal error occurred while attempting to perform this command");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
IUser user = null;
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
user = ess.getUser((Player)sender);
|
||||
LOGGER.log(Level.INFO, String.format("[PLAYER_COMMAND] %s: /%s %s ", ((Player)sender).getName(), commandLabel, EssentialsCommand.getFinalArg(args, 0)));
|
||||
}
|
||||
|
||||
// Check for disabled commands
|
||||
if (disabled)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
final String commandName = command.getName().toLowerCase(Locale.ENGLISH);
|
||||
IEssentialsCommand cmd = commands.get(commandName);
|
||||
if (cmd == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd = (IEssentialsCommand)classLoader.loadClass(commandPath + commandName).newInstance();
|
||||
cmd.init(ess, commandName);
|
||||
cmd.setEssentialsModule(module);
|
||||
commands.put(commandName, cmd);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
sender.sendMessage(_("commandNotLoaded", commandName));
|
||||
LOGGER.log(Level.SEVERE, _("commandNotLoaded", commandName), ex);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check authorization
|
||||
if (sender != null && cmd.isAuthorized(sender))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("deniedAccessCommand", user.getName()));
|
||||
user.sendMessage(_("noAccessCommand"));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Run the command
|
||||
try
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
cmd.run(sender, command, commandLabel, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.acquireReadLock();
|
||||
try
|
||||
{
|
||||
cmd.run(user, command, commandLabel, args);
|
||||
}
|
||||
finally
|
||||
{
|
||||
user.unlock();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (NoChargeException ex)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
catch (NotEnoughArgumentsException ex)
|
||||
{
|
||||
sender.sendMessage(command.getDescription());
|
||||
sender.sendMessage(command.getUsage().replaceAll("<command>", commandLabel));
|
||||
if (!ex.getMessage().isEmpty())
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
showCommandError(sender, commandLabel, ex);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, _("commandFailed", commandLabel), ex);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showCommandError(final CommandSender sender, final String commandLabel, final Throwable exception)
|
||||
{
|
||||
sender.sendMessage(_("errorWithMessage", exception.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("errorCallingCommand", commandLabel), exception);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReload()
|
||||
{
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 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 void executed(final String label, final String otherLabel)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials: Alternative command " + label + " found, using " + otherLabel);
|
||||
}
|
||||
disabledList.put(label, otherLabel);
|
||||
}
|
||||
|
||||
public Map<String, String> disabledCommands()
|
||||
{
|
||||
return disabledList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,664 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.google.common.io.Files;
|
||||
import java.io.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
|
||||
public class EssentialsConf extends YamlConfiguration
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient File configFile;
|
||||
private transient String templateName = null;
|
||||
private transient Class<?> resourceClass = EssentialsConf.class;
|
||||
private static final Charset UTF8 = Charset.forName("UTF-8");
|
||||
|
||||
public EssentialsConf(final File configFile)
|
||||
{
|
||||
super();
|
||||
this.configFile = configFile;
|
||||
}
|
||||
private final byte[] bytebuffer = new byte[1024];
|
||||
|
||||
public synchronized void load()
|
||||
{
|
||||
configFile = configFile.getAbsoluteFile();
|
||||
if (!configFile.getParentFile().exists())
|
||||
{
|
||||
if (!configFile.getParentFile().mkdirs())
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()));
|
||||
}
|
||||
}
|
||||
// This will delete files where the first character is 0. In most cases they are broken.
|
||||
if (configFile.exists() && configFile.length() != 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
final InputStream input = new FileInputStream(configFile);
|
||||
try
|
||||
{
|
||||
if (input.read() == 0)
|
||||
{
|
||||
input.close();
|
||||
configFile.delete();
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
input.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (!configFile.exists())
|
||||
{
|
||||
if (templateName != null)
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("creatingConfigFromTemplate", configFile.toString()));
|
||||
createFromTemplate();
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
final FileInputStream inputStream = new FileInputStream(configFile);
|
||||
try
|
||||
{
|
||||
final ByteBuffer buffer = ByteBuffer.allocate((int)configFile.length());
|
||||
int length;
|
||||
while ((length = inputStream.read(bytebuffer)) != -1)
|
||||
{
|
||||
buffer.put(bytebuffer, 0, length);
|
||||
}
|
||||
buffer.rewind();
|
||||
final CharBuffer data = CharBuffer.allocate((int)configFile.length());
|
||||
CharsetDecoder decoder = UTF8.newDecoder();
|
||||
CoderResult result = decoder.decode(buffer, data, true);
|
||||
if (result.isError())
|
||||
{
|
||||
buffer.rewind();
|
||||
data.clear();
|
||||
LOGGER.log(Level.INFO, "File " + configFile.getAbsolutePath().toString() + " is not utf-8 encoded, trying " + Charset.defaultCharset().displayName());
|
||||
decoder = Charset.defaultCharset().newDecoder();
|
||||
result = decoder.decode(buffer, data, true);
|
||||
if (result.isError())
|
||||
{
|
||||
throw new InvalidConfigurationException("Invalid Characters in file " + configFile.getAbsolutePath().toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
decoder.flush(data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
decoder.flush(data);
|
||||
}
|
||||
final int end = data.position();
|
||||
data.rewind();
|
||||
super.loadFromString(data.subSequence(0, end).toString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
|
||||
}
|
||||
catch (InvalidConfigurationException ex)
|
||||
{
|
||||
File broken = new File(configFile.getAbsolutePath() + ".broken." + System.currentTimeMillis());
|
||||
configFile.renameTo(broken);
|
||||
LOGGER.log(Level.SEVERE, "The file " + configFile.toString() + " is broken, it has been renamed to " + broken.toString(), ex.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
private void createFromTemplate()
|
||||
{
|
||||
InputStream istr = null;
|
||||
OutputStream ostr = null;
|
||||
try
|
||||
{
|
||||
istr = resourceClass.getResourceAsStream(templateName);
|
||||
if (istr == null)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, _("couldNotFindTemplate", templateName));
|
||||
return;
|
||||
}
|
||||
ostr = new FileOutputStream(configFile);
|
||||
byte[] buffer = new byte[1024];
|
||||
int length = 0;
|
||||
length = istr.read(buffer);
|
||||
while (length > 0)
|
||||
{
|
||||
ostr.write(buffer, 0, length);
|
||||
length = istr.read(buffer);
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, _("failedToWriteConfig", configFile.toString()), ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (istr != null)
|
||||
{
|
||||
istr.close();
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.getLogger(EssentialsConf.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
try
|
||||
{
|
||||
if (ostr != null)
|
||||
{
|
||||
ostr.close();
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, _("failedToCloseConfig", configFile.toString()), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTemplateName(final String templateName)
|
||||
{
|
||||
this.templateName = templateName;
|
||||
}
|
||||
|
||||
public File getFile()
|
||||
{
|
||||
return configFile;
|
||||
}
|
||||
|
||||
public void setTemplateName(final String templateName, final Class<?> resClass)
|
||||
{
|
||||
this.templateName = templateName;
|
||||
this.resourceClass = resClass;
|
||||
}
|
||||
|
||||
public boolean hasProperty(final String path)
|
||||
{
|
||||
return isSet(path);
|
||||
}
|
||||
|
||||
public Location getLocation(final String path, final Server server) throws Exception
|
||||
{
|
||||
final String worldName = getString((path == null ? "" : path + ".") + "world");
|
||||
if (worldName == null || worldName.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
final World world = server.getWorld(worldName);
|
||||
if (world == null)
|
||||
{
|
||||
throw new Exception(_("invalidWorld"));
|
||||
}
|
||||
return new Location(world,
|
||||
getDouble((path == null ? "" : path + ".") + "x", 0),
|
||||
getDouble((path == null ? "" : path + ".") + "y", 0),
|
||||
getDouble((path == null ? "" : path + ".") + "z", 0),
|
||||
(float)getDouble((path == null ? "" : path + ".") + "yaw", 0),
|
||||
(float)getDouble((path == null ? "" : path + ".") + "pitch", 0));
|
||||
}
|
||||
|
||||
public void setProperty(final String path, final Location loc)
|
||||
{
|
||||
set((path == null ? "" : path + ".") + "world", loc.getWorld().getName());
|
||||
set((path == null ? "" : path + ".") + "x", loc.getX());
|
||||
set((path == null ? "" : path + ".") + "y", loc.getY());
|
||||
set((path == null ? "" : path + ".") + "z", loc.getZ());
|
||||
set((path == null ? "" : path + ".") + "yaw", loc.getYaw());
|
||||
set((path == null ? "" : path + ".") + "pitch", loc.getPitch());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack(final String path)
|
||||
{
|
||||
final ItemStack stack = new ItemStack(
|
||||
Material.valueOf(getString(path + ".type", "AIR")),
|
||||
getInt(path + ".amount", 1),
|
||||
(short)getInt(path + ".damage", 0));
|
||||
final ConfigurationSection enchants = getConfigurationSection(path + ".enchant");
|
||||
if (enchants != null)
|
||||
{
|
||||
for (String enchant : enchants.getKeys(false))
|
||||
{
|
||||
final Enchantment enchantment = Enchantment.getByName(enchant.toUpperCase(Locale.ENGLISH));
|
||||
if (enchantment == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final int level = getInt(path + ".enchant." + enchant, enchantment.getStartLevel());
|
||||
stack.addUnsafeEnchantment(enchantment, level);
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
/*
|
||||
* ,
|
||||
* (byte)getInt(path + ".data", 0)
|
||||
*/
|
||||
}
|
||||
|
||||
public void setProperty(final String path, final ItemStack stack)
|
||||
{
|
||||
final Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("type", stack.getType().toString());
|
||||
map.put("amount", stack.getAmount());
|
||||
map.put("damage", stack.getDurability());
|
||||
Map<Enchantment, Integer> enchantments = stack.getEnchantments();
|
||||
if (!enchantments.isEmpty())
|
||||
{
|
||||
Map<String, Integer> enchant = new HashMap<String, Integer>();
|
||||
for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet())
|
||||
{
|
||||
enchant.put(entry.getKey().getName().toLowerCase(Locale.ENGLISH), entry.getValue());
|
||||
}
|
||||
map.put("enchant", enchant);
|
||||
}
|
||||
// getData().getData() is broken
|
||||
//map.put("data", stack.getDurability());
|
||||
set(path, map);
|
||||
}
|
||||
|
||||
public long getLong(final String path, final long def)
|
||||
{
|
||||
try
|
||||
{
|
||||
final Number num = (Number)get(path);
|
||||
return num == null ? def : num.longValue();
|
||||
}
|
||||
catch (ClassCastException ex)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(final String path, final double def)
|
||||
{
|
||||
try
|
||||
{
|
||||
Number num = (Number)get(path);
|
||||
return num == null ? def : num.doubleValue();
|
||||
}
|
||||
catch (ClassCastException ex)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
try
|
||||
{
|
||||
save(configFile);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void save(final File file) throws IOException
|
||||
{
|
||||
if (file == null)
|
||||
{
|
||||
throw new IllegalArgumentException("File cannot be null");
|
||||
}
|
||||
|
||||
Files.createParentDirs(file);
|
||||
|
||||
final String data = saveToString();
|
||||
|
||||
if (data.length() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!configFile.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("creatingEmptyConfig", configFile.toString()));
|
||||
if (!configFile.createNewFile())
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()));
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()), ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), UTF8);
|
||||
|
||||
try
|
||||
{
|
||||
writer.write(data);
|
||||
}
|
||||
finally
|
||||
{
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
public Object getProperty(String path)
|
||||
{
|
||||
return get(path);
|
||||
}
|
||||
|
||||
public void setProperty(String path, Object object)
|
||||
{
|
||||
set(path, object);
|
||||
}
|
||||
|
||||
public void removeProperty(String path)
|
||||
{
|
||||
set(path, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Object get(String path)
|
||||
{
|
||||
return super.get(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Object get(String path, Object def)
|
||||
{
|
||||
return super.get(path, def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean getBoolean(String path)
|
||||
{
|
||||
return super.getBoolean(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean getBoolean(String path, boolean def)
|
||||
{
|
||||
return super.getBoolean(path, def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<Boolean> getBooleanList(String path)
|
||||
{
|
||||
return super.getBooleanList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<Byte> getByteList(String path)
|
||||
{
|
||||
return super.getByteList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<Character> getCharacterList(String path)
|
||||
{
|
||||
return super.getCharacterList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ConfigurationSection getConfigurationSection(String path)
|
||||
{
|
||||
return super.getConfigurationSection(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized double getDouble(String path)
|
||||
{
|
||||
return super.getDouble(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<Double> getDoubleList(String path)
|
||||
{
|
||||
return super.getDoubleList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<Float> getFloatList(String path)
|
||||
{
|
||||
return super.getFloatList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized int getInt(String path)
|
||||
{
|
||||
return super.getInt(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized int getInt(String path, int def)
|
||||
{
|
||||
return super.getInt(path, def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<Integer> getIntegerList(String path)
|
||||
{
|
||||
return super.getIntegerList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ItemStack getItemStack(String path, ItemStack def)
|
||||
{
|
||||
return super.getItemStack(path, def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Set<String> getKeys(boolean deep)
|
||||
{
|
||||
return super.getKeys(deep);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<?> getList(String path)
|
||||
{
|
||||
return super.getList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<?> getList(String path, List<?> def)
|
||||
{
|
||||
return super.getList(path, def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized long getLong(String path)
|
||||
{
|
||||
return super.getLong(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<Long> getLongList(String path)
|
||||
{
|
||||
return super.getLongList(path);
|
||||
}
|
||||
|
||||
public synchronized Map<String, Object> getMap()
|
||||
{
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<Map<?, ?>> getMapList(String path)
|
||||
{
|
||||
return super.getMapList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized OfflinePlayer getOfflinePlayer(String path)
|
||||
{
|
||||
return super.getOfflinePlayer(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized OfflinePlayer getOfflinePlayer(String path, OfflinePlayer def)
|
||||
{
|
||||
return super.getOfflinePlayer(path, def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<Short> getShortList(String path)
|
||||
{
|
||||
return super.getShortList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized String getString(String path)
|
||||
{
|
||||
return super.getString(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized String getString(String path, String def)
|
||||
{
|
||||
return super.getString(path, def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List<String> getStringList(String path)
|
||||
{
|
||||
return super.getStringList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Map<String, Object> getValues(boolean deep)
|
||||
{
|
||||
return super.getValues(deep);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Vector getVector(String path)
|
||||
{
|
||||
return super.getVector(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Vector getVector(String path, Vector def)
|
||||
{
|
||||
return super.getVector(path, def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isBoolean(String path)
|
||||
{
|
||||
return super.isBoolean(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isConfigurationSection(String path)
|
||||
{
|
||||
return super.isConfigurationSection(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isDouble(String path)
|
||||
{
|
||||
return super.isDouble(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isInt(String path)
|
||||
{
|
||||
return super.isInt(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isItemStack(String path)
|
||||
{
|
||||
return super.isItemStack(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isList(String path)
|
||||
{
|
||||
return super.isList(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isLong(String path)
|
||||
{
|
||||
return super.isLong(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isOfflinePlayer(String path)
|
||||
{
|
||||
return super.isOfflinePlayer(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isSet(String path)
|
||||
{
|
||||
return super.isSet(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isString(String path)
|
||||
{
|
||||
return super.isString(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isVector(String path)
|
||||
{
|
||||
return super.isVector(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void set(String path, Object value)
|
||||
{
|
||||
super.set(path, value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class EssentialsEntityListener implements Listener
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final IEssentials ess;
|
||||
|
||||
public EssentialsEntityListener(IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onEntityDamage(final EntityDamageByEntityEvent event)
|
||||
{
|
||||
final Entity eAttack = event.getDamager();
|
||||
final Entity eDefend = event.getEntity();
|
||||
if (eDefend instanceof Player && eAttack instanceof Player)
|
||||
{
|
||||
final User defender = ess.getUser(eDefend);
|
||||
final User attacker = ess.getUser(eAttack);
|
||||
|
||||
if (ess.getSettings().getLoginAttackDelay() > 0 && !attacker.isAuthorized("essentials.pvpdelay.exempt")
|
||||
&& (System.currentTimeMillis() < (attacker.getLastLogin() + ess.getSettings().getLoginAttackDelay())))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (attacker.hasInvulnerabilityAfterTeleport() || defender.hasInvulnerabilityAfterTeleport())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (attacker.isGodModeEnabled() && !attacker.isAuthorized("essentials.god.pvp"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
attacker.updateActivity(true);
|
||||
final List<String> commandList = attacker.getPowertool(attacker.getItemInHand());
|
||||
if (commandList != null && !commandList.isEmpty())
|
||||
{
|
||||
for (final String command : commandList)
|
||||
{
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
attacker.getServer().dispatchCommand(attacker.getBase(), command.replaceAll("\\{player\\}", defender.getName()));
|
||||
LOGGER.log(Level.INFO, String.format("[PT] %s issued server command: /%s", attacker.getName(), command));
|
||||
}
|
||||
});
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (eAttack instanceof Player)
|
||||
{
|
||||
final User player = ess.getUser(eAttack);
|
||||
player.updateActivity(true);
|
||||
if (eDefend instanceof Ageable)
|
||||
{
|
||||
final ItemStack hand = player.getItemInHand();
|
||||
if (hand != null && hand.getType() == Material.MILK_BUCKET)
|
||||
{
|
||||
((Ageable)eDefend).setBaby();
|
||||
hand.setType(Material.BUCKET);
|
||||
player.setItemInHand(hand);
|
||||
player.updateInventory();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityDamage(final EntityDamageEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
final Player player = (Player)event.getEntity();
|
||||
player.setFireTicks(0);
|
||||
player.setRemainingAir(player.getMaximumAir());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityCombust(final EntityCombustEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@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)
|
||||
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 onFoodLevelChange(final FoodLevelChangeEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
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(event.getEntity()).isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPotionSplashEvent(final PotionSplashEvent event)
|
||||
{
|
||||
for (LivingEntity entity : event.getAffectedEntities())
|
||||
{
|
||||
if (entity instanceof Player && ess.getUser(entity).isGodModeEnabled())
|
||||
{
|
||||
event.setIntensity(entity, 0d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,541 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.textreader.IText;
|
||||
import com.earth2me.essentials.textreader.KeywordReplacer;
|
||||
import com.earth2me.essentials.textreader.TextInput;
|
||||
import com.earth2me.essentials.textreader.TextPager;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class EssentialsPlayerListener implements Listener
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final transient IEssentials ess;
|
||||
private static final int AIR = Material.AIR.getId();
|
||||
private static final int BED = Material.BED_BLOCK.getId();
|
||||
|
||||
public EssentialsPlayerListener(final IEssentials parent)
|
||||
{
|
||||
this.ess = parent;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerRespawn(final PlayerRespawnEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
updateCompass(user);
|
||||
user.setDisplayNick();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerChat(final AsyncPlayerChatEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isMuted())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
user.sendMessage(_("playerMuted"));
|
||||
LOGGER.info(_("mutedUserSpeaks", user.getName()));
|
||||
}
|
||||
final Iterator<Player> it = event.getRecipients().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
final User u = ess.getUser(it.next());
|
||||
if (u.isIgnoredPlayer(user))
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
user.updateActivity(true);
|
||||
user.setDisplayNick();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerMove(final PlayerMoveEvent event)
|
||||
{
|
||||
if ((!ess.getSettings().cancelAfkOnMove() && !ess.getSettings().getFreezeAfkPlayers())
|
||||
|| event.getFrom().getBlockX() == event.getTo().getBlockX()
|
||||
&& event.getFrom().getBlockZ() == event.getTo().getBlockZ()
|
||||
&& event.getFrom().getBlockY() == event.getTo().getBlockY())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
final Location from = event.getFrom();
|
||||
final Location origTo = event.getTo();
|
||||
final Location to = origTo.clone();
|
||||
if (ess.getSettings().cancelAfkOnMove() && origTo.getY() >= from.getBlockY() + 1)
|
||||
{
|
||||
user.updateActivity(true);
|
||||
return;
|
||||
}
|
||||
to.setX(from.getX());
|
||||
to.setY(from.getY());
|
||||
to.setZ(from.getZ());
|
||||
try
|
||||
{
|
||||
event.setTo(Util.getSafeDestination(to));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
event.setTo(to);
|
||||
}
|
||||
return;
|
||||
}
|
||||
final Location afk = user.getAfkPosition();
|
||||
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9)
|
||||
{
|
||||
user.updateActivity(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerQuit(final PlayerQuitEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (ess.getSettings().removeGodOnDisconnect() && user.isGodModeEnabled())
|
||||
{
|
||||
user.setGodModeEnabled(false);
|
||||
}
|
||||
if (user.isVanished())
|
||||
{
|
||||
user.toggleVanished();
|
||||
}
|
||||
if (!user.isJailed())
|
||||
{
|
||||
user.setLastLocation();
|
||||
}
|
||||
user.updateActivity(false);
|
||||
user.dispose();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
ess.scheduleAsyncDelayedTask(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
delayedJoin(event.getPlayer());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void delayedJoin(final Player player)
|
||||
{
|
||||
if (!player.isOnline())
|
||||
{
|
||||
return;
|
||||
}
|
||||
ess.getBackup().onPlayerJoin();
|
||||
final User user = ess.getUser(player);
|
||||
user.setDisplayNick();
|
||||
updateCompass(user);
|
||||
user.setLastLogin(System.currentTimeMillis());
|
||||
user.updateActivity(false);
|
||||
|
||||
if (!ess.getVanishedPlayers().isEmpty() && !user.isAuthorized("essentials.vanish.see"))
|
||||
{
|
||||
for (String p : ess.getVanishedPlayers())
|
||||
{
|
||||
Player toVanish = ess.getUser(p).getBase();
|
||||
if (toVanish.isOnline()) {
|
||||
user.hidePlayer(toVanish);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (user.isAuthorized("essentials.sleepingignored"))
|
||||
{
|
||||
user.setSleepingIgnored(true);
|
||||
}
|
||||
|
||||
if (!ess.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final IText input = new TextInput(user, "motd", true, ess);
|
||||
final IText output = new KeywordReplacer(input, user, ess);
|
||||
final TextPager pager = new TextPager(output, true);
|
||||
pager.showPage("1", null, "motd", user);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.log(Level.WARNING, ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!ess.getSettings().isCommandDisabled("mail") && user.isAuthorized("essentials.mail"))
|
||||
{
|
||||
final List<String> mail = user.getMails();
|
||||
if (mail.isEmpty())
|
||||
{
|
||||
user.sendMessage(_("noNewMail"));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(_("youHaveNewMail", mail.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCompass(final User user)
|
||||
{
|
||||
Location loc = user.getHome(user.getLocation());
|
||||
if (loc == null)
|
||||
{
|
||||
loc = user.getBedSpawnLocation();
|
||||
}
|
||||
if (loc != null)
|
||||
{
|
||||
final Location updateLoc = loc;
|
||||
ess.scheduleSyncDelayedTask(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
user.setCompassTarget(updateLoc);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerLogin(final PlayerLoginEvent event)
|
||||
{
|
||||
switch (event.getResult())
|
||||
{
|
||||
case ALLOWED:
|
||||
case KICK_FULL:
|
||||
case KICK_BANNED:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isNPC())
|
||||
{
|
||||
user.setNPC(false);
|
||||
}
|
||||
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
final boolean banExpired = user.checkBanTimeout(currentTime);
|
||||
user.checkMuteTimeout(currentTime);
|
||||
user.checkJailTimeout(currentTime);
|
||||
|
||||
if (!banExpired && (user.isBanned() || event.getResult() == Result.KICK_BANNED))
|
||||
{
|
||||
final String banReason = user.getBanReason();
|
||||
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : _("defaultBanReason"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getResult() == Result.KICK_FULL && !user.isAuthorized("essentials.joinfullserver"))
|
||||
{
|
||||
event.disallow(Result.KICK_FULL, _("serverFull"));
|
||||
return;
|
||||
}
|
||||
event.allow();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerTeleport(final PlayerTeleportEvent event)
|
||||
{
|
||||
final boolean backListener = ess.getSettings().registerBackInListener();
|
||||
final boolean teleportInvulnerability = ess.getSettings().isTeleportInvulnerability();
|
||||
if (backListener || teleportInvulnerability)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
//There is TeleportCause.COMMMAND but plugins have to actively pass the cause in on their teleports.
|
||||
if (backListener && (event.getCause() == TeleportCause.PLUGIN || event.getCause() == TeleportCause.COMMAND))
|
||||
{
|
||||
user.setLastLocation();
|
||||
}
|
||||
if (teleportInvulnerability)
|
||||
{
|
||||
user.enableInvulnerabilityAfterTeleport();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerEggThrow(final PlayerEggThrowEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final ItemStack stack = new ItemStack(Material.EGG, 1);
|
||||
if (user.hasUnlimited(stack))
|
||||
{
|
||||
user.getInventory().addItem(stack);
|
||||
user.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.hasUnlimited(new ItemStack(event.getBucket())))
|
||||
{
|
||||
event.getItemStack().setType(event.getBucket());
|
||||
ess.scheduleSyncDelayedTask(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
user.updateInventory();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
private final static List<String> COMMANDS = Arrays.asList("msg", "r", "mail", "m", "t", "whisper", "emsg", "tell", "er", "reply", "ereply", "email", "action", "describe", "eme", "eaction", "edescribe", "etell", "ewhisper", "pm");
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
final String cmd = event.getMessage().toLowerCase(Locale.ENGLISH).split(" ")[0].replace("/", "").toLowerCase(Locale.ENGLISH);
|
||||
if (COMMANDS.contains(cmd))
|
||||
{
|
||||
for (Player onlinePlayer : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
final User spyer = ess.getUser(onlinePlayer);
|
||||
if (spyer.isSocialSpyEnabled() && !player.equals(onlinePlayer))
|
||||
{
|
||||
onlinePlayer.sendMessage(player.getDisplayName() + " : " + event.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!cmd.equalsIgnoreCase("afk"))
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
user.updateActivity(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerChangedWorldHack(final PlayerChangedWorldEvent event)
|
||||
{
|
||||
final Player user = event.getPlayer();
|
||||
if (user.getGameMode() != GameMode.CREATIVE) {
|
||||
user.setAllowFlight(false);
|
||||
}
|
||||
user.setFlySpeed(0.1f);
|
||||
user.setWalkSpeed(0.2f);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerChangedWorld(final PlayerChangedWorldEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final String newWorld = event.getPlayer().getLocation().getWorld().getName();
|
||||
user.setDisplayNick();
|
||||
updateCompass(user);
|
||||
if (ess.getSettings().getNoGodWorlds().contains(newWorld) && user.isGodModeEnabledRaw())
|
||||
{
|
||||
user.sendMessage(_("noGodWorldWarning"));
|
||||
}
|
||||
|
||||
if (!event.getPlayer().getWorld().getName().equals(newWorld))
|
||||
{
|
||||
user.sendMessage(_("currentWorld", newWorld));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event)
|
||||
{
|
||||
switch (event.getAction())
|
||||
{
|
||||
case RIGHT_CLICK_BLOCK:
|
||||
if (!event.isCancelled() && event.getClickedBlock().getTypeId() == BED && ess.getSettings().getUpdateBedAtDaytime())
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
player.setBedSpawnLocation(event.getClickedBlock().getLocation());
|
||||
player.sendMessage(_("homeSet", player.getLocation().getWorld().getName(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()));
|
||||
}
|
||||
break;
|
||||
case LEFT_CLICK_AIR:
|
||||
if (event.getPlayer().isFlying())
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isFlyClickJump())
|
||||
{
|
||||
useFlyClickJump(user);
|
||||
return;
|
||||
}
|
||||
}
|
||||
case LEFT_CLICK_BLOCK:
|
||||
if (event.getItem() != null && event.getItem().getTypeId() != AIR)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.hasPowerTools() && user.arePowerToolsEnabled() && usePowertools(user, event.getItem().getTypeId()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void useFlyClickJump(final User user)
|
||||
{
|
||||
try
|
||||
{
|
||||
final Location otarget = Util.getTarget(user);
|
||||
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Location loc = user.getLocation();
|
||||
loc.setX(otarget.getX());
|
||||
loc.setZ(otarget.getZ());
|
||||
while (Util.isBlockDamaging(loc.getWorld(), loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ()))
|
||||
{
|
||||
loc.setY(loc.getY() + 1d);
|
||||
}
|
||||
user.getBase().teleport(loc, TeleportCause.PLUGIN);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean usePowertools(final User user, final int id)
|
||||
{
|
||||
final List<String> commandList = user.getPowertool(id);
|
||||
if (commandList == null || commandList.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
boolean used = false;
|
||||
// We need to loop through each command and execute
|
||||
for (final String command : commandList)
|
||||
{
|
||||
if (command.contains("{player}"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (command.startsWith("c:"))
|
||||
{
|
||||
used = true;
|
||||
user.chat(command.substring(2));
|
||||
}
|
||||
else
|
||||
{
|
||||
used = true;
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
user.getServer().dispatchCommand(user.getBase(), command);
|
||||
LOGGER.log(Level.INFO, String.format("[PT] %s issued server command: /%s", user.getName(), command));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return used;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerPickupItem(final PlayerPickupItemEvent event)
|
||||
{
|
||||
if (ess.getSettings().getDisableItemPickupWhileAfk())
|
||||
{
|
||||
if (ess.getUser(event.getPlayer()).isAfk())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onInventoryClickEvent(final InventoryClickEvent event)
|
||||
{
|
||||
if (event.getView().getTopInventory().getType() == InventoryType.PLAYER)
|
||||
{
|
||||
final User user = ess.getUser(event.getWhoClicked());
|
||||
final InventoryHolder invHolder = event.getView().getTopInventory().getHolder();
|
||||
if (invHolder != null && invHolder instanceof HumanEntity)
|
||||
{
|
||||
final User invOwner = ess.getUser((HumanEntity)invHolder);
|
||||
if (user.isInvSee() && (!user.isAuthorized("essentials.invsee.modify")
|
||||
|| invOwner.isAuthorized("essentials.invsee.preventmodify")
|
||||
|| !invOwner.isOnline()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (event.getView().getTopInventory().getType() == InventoryType.ENDER_CHEST)
|
||||
{
|
||||
final User user = ess.getUser(event.getWhoClicked());
|
||||
if (user.isEnderSee() && (!user.isAuthorized("essentials.enderchest.modify")))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onInventoryCloseEvent(final InventoryCloseEvent event)
|
||||
{
|
||||
if (event.getView().getTopInventory().getType() == InventoryType.PLAYER)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.setInvSee(false);
|
||||
}
|
||||
else if (event.getView().getTopInventory().getType() == InventoryType.ENDER_CHEST)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.setEnderSee(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
|
||||
|
||||
public class EssentialsPluginListener implements Listener, IConf
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public EssentialsPluginListener(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(final PluginEnableEvent event)
|
||||
{
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
ess.getAlternativeCommandsHandler().addPlugin(event.getPlugin());
|
||||
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(ess.getServer().getPluginManager()))
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "Payment method found (" + ess.getPaymentMethod().getMethod().getLongName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(final PluginDisableEvent event)
|
||||
{
|
||||
ess.getPermissionsHandler().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 && ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().checkDisabled(event.getPlugin()))
|
||||
{
|
||||
ess.getPaymentMethod().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();
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,8 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import com.earth2me.essentials.user.UserData.TimestampType;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -17,7 +11,9 @@ import org.bukkit.entity.Player;
|
||||
public class EssentialsTimer implements Runnable
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
private final transient Set<IUser> onlineUsers = new HashSet<IUser>();
|
||||
private final transient Set<User> onlineUsers = new HashSet<User>();
|
||||
private transient long lastPoll = System.currentTimeMillis();
|
||||
private final transient LinkedList<Float> history = new LinkedList<Float>();
|
||||
|
||||
EssentialsTimer(final IEssentials ess)
|
||||
{
|
||||
@@ -28,36 +24,29 @@ public class EssentialsTimer implements Runnable
|
||||
public void run()
|
||||
{
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
long timeSpent = (currentTime - lastPoll) / 1000;
|
||||
if (timeSpent == 0)
|
||||
{
|
||||
timeSpent = 1;
|
||||
}
|
||||
if (history.size() > 10)
|
||||
{
|
||||
history.remove();
|
||||
}
|
||||
float tps = 100f / timeSpent;
|
||||
if (tps <= 20)
|
||||
{
|
||||
history.add(tps);
|
||||
}
|
||||
lastPoll = currentTime;
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
final IUser user = ess.getUser(player);
|
||||
final User user = ess.getUser(player);
|
||||
onlineUsers.add(user);
|
||||
user.setLastOnlineActivity(currentTime);
|
||||
user.checkActivity();
|
||||
|
||||
boolean mailDisabled = false;
|
||||
ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
try
|
||||
{
|
||||
mailDisabled = settings.getData().getCommands().isDisabled("mail");
|
||||
}
|
||||
finally
|
||||
{
|
||||
settings.unlock();
|
||||
}
|
||||
// New mail notification
|
||||
if (user != null && !mailDisabled && Permissions.MAIL.isAuthorized(user) && !user.gotMailInfo())
|
||||
{
|
||||
final List<String> mail = user.getMails();
|
||||
if (mail != null && !mail.isEmpty())
|
||||
{
|
||||
user.sendMessage(_("youHaveNewMail", mail.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -65,18 +54,32 @@ public class EssentialsTimer implements Runnable
|
||||
}
|
||||
}
|
||||
|
||||
final Iterator<IUser> iterator = onlineUsers.iterator();
|
||||
final Iterator<User> iterator = onlineUsers.iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
final IUser user = iterator.next();
|
||||
if (user.getLastOnlineActivity() < currentTime && user.getLastOnlineActivity() > user.getTimestamp(TimestampType.LOGOUT))
|
||||
final User user = iterator.next();
|
||||
if (user.getLastOnlineActivity() < currentTime && user.getLastOnlineActivity() > user.getLastLogout())
|
||||
{
|
||||
user.setTimestamp(TimestampType.LOGOUT, user.getLastOnlineActivity());
|
||||
user.setLastLogout(user.getLastOnlineActivity());
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
user.checkMuteTimeout(currentTime);
|
||||
user.checkJailTimeout(currentTime);
|
||||
user.resetInvulnerabilityAfterTeleport();
|
||||
}
|
||||
}
|
||||
|
||||
public float getAverageTPS()
|
||||
{
|
||||
float avg = 0;
|
||||
for (Float f : history)
|
||||
{
|
||||
if (f != null)
|
||||
{
|
||||
avg += f;
|
||||
}
|
||||
}
|
||||
return avg / history.size();
|
||||
}
|
||||
}
|
||||
+158
-58
@@ -1,10 +1,8 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.storage.ManagedFile;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.craftbukkit.FakeWorld;
|
||||
import com.earth2me.essentials.settings.Spawns;
|
||||
import com.earth2me.essentials.storage.Location;
|
||||
import com.earth2me.essentials.storage.YamlStorageWriter;
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
@@ -14,12 +12,12 @@ import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@Deprecated
|
||||
public class EssentialsUpgrade
|
||||
{
|
||||
private final static Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
@@ -52,7 +50,7 @@ public class EssentialsUpgrade
|
||||
}
|
||||
final EssentialsConf conf = new EssentialsConf(configFile);
|
||||
conf.load();
|
||||
final Worth worth = new Worth(ess);
|
||||
final Worth worth = new Worth(ess.getDataFolder());
|
||||
boolean found = false;
|
||||
for (Material mat : Material.values())
|
||||
{
|
||||
@@ -212,10 +210,14 @@ public class EssentialsUpgrade
|
||||
continue;
|
||||
}
|
||||
World world = ess.getServer().getWorlds().get(0);
|
||||
if (vals.size() > 5)
|
||||
{
|
||||
world = ess.getServer().getWorld((String)vals.get(5));
|
||||
}
|
||||
if (world != null)
|
||||
{
|
||||
final Location loc = new Location(
|
||||
(String)vals.get(5),
|
||||
world,
|
||||
((Number)vals.get(0)).doubleValue(),
|
||||
((Number)vals.get(1)).doubleValue(),
|
||||
((Number)vals.get(2)).doubleValue(),
|
||||
@@ -269,18 +271,18 @@ public class EssentialsUpgrade
|
||||
if (config.hasProperty("powertools"))
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
final Map<Integer, Object> powertools = (Map<Integer, Object>)config.getProperty("powertools");
|
||||
final Map<String, Object> powertools = config.getConfigurationSection("powertools").getValues(false);
|
||||
if (powertools == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (Map.Entry<Integer, Object> entry : powertools.entrySet())
|
||||
for (Map.Entry<String, Object> entry : powertools.entrySet())
|
||||
{
|
||||
if (entry.getValue() instanceof String)
|
||||
{
|
||||
List<String> temp = new ArrayList<String>();
|
||||
temp.add((String)entry.getValue());
|
||||
((Map<Integer, Object>)powertools).put(entry.getKey(), temp);
|
||||
((Map<String, Object>)powertools).put(entry.getKey(), temp);
|
||||
}
|
||||
}
|
||||
config.save();
|
||||
@@ -349,7 +351,7 @@ public class EssentialsUpgrade
|
||||
{
|
||||
continue;
|
||||
}
|
||||
worldName = loc.getWorldName().toLowerCase(Locale.ENGLISH);
|
||||
worldName = loc.getWorld().getName().toLowerCase(Locale.ENGLISH);
|
||||
if (worldName != null && !worldName.isEmpty())
|
||||
{
|
||||
config.setProperty("homes." + worldName, loc);
|
||||
@@ -370,21 +372,53 @@ public class EssentialsUpgrade
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
/*
|
||||
* private void moveUsersDataToUserdataFolder() { final File usersFile = new File(ess.getDataFolder(), "users.yml");
|
||||
* if (!usersFile.exists()) { return; } final EssentialsConf usersConfig = new EssentialsConf(usersFile);
|
||||
* usersConfig.load(); for (String username : usersConfig.getKeys(null)) { final User user = new User(new
|
||||
* OfflinePlayer(username, ess), ess); final String nickname = usersConfig.getString(username + ".nickname"); if
|
||||
* (nickname != null && !nickname.isEmpty() && !nickname.equals(username)) { user.setNickname(nickname); } final
|
||||
* List<String> mails = usersConfig.getStringList(username + ".mail", null); if (mails != null && !mails.isEmpty())
|
||||
* { user.setMails(mails); } if (!user.hasHome()) { @SuppressWarnings("unchecked") final List<Object> vals =
|
||||
* (List<Object>)usersConfig.getProperty(username + ".home"); if (vals != null) { World world =
|
||||
* ess.getServer().getWorlds().get(0); if (vals.size() > 5) { world = getFakeWorld((String)vals.get(5)); } if (world
|
||||
* != null) { user.setHome("home", new Location(world, ((Number)vals.get(0)).doubleValue(),
|
||||
* ((Number)vals.get(1)).doubleValue(), ((Number)vals.get(2)).doubleValue(), ((Number)vals.get(3)).floatValue(),
|
||||
* ((Number)vals.get(4)).floatValue())); } } } } usersFile.renameTo(new File(usersFile.getAbsolutePath() + ".old"));
|
||||
* }
|
||||
*/
|
||||
private void moveUsersDataToUserdataFolder()
|
||||
{
|
||||
final File usersFile = new File(ess.getDataFolder(), "users.yml");
|
||||
if (!usersFile.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final EssentialsConf usersConfig = new EssentialsConf(usersFile);
|
||||
usersConfig.load();
|
||||
for (String username : usersConfig.getKeys(false))
|
||||
{
|
||||
final User user = new User(new OfflinePlayer(username, ess), ess);
|
||||
final String nickname = usersConfig.getString(username + ".nickname");
|
||||
if (nickname != null && !nickname.isEmpty() && !nickname.equals(username))
|
||||
{
|
||||
user.setNickname(nickname);
|
||||
}
|
||||
final List<String> mails = usersConfig.getStringList(username + ".mail");
|
||||
if (mails != null && !mails.isEmpty())
|
||||
{
|
||||
user.setMails(mails);
|
||||
}
|
||||
if (!user.hasHome())
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
final List<Object> vals = (List<Object>)usersConfig.getProperty(username + ".home");
|
||||
if (vals != null)
|
||||
{
|
||||
World world = ess.getServer().getWorlds().get(0);
|
||||
if (vals.size() > 5)
|
||||
{
|
||||
world = getFakeWorld((String)vals.get(5));
|
||||
}
|
||||
if (world != null)
|
||||
{
|
||||
user.setHome("home", new Location(world,
|
||||
((Number)vals.get(0)).doubleValue(),
|
||||
((Number)vals.get(1)).doubleValue(),
|
||||
((Number)vals.get(2)).doubleValue(),
|
||||
((Number)vals.get(3)).floatValue(),
|
||||
((Number)vals.get(4)).floatValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
usersFile.renameTo(new File(usersFile.getAbsolutePath() + ".old"));
|
||||
}
|
||||
|
||||
private void convertWarps()
|
||||
{
|
||||
@@ -440,16 +474,31 @@ public class EssentialsUpgrade
|
||||
{
|
||||
rx.close();
|
||||
}
|
||||
if (worldName != null)
|
||||
World w = null;
|
||||
for (World world : ess.getServer().getWorlds())
|
||||
{
|
||||
final Location loc = new Location(worldName, x, y, z, yaw, pitch);
|
||||
((Warps)ess.getWarps()).setWarp(filename.substring(0, filename.length() - 4), loc);
|
||||
if (!listOfFiles[i].renameTo(new File(warpsFolder, filename + ".old")))
|
||||
if (world.getEnvironment() != World.Environment.NETHER)
|
||||
{
|
||||
throw new Exception(_("fileRenameError", filename));
|
||||
w = world;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (worldName != null)
|
||||
{
|
||||
worldName = worldName.trim();
|
||||
World w1 = null;
|
||||
w1 = getFakeWorld(worldName);
|
||||
if (w1 != null)
|
||||
{
|
||||
w = w1;
|
||||
}
|
||||
}
|
||||
final Location loc = new Location(w, x, y, z, yaw, pitch);
|
||||
ess.getWarps().setWarp(filename.substring(0, filename.length() - 4), loc);
|
||||
if (!listOfFiles[i].renameTo(new File(warpsFolder, filename + ".old")))
|
||||
{
|
||||
throw new Exception(_("fileRenameError", filename));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -459,7 +508,7 @@ public class EssentialsUpgrade
|
||||
}
|
||||
|
||||
}
|
||||
/*final File warpFile = new File(ess.getDataFolder(), "warps.txt");
|
||||
final File warpFile = new File(ess.getDataFolder(), "warps.txt");
|
||||
if (warpFile.exists())
|
||||
{
|
||||
try
|
||||
@@ -492,7 +541,7 @@ public class EssentialsUpgrade
|
||||
break;
|
||||
}
|
||||
}
|
||||
final Location loc = new Location(name, x, y, z, yaw, pitch);
|
||||
final Location loc = new Location(w, x, y, z, yaw, pitch);
|
||||
ess.getWarps().setWarp(name, loc);
|
||||
if (!warpFile.renameTo(new File(ess.getDataFolder(), "warps.txt.old")))
|
||||
{
|
||||
@@ -509,30 +558,65 @@ public class EssentialsUpgrade
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* private void sanitizeAllUserFilenames() { if (doneFile.getBoolean("sanitizeAllUserFilenames", false)) { return; }
|
||||
* final File usersFolder = new File(ess.getDataFolder(), "userdata"); if (!usersFolder.exists()) { return; } final
|
||||
* File[] listOfFiles = usersFolder.listFiles(); for (int i = 0; i < listOfFiles.length; i++) { final String
|
||||
* filename = listOfFiles[i].getName(); if (!listOfFiles[i].isFile() || !filename.endsWith(".yml")) { continue; }
|
||||
* final String sanitizedFilename = Util.sanitizeFileName(filename.substring(0, filename.length() - 4)) + ".yml"; if
|
||||
* (sanitizedFilename.equals(filename)) { continue; } final File tmpFile = new File(listOfFiles[i].getParentFile(),
|
||||
* sanitizedFilename + ".tmp"); final File newFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename); if
|
||||
* (!listOfFiles[i].renameTo(tmpFile)) { LOGGER.log(Level.WARNING, _("userdataMoveError", filename,
|
||||
* sanitizedFilename)); continue; } if (newFile.exists()) { LOGGER.log(Level.WARNING, _("duplicatedUserdata",
|
||||
* filename, sanitizedFilename)); continue; } if (!tmpFile.renameTo(newFile)) { LOGGER.log(Level.WARNING,
|
||||
* _("userdataMoveBackError", sanitizedFilename, sanitizedFilename)); } }
|
||||
* doneFile.setProperty("sanitizeAllUserFilenames", true); doneFile.save(); }
|
||||
*/
|
||||
/*
|
||||
* private World getFakeWorld(final String name) { final File bukkitDirectory =
|
||||
* ess.getDataFolder().getParentFile().getParentFile(); final File worldDirectory = new File(bukkitDirectory, name);
|
||||
* if (worldDirectory.exists() && worldDirectory.isDirectory()) { return new FakeWorld(worldDirectory.getName(),
|
||||
* World.Environment.NORMAL); } return null;
|
||||
private void sanitizeAllUserFilenames()
|
||||
{
|
||||
if (doneFile.getBoolean("sanitizeAllUserFilenames", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File usersFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!usersFolder.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File[] listOfFiles = usersFolder.listFiles();
|
||||
for (int i = 0; i < listOfFiles.length; i++)
|
||||
{
|
||||
final String filename = listOfFiles[i].getName();
|
||||
if (!listOfFiles[i].isFile() || !filename.endsWith(".yml"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final String sanitizedFilename = Util.sanitizeFileName(filename.substring(0, filename.length() - 4)) + ".yml";
|
||||
if (sanitizedFilename.equals(filename))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final File tmpFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename + ".tmp");
|
||||
final File newFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename);
|
||||
if (!listOfFiles[i].renameTo(tmpFile))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("userdataMoveError", filename, sanitizedFilename));
|
||||
continue;
|
||||
}
|
||||
if (newFile.exists())
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("duplicatedUserdata", filename, sanitizedFilename));
|
||||
continue;
|
||||
}
|
||||
if (!tmpFile.renameTo(newFile))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("userdataMoveBackError", sanitizedFilename, sanitizedFilename));
|
||||
}
|
||||
}
|
||||
doneFile.setProperty("sanitizeAllUserFilenames", true);
|
||||
doneFile.save();
|
||||
}
|
||||
*/
|
||||
|
||||
private World getFakeWorld(final String name)
|
||||
{
|
||||
final File bukkitDirectory = ess.getDataFolder().getParentFile().getParentFile();
|
||||
final File worldDirectory = new File(bukkitDirectory, name);
|
||||
if (worldDirectory.exists() && worldDirectory.isDirectory())
|
||||
{
|
||||
return new FakeWorld(worldDirectory.getName(), World.Environment.NORMAL);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Location getFakeLocation(EssentialsConf config, String path)
|
||||
{
|
||||
String worldName = config.getString((path != null ? path + "." : "") + "world");
|
||||
@@ -540,7 +624,12 @@ public class EssentialsUpgrade
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Location(worldName,
|
||||
World world = getFakeWorld(worldName);
|
||||
if (world == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Location(world,
|
||||
config.getDouble((path != null ? path + "." : "") + "x", 0),
|
||||
config.getDouble((path != null ? path + "." : "") + "y", 0),
|
||||
config.getDouble((path != null ? path + "." : "") + "z", 0),
|
||||
@@ -689,6 +778,17 @@ public class EssentialsUpgrade
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
private void warnMetrics()
|
||||
{
|
||||
if (doneFile.getBoolean("warnMetrics", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
ess.getSettings().setMetricsEnabled(false);
|
||||
doneFile.setProperty("warnMetrics", true);
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
public void beforeSettings()
|
||||
{
|
||||
if (!ess.getDataFolder().exists())
|
||||
@@ -702,15 +802,15 @@ public class EssentialsUpgrade
|
||||
|
||||
public void afterSettings()
|
||||
{
|
||||
//TODO?
|
||||
//sanitizeAllUserFilenames();
|
||||
sanitizeAllUserFilenames();
|
||||
updateUsersToNewDefaultHome();
|
||||
//moveUsersDataToUserdataFolder();
|
||||
moveUsersDataToUserdataFolder();
|
||||
convertWarps();
|
||||
updateUsersPowerToolsFormat();
|
||||
updateUsersHomesFormat();
|
||||
deleteOldItemsCsv();
|
||||
updateSpawnsToNewSpawnsConfig();
|
||||
updateJailsToNewJailsConfig();
|
||||
warnMetrics();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.II18n;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -44,7 +43,6 @@ public class I18n implements II18n
|
||||
instance = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getCurrentLocale()
|
||||
{
|
||||
return currentLocale;
|
||||
@@ -72,7 +70,8 @@ public class I18n implements II18n
|
||||
|
||||
public static String _(final String string, final Object... objects)
|
||||
{
|
||||
if (instance == null) {
|
||||
if (instance == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
if (objects.length == 0)
|
||||
@@ -87,11 +86,20 @@ public class I18n implements II18n
|
||||
|
||||
public String format(final String string, final Object... objects)
|
||||
{
|
||||
final String format = translate(string);
|
||||
String format = translate(string);
|
||||
MessageFormat messageFormat = messageFormatCache.get(format);
|
||||
if (messageFormat == null)
|
||||
{
|
||||
messageFormat = new MessageFormat(format);
|
||||
try
|
||||
{
|
||||
messageFormat = new MessageFormat(format);
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
ess.getLogger().log(Level.SEVERE, "Invalid Translation key for '" + string + "': " + e.getMessage());
|
||||
format = format.replaceAll("\\{(\\D*?)\\}", "\\[$1\\]");
|
||||
messageFormat = new MessageFormat(format);
|
||||
}
|
||||
messageFormatCache.put(format, messageFormat);
|
||||
}
|
||||
return messageFormat.format(objects);
|
||||
@@ -116,6 +124,7 @@ public class I18n implements II18n
|
||||
{
|
||||
currentLocale = new Locale(parts[0], parts[1], parts[2]);
|
||||
}
|
||||
ResourceBundle.clearCache();
|
||||
Logger.getLogger("Minecraft").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);
|
||||
@@ -134,7 +143,7 @@ public class I18n implements II18n
|
||||
{
|
||||
private final transient File dataFolder;
|
||||
|
||||
public FileResClassLoader(final ClassLoader classLoader, final IEssentials ess)
|
||||
FileResClassLoader(final ClassLoader classLoader, final IEssentials ess)
|
||||
{
|
||||
super(classLoader);
|
||||
this.dataFolder = ess.getDataFolder();
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
public interface IConf {
|
||||
public void reloadConfig();
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.IJails;
|
||||
import com.earth2me.essentials.metrics.Metrics;
|
||||
import com.earth2me.essentials.perm.PermissionsHandler;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import java.util.List;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
|
||||
public interface IEssentials extends Plugin
|
||||
{
|
||||
void addReloadListener(IConf listener);
|
||||
|
||||
void reload();
|
||||
|
||||
boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix, IEssentialsModule module);
|
||||
|
||||
User getUser(Object base);
|
||||
|
||||
I18n getI18n();
|
||||
|
||||
User getOfflineUser(String name);
|
||||
|
||||
World getWorld(String name);
|
||||
|
||||
int broadcastMessage(IUser sender, String message);
|
||||
|
||||
ISettings getSettings();
|
||||
|
||||
BukkitScheduler getScheduler();
|
||||
|
||||
IJails getJails();
|
||||
|
||||
Warps getWarps();
|
||||
|
||||
Worth getWorth();
|
||||
|
||||
Backup getBackup();
|
||||
|
||||
Methods getPaymentMethod();
|
||||
|
||||
int scheduleAsyncDelayedTask(Runnable run);
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run);
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run, long delay);
|
||||
|
||||
int scheduleSyncRepeatingTask(final Runnable run, long delay, long period);
|
||||
|
||||
TNTExplodeListener getTNTListener();
|
||||
|
||||
PermissionsHandler getPermissionsHandler();
|
||||
|
||||
AlternativeCommandsHandler getAlternativeCommandsHandler();
|
||||
|
||||
void showError(final CommandSender sender, final Throwable exception, final String commandLabel);
|
||||
|
||||
ItemDb getItemDb();
|
||||
|
||||
UserMap getUserMap();
|
||||
|
||||
Metrics getMetrics();
|
||||
|
||||
void setMetrics(Metrics metrics);
|
||||
|
||||
EssentialsTimer getTimer();
|
||||
|
||||
List<String> getVanishedPlayers();
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.earth2me.essentials.api;
|
||||
package com.earth2me.essentials;
|
||||
|
||||
|
||||
public interface IEssentialsModule
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public interface IReplyTo {
|
||||
public void setReplyTo(CommandSender user);
|
||||
|
||||
public CommandSender getReplyTo();
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.signs.EssentialsSign;
|
||||
import com.earth2me.essentials.textreader.IText;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
|
||||
public interface ISettings extends IConf
|
||||
{
|
||||
boolean areSignsDisabled();
|
||||
|
||||
IText getAnnounceNewPlayerFormat();
|
||||
|
||||
boolean getAnnounceNewPlayers();
|
||||
|
||||
String getNewPlayerKit();
|
||||
|
||||
String getBackupCommand();
|
||||
|
||||
long getBackupInterval();
|
||||
|
||||
MessageFormat getChatFormat(String group);
|
||||
|
||||
int getChatRadius();
|
||||
|
||||
double getCommandCost(IEssentialsCommand cmd);
|
||||
|
||||
double getCommandCost(String label);
|
||||
|
||||
String getCurrencySymbol();
|
||||
|
||||
int getOversizedStackSize();
|
||||
|
||||
int getDefaultStackSize();
|
||||
|
||||
double getHealCooldown();
|
||||
|
||||
Map<String, Object> getKit(String name);
|
||||
|
||||
ConfigurationSection getKits();
|
||||
|
||||
String getLocale();
|
||||
|
||||
String getNewbieSpawn();
|
||||
|
||||
String getNicknamePrefix();
|
||||
|
||||
ChatColor getOperatorColor() throws Exception;
|
||||
|
||||
boolean getPerWarpPermission();
|
||||
|
||||
boolean getProtectBoolean(final String configName, boolean def);
|
||||
|
||||
int getProtectCreeperMaxHeight();
|
||||
|
||||
List<Integer> getProtectList(final String configName);
|
||||
|
||||
boolean getProtectPreventSpawn(final String creatureName);
|
||||
|
||||
String getProtectString(final String configName);
|
||||
|
||||
boolean getRespawnAtHome();
|
||||
|
||||
Set getMultipleHomes();
|
||||
|
||||
int getHomeLimit(String set);
|
||||
|
||||
int getHomeLimit(User user);
|
||||
|
||||
boolean getSortListByGroups();
|
||||
|
||||
int getSpawnMobLimit();
|
||||
|
||||
int getStartingBalance();
|
||||
|
||||
double getTeleportCooldown();
|
||||
|
||||
double getTeleportDelay();
|
||||
|
||||
boolean hidePermissionlessHelp();
|
||||
|
||||
boolean isCommandDisabled(final IEssentialsCommand cmd);
|
||||
|
||||
boolean isCommandDisabled(String label);
|
||||
|
||||
boolean isCommandOverridden(String name);
|
||||
|
||||
boolean isDebug();
|
||||
|
||||
boolean isEcoDisabled();
|
||||
|
||||
boolean isTradeInStacks(int id);
|
||||
|
||||
List<Integer> itemSpawnBlacklist();
|
||||
|
||||
List<EssentialsSign> enabledSigns();
|
||||
|
||||
boolean permissionBasedItemSpawn();
|
||||
|
||||
boolean showNonEssCommandsInHelp();
|
||||
|
||||
boolean warnOnBuildDisallow();
|
||||
|
||||
boolean warnOnSmite();
|
||||
|
||||
double getMaxMoney();
|
||||
|
||||
double getMinMoney();
|
||||
|
||||
boolean isEcoLogEnabled();
|
||||
|
||||
boolean isEcoLogUpdateEnabled();
|
||||
|
||||
boolean removeGodOnDisconnect();
|
||||
|
||||
boolean changeDisplayName();
|
||||
|
||||
boolean changePlayerListName();
|
||||
|
||||
boolean isPlayerCommand(String string);
|
||||
|
||||
boolean useBukkitPermissions();
|
||||
|
||||
boolean addPrefixSuffix();
|
||||
|
||||
boolean disablePrefix();
|
||||
|
||||
boolean disableSuffix();
|
||||
|
||||
long getAutoAfk();
|
||||
|
||||
long getAutoAfkKick();
|
||||
|
||||
boolean getFreezeAfkPlayers();
|
||||
|
||||
boolean cancelAfkOnMove();
|
||||
|
||||
boolean areDeathMessagesEnabled();
|
||||
|
||||
public void setDebug(boolean debug);
|
||||
|
||||
Set<String> getNoGodWorlds();
|
||||
|
||||
boolean getUpdateBedAtDaytime();
|
||||
|
||||
boolean getRepairEnchanted();
|
||||
|
||||
boolean isWorldTeleportPermissions();
|
||||
|
||||
boolean isWorldHomePermissions();
|
||||
|
||||
boolean registerBackInListener();
|
||||
|
||||
boolean getDisableItemPickupWhileAfk();
|
||||
|
||||
EventPriority getRespawnPriority();
|
||||
|
||||
long getTpaAcceptCancellation();
|
||||
|
||||
boolean isMetricsEnabled();
|
||||
|
||||
void setMetricsEnabled(boolean metricsEnabled);
|
||||
|
||||
long getTeleportInvulnerability();
|
||||
|
||||
boolean isTeleportInvulnerability();
|
||||
|
||||
long getLoginAttackDelay();
|
||||
|
||||
int getSignUsePerSecond();
|
||||
|
||||
double getMaxFlySpeed();
|
||||
|
||||
double getMaxWalkSpeed();
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public interface IUser extends Player
|
||||
{
|
||||
long getLastTeleportTimestamp();
|
||||
|
||||
boolean isAuthorized(String node);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
|
||||
|
||||
void setLastTeleportTimestamp(long time);
|
||||
|
||||
Location getLastLocation();
|
||||
|
||||
Player getBase();
|
||||
|
||||
double getMoney();
|
||||
|
||||
void takeMoney(double value);
|
||||
|
||||
void giveMoney(double value);
|
||||
|
||||
boolean canAfford(double value);
|
||||
|
||||
String getGroup();
|
||||
|
||||
void setLastLocation();
|
||||
|
||||
Location getHome(String name) throws Exception;
|
||||
|
||||
Location getHome(Location loc) throws Exception;
|
||||
|
||||
boolean isHidden();
|
||||
|
||||
Teleport getTeleport();
|
||||
|
||||
void setJail(String jail);
|
||||
}
|
||||
@@ -1,22 +1,13 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.storage.ManagedFile;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IItemDb;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
import lombok.Cleanup;
|
||||
import java.util.*;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class ItemDb implements IItemDb
|
||||
public class ItemDb implements IConf, IItemDb
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
|
||||
@@ -25,12 +16,13 @@ public class ItemDb implements IItemDb
|
||||
this.ess = ess;
|
||||
file = new ManagedFile("items.csv", ess);
|
||||
}
|
||||
private final transient Map<String, Long> items = new HashMap<String, Long>();
|
||||
private final transient Map<String, Integer> items = new HashMap<String, Integer>();
|
||||
private final transient Map<ItemData, List<String>> names = new HashMap<ItemData, List<String>>();
|
||||
private final transient Map<String, Short> durabilities = new HashMap<String, Short>();
|
||||
private final transient ManagedFile file;
|
||||
private static final Pattern SPLIT = Pattern.compile("[^a-zA-Z0-9]");
|
||||
|
||||
@Override
|
||||
public void onReload()
|
||||
public void reloadConfig()
|
||||
{
|
||||
final List<String> lines = file.getLines();
|
||||
|
||||
@@ -39,52 +31,45 @@ public class ItemDb implements IItemDb
|
||||
return;
|
||||
}
|
||||
|
||||
durabilities.clear();
|
||||
items.clear();
|
||||
names.clear();
|
||||
|
||||
for (String line : lines)
|
||||
{
|
||||
line = line.trim();
|
||||
line = line.trim().toLowerCase(Locale.ENGLISH);
|
||||
if (line.length() > 0 && line.charAt(0) == '#')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final String[] parts = SPLIT.split(line);
|
||||
final String[] parts = line.split("[^a-z0-9]");
|
||||
if (parts.length < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final long numeric = Integer.parseInt(parts[1]);
|
||||
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);
|
||||
|
||||
final long durability = parts.length > 2 && !(parts[2].length() == 1 && parts[2].charAt(0) == '0') ? Short.parseShort(parts[2]) : 0;
|
||||
items.put(parts[0].toLowerCase(Locale.ENGLISH), numeric | (durability << 32));
|
||||
}
|
||||
}
|
||||
durabilities.put(itemName, data);
|
||||
items.put(itemName, numeric);
|
||||
|
||||
public ItemStack get(final String id, final IUser user) throws Exception
|
||||
{
|
||||
final ItemStack stack = get(id.toLowerCase(Locale.ENGLISH));
|
||||
|
||||
@Cleanup
|
||||
com.earth2me.essentials.api.ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
|
||||
final int defaultStackSize = settings.getData().getGeneral().getDefaultStacksize();
|
||||
|
||||
if (defaultStackSize > 0)
|
||||
{
|
||||
stack.setAmount(defaultStackSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
final int oversizedStackSize = settings.getData().getGeneral().getOversizedStacksize();
|
||||
if (oversizedStackSize > 0 && Permissions.OVERSIZEDSTACKS.isAuthorized(user))
|
||||
ItemData itemData = new ItemData(numeric, data);
|
||||
if (names.containsKey(itemData))
|
||||
{
|
||||
stack.setAmount(oversizedStackSize);
|
||||
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);
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
public ItemStack get(final String id, final int quantity) throws Exception
|
||||
@@ -122,11 +107,10 @@ public class ItemDb implements IItemDb
|
||||
{
|
||||
if (items.containsKey(itemname))
|
||||
{
|
||||
long item = items.get(itemname);
|
||||
itemid = (int)(item & 0xffffffffL);
|
||||
if (metaData == 0)
|
||||
itemid = items.get(itemname);
|
||||
if (durabilities.containsKey(itemname) && metaData == 0)
|
||||
{
|
||||
metaData = (short)((item >> 32) & 0xffffL);
|
||||
metaData = durabilities.get(itemname);
|
||||
}
|
||||
}
|
||||
else if (Material.getMaterial(itemname) != null)
|
||||
@@ -150,4 +134,81 @@ public class ItemDb implements IItemDb
|
||||
retval.setDurability(metaData);
|
||||
return retval;
|
||||
}
|
||||
|
||||
public String names(ItemStack item)
|
||||
{
|
||||
ItemData itemData = new ItemData(item.getTypeId(), item.getDurability());
|
||||
List<String> nameList = names.get(itemData);
|
||||
if (nameList == null) {
|
||||
itemData = new ItemData(item.getTypeId(), (short) 0);
|
||||
nameList = names.get(itemData);
|
||||
if (nameList == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (nameList.size() > 15)
|
||||
{
|
||||
nameList = nameList.subList(0, 14);
|
||||
}
|
||||
return Util.joinList(", ", nameList);
|
||||
}
|
||||
|
||||
class ItemData
|
||||
{
|
||||
final private int itemNo;
|
||||
final private short itemData;
|
||||
|
||||
ItemData(final int itemNo, final short itemData)
|
||||
{
|
||||
this.itemNo = itemNo;
|
||||
this.itemData = itemData;
|
||||
}
|
||||
|
||||
public int getItemNo()
|
||||
{
|
||||
return itemNo;
|
||||
}
|
||||
|
||||
public short getItemData()
|
||||
{
|
||||
return itemData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return (31 * itemNo) ^ itemData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (o == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!(o instanceof ItemData))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ItemData pairo = (ItemData)o;
|
||||
return this.itemNo == pairo.getItemNo()
|
||||
&& this.itemData == pairo.getItemData();
|
||||
}
|
||||
}
|
||||
|
||||
class LengthCompare implements java.util.Comparator<String>
|
||||
{
|
||||
public LengthCompare()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(String s1, String s2)
|
||||
{
|
||||
return s1.length() - s2.length();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,24 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IJails;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.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.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
@@ -29,21 +30,20 @@ import org.bukkit.plugin.PluginManager;
|
||||
public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.settings.Jails> implements IJails
|
||||
{
|
||||
private static final transient Logger LOGGER = Bukkit.getLogger();
|
||||
private static transient boolean enabled = false;
|
||||
|
||||
public Jails(final IEssentials ess)
|
||||
{
|
||||
super(ess, com.earth2me.essentials.settings.Jails.class);
|
||||
onReload();
|
||||
registerListeners();
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
private void registerListeners()
|
||||
{
|
||||
enabled = true;
|
||||
final PluginManager pluginManager = ess.getServer().getPluginManager();
|
||||
final JailBlockListener blockListener = new JailBlockListener();
|
||||
final JailPlayerListener playerListener = new JailPlayerListener();
|
||||
final JailListener blockListener = new JailListener();
|
||||
pluginManager.registerEvents(blockListener, ess);
|
||||
pluginManager.registerEvents(playerListener, ess);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,6 +52,24 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
return new File(ess.getDataFolder(), "jail.yml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishRead()
|
||||
{
|
||||
if (enabled == false && getCount() > 0)
|
||||
{
|
||||
registerListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishWrite()
|
||||
{
|
||||
if (enabled == false)
|
||||
{
|
||||
registerListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getJail(final String jailName) throws Exception
|
||||
{
|
||||
@@ -63,7 +81,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
{
|
||||
throw new Exception(_("jailNotExist"));
|
||||
}
|
||||
Location loc = getData().getJails().get(jailName.toLowerCase(Locale.ENGLISH)).getBukkitLocation();
|
||||
Location loc = getData().getJails().get(jailName.toLowerCase(Locale.ENGLISH));
|
||||
if (loc == null || loc.getWorld() == null)
|
||||
{
|
||||
throw new Exception(_("jailNotExist"));
|
||||
@@ -118,20 +136,12 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
acquireReadLock();
|
||||
try
|
||||
{
|
||||
if (!(user.isOnline()))
|
||||
if (user.isOnline())
|
||||
{
|
||||
Location loc = getJail(jail);
|
||||
user.getTeleport().now(loc, false, TeleportCause.COMMAND);
|
||||
}
|
||||
user.acquireWriteLock();
|
||||
try
|
||||
{
|
||||
user.getData().setJail(jail);
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
user.setJail(jail);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -147,9 +157,9 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
{
|
||||
if (getData().getJails() == null)
|
||||
{
|
||||
getData().setJails(new HashMap<String, com.earth2me.essentials.storage.Location>());
|
||||
getData().setJails(new HashMap<String, Location>());
|
||||
}
|
||||
getData().getJails().put(jailName.toLowerCase(Locale.ENGLISH), new com.earth2me.essentials.storage.Location(loc));
|
||||
getData().getJails().put(jailName.toLowerCase(Locale.ENGLISH), loc);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -157,75 +167,92 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class JailBlockListener implements Listener
|
||||
@Override
|
||||
public int getCount()
|
||||
{
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onBlockBreak(final BlockBreakEvent event)
|
||||
try
|
||||
{
|
||||
@Cleanup
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
user.acquireReadLock();
|
||||
if (user.getData().isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return getList().size();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onBlockPlace(final BlockPlaceEvent event)
|
||||
catch (Exception ex)
|
||||
{
|
||||
@Cleanup
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
user.acquireReadLock();
|
||||
if (user.getData().isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onBlockDamage(final BlockDamageEvent event)
|
||||
{
|
||||
@Cleanup
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
user.acquireReadLock();
|
||||
if (user.getData().isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class JailPlayerListener implements Listener
|
||||
private class JailListener implements Listener
|
||||
{
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event)
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockBreak(final BlockBreakEvent event)
|
||||
{
|
||||
@Cleanup
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
user.acquireReadLock();
|
||||
if (user.getData().isJailed())
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
@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 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(damager);
|
||||
if (user != null && user.isJailed())
|
||||
{
|
||||
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.HIGHEST)
|
||||
public void onPlayerRespawn(final PlayerRespawnEvent event)
|
||||
{
|
||||
@Cleanup
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
user.acquireReadLock();
|
||||
if (!user.getData().isJailed() || user.getData().getJail() == null || user.getData().getJail().isEmpty())
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
event.setRespawnLocation(getJail(user.getData().getJail()));
|
||||
event.setRespawnLocation(getJail(user.getJail()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -243,17 +270,15 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerTeleport(final PlayerTeleportEvent event)
|
||||
{
|
||||
@Cleanup
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
user.acquireReadLock();
|
||||
if (!user.getData().isJailed() || user.getData().getJail() == null || user.getData().getJail().isEmpty())
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
event.setTo(getJail(user.getData().getJail()));
|
||||
event.setTo(getJail(user.getJail()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -269,20 +294,18 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
user.sendMessage(_("jailMessage"));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
@Cleanup
|
||||
final IUser user = ess.getUser(event.getPlayer());
|
||||
user.acquireReadLock();
|
||||
if (!user.getData().isJailed() || user.getData().getJail() == null || user.getData().getJail().isEmpty())
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
sendToJail(user, user.getData().getJail());
|
||||
sendToJail(user, user.getJail());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import static com.earth2me.essentials.I18n.capitalCase;
|
||||
import com.earth2me.essentials.commands.NoChargeException;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
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 kiteItem : kits.getKeys(false))
|
||||
{
|
||||
if (user == null || user.isAuthorized("essentials.kits." + kiteItem.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
list.append(" ").append(capitalCase(kiteItem));
|
||||
}
|
||||
}
|
||||
return list.toString().trim();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(_("kitError"), ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void checkTime(final User user, final String kitName, final Map<String, Object> els) throws NoChargeException
|
||||
{
|
||||
if (user.isAuthorized("essentials.kit.exemptdelay")) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Calendar time = new GregorianCalendar();
|
||||
|
||||
// Take the current time, and remove the delay from it.
|
||||
final double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0L;
|
||||
final Calendar earliestTime = new GregorianCalendar();
|
||||
earliestTime.add(Calendar.SECOND, -(int)delay);
|
||||
earliestTime.add(Calendar.MILLISECOND, -(int)((delay * 1000.0) % 1000.0));
|
||||
// This value contains the most recent time a kit could have been used that would allow another use.
|
||||
final long earliestLong = earliestTime.getTimeInMillis();
|
||||
|
||||
// When was the last kit used?
|
||||
final long lastTime = user.getKitTimestamp(kitName);
|
||||
|
||||
if (lastTime < earliestLong)
|
||||
{
|
||||
user.setKitTimestamp(kitName, time.getTimeInMillis());
|
||||
}
|
||||
else if (lastTime > time.getTimeInMillis())
|
||||
{
|
||||
// This is to make sure time didn't get messed up on last kit use.
|
||||
// If this happens, let's give the user the benifit of the doubt.
|
||||
user.setKitTimestamp(kitName, time.getTimeInMillis());
|
||||
}
|
||||
else
|
||||
{
|
||||
time.setTimeInMillis(lastTime);
|
||||
time.add(Calendar.SECOND, (int)delay);
|
||||
time.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
|
||||
user.sendMessage(_("kitTimed", Util.formatDateDiff(time.getTimeInMillis())));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getItems(final User user, final Map<String, Object> kit) throws Exception
|
||||
{
|
||||
if (kit == null)
|
||||
{
|
||||
throw new Exception(_("kitError2"));
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
return (List<String>)kit.get("items");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
user.sendMessage(_("kitError2"));
|
||||
throw new Exception(_("kitErrorHelp"), e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void expandItems(final IEssentials ess, final User user, final List<String> items) throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
boolean spew = false;
|
||||
for (String d : items)
|
||||
{
|
||||
final String[] parts = d.split(" ");
|
||||
final String[] item = parts[0].split("[:+',;.]", 2);
|
||||
final int id = Material.getMaterial(Integer.parseInt(item[0])).getId();
|
||||
final short data = item.length > 1 ? Short.parseShort(item[1]) : 0;
|
||||
final int amount = parts.length > 1 ? Integer.parseInt(parts[1]) : 1;
|
||||
|
||||
final ItemStack stack = new ItemStack(id, amount, data);
|
||||
if (parts.length > 2)
|
||||
{
|
||||
for (int i = 2; i < parts.length; i++)
|
||||
{
|
||||
final String[] split = parts[i].split("[:+',;.]", 2);
|
||||
if (split.length < 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final Enchantment enchantment = Enchantments.getByName(split[0]);
|
||||
if (enchantment == null)
|
||||
{
|
||||
throw new Exception("Enchantment not found: " + split[0]);
|
||||
}
|
||||
int level;
|
||||
if (split.length > 1)
|
||||
{
|
||||
level = Integer.parseInt(split[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
level = enchantment.getMaxLevel();
|
||||
}
|
||||
try
|
||||
{
|
||||
stack.addEnchantment(enchantment, level);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Enchantment " + enchantment.getName() + ": " + ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Map<Integer, ItemStack> overfilled;
|
||||
if (user.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
|
||||
}
|
||||
else
|
||||
{
|
||||
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, 0, stack);
|
||||
}
|
||||
for (ItemStack itemStack : overfilled.values())
|
||||
{
|
||||
user.getWorld().dropItemNaturally(user.getLocation(), itemStack);
|
||||
spew = true;
|
||||
}
|
||||
}
|
||||
user.updateInventory();
|
||||
if (spew)
|
||||
{
|
||||
user.sendMessage(_("kitInvFull"));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
user.updateInventory();
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.WARNING, e.getMessage());
|
||||
}
|
||||
else
|
||||
{
|
||||
ess.getLogger().log(Level.WARNING, e.getMessage());
|
||||
}
|
||||
throw new Exception(_("kitError2"), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IKits;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.settings.Kit;
|
||||
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Kits extends AsyncStorageObjectHolder<com.earth2me.essentials.settings.Kits> implements IKits
|
||||
{
|
||||
public Kits(final IEssentials ess)
|
||||
{
|
||||
super(ess, com.earth2me.essentials.settings.Kits.class);
|
||||
onReload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getStorageFile() throws IOException
|
||||
{
|
||||
return new File(ess.getDataFolder(), "kits.yml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Kit getKit(String kitName) throws Exception
|
||||
{
|
||||
acquireReadLock();
|
||||
try
|
||||
{
|
||||
if (getData().getKits() == null || kitName == null
|
||||
|| !getData().getKits().containsKey(kitName.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new Exception(_("kitError2"));
|
||||
}
|
||||
final Kit kit = getData().getKits().get(kitName.toLowerCase(Locale.ENGLISH));
|
||||
if (kit == null)
|
||||
{
|
||||
throw new Exception(_("kitError2"));
|
||||
}
|
||||
return kit;
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendKit(IUser user, String kitName) throws Exception
|
||||
{
|
||||
final Kit kit = getKit(kitName);
|
||||
sendKit(user, kit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendKit(IUser user, Kit kit) throws Exception
|
||||
{
|
||||
final List<ItemStack> itemList = kit.getItems();
|
||||
user.giveItems(itemList, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getList() throws Exception
|
||||
{
|
||||
acquireReadLock();
|
||||
try
|
||||
{
|
||||
if (getData().getKits() == null)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return new ArrayList<String>(getData().getKits().keySet());
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return getData().getKits().isEmpty();
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.storage;
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.security.DigestInputStream;
|
||||
@@ -1,48 +1,47 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public enum Mob
|
||||
{
|
||||
CHICKEN("Chicken", Enemies.FRIENDLY, CreatureType.CHICKEN),
|
||||
COW("Cow", Enemies.FRIENDLY, CreatureType.COW),
|
||||
CREEPER("Creeper", Enemies.ENEMY, CreatureType.CREEPER),
|
||||
GHAST("Ghast", Enemies.ENEMY, CreatureType.GHAST),
|
||||
GIANT("Giant", Enemies.ENEMY, CreatureType.GIANT),
|
||||
PIG("Pig", Enemies.FRIENDLY, CreatureType.PIG),
|
||||
PIGZOMB("PigZombie", Enemies.NEUTRAL, CreatureType.PIG_ZOMBIE),
|
||||
SHEEP("Sheep", Enemies.FRIENDLY, "", CreatureType.SHEEP),
|
||||
SKELETON("Skeleton", Enemies.ENEMY, CreatureType.SKELETON),
|
||||
SLIME("Slime", Enemies.ENEMY, CreatureType.SLIME),
|
||||
SPIDER("Spider", Enemies.ENEMY, CreatureType.SPIDER),
|
||||
SQUID("Squid", Enemies.FRIENDLY, CreatureType.SQUID),
|
||||
ZOMBIE("Zombie", Enemies.ENEMY, CreatureType.ZOMBIE),
|
||||
WOLF("Wolf", Enemies.NEUTRAL, CreatureType.WOLF),
|
||||
CAVESPIDER("CaveSpider", Enemies.ENEMY, CreatureType.CAVE_SPIDER),
|
||||
ENDERMAN("Enderman", Enemies.ENEMY, "", CreatureType.ENDERMAN),
|
||||
SILVERFISH("Silverfish", Enemies.ENEMY, "", CreatureType.SILVERFISH),
|
||||
ENDERDRAGON("EnderDragon", Enemies.ENEMY, CreatureType.ENDER_DRAGON),
|
||||
VILLAGER("Villager", Enemies.FRIENDLY, CreatureType.VILLAGER),
|
||||
BLAZE("Blaze", Enemies.ENEMY, CreatureType.BLAZE),
|
||||
MUSHROOMCOW("MushroomCow", Enemies.FRIENDLY, CreatureType.MUSHROOM_COW),
|
||||
MAGMACUBE("MagmaCube", Enemies.ENEMY, CreatureType.MAGMA_CUBE),
|
||||
SNOWMAN("Snowman", Enemies.FRIENDLY, "", CreatureType.SNOWMAN);
|
||||
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),
|
||||
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);
|
||||
|
||||
public static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
private Mob(String n, Enemies en, String s, CreatureType type)
|
||||
private Mob(String n, Enemies en, String s, EntityType type)
|
||||
{
|
||||
this.suffix = s;
|
||||
this.name = n;
|
||||
@@ -50,7 +49,7 @@ public enum Mob
|
||||
this.bukkitType = type;
|
||||
}
|
||||
|
||||
private Mob(String n, Enemies en, CreatureType type)
|
||||
private Mob(String n, Enemies en, EntityType type)
|
||||
{
|
||||
this.name = n;
|
||||
this.type = en;
|
||||
@@ -59,7 +58,7 @@ public enum Mob
|
||||
public String suffix = "s";
|
||||
final public String name;
|
||||
final public Enemies type;
|
||||
final private CreatureType bukkitType;
|
||||
final private EntityType bukkitType;
|
||||
private static final Map<String, Mob> hashMap = new HashMap<String, Mob>();
|
||||
|
||||
static
|
||||
@@ -71,7 +70,7 @@ public enum Mob
|
||||
}
|
||||
|
||||
public static Set<String> getMobList() {
|
||||
return hashMap.keySet();
|
||||
return Collections.unmodifiableSet(hashMap.keySet());
|
||||
}
|
||||
|
||||
public LivingEntity spawn(final Player player, final Server server, final Location loc) throws MobException
|
||||
@@ -99,7 +98,7 @@ public enum Mob
|
||||
final protected String type;
|
||||
}
|
||||
|
||||
public CreatureType getType()
|
||||
public EntityType getType()
|
||||
{
|
||||
return bukkitType;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,38 @@
|
||||
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.entity.Player;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.permissions.ServerOperator;
|
||||
|
||||
|
||||
public class PlayerExtension implements Player
|
||||
{
|
||||
@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 final Player getBase()
|
||||
{
|
||||
return base;
|
||||
}
|
||||
|
||||
public final Player setBase(final Player base)
|
||||
{
|
||||
return this.base = base;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,937 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.signs.EssentialsSign;
|
||||
import com.earth2me.essentials.signs.Signs;
|
||||
import com.earth2me.essentials.textreader.IText;
|
||||
import com.earth2me.essentials.textreader.SimpleTextInput;
|
||||
import java.io.File;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.MemoryConfiguration;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Settings implements ISettings
|
||||
{
|
||||
private final transient EssentialsConf config;
|
||||
private final static Logger logger = Logger.getLogger("Minecraft");
|
||||
private final transient IEssentials ess;
|
||||
private boolean metricsEnabled = true;
|
||||
|
||||
public Settings(IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
config = new EssentialsConf(new File(ess.getDataFolder(), "config.yml"));
|
||||
config.setTemplateName("/config.yml");
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getRespawnAtHome()
|
||||
{
|
||||
return config.getBoolean("respawn-at-home", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUpdateBedAtDaytime()
|
||||
{
|
||||
return config.getBoolean("update-bed-at-daytime", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getMultipleHomes()
|
||||
{
|
||||
return config.getConfigurationSection("sethome-multiple").getKeys(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHomeLimit(final User user)
|
||||
{
|
||||
int limit = 1;
|
||||
if (user.isAuthorized("essentials.sethome.multiple"))
|
||||
{
|
||||
limit = getHomeLimit("default");
|
||||
}
|
||||
|
||||
final Set<String> homeList = getMultipleHomes();
|
||||
if (homeList != null)
|
||||
{
|
||||
for (String set : homeList)
|
||||
{
|
||||
if (user.isAuthorized("essentials.sethome.multiple." + set) && (limit < getHomeLimit(set)))
|
||||
{
|
||||
limit = getHomeLimit(set);
|
||||
}
|
||||
}
|
||||
}
|
||||
return limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHomeLimit(final String set)
|
||||
{
|
||||
return config.getInt("sethome-multiple." + set, config.getInt("sethome-multiple.default", 3));
|
||||
}
|
||||
private int chatRadius = 0;
|
||||
|
||||
private int _getChatRadius()
|
||||
{
|
||||
return config.getInt("chat.radius", config.getInt("chat-radius", 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChatRadius()
|
||||
{
|
||||
return chatRadius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTeleportDelay()
|
||||
{
|
||||
return config.getDouble("teleport-delay", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOversizedStackSize()
|
||||
{
|
||||
return config.getInt("oversized-stacksize", 64);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultStackSize()
|
||||
{
|
||||
return config.getInt("default-stack-size", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartingBalance()
|
||||
{
|
||||
return config.getInt("starting-balance", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandDisabled(final IEssentialsCommand cmd)
|
||||
{
|
||||
return isCommandDisabled(cmd.getName());
|
||||
}
|
||||
private Set<String> disabledCommands = new HashSet<String>();
|
||||
|
||||
@Override
|
||||
public boolean isCommandDisabled(String label)
|
||||
{
|
||||
return disabledCommands.contains(label);
|
||||
}
|
||||
|
||||
private Set<String> getDisabledCommands()
|
||||
{
|
||||
Set<String> disCommands = new HashSet<String>();
|
||||
for (String c : config.getStringList("disabled-commands"))
|
||||
{
|
||||
disCommands.add(c.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
for (String c : config.getKeys(false))
|
||||
{
|
||||
if (c.startsWith("disable-"))
|
||||
{
|
||||
disCommands.add(c.substring(8).toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
}
|
||||
return disCommands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerCommand(String label)
|
||||
{
|
||||
for (String c : config.getStringList("player-commands"))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(label))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandOverridden(String name)
|
||||
{
|
||||
for (String c : config.getStringList("overridden-commands"))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return config.getBoolean("override-" + name.toLowerCase(Locale.ENGLISH), false);
|
||||
}
|
||||
private ConfigurationSection commandCosts;
|
||||
|
||||
@Override
|
||||
public double getCommandCost(IEssentialsCommand cmd)
|
||||
{
|
||||
return getCommandCost(cmd.getName());
|
||||
}
|
||||
|
||||
public ConfigurationSection _getCommandCosts()
|
||||
{
|
||||
if (config.isConfigurationSection("command-costs"))
|
||||
{
|
||||
final ConfigurationSection section = config.getConfigurationSection("command-costs");
|
||||
final ConfigurationSection newSection = new MemoryConfiguration();
|
||||
for (String command : section.getKeys(false))
|
||||
{
|
||||
if (section.isDouble(command))
|
||||
{
|
||||
newSection.set(command.toLowerCase(Locale.ENGLISH), section.getDouble(command));
|
||||
}
|
||||
else if (section.isInt(command))
|
||||
{
|
||||
newSection.set(command.toLowerCase(Locale.ENGLISH), (double)section.getInt(command));
|
||||
}
|
||||
}
|
||||
return newSection;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCommandCost(String name)
|
||||
{
|
||||
name = name.replace('.', '_').replace('/', '_');
|
||||
if (commandCosts != null)
|
||||
{
|
||||
return commandCosts.getDouble(name, 0.0);
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
private String nicknamePrefix = "~";
|
||||
|
||||
private String _getNicknamePrefix()
|
||||
{
|
||||
return config.getString("nickname-prefix", "~");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNicknamePrefix()
|
||||
{
|
||||
return nicknamePrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTeleportCooldown()
|
||||
{
|
||||
return config.getDouble("teleport-cooldown", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHealCooldown()
|
||||
{
|
||||
return config.getDouble("heal-cooldown", 0);
|
||||
}
|
||||
private ConfigurationSection kits;
|
||||
|
||||
public ConfigurationSection _getKits()
|
||||
{
|
||||
if (config.isConfigurationSection("kits"))
|
||||
{
|
||||
final ConfigurationSection section = config.getConfigurationSection("kits");
|
||||
final ConfigurationSection newSection = new MemoryConfiguration();
|
||||
for (String kitItem : section.getKeys(false))
|
||||
{
|
||||
if (section.isConfigurationSection(kitItem))
|
||||
{
|
||||
newSection.set(kitItem.toLowerCase(Locale.ENGLISH), section.getConfigurationSection(kitItem));
|
||||
}
|
||||
}
|
||||
return newSection;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigurationSection getKits()
|
||||
{
|
||||
return kits;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getKit(String name)
|
||||
{
|
||||
name = name.replace('.', '_').replace('/', '_');
|
||||
if (getKits() != null)
|
||||
{
|
||||
final ConfigurationSection kits = getKits();
|
||||
if (kits.isConfigurationSection(name))
|
||||
{
|
||||
return kits.getConfigurationSection(name).getValues(true);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private ChatColor operatorColor = null;
|
||||
|
||||
@Override
|
||||
public ChatColor getOperatorColor()
|
||||
{
|
||||
return operatorColor;
|
||||
}
|
||||
|
||||
private ChatColor _getOperatorColor()
|
||||
{
|
||||
String colorName = config.getString("ops-name-color", null);
|
||||
|
||||
if (colorName == null)
|
||||
{
|
||||
return ChatColor.DARK_RED;
|
||||
}
|
||||
if ("none".equalsIgnoreCase(colorName) || colorName.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return ChatColor.valueOf(colorName.toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
}
|
||||
|
||||
return ChatColor.getByChar(colorName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpawnMobLimit()
|
||||
{
|
||||
return config.getInt("spawnmob-limit", 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showNonEssCommandsInHelp()
|
||||
{
|
||||
return config.getBoolean("non-ess-in-help", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hidePermissionlessHelp()
|
||||
{
|
||||
return config.getBoolean("hide-permissionless-help", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProtectCreeperMaxHeight()
|
||||
{
|
||||
return config.getInt("protect.creeper.max-height", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areSignsDisabled()
|
||||
{
|
||||
return !signsEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBackupInterval()
|
||||
{
|
||||
return config.getInt("backup.interval", 1440); // 1440 = 24 * 60
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBackupCommand()
|
||||
{
|
||||
return config.getString("backup.command", null);
|
||||
}
|
||||
private Map<String, MessageFormat> chatFormats = Collections.synchronizedMap(new HashMap<String, MessageFormat>());
|
||||
|
||||
@Override
|
||||
public MessageFormat getChatFormat(String group)
|
||||
{
|
||||
MessageFormat mFormat = chatFormats.get(group);
|
||||
if (mFormat == null)
|
||||
{
|
||||
String format = config.getString("chat.group-formats." + (group == null ? "Default" : group),
|
||||
config.getString("chat.format", "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}"));
|
||||
format = Util.replaceFormat(format);
|
||||
format = format.replace("{DISPLAYNAME}", "%1$s");
|
||||
format = format.replace("{GROUP}", "{0}");
|
||||
format = format.replace("{MESSAGE}", "%2$s");
|
||||
format = format.replace("{WORLDNAME}", "{1}");
|
||||
format = format.replace("{SHORTWORLDNAME}", "{2}");
|
||||
format = format.replaceAll("\\{(\\D*?)\\}", "\\[$1\\]");
|
||||
format = "§r".concat(format);
|
||||
mFormat = new MessageFormat(format);
|
||||
chatFormats.put(group, mFormat);
|
||||
}
|
||||
return mFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAnnounceNewPlayers()
|
||||
{
|
||||
return !config.getString("newbies.announce-format", "-").isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IText getAnnounceNewPlayerFormat()
|
||||
{
|
||||
return new SimpleTextInput(Util.replaceFormat(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNewPlayerKit()
|
||||
{
|
||||
return config.getString("newbies.kit", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNewbieSpawn()
|
||||
{
|
||||
return config.getString("newbies.spawnpoint", "default");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPerWarpPermission()
|
||||
{
|
||||
return config.getBoolean("per-warp-permission", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getSortListByGroups()
|
||||
{
|
||||
return config.getBoolean("sort-list-by-groups", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
config.load();
|
||||
noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds"));
|
||||
enabledSigns = _getEnabledSigns();
|
||||
teleportInvulnerability = _isTeleportInvulnerability();
|
||||
disableItemPickupWhileAfk = _getDisableItemPickupWhileAfk();
|
||||
registerBackInListener = _registerBackInListener();
|
||||
cancelAfkOnMove = _cancelAfkOnMove();
|
||||
getFreezeAfkPlayers = _getFreezeAfkPlayers();
|
||||
itemSpawnBl = _getItemSpawnBlacklist();
|
||||
loginAttackDelay = _getLoginAttackDelay();
|
||||
signUsePerSecond = _getSignUsePerSecond();
|
||||
kits = _getKits();
|
||||
chatFormats.clear();
|
||||
changeDisplayName = _changeDisplayName();
|
||||
disabledCommands = getDisabledCommands();
|
||||
nicknamePrefix = _getNicknamePrefix();
|
||||
operatorColor = _getOperatorColor();
|
||||
changePlayerListName = _changePlayerListName();
|
||||
configDebug = _isDebug();
|
||||
prefixsuffixconfigured = _isPrefixSuffixConfigured();
|
||||
addprefixsuffix = _addPrefixSuffix();
|
||||
disablePrefix = _disablePrefix();
|
||||
disableSuffix = _disableSuffix();
|
||||
chatRadius = _getChatRadius();
|
||||
commandCosts = _getCommandCosts();
|
||||
warnOnBuildDisallow = _warnOnBuildDisallow();
|
||||
}
|
||||
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
|
||||
|
||||
@Override
|
||||
public List<Integer> itemSpawnBlacklist()
|
||||
{
|
||||
return itemSpawnBl;
|
||||
}
|
||||
|
||||
private List<Integer> _getItemSpawnBlacklist()
|
||||
{
|
||||
final List<Integer> epItemSpwn = new ArrayList<Integer>();
|
||||
if (ess.getItemDb() == null)
|
||||
{
|
||||
logger.log(Level.FINE, "Aborting ItemSpawnBL read, itemDB not yet loaded.");
|
||||
return epItemSpwn;
|
||||
}
|
||||
for (String itemName : config.getString("item-spawn-blacklist", "").split(","))
|
||||
{
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
try
|
||||
{
|
||||
final ItemStack iStack = ess.getItemDb().get(itemName);
|
||||
epItemSpwn.add(iStack.getTypeId());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, _("unknownItemInList", itemName, "item-spawn-blacklist"));
|
||||
}
|
||||
}
|
||||
return epItemSpwn;
|
||||
}
|
||||
private List<EssentialsSign> enabledSigns = new ArrayList<EssentialsSign>();
|
||||
private boolean signsEnabled = false;
|
||||
|
||||
@Override
|
||||
public List<EssentialsSign> enabledSigns()
|
||||
{
|
||||
return enabledSigns;
|
||||
}
|
||||
|
||||
private List<EssentialsSign> _getEnabledSigns()
|
||||
{
|
||||
List<EssentialsSign> newSigns = new ArrayList<EssentialsSign>();
|
||||
|
||||
for (String signName : config.getStringList("enabledSigns"))
|
||||
{
|
||||
signName = signName.trim().toUpperCase(Locale.ENGLISH);
|
||||
if (signName.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (signName.equals("COLOR") || signName.equals("COLOUR"))
|
||||
{
|
||||
signsEnabled = true;
|
||||
continue;
|
||||
}
|
||||
try
|
||||
{
|
||||
newSigns.add(Signs.valueOf(signName).getSign());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, _("unknownItemInList", signName, "enabledSigns"));
|
||||
continue;
|
||||
}
|
||||
signsEnabled = true;
|
||||
}
|
||||
return newSigns;
|
||||
}
|
||||
private boolean warnOnBuildDisallow;
|
||||
|
||||
private boolean _warnOnBuildDisallow()
|
||||
{
|
||||
return config.getBoolean("protect.disable.warn-on-build-disallow", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean warnOnBuildDisallow()
|
||||
{
|
||||
return warnOnBuildDisallow;
|
||||
}
|
||||
private boolean debug = false;
|
||||
private boolean configDebug = false;
|
||||
|
||||
private boolean _isDebug()
|
||||
{
|
||||
return config.getBoolean("debug", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebug()
|
||||
{
|
||||
return debug || configDebug;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean warnOnSmite()
|
||||
{
|
||||
return config.getBoolean("warn-on-smite", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean permissionBasedItemSpawn()
|
||||
{
|
||||
return config.getBoolean("permission-based-item-spawn", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocale()
|
||||
{
|
||||
return config.getString("locale", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrencySymbol()
|
||||
{
|
||||
return config.getString("currency-symbol", "$").concat("$").substring(0, 1).replaceAll("[0-9]", "$");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTradeInStacks(int id)
|
||||
{
|
||||
return config.getBoolean("trade-in-stacks-" + id, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEcoDisabled()
|
||||
{
|
||||
return config.getBoolean("disable-eco", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getProtectPreventSpawn(final String creatureName)
|
||||
{
|
||||
return config.getBoolean("protect.prevent.spawn." + creatureName, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getProtectList(final String configName)
|
||||
{
|
||||
final List<Integer> list = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString(configName, "").split(","))
|
||||
{
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ItemStack itemStack;
|
||||
try
|
||||
{
|
||||
itemStack = ess.getItemDb().get(itemName);
|
||||
list.add(itemStack.getTypeId());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, _("unknownItemInList", itemName, configName));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtectString(final String configName)
|
||||
{
|
||||
return config.getString(configName, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getProtectBoolean(final String configName, boolean def)
|
||||
{
|
||||
return config.getBoolean(configName, def);
|
||||
}
|
||||
private final static double MAXMONEY = 10000000000000.0;
|
||||
|
||||
@Override
|
||||
public double getMaxMoney()
|
||||
{
|
||||
double max = config.getDouble("max-money", MAXMONEY);
|
||||
if (Math.abs(max) > MAXMONEY)
|
||||
{
|
||||
max = max < 0 ? -MAXMONEY : MAXMONEY;
|
||||
}
|
||||
return max;
|
||||
}
|
||||
private final static double MINMONEY = -10000000000000.0;
|
||||
|
||||
@Override
|
||||
public double getMinMoney()
|
||||
{
|
||||
double min = config.getDouble("min-money", MINMONEY);
|
||||
if (min > 0)
|
||||
{
|
||||
min = -min;
|
||||
}
|
||||
if (min < MINMONEY)
|
||||
{
|
||||
min = MINMONEY;
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEcoLogEnabled()
|
||||
{
|
||||
return config.getBoolean("economy-log-enabled", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEcoLogUpdateEnabled()
|
||||
{
|
||||
return config.getBoolean("economy-log-update-enabled", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeGodOnDisconnect()
|
||||
{
|
||||
return config.getBoolean("remove-god-on-disconnect", false);
|
||||
}
|
||||
private boolean changeDisplayName = true;
|
||||
|
||||
private boolean _changeDisplayName()
|
||||
{
|
||||
return config.getBoolean("change-displayname", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean changeDisplayName()
|
||||
{
|
||||
return changeDisplayName;
|
||||
}
|
||||
private boolean changePlayerListName = false;
|
||||
|
||||
private boolean _changePlayerListName()
|
||||
{
|
||||
return config.getBoolean("change-playerlist", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean changePlayerListName()
|
||||
{
|
||||
return changePlayerListName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useBukkitPermissions()
|
||||
{
|
||||
return config.getBoolean("use-bukkit-permissions", false);
|
||||
}
|
||||
private boolean prefixsuffixconfigured = false;
|
||||
private boolean addprefixsuffix = false;
|
||||
|
||||
private boolean _addPrefixSuffix()
|
||||
{
|
||||
return config.getBoolean("add-prefix-suffix", false);
|
||||
}
|
||||
|
||||
private boolean _isPrefixSuffixConfigured()
|
||||
{
|
||||
return config.hasProperty("add-prefix-suffix");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPrefixSuffix()
|
||||
{
|
||||
return prefixsuffixconfigured ? addprefixsuffix : ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat");
|
||||
}
|
||||
private boolean disablePrefix = false;
|
||||
|
||||
private boolean _disablePrefix()
|
||||
{
|
||||
return config.getBoolean("disablePrefix", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disablePrefix()
|
||||
{
|
||||
return disablePrefix;
|
||||
}
|
||||
private boolean disableSuffix = false;
|
||||
|
||||
private boolean _disableSuffix()
|
||||
{
|
||||
return config.getBoolean("disableSuffix", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableSuffix()
|
||||
{
|
||||
return disableSuffix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAutoAfk()
|
||||
{
|
||||
return config.getLong("auto-afk", 300);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAutoAfkKick()
|
||||
{
|
||||
return config.getLong("auto-afk-kick", -1);
|
||||
}
|
||||
private boolean getFreezeAfkPlayers;
|
||||
|
||||
@Override
|
||||
public boolean getFreezeAfkPlayers()
|
||||
{
|
||||
return getFreezeAfkPlayers;
|
||||
}
|
||||
|
||||
private boolean _getFreezeAfkPlayers()
|
||||
{
|
||||
return config.getBoolean("freeze-afk-players", false);
|
||||
}
|
||||
private boolean cancelAfkOnMove;
|
||||
|
||||
@Override
|
||||
public boolean cancelAfkOnMove()
|
||||
{
|
||||
return cancelAfkOnMove;
|
||||
}
|
||||
|
||||
private boolean _cancelAfkOnMove()
|
||||
{
|
||||
return config.getBoolean("cancel-afk-on-move", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areDeathMessagesEnabled()
|
||||
{
|
||||
return config.getBoolean("death-messages", true);
|
||||
}
|
||||
private Set<String> noGodWorlds = new HashSet<String>();
|
||||
|
||||
@Override
|
||||
public Set<String> getNoGodWorlds()
|
||||
{
|
||||
return noGodWorlds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDebug(final boolean debug)
|
||||
{
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getRepairEnchanted()
|
||||
{
|
||||
return config.getBoolean("repair-enchanted", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorldTeleportPermissions()
|
||||
{
|
||||
return config.getBoolean("world-teleport-permissions", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorldHomePermissions()
|
||||
{
|
||||
return config.getBoolean("world-home-permissions", false);
|
||||
}
|
||||
private boolean registerBackInListener;
|
||||
|
||||
@Override
|
||||
public boolean registerBackInListener()
|
||||
{
|
||||
return registerBackInListener;
|
||||
}
|
||||
|
||||
private boolean _registerBackInListener()
|
||||
{
|
||||
return config.getBoolean("register-back-in-listener", false);
|
||||
}
|
||||
private boolean disableItemPickupWhileAfk;
|
||||
|
||||
@Override
|
||||
public boolean getDisableItemPickupWhileAfk()
|
||||
{
|
||||
return disableItemPickupWhileAfk;
|
||||
}
|
||||
|
||||
private boolean _getDisableItemPickupWhileAfk()
|
||||
{
|
||||
return config.getBoolean("disable-item-pickup-while-afk", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventPriority getRespawnPriority()
|
||||
{
|
||||
String priority = config.getString("respawn-listener-priority", "normal").toLowerCase(Locale.ENGLISH);
|
||||
if ("lowest".equals(priority))
|
||||
{
|
||||
return EventPriority.LOWEST;
|
||||
}
|
||||
if ("low".equals(priority))
|
||||
{
|
||||
return EventPriority.LOW;
|
||||
}
|
||||
if ("normal".equals(priority))
|
||||
{
|
||||
return EventPriority.NORMAL;
|
||||
}
|
||||
if ("high".equals(priority))
|
||||
{
|
||||
return EventPriority.HIGH;
|
||||
}
|
||||
if ("highest".equals(priority))
|
||||
{
|
||||
return EventPriority.HIGHEST;
|
||||
}
|
||||
return EventPriority.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTpaAcceptCancellation()
|
||||
{
|
||||
return config.getLong("tpa-accept-cancellation", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMetricsEnabled()
|
||||
{
|
||||
return metricsEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetricsEnabled(boolean metricsEnabled)
|
||||
{
|
||||
this.metricsEnabled = metricsEnabled;
|
||||
}
|
||||
private boolean teleportInvulnerability;
|
||||
|
||||
@Override
|
||||
public long getTeleportInvulnerability()
|
||||
{
|
||||
return config.getLong("teleport-invulnerability", 0) * 1000;
|
||||
}
|
||||
|
||||
private boolean _isTeleportInvulnerability()
|
||||
{
|
||||
return (config.getLong("teleport-invulnerability", 0) > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTeleportInvulnerability()
|
||||
{
|
||||
return teleportInvulnerability;
|
||||
}
|
||||
private long loginAttackDelay;
|
||||
|
||||
private long _getLoginAttackDelay()
|
||||
{
|
||||
return config.getLong("login-attack-delay", 0) * 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLoginAttackDelay()
|
||||
{
|
||||
return loginAttackDelay;
|
||||
}
|
||||
private int signUsePerSecond;
|
||||
|
||||
private int _getSignUsePerSecond()
|
||||
{
|
||||
final int perSec = config.getInt("sign-use-per-second", 4);
|
||||
return perSec > 0 ? perSec : 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSignUsePerSecond()
|
||||
{
|
||||
return signUsePerSecond;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxFlySpeed()
|
||||
{
|
||||
double maxSpeed = config.getDouble("max-fly-speed", 1.0);
|
||||
return maxSpeed > 1.0 ? 1.0 : Math.abs(maxSpeed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxWalkSpeed()
|
||||
{
|
||||
double maxSpeed = config.getDouble("max-walk-speed", 0.8);
|
||||
return maxSpeed > 1.0 ? 1.0 : Math.abs(maxSpeed);
|
||||
}
|
||||
}
|
||||
+14
-12
@@ -1,8 +1,5 @@
|
||||
package com.earth2me.essentials.listener;
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.craftbukkit.FakeExplosion;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -10,13 +7,13 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
|
||||
public class TntExplodeListener implements Listener, Runnable
|
||||
public class TNTExplodeListener implements Listener, Runnable
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
private transient AtomicBoolean enabled = new AtomicBoolean(false);
|
||||
private transient boolean enabled = false;
|
||||
private transient int timer = -1;
|
||||
|
||||
public TntExplodeListener(final IEssentials ess)
|
||||
public TNTExplodeListener(final IEssentials ess)
|
||||
{
|
||||
super();
|
||||
this.ess = ess;
|
||||
@@ -24,14 +21,15 @@ public class TntExplodeListener implements Listener, Runnable
|
||||
|
||||
public void enable()
|
||||
{
|
||||
if (enabled.compareAndSet(false, true))
|
||||
if (!enabled)
|
||||
{
|
||||
enabled = true;
|
||||
timer = ess.scheduleSyncDelayedTask(this, 1000);
|
||||
return;
|
||||
}
|
||||
if (timer != -1)
|
||||
{
|
||||
ess.getServer().getScheduler().cancelTask(timer);
|
||||
ess.getScheduler().cancelTask(timer);
|
||||
timer = ess.scheduleSyncDelayedTask(this, 1000);
|
||||
}
|
||||
}
|
||||
@@ -39,7 +37,7 @@ public class TntExplodeListener implements Listener, Runnable
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onEntityExplode(final EntityExplodeEvent event)
|
||||
{
|
||||
if (!enabled.get())
|
||||
if (!enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -47,13 +45,17 @@ public class TntExplodeListener implements Listener, Runnable
|
||||
{
|
||||
return;
|
||||
}
|
||||
FakeExplosion.createExplosion(event, ess.getServer(), ess.getServer().getOnlinePlayers());
|
||||
if (event.blockList().size() < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
event.getLocation().getWorld().createExplosion(event.getLocation(), 0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
enabled.set(false);
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,11 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.ITeleport;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import com.earth2me.essentials.user.CooldownException;
|
||||
import com.earth2me.essentials.user.UserData.TimestampType;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
@@ -23,28 +16,29 @@ public class Teleport implements Runnable, ITeleport
|
||||
private static final double MOVE_CONSTANT = 0.3;
|
||||
|
||||
|
||||
private static class Target
|
||||
private class Target
|
||||
{
|
||||
private final Location location;
|
||||
private final Entity entity;
|
||||
private final String name;
|
||||
|
||||
public Target(Location location)
|
||||
Target(Location location)
|
||||
{
|
||||
this.location = location;
|
||||
this.entity = null;
|
||||
this.name = null;
|
||||
}
|
||||
|
||||
public Target(Entity entity)
|
||||
Target(Player entity)
|
||||
{
|
||||
this.entity = entity;
|
||||
this.name = entity.getName();
|
||||
this.location = null;
|
||||
}
|
||||
|
||||
public Location getLocation()
|
||||
{
|
||||
if (this.entity != null)
|
||||
if (this.name != null)
|
||||
{
|
||||
return this.entity.getLocation();
|
||||
|
||||
return ess.getServer().getPlayerExact(name).getLocation();
|
||||
}
|
||||
return location;
|
||||
}
|
||||
@@ -117,7 +111,7 @@ public class Teleport implements Runnable, ITeleport
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
ess.getCommandHandler().showCommandError(user.getBase(), "teleport", ex);
|
||||
ess.showError(user.getBase(), ex, "teleport");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -144,21 +138,46 @@ public class Teleport implements Runnable, ITeleport
|
||||
|
||||
public void warp(String warp, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
final Location loc = ess.getWarps().getWarp(warp);
|
||||
Location loc = ess.getWarps().getWarp(warp);
|
||||
teleport(new Target(loc), chargeFor, cause);
|
||||
user.sendMessage(_("warpingTo", warp));
|
||||
}
|
||||
|
||||
public void cooldown(boolean check) throws Exception
|
||||
{
|
||||
try
|
||||
final Calendar time = new GregorianCalendar();
|
||||
if (user.getLastTeleportTimestamp() > 0)
|
||||
{
|
||||
user.checkCooldown(TimestampType.LASTTELEPORT, ess.getGroups().getTeleportCooldown(user), !check, Permissions.TELEPORT_COOLDOWN_BYPASS);
|
||||
}
|
||||
catch (CooldownException ex)
|
||||
{
|
||||
throw new Exception(_("timeBeforeTeleport", ex.getMessage()));
|
||||
// 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 teleport could have been used that would allow another use.
|
||||
final long earliestLong = earliestTime.getTimeInMillis();
|
||||
|
||||
// When was the last teleport used?
|
||||
final Long lastTime = user.getLastTeleportTimestamp();
|
||||
|
||||
if (lastTime > time.getTimeInMillis())
|
||||
{
|
||||
// This is to make sure time didn't get messed up on last kit use.
|
||||
// If this happens, let's give the user the benifit of the doubt.
|
||||
user.setLastTeleportTimestamp(time.getTimeInMillis());
|
||||
return;
|
||||
}
|
||||
else if (lastTime > earliestLong && !user.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", Util.formatDateDiff(time.getTimeInMillis())));
|
||||
}
|
||||
}
|
||||
// if justCheck is set, don't update lastTeleport; we're just checking
|
||||
if (!check)
|
||||
{
|
||||
user.setLastTeleportTimestamp(time.getTimeInMillis());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,21 +216,21 @@ public class Teleport implements Runnable, ITeleport
|
||||
teleport(new Target(loc), chargeFor, cause);
|
||||
}
|
||||
|
||||
public void teleport(Entity entity, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
public void teleport(Player entity, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
teleport(new Target(entity), chargeFor, cause);
|
||||
}
|
||||
|
||||
private void teleport(Target target, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
double delay = ess.getGroups().getTeleportDelay(user);
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
|
||||
if (chargeFor != null)
|
||||
{
|
||||
chargeFor.isAffordableFor(user);
|
||||
}
|
||||
cooldown(true);
|
||||
if (delay <= 0 || Permissions.TELEPORT_TIMER_BYPASS.isAuthorized(user))
|
||||
if (delay <= 0 || user.isAuthorized("essentials.teleport.timer.bypass"))
|
||||
{
|
||||
cooldown(false);
|
||||
now(target, cause);
|
||||
@@ -255,7 +274,7 @@ public class Teleport implements Runnable, ITeleport
|
||||
now(new Target(loc), cause);
|
||||
}
|
||||
|
||||
public void now(Entity entity, boolean cooldown, TeleportCause cause) throws Exception
|
||||
public void now(Player entity, boolean cooldown, TeleportCause cause) throws Exception
|
||||
{
|
||||
if (cooldown)
|
||||
{
|
||||
@@ -266,37 +285,16 @@ public class Teleport implements Runnable, ITeleport
|
||||
|
||||
public void back(Trade chargeFor) throws Exception
|
||||
{
|
||||
user.acquireReadLock();
|
||||
try
|
||||
{
|
||||
teleport(new Target(user.getData().getLastLocation().getBukkitLocation()), chargeFor, TeleportCause.COMMAND);
|
||||
}
|
||||
finally
|
||||
{
|
||||
user.unlock();
|
||||
}
|
||||
teleport(new Target(user.getLastLocation()), chargeFor, TeleportCause.COMMAND);
|
||||
}
|
||||
|
||||
public void back() throws Exception
|
||||
{
|
||||
user.acquireReadLock();
|
||||
try
|
||||
{
|
||||
now(new Target(user.getData().getLastLocation().getBukkitLocation()), TeleportCause.COMMAND);
|
||||
}
|
||||
finally
|
||||
{
|
||||
user.unlock();
|
||||
}
|
||||
now(new Target(user.getLastLocation()), TeleportCause.COMMAND);
|
||||
}
|
||||
|
||||
public void home(IUser user, String home, Trade chargeFor) throws Exception
|
||||
public void home(Location loc, Trade chargeFor) throws Exception
|
||||
{
|
||||
final Location loc = user.getHome(home);
|
||||
if (loc == null)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
teleport(new Target(loc), chargeFor, TeleportCause.COMMAND);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,8 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.ChargeException;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import com.earth2me.essentials.craftbukkit.SetExpFix;
|
||||
import com.earth2me.essentials.perm.NoCommandCostPermissions;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
@@ -18,7 +12,6 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -27,6 +20,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
public class Trade
|
||||
{
|
||||
private final transient String command;
|
||||
private final transient Trade fallbackTrade;
|
||||
private final transient Double money;
|
||||
private final transient ItemStack itemStack;
|
||||
private final transient Integer exp;
|
||||
@@ -34,27 +28,33 @@ public class Trade
|
||||
|
||||
public Trade(final String command, final IEssentials ess)
|
||||
{
|
||||
this(command, null, null, null, ess);
|
||||
this(command, null, null, null, null, ess);
|
||||
}
|
||||
|
||||
public Trade(final String command, final Trade fallback, final IEssentials ess)
|
||||
{
|
||||
this(command, fallback, null, null, null, ess);
|
||||
}
|
||||
|
||||
public Trade(final double money, final IEssentials ess)
|
||||
{
|
||||
this(null, money, null, null, ess);
|
||||
this(null, null, money, null, null, ess);
|
||||
}
|
||||
|
||||
public Trade(final ItemStack items, final IEssentials ess)
|
||||
{
|
||||
this(null, null, items, null, ess);
|
||||
this(null, null, null, items, null, ess);
|
||||
}
|
||||
|
||||
public Trade(final int exp, final IEssentials ess)
|
||||
{
|
||||
this(null, null, null, exp, ess);
|
||||
this(null, null, null, null, exp, ess);
|
||||
}
|
||||
|
||||
private Trade(final String command, final Double money, final ItemStack item, final Integer exp, final IEssentials ess)
|
||||
private Trade(final String command, final Trade fallback, final Double money, final ItemStack item, final Integer exp, final IEssentials ess)
|
||||
{
|
||||
this.command = command;
|
||||
this.fallbackTrade = fallback;
|
||||
this.money = money;
|
||||
this.itemStack = item;
|
||||
this.exp = exp;
|
||||
@@ -63,11 +63,15 @@ public class Trade
|
||||
|
||||
public void isAffordableFor(final IUser user) throws ChargeException
|
||||
{
|
||||
final double mon = user.getMoney();
|
||||
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "checking if " + user.getName() + " can afford charge.");
|
||||
}
|
||||
|
||||
if (getMoney() != null
|
||||
&& mon < getMoney()
|
||||
&& getMoney() > 0
|
||||
&& !Permissions.ECO_LOAN.isAuthorized(user))
|
||||
&& !user.canAfford(getMoney()))
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
@@ -78,15 +82,10 @@ public class Trade
|
||||
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
|
||||
}
|
||||
|
||||
@Cleanup
|
||||
final ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
|
||||
double money;
|
||||
if (command != null && !command.isEmpty()
|
||||
&& !NoCommandCostPermissions.getPermission(command).isAuthorized(user)
|
||||
&& mon < settings.getData().getEconomy().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
|
||||
&& 0 < settings.getData().getEconomy().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
|
||||
&& !Permissions.ECO_LOAN.isAuthorized(user))
|
||||
&& 0 < (money = getCommandCost(user))
|
||||
&& !user.canAfford(money))
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
@@ -116,21 +115,21 @@ public class Trade
|
||||
{
|
||||
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItem(user.getInventory(), true, getItemStack());
|
||||
final Location loc = user.getLocation();
|
||||
for (ItemStack dropStack : leftOver.values())
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
final int maxStackSize = dropStack.getType().getMaxStackSize();
|
||||
final int stacks = dropStack.getAmount() / maxStackSize;
|
||||
final int leftover = dropStack.getAmount() % maxStackSize;
|
||||
final int maxStackSize = itemStack.getType().getMaxStackSize();
|
||||
final int stacks = itemStack.getAmount() / maxStackSize;
|
||||
final int leftover = itemStack.getAmount() % maxStackSize;
|
||||
final Item[] itemStacks = new Item[stacks + (leftover > 0 ? 1 : 0)];
|
||||
for (int i = 0; i < stacks; i++)
|
||||
{
|
||||
final ItemStack stack = dropStack.clone();
|
||||
final ItemStack stack = itemStack.clone();
|
||||
stack.setAmount(maxStackSize);
|
||||
itemStacks[i] = loc.getWorld().dropItem(loc, stack);
|
||||
}
|
||||
if (leftover > 0)
|
||||
{
|
||||
final ItemStack stack = dropStack.clone();
|
||||
final ItemStack stack = itemStack.clone();
|
||||
stack.setAmount(leftover);
|
||||
itemStacks[stacks] = loc.getWorld().dropItem(loc, stack);
|
||||
}
|
||||
@@ -151,10 +150,14 @@ public class Trade
|
||||
|
||||
public void charge(final IUser user) throws ChargeException
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "charging user " + user.getName());
|
||||
}
|
||||
|
||||
if (getMoney() != null)
|
||||
{
|
||||
final double mon = user.getMoney();
|
||||
if (mon < getMoney() && getMoney() > 0 && !Permissions.ECO_LOAN.isAuthorized(user))
|
||||
if (!user.canAfford(getMoney()) && getMoney() > 0.0d)
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
@@ -169,15 +172,10 @@ public class Trade
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, true, getItemStack());
|
||||
user.updateInventory();
|
||||
}
|
||||
if (command != null && !command.isEmpty()
|
||||
&& !NoCommandCostPermissions.getPermission(command).isAuthorized(user))
|
||||
if (command != null)
|
||||
{
|
||||
@Cleanup
|
||||
final ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
final double mon = user.getMoney();
|
||||
final double cost = settings.getData().getEconomy().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
|
||||
if (mon < cost && cost > 0 && !Permissions.ECO_LOAN.isAuthorized(user))
|
||||
final double cost = getCommandCost(user);
|
||||
if (!user.canAfford(cost) && cost > 0.0d)
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
@@ -208,14 +206,36 @@ public class Trade
|
||||
{
|
||||
return exp;
|
||||
}
|
||||
|
||||
public Double getCommandCost(final IUser user)
|
||||
{
|
||||
double cost = 0.0d;
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
|
||||
if (cost == 0.0d && 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 != 0.0d && (user.isAuthorized("essentials.nocommandcost.all")
|
||||
|| user.isAuthorized("essentials.nocommandcost." + command)))
|
||||
{
|
||||
return 0.0d;
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
private static FileWriter fw = null;
|
||||
|
||||
public static void log(String type, String subtype, String event, String sender, Trade charge, String receiver, Trade pay, Location loc, IEssentials ess)
|
||||
{
|
||||
@Cleanup
|
||||
final ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
if (!settings.getData().getEconomy().isLogEnabled())
|
||||
if ((loc == null && !ess.getSettings().isEcoLogUpdateEnabled())
|
||||
|| (loc != null && !ess.getSettings().isEcoLogEnabled()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -255,7 +275,7 @@ public class Trade
|
||||
{
|
||||
sb.append(charge.getMoney()).append(",");
|
||||
sb.append("money").append(",");
|
||||
sb.append(settings.getData().getEconomy().getCurrencySymbol());
|
||||
sb.append(ess.getSettings().getCurrencySymbol());
|
||||
}
|
||||
if (charge.getExperience() != null)
|
||||
{
|
||||
@@ -286,7 +306,7 @@ public class Trade
|
||||
{
|
||||
sb.append(pay.getMoney()).append(",");
|
||||
sb.append("money").append(",");
|
||||
sb.append(settings.getData().getEconomy().getCurrencySymbol());
|
||||
sb.append(ess.getSettings().getCurrencySymbol());
|
||||
}
|
||||
if (pay.getExperience() != null)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,731 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
|
||||
public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
{
|
||||
private CommandSender replyTo = null;
|
||||
private transient User teleportRequester;
|
||||
private transient boolean teleportRequestHere;
|
||||
private transient boolean vanished;
|
||||
private transient final Teleport teleport;
|
||||
private transient long teleportRequestTime;
|
||||
private transient long lastOnlineActivity;
|
||||
private transient long lastThrottledAction;
|
||||
private transient long lastActivity = System.currentTimeMillis();
|
||||
private boolean hidden = false;
|
||||
private boolean rightClickJump = false;
|
||||
private transient Location afkPosition = null;
|
||||
private boolean invSee = false;
|
||||
private boolean enderSee = false;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
User(final Player base, final IEssentials ess)
|
||||
{
|
||||
super(base, ess);
|
||||
teleport = new Teleport(this, ess);
|
||||
if (isAfk())
|
||||
{
|
||||
afkPosition = getLocation();
|
||||
}
|
||||
}
|
||||
|
||||
User update(final Player base)
|
||||
{
|
||||
setBase(base);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(final IEssentialsCommand cmd)
|
||||
{
|
||||
return isAuthorized(cmd, "essentials.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(final IEssentialsCommand cmd, final String permissionPrefix)
|
||||
{
|
||||
return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(final String node)
|
||||
{
|
||||
final boolean result = isAuthorizedCheck(node);
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "checking if " + base.getName() + " has " + node + " - " + result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isAuthorizedCheck(final String node)
|
||||
{
|
||||
|
||||
if (base instanceof OfflinePlayer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isJailed())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return ess.getPermissionsHandler().hasPermission(base, node);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.SEVERE, "Permission System Error: " + ess.getPermissionsHandler().getName() + " returned: " + ex.getMessage(), ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
ess.getLogger().log(Level.SEVERE, "Permission System Error: " + ess.getPermissionsHandler().getName() + " returned: " + ex.getMessage());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void healCooldown() throws Exception
|
||||
{
|
||||
final Calendar now = new GregorianCalendar();
|
||||
if (getLastHealTimestamp() > 0)
|
||||
{
|
||||
final double cooldown = ess.getSettings().getHealCooldown();
|
||||
final Calendar cooldownTime = new GregorianCalendar();
|
||||
cooldownTime.setTimeInMillis(getLastHealTimestamp());
|
||||
cooldownTime.add(Calendar.SECOND, (int)cooldown);
|
||||
cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
|
||||
if (cooldownTime.after(now) && !isAuthorized("essentials.heal.cooldown.bypass"))
|
||||
{
|
||||
throw new Exception(_("timeBeforeHeal", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
|
||||
}
|
||||
}
|
||||
setLastHealTimestamp(now.getTimeInMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveMoney(final double value)
|
||||
{
|
||||
giveMoney(value, null);
|
||||
}
|
||||
|
||||
public void giveMoney(final double value, final CommandSender initiator)
|
||||
{
|
||||
if (value == 0.0d)
|
||||
{
|
||||
return;
|
||||
}
|
||||
setMoney(getMoney() + value);
|
||||
sendMessage(_("addedToAccount", Util.displayCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage(_("addedToOthersAccount", Util.displayCurrency(value, ess), this.getDisplayName(), Util.displayCurrency(getMoney(), ess)));
|
||||
}
|
||||
}
|
||||
|
||||
public void payUser(final User reciever, final double value) throws Exception
|
||||
{
|
||||
if (value == 0.0d)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (canAfford(value))
|
||||
{
|
||||
setMoney(getMoney() - value);
|
||||
reciever.setMoney(reciever.getMoney() + value);
|
||||
sendMessage(_("moneySentTo", Util.displayCurrency(value, ess), reciever.getDisplayName()));
|
||||
reciever.sendMessage(_("moneyRecievedFrom", Util.displayCurrency(value, ess), getDisplayName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("notEnoughMoney"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void takeMoney(final double value)
|
||||
{
|
||||
takeMoney(value, null);
|
||||
}
|
||||
|
||||
public void takeMoney(final double value, final CommandSender initiator)
|
||||
{
|
||||
if (value == 0.0d)
|
||||
{
|
||||
return;
|
||||
}
|
||||
setMoney(getMoney() - value);
|
||||
sendMessage(_("takenFromAccount", Util.displayCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage(_("takenFromOthersAccount", Util.displayCurrency(value, ess), this.getDisplayName(), Util.displayCurrency(getMoney(), ess)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAfford(final double cost)
|
||||
{
|
||||
return canAfford(cost, true);
|
||||
}
|
||||
|
||||
public boolean canAfford(final double cost, final boolean permcheck)
|
||||
{
|
||||
if (cost <= 0.0d)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
final double mon = getMoney();
|
||||
if (!permcheck || isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
return (mon - cost) >= ess.getSettings().getMinMoney();
|
||||
}
|
||||
return cost <= mon;
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
this.base = new OfflinePlayer(getName(), ess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReplyTo(final CommandSender user)
|
||||
{
|
||||
replyTo = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSender getReplyTo()
|
||||
{
|
||||
return replyTo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(final User other)
|
||||
{
|
||||
return Util.stripFormat(this.getDisplayName()).compareToIgnoreCase(Util.stripFormat(other.getDisplayName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object object)
|
||||
{
|
||||
if (!(object instanceof User))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return this.getName().equalsIgnoreCase(((User)object).getName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return this.getName().hashCode();
|
||||
}
|
||||
|
||||
public Boolean canSpawnItem(final int itemId)
|
||||
{
|
||||
return !ess.getSettings().itemSpawnBlacklist().contains(itemId);
|
||||
}
|
||||
|
||||
public Location getHome() throws Exception
|
||||
{
|
||||
return getHome(getHomes().get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastLocation()
|
||||
{
|
||||
setLastLocation(getLocation());
|
||||
}
|
||||
|
||||
public void requestTeleport(final User player, final boolean here)
|
||||
{
|
||||
teleportRequestTime = System.currentTimeMillis();
|
||||
teleportRequester = player;
|
||||
teleportRequestHere = here;
|
||||
}
|
||||
|
||||
public User getTeleportRequest()
|
||||
{
|
||||
return teleportRequester;
|
||||
}
|
||||
|
||||
public boolean isTpRequestHere()
|
||||
{
|
||||
return teleportRequestHere;
|
||||
}
|
||||
|
||||
public String getNick(final boolean longnick)
|
||||
{
|
||||
final StringBuilder prefix = new StringBuilder();
|
||||
String nickname;
|
||||
String suffix = "";
|
||||
final String nick = getNickname();
|
||||
if (ess.getSettings().isCommandDisabled("nick") || nick == null || nick.isEmpty() || nick.equals(getName()))
|
||||
{
|
||||
nickname = getName();
|
||||
}
|
||||
else
|
||||
{
|
||||
nickname = ess.getSettings().getNicknamePrefix() + nick;
|
||||
}
|
||||
|
||||
if (isOp())
|
||||
{
|
||||
try
|
||||
{
|
||||
final ChatColor opPrefix = ess.getSettings().getOperatorColor();
|
||||
if (opPrefix != null && opPrefix.toString().length() > 0)
|
||||
{
|
||||
prefix.insert(0, opPrefix.toString());
|
||||
suffix = "§r";
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (ess.getSettings().addPrefixSuffix())
|
||||
{
|
||||
if (!ess.getSettings().disablePrefix())
|
||||
{
|
||||
final String ptext = ess.getPermissionsHandler().getPrefix(base).replace('&', '§');
|
||||
prefix.insert(0, ptext);
|
||||
suffix = "§r";
|
||||
}
|
||||
if (!ess.getSettings().disableSuffix())
|
||||
{
|
||||
final String stext = ess.getPermissionsHandler().getSuffix(base).replace('&', '§');
|
||||
suffix = stext + "§r";
|
||||
suffix = suffix.replace("§f§f", "§f").replace("§f§r", "§r").replace("§r§r", "§r");
|
||||
}
|
||||
}
|
||||
final String strPrefix = prefix.toString();
|
||||
String output = strPrefix + nickname + suffix;
|
||||
if (!longnick && output.length() > 16)
|
||||
{
|
||||
output = strPrefix + nickname;
|
||||
}
|
||||
if (!longnick && output.length() > 16)
|
||||
{
|
||||
output = Util.lastCode(strPrefix) + nickname;
|
||||
}
|
||||
if (!longnick && output.length() > 16)
|
||||
{
|
||||
output = Util.lastCode(strPrefix) + nickname.substring(0, 14);
|
||||
}
|
||||
if (output.charAt(output.length() - 1) == '§')
|
||||
{
|
||||
output = output.substring(0, output.length() - 1);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public void setDisplayNick()
|
||||
{
|
||||
if (base.isOnline() && ess.getSettings().changeDisplayName())
|
||||
{
|
||||
setDisplayName(getNick(true));
|
||||
if (ess.getSettings().changePlayerListName())
|
||||
{
|
||||
String name = getNick(false);
|
||||
try
|
||||
{
|
||||
setPlayerListName(name);
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.INFO, "Playerlist for " + name + " was not updated. Name clashed with another online player.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
return super.getDisplayName() == null ? super.getName() : super.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Teleport getTeleport()
|
||||
{
|
||||
return teleport;
|
||||
}
|
||||
|
||||
public long getLastOnlineActivity()
|
||||
{
|
||||
return lastOnlineActivity;
|
||||
}
|
||||
|
||||
public void setLastOnlineActivity(final long timestamp)
|
||||
{
|
||||
lastOnlineActivity = timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMoney()
|
||||
{
|
||||
if (ess.getPaymentMethod().hasMethod())
|
||||
{
|
||||
try
|
||||
{
|
||||
final Method method = ess.getPaymentMethod().getMethod();
|
||||
if (!method.hasAccount(this.getName()))
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
return account.balance();
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
return super.getMoney();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMoney(final double value)
|
||||
{
|
||||
if (ess.getPaymentMethod().hasMethod())
|
||||
{
|
||||
try
|
||||
{
|
||||
final Method method = ess.getPaymentMethod().getMethod();
|
||||
if (!method.hasAccount(this.getName()))
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
account.set(value);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
super.setMoney(value);
|
||||
Trade.log("Update", "Set", "API", getName(), new Trade(value, ess), null, null, null, ess);
|
||||
}
|
||||
|
||||
public void updateMoneyCache(final double value)
|
||||
{
|
||||
if (ess.getPaymentMethod().hasMethod() && super.getMoney() != value)
|
||||
{
|
||||
super.setMoney(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAfk(final boolean set)
|
||||
{
|
||||
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
|
||||
if (set && !isAfk())
|
||||
{
|
||||
afkPosition = getLocation();
|
||||
}
|
||||
else if (!set && isAfk())
|
||||
{
|
||||
afkPosition = null;
|
||||
}
|
||||
super.setAfk(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggleAfk()
|
||||
{
|
||||
final boolean now = super.toggleAfk();
|
||||
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : now);
|
||||
return now;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden()
|
||||
{
|
||||
return hidden;
|
||||
}
|
||||
|
||||
public void setHidden(final boolean hidden)
|
||||
{
|
||||
this.hidden = hidden;
|
||||
if (hidden == true)
|
||||
{
|
||||
setLastLogout(getLastOnlineActivity());
|
||||
}
|
||||
}
|
||||
|
||||
//Returns true if status expired during this check
|
||||
public boolean checkJailTimeout(final long currentTime)
|
||||
{
|
||||
if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed())
|
||||
{
|
||||
setJailTimeout(0);
|
||||
setJailed(false);
|
||||
sendMessage(_("haveBeenReleased"));
|
||||
setJail(null);
|
||||
try
|
||||
{
|
||||
getTeleport().back();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
getTeleport().respawn(null, TeleportCause.PLUGIN);
|
||||
}
|
||||
catch (Exception ex1)
|
||||
{
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//Returns true if status expired during this check
|
||||
public boolean checkMuteTimeout(final long currentTime)
|
||||
{
|
||||
if (getMuteTimeout() > 0 && getMuteTimeout() < currentTime && isMuted())
|
||||
{
|
||||
setMuteTimeout(0);
|
||||
sendMessage(_("canTalkAgain"));
|
||||
setMuted(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//Returns true if status expired during this check
|
||||
public boolean checkBanTimeout(final long currentTime)
|
||||
{
|
||||
if (getBanTimeout() > 0 && getBanTimeout() < currentTime && isBanned())
|
||||
{
|
||||
setBanTimeout(0);
|
||||
setBanned(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void updateActivity(final boolean broadcast)
|
||||
{
|
||||
if (isAfk())
|
||||
{
|
||||
setAfk(false);
|
||||
if (broadcast && !isHidden())
|
||||
{
|
||||
setDisplayNick();
|
||||
ess.broadcastMessage(this, _("userIsNotAway", getDisplayName()));
|
||||
}
|
||||
}
|
||||
lastActivity = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void checkActivity()
|
||||
{
|
||||
final long autoafkkick = ess.getSettings().getAutoAfkKick();
|
||||
if (autoafkkick > 0 && lastActivity > 0 && (lastActivity + (autoafkkick * 1000)) < System.currentTimeMillis()
|
||||
&& !isHidden() && !isAuthorized("essentials.kick.exempt") && !isAuthorized("essentials.afk.kickexempt"))
|
||||
{
|
||||
final String kickReason = _("autoAfkKickReason", autoafkkick / 60.0);
|
||||
lastActivity = 0;
|
||||
kickPlayer(kickReason);
|
||||
|
||||
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
if (user.isAuthorized("essentials.kick.notify"))
|
||||
{
|
||||
player.sendMessage(_("playerKicked", Console.NAME, getName(), kickReason));
|
||||
}
|
||||
}
|
||||
}
|
||||
final long autoafk = ess.getSettings().getAutoAfk();
|
||||
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis() && isAuthorized("essentials.afk.auto"))
|
||||
{
|
||||
setAfk(true);
|
||||
if (!isHidden())
|
||||
{
|
||||
setDisplayNick();
|
||||
ess.broadcastMessage(this, _("userIsAway", getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Location getAfkPosition()
|
||||
{
|
||||
return afkPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGodModeEnabled()
|
||||
{
|
||||
return (super.isGodModeEnabled() && !ess.getSettings().getNoGodWorlds().contains(getLocation().getWorld().getName()))
|
||||
|| (isAfk() && ess.getSettings().getFreezeAfkPlayers());
|
||||
}
|
||||
|
||||
public boolean isGodModeEnabledRaw()
|
||||
{
|
||||
return super.isGodModeEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup()
|
||||
{
|
||||
return ess.getPermissionsHandler().getGroup(base);
|
||||
}
|
||||
|
||||
public boolean inGroup(final String group)
|
||||
{
|
||||
return ess.getPermissionsHandler().inGroup(base, group);
|
||||
}
|
||||
|
||||
public boolean canBuild()
|
||||
{
|
||||
if (isOp())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return ess.getPermissionsHandler().canBuild(base, getGroup());
|
||||
}
|
||||
|
||||
public long getTeleportRequestTime()
|
||||
{
|
||||
return teleportRequestTime;
|
||||
}
|
||||
|
||||
public boolean isInvSee()
|
||||
{
|
||||
return invSee;
|
||||
}
|
||||
|
||||
public void setInvSee(final boolean set)
|
||||
{
|
||||
invSee = set;
|
||||
}
|
||||
|
||||
public boolean isEnderSee()
|
||||
{
|
||||
return enderSee;
|
||||
}
|
||||
|
||||
public void setEnderSee(final boolean set)
|
||||
{
|
||||
enderSee = set;
|
||||
}
|
||||
private transient long teleportInvulnerabilityTimestamp = 0;
|
||||
|
||||
public void enableInvulnerabilityAfterTeleport()
|
||||
{
|
||||
final long time = ess.getSettings().getTeleportInvulnerability();
|
||||
if (time > 0)
|
||||
{
|
||||
teleportInvulnerabilityTimestamp = System.currentTimeMillis() + time;
|
||||
}
|
||||
}
|
||||
|
||||
public void resetInvulnerabilityAfterTeleport()
|
||||
{
|
||||
if (teleportInvulnerabilityTimestamp != 0
|
||||
&& teleportInvulnerabilityTimestamp < System.currentTimeMillis())
|
||||
{
|
||||
teleportInvulnerabilityTimestamp = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasInvulnerabilityAfterTeleport()
|
||||
{
|
||||
return teleportInvulnerabilityTimestamp != 0 && teleportInvulnerabilityTimestamp >= System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public boolean isVanished()
|
||||
{
|
||||
return vanished;
|
||||
}
|
||||
|
||||
public void setVanished(final boolean set)
|
||||
{
|
||||
vanished = set;
|
||||
if (set)
|
||||
{
|
||||
for (Player p : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
if (!ess.getUser(p).isAuthorized("essentials.vanish.see"))
|
||||
{
|
||||
p.hidePlayer(getBase());
|
||||
}
|
||||
}
|
||||
setHidden(true);
|
||||
ess.getVanishedPlayers().add(getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Player p : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
p.showPlayer(getBase());
|
||||
}
|
||||
setHidden(false);
|
||||
ess.getVanishedPlayers().remove(getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleVanished()
|
||||
{
|
||||
final boolean set = !vanished;
|
||||
this.setVanished(set);
|
||||
}
|
||||
|
||||
public boolean checkSignThrottle()
|
||||
{
|
||||
if (isSignThrottled())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
updateThrottle();
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isSignThrottled()
|
||||
{
|
||||
final long minTime = lastThrottledAction + (1000 / ess.getSettings().getSignUsePerSecond());
|
||||
return (System.currentTimeMillis() < minTime);
|
||||
}
|
||||
|
||||
public void updateThrottle()
|
||||
{
|
||||
lastThrottledAction = System.currentTimeMillis();;
|
||||
}
|
||||
|
||||
public boolean isFlyClickJump()
|
||||
{
|
||||
return rightClickJump;
|
||||
}
|
||||
|
||||
public void setRightClickJump(boolean rightClickJump)
|
||||
{
|
||||
this.rightClickJump = rightClickJump;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,835 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.MemoryConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public abstract class UserData extends PlayerExtension implements IConf
|
||||
{
|
||||
protected final transient IEssentials ess;
|
||||
private EssentialsConf config;
|
||||
private final File folder;
|
||||
|
||||
protected UserData(Player base, IEssentials ess)
|
||||
{
|
||||
super(base);
|
||||
this.ess = ess;
|
||||
folder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!folder.exists())
|
||||
{
|
||||
folder.mkdirs();
|
||||
}
|
||||
config = new EssentialsConf(new File(folder, Util.sanitizeFileName(base.getName()) + ".yml"));
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
public final void reset()
|
||||
{
|
||||
config.getFile().delete();
|
||||
config = new EssentialsConf(new File(folder, Util.sanitizeFileName(base.getName()) + ".yml"));
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void reloadConfig()
|
||||
{
|
||||
config.load();
|
||||
money = _getMoney();
|
||||
unlimited = _getUnlimited();
|
||||
powertools = _getPowertools();
|
||||
homes = _getHomes();
|
||||
lastLocation = _getLastLocation();
|
||||
lastTeleportTimestamp = _getLastTeleportTimestamp();
|
||||
lastHealTimestamp = _getLastHealTimestamp();
|
||||
jail = _getJail();
|
||||
mails = _getMails();
|
||||
teleportEnabled = getTeleportEnabled();
|
||||
ignoredPlayers = getIgnoredPlayers();
|
||||
godmode = _getGodModeEnabled();
|
||||
muted = getMuted();
|
||||
muteTimeout = _getMuteTimeout();
|
||||
jailed = getJailed();
|
||||
jailTimeout = _getJailTimeout();
|
||||
lastLogin = _getLastLogin();
|
||||
lastLogout = _getLastLogout();
|
||||
lastLoginAddress = _getLastLoginAddress();
|
||||
afk = getAfk();
|
||||
geolocation = _getGeoLocation();
|
||||
isSocialSpyEnabled = _isSocialSpyEnabled();
|
||||
isNPC = _isNPC();
|
||||
arePowerToolsEnabled = _arePowerToolsEnabled();
|
||||
kitTimestamps = _getKitTimestamps();
|
||||
nickname = _getNickname();
|
||||
}
|
||||
private double money;
|
||||
|
||||
private double _getMoney()
|
||||
{
|
||||
double money = ess.getSettings().getStartingBalance();
|
||||
if (config.hasProperty("money"))
|
||||
{
|
||||
money = config.getDouble("money", money);
|
||||
}
|
||||
if (Math.abs(money) > ess.getSettings().getMaxMoney())
|
||||
{
|
||||
money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney();
|
||||
}
|
||||
return money;
|
||||
}
|
||||
|
||||
public double getMoney()
|
||||
{
|
||||
return money;
|
||||
}
|
||||
|
||||
public void setMoney(double value)
|
||||
{
|
||||
money = value;
|
||||
if (Math.abs(money) > ess.getSettings().getMaxMoney())
|
||||
{
|
||||
money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney();
|
||||
}
|
||||
config.setProperty("money", value);
|
||||
config.save();
|
||||
}
|
||||
private Map<String, Object> homes;
|
||||
|
||||
private Map<String, Object> _getHomes()
|
||||
{
|
||||
if (config.isConfigurationSection("homes"))
|
||||
{
|
||||
return config.getConfigurationSection("homes").getValues(false);
|
||||
}
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
private String getHomeName(String search)
|
||||
{
|
||||
if (Util.isInt(search))
|
||||
{
|
||||
try
|
||||
{
|
||||
search = getHomes().get(Integer.parseInt(search) - 1);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
return search;
|
||||
}
|
||||
|
||||
public Location getHome(String name) throws Exception
|
||||
{
|
||||
String search = getHomeName(name);
|
||||
return config.getLocation("homes." + search, getServer());
|
||||
}
|
||||
|
||||
public Location getHome(final Location world)
|
||||
{
|
||||
try
|
||||
{
|
||||
Location loc;
|
||||
for (String home : getHomes())
|
||||
{
|
||||
loc = config.getLocation("homes." + home, getServer());
|
||||
if (world.getWorld() == loc.getWorld())
|
||||
{
|
||||
return loc;
|
||||
}
|
||||
|
||||
}
|
||||
loc = config.getLocation("homes." + getHomes().get(0), getServer());
|
||||
return loc;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getHomes()
|
||||
{
|
||||
return new ArrayList<String>(homes.keySet());
|
||||
}
|
||||
|
||||
public void setHome(String name, Location loc)
|
||||
{
|
||||
//Invalid names will corrupt the yaml
|
||||
name = Util.sanitizeFileName(name);
|
||||
homes.put(name, loc);
|
||||
config.setProperty("homes." + name, loc);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public void delHome(String name) throws Exception
|
||||
{
|
||||
String search = getHomeName(name);
|
||||
if (!homes.containsKey(search))
|
||||
{
|
||||
search = Util.sanitizeFileName(search);
|
||||
}
|
||||
if (homes.containsKey(search))
|
||||
{
|
||||
homes.remove(search);
|
||||
config.removeProperty("homes." + search);
|
||||
config.save();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("invalidHome", search));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasHome()
|
||||
{
|
||||
if (config.hasProperty("home"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private String nickname;
|
||||
|
||||
public String _getNickname()
|
||||
{
|
||||
return config.getString("nickname");
|
||||
}
|
||||
|
||||
public String getNickname()
|
||||
{
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public void setNickname(String nick)
|
||||
{
|
||||
nickname = nick;
|
||||
config.setProperty("nickname", nick);
|
||||
config.save();
|
||||
}
|
||||
private List<Integer> unlimited;
|
||||
|
||||
private List<Integer> _getUnlimited()
|
||||
{
|
||||
return config.getIntegerList("unlimited");
|
||||
}
|
||||
|
||||
public List<Integer> getUnlimited()
|
||||
{
|
||||
return unlimited;
|
||||
}
|
||||
|
||||
public boolean hasUnlimited(ItemStack stack)
|
||||
{
|
||||
return unlimited.contains(stack.getTypeId());
|
||||
}
|
||||
|
||||
public void setUnlimited(ItemStack stack, boolean state)
|
||||
{
|
||||
if (unlimited.contains(stack.getTypeId()))
|
||||
{
|
||||
unlimited.remove(Integer.valueOf(stack.getTypeId()));
|
||||
}
|
||||
if (state)
|
||||
{
|
||||
unlimited.add(stack.getTypeId());
|
||||
}
|
||||
config.setProperty("unlimited", unlimited);
|
||||
config.save();
|
||||
}
|
||||
private Map<String, Object> powertools;
|
||||
|
||||
private Map<String, Object> _getPowertools()
|
||||
{
|
||||
if (config.isConfigurationSection("powertools"))
|
||||
{
|
||||
return config.getConfigurationSection("powertools").getValues(false);
|
||||
}
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
public void clearAllPowertools()
|
||||
{
|
||||
powertools.clear();
|
||||
config.setProperty("powertools", powertools);
|
||||
config.save();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getPowertool(ItemStack stack)
|
||||
{
|
||||
return (List<String>)powertools.get("" + stack.getTypeId());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getPowertool(int id)
|
||||
{
|
||||
return (List<String>)powertools.get("" + id);
|
||||
}
|
||||
|
||||
public void setPowertool(ItemStack stack, List<String> commandList)
|
||||
{
|
||||
if (commandList == null || commandList.isEmpty())
|
||||
{
|
||||
powertools.remove("" + stack.getTypeId());
|
||||
}
|
||||
else
|
||||
{
|
||||
powertools.put("" + stack.getTypeId(), commandList);
|
||||
}
|
||||
config.setProperty("powertools", powertools);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean hasPowerTools()
|
||||
{
|
||||
return !powertools.isEmpty();
|
||||
}
|
||||
private Location lastLocation;
|
||||
|
||||
private Location _getLastLocation()
|
||||
{
|
||||
try
|
||||
{
|
||||
return config.getLocation("lastlocation", getServer());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Location getLastLocation()
|
||||
{
|
||||
return lastLocation;
|
||||
}
|
||||
|
||||
public void setLastLocation(Location loc)
|
||||
{
|
||||
if (loc == null || loc.getWorld() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lastLocation = loc;
|
||||
config.setProperty("lastlocation", loc);
|
||||
config.save();
|
||||
}
|
||||
private long lastTeleportTimestamp;
|
||||
|
||||
private long _getLastTeleportTimestamp()
|
||||
{
|
||||
return config.getLong("timestamps.lastteleport", 0);
|
||||
}
|
||||
|
||||
public long getLastTeleportTimestamp()
|
||||
{
|
||||
return lastTeleportTimestamp;
|
||||
}
|
||||
|
||||
public void setLastTeleportTimestamp(long time)
|
||||
{
|
||||
lastTeleportTimestamp = time;
|
||||
config.setProperty("timestamps.lastteleport", time);
|
||||
config.save();
|
||||
}
|
||||
private long lastHealTimestamp;
|
||||
|
||||
private long _getLastHealTimestamp()
|
||||
{
|
||||
return config.getLong("timestamps.lastheal", 0);
|
||||
}
|
||||
|
||||
public long getLastHealTimestamp()
|
||||
{
|
||||
return lastHealTimestamp;
|
||||
}
|
||||
|
||||
public void setLastHealTimestamp(long time)
|
||||
{
|
||||
lastHealTimestamp = time;
|
||||
config.setProperty("timestamps.lastheal", time);
|
||||
config.save();
|
||||
}
|
||||
private String jail;
|
||||
|
||||
private String _getJail()
|
||||
{
|
||||
return config.getString("jail");
|
||||
}
|
||||
|
||||
public String getJail()
|
||||
{
|
||||
return jail;
|
||||
}
|
||||
|
||||
public void setJail(String jail)
|
||||
{
|
||||
if (jail == null || jail.isEmpty())
|
||||
{
|
||||
this.jail = null;
|
||||
config.removeProperty("jail");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.jail = jail;
|
||||
config.setProperty("jail", jail);
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
private List<String> mails;
|
||||
|
||||
private List<String> _getMails()
|
||||
{
|
||||
return config.getStringList("mail");
|
||||
}
|
||||
|
||||
public List<String> getMails()
|
||||
{
|
||||
return mails;
|
||||
}
|
||||
|
||||
public void setMails(List<String> mails)
|
||||
{
|
||||
if (mails == null)
|
||||
{
|
||||
config.removeProperty("mail");
|
||||
mails = _getMails();
|
||||
}
|
||||
else
|
||||
{
|
||||
config.setProperty("mail", mails);
|
||||
}
|
||||
this.mails = mails;
|
||||
config.save();
|
||||
}
|
||||
|
||||
public void addMail(String mail)
|
||||
{
|
||||
mails.add(mail);
|
||||
setMails(mails);
|
||||
}
|
||||
private boolean teleportEnabled;
|
||||
|
||||
private boolean getTeleportEnabled()
|
||||
{
|
||||
return config.getBoolean("teleportenabled", true);
|
||||
}
|
||||
|
||||
public boolean isTeleportEnabled()
|
||||
{
|
||||
return teleportEnabled;
|
||||
}
|
||||
|
||||
public void setTeleportEnabled(boolean set)
|
||||
{
|
||||
teleportEnabled = set;
|
||||
config.setProperty("teleportenabled", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean toggleTeleportEnabled()
|
||||
{
|
||||
boolean ret = !isTeleportEnabled();
|
||||
setTeleportEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean toggleSocialSpy()
|
||||
{
|
||||
boolean ret = !isSocialSpyEnabled();
|
||||
setSocialSpyEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
private List<String> ignoredPlayers;
|
||||
|
||||
public List<String> getIgnoredPlayers()
|
||||
{
|
||||
return Collections.synchronizedList(config.getStringList("ignore"));
|
||||
}
|
||||
|
||||
public void setIgnoredPlayers(List<String> players)
|
||||
{
|
||||
if (players == null || players.isEmpty())
|
||||
{
|
||||
ignoredPlayers = Collections.synchronizedList(new ArrayList<String>());
|
||||
config.removeProperty("ignore");
|
||||
}
|
||||
else
|
||||
{
|
||||
ignoredPlayers = players;
|
||||
config.setProperty("ignore", players);
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean isIgnoredPlayer(final String userName)
|
||||
{
|
||||
final IUser user = ess.getUser(userName);
|
||||
if (user == null || !user.isOnline())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return isIgnoredPlayer(user);
|
||||
}
|
||||
|
||||
public boolean isIgnoredPlayer(IUser user)
|
||||
{
|
||||
return (ignoredPlayers.contains(user.getName().toLowerCase(Locale.ENGLISH)) && !user.isAuthorized("essentials.chat.ignoreexempt"));
|
||||
}
|
||||
|
||||
public void setIgnoredPlayer(IUser user, boolean set)
|
||||
{
|
||||
if (set)
|
||||
{
|
||||
ignoredPlayers.add(user.getName().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
else
|
||||
{
|
||||
ignoredPlayers.remove(user.getName().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
setIgnoredPlayers(ignoredPlayers);
|
||||
}
|
||||
private boolean godmode;
|
||||
|
||||
private boolean _getGodModeEnabled()
|
||||
{
|
||||
return config.getBoolean("godmode", false);
|
||||
}
|
||||
|
||||
public boolean isGodModeEnabled()
|
||||
{
|
||||
return godmode;
|
||||
}
|
||||
|
||||
public void setGodModeEnabled(boolean set)
|
||||
{
|
||||
godmode = set;
|
||||
config.setProperty("godmode", set);
|
||||
config.save();
|
||||
}
|
||||
private boolean muted;
|
||||
|
||||
public boolean getMuted()
|
||||
{
|
||||
return config.getBoolean("muted", false);
|
||||
}
|
||||
|
||||
public boolean isMuted()
|
||||
{
|
||||
return muted;
|
||||
}
|
||||
|
||||
public void setMuted(boolean set)
|
||||
{
|
||||
muted = set;
|
||||
config.setProperty("muted", set);
|
||||
config.save();
|
||||
}
|
||||
private long muteTimeout;
|
||||
|
||||
private long _getMuteTimeout()
|
||||
{
|
||||
return config.getLong("timestamps.mute", 0);
|
||||
}
|
||||
|
||||
public long getMuteTimeout()
|
||||
{
|
||||
return muteTimeout;
|
||||
}
|
||||
|
||||
public void setMuteTimeout(long time)
|
||||
{
|
||||
muteTimeout = time;
|
||||
config.setProperty("timestamps.mute", time);
|
||||
config.save();
|
||||
}
|
||||
private boolean jailed;
|
||||
|
||||
private boolean getJailed()
|
||||
{
|
||||
return config.getBoolean("jailed", false);
|
||||
}
|
||||
|
||||
public boolean isJailed()
|
||||
{
|
||||
return jailed;
|
||||
}
|
||||
|
||||
public void setJailed(boolean set)
|
||||
{
|
||||
jailed = set;
|
||||
config.setProperty("jailed", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean toggleJailed()
|
||||
{
|
||||
boolean ret = !isJailed();
|
||||
setJailed(ret);
|
||||
return ret;
|
||||
}
|
||||
private long jailTimeout;
|
||||
|
||||
private long _getJailTimeout()
|
||||
{
|
||||
return config.getLong("timestamps.jail", 0);
|
||||
}
|
||||
|
||||
public long getJailTimeout()
|
||||
{
|
||||
return jailTimeout;
|
||||
}
|
||||
|
||||
public void setJailTimeout(long time)
|
||||
{
|
||||
jailTimeout = time;
|
||||
config.setProperty("timestamps.jail", time);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public String getBanReason()
|
||||
{
|
||||
return config.getString("ban.reason");
|
||||
}
|
||||
|
||||
public void setBanReason(String reason)
|
||||
{
|
||||
config.setProperty("ban.reason", Util.sanitizeString(reason));
|
||||
config.save();
|
||||
}
|
||||
|
||||
public long getBanTimeout()
|
||||
{
|
||||
return config.getLong("ban.timeout", 0);
|
||||
}
|
||||
|
||||
public void setBanTimeout(long time)
|
||||
{
|
||||
config.setProperty("ban.timeout", time);
|
||||
config.save();
|
||||
}
|
||||
private long lastLogin;
|
||||
|
||||
private long _getLastLogin()
|
||||
{
|
||||
return config.getLong("timestamps.login", 0);
|
||||
}
|
||||
|
||||
public long getLastLogin()
|
||||
{
|
||||
return lastLogin;
|
||||
}
|
||||
|
||||
private void _setLastLogin(long time)
|
||||
{
|
||||
lastLogin = time;
|
||||
config.setProperty("timestamps.login", time);
|
||||
}
|
||||
|
||||
public void setLastLogin(long time)
|
||||
{
|
||||
_setLastLogin(time);
|
||||
_setLastLoginAddress(base.getAddress().getAddress().getHostAddress());
|
||||
config.save();
|
||||
}
|
||||
private long lastLogout;
|
||||
|
||||
private long _getLastLogout()
|
||||
{
|
||||
return config.getLong("timestamps.logout", 0);
|
||||
}
|
||||
|
||||
public long getLastLogout()
|
||||
{
|
||||
return lastLogout;
|
||||
}
|
||||
|
||||
public void setLastLogout(long time)
|
||||
{
|
||||
lastLogout = time;
|
||||
config.setProperty("timestamps.logout", time);
|
||||
config.save();
|
||||
}
|
||||
private String lastLoginAddress;
|
||||
|
||||
private String _getLastLoginAddress()
|
||||
{
|
||||
return config.getString("ipAddress", "");
|
||||
}
|
||||
|
||||
public String getLastLoginAddress()
|
||||
{
|
||||
return lastLoginAddress;
|
||||
}
|
||||
|
||||
private void _setLastLoginAddress(String address)
|
||||
{
|
||||
lastLoginAddress = address;
|
||||
config.setProperty("ipAddress", address);
|
||||
}
|
||||
private boolean afk;
|
||||
|
||||
private boolean getAfk()
|
||||
{
|
||||
return config.getBoolean("afk", false);
|
||||
}
|
||||
|
||||
public boolean isAfk()
|
||||
{
|
||||
return afk;
|
||||
}
|
||||
|
||||
public void setAfk(boolean set)
|
||||
{
|
||||
afk = set;
|
||||
config.setProperty("afk", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean toggleAfk()
|
||||
{
|
||||
boolean ret = !isAfk();
|
||||
setAfk(ret);
|
||||
return ret;
|
||||
}
|
||||
private boolean newplayer;
|
||||
private String geolocation;
|
||||
|
||||
private String _getGeoLocation()
|
||||
{
|
||||
return config.getString("geolocation");
|
||||
}
|
||||
|
||||
public String getGeoLocation()
|
||||
{
|
||||
return geolocation;
|
||||
}
|
||||
|
||||
public void setGeoLocation(String geolocation)
|
||||
{
|
||||
if (geolocation == null || geolocation.isEmpty())
|
||||
{
|
||||
this.geolocation = null;
|
||||
config.removeProperty("geolocation");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.geolocation = geolocation;
|
||||
config.setProperty("geolocation", geolocation);
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
private boolean isSocialSpyEnabled;
|
||||
|
||||
private boolean _isSocialSpyEnabled()
|
||||
{
|
||||
return config.getBoolean("socialspy", false);
|
||||
}
|
||||
|
||||
public boolean isSocialSpyEnabled()
|
||||
{
|
||||
return isSocialSpyEnabled;
|
||||
}
|
||||
|
||||
public void setSocialSpyEnabled(boolean status)
|
||||
{
|
||||
isSocialSpyEnabled = status;
|
||||
config.setProperty("socialspy", status);
|
||||
config.save();
|
||||
}
|
||||
private boolean isNPC;
|
||||
|
||||
private boolean _isNPC()
|
||||
{
|
||||
return config.getBoolean("npc", false);
|
||||
}
|
||||
|
||||
public boolean isNPC()
|
||||
{
|
||||
return isNPC;
|
||||
}
|
||||
|
||||
public void setNPC(boolean set)
|
||||
{
|
||||
isNPC = set;
|
||||
config.setProperty("npc", set);
|
||||
config.save();
|
||||
}
|
||||
private boolean arePowerToolsEnabled;
|
||||
|
||||
public boolean arePowerToolsEnabled()
|
||||
{
|
||||
return arePowerToolsEnabled;
|
||||
}
|
||||
|
||||
public void setPowerToolsEnabled(boolean set)
|
||||
{
|
||||
arePowerToolsEnabled = set;
|
||||
config.setProperty("powertoolsenabled", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean togglePowerToolsEnabled()
|
||||
{
|
||||
boolean ret = !arePowerToolsEnabled();
|
||||
setPowerToolsEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private boolean _arePowerToolsEnabled()
|
||||
{
|
||||
return config.getBoolean("powertoolsenabled", true);
|
||||
}
|
||||
private ConfigurationSection kitTimestamps;
|
||||
|
||||
private ConfigurationSection _getKitTimestamps()
|
||||
{
|
||||
|
||||
if (config.isConfigurationSection("timestamps.kits"))
|
||||
{
|
||||
final ConfigurationSection section = config.getConfigurationSection("timestamps.kits");
|
||||
final ConfigurationSection newSection = new MemoryConfiguration();
|
||||
for (String command : section.getKeys(false))
|
||||
{
|
||||
if (section.isLong(command))
|
||||
{
|
||||
newSection.set(command.toLowerCase(Locale.ENGLISH), section.getLong(command));
|
||||
}
|
||||
else if (section.isInt(command))
|
||||
{
|
||||
newSection.set(command.toLowerCase(Locale.ENGLISH), (long)section.getInt(command));
|
||||
}
|
||||
}
|
||||
return newSection;
|
||||
}
|
||||
return new MemoryConfiguration();
|
||||
}
|
||||
|
||||
public long getKitTimestamp(String name)
|
||||
{
|
||||
name = name.replace('.', '_').replace('/', '_');
|
||||
if (kitTimestamps != null)
|
||||
{
|
||||
return kitTimestamps.getLong(name, 0l);
|
||||
}
|
||||
return 0l;
|
||||
}
|
||||
|
||||
public void setKitTimestamp(final String name, final long time)
|
||||
{
|
||||
kitTimestamps.set(name.toLowerCase(Locale.ENGLISH), time);
|
||||
config.setProperty("timestamps.kits", kitTimestamps);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
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 org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class UserMap extends CacheLoader<String, User> implements IConf
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
private final transient Cache<String, User> users = CacheBuilder.newBuilder().softValues().build(this);
|
||||
private final transient ConcurrentSkipListSet<String> keys = new ConcurrentSkipListSet<String>();
|
||||
|
||||
public UserMap(final IEssentials ess)
|
||||
{
|
||||
super();
|
||||
this.ess = ess;
|
||||
loadAllUsersAsync(ess);
|
||||
}
|
||||
|
||||
private void loadAllUsersAsync(final IEssentials ess)
|
||||
{
|
||||
ess.scheduleAsyncDelayedTask(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final File userdir = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdir.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
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(Util.sanitizeFileName(name));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean userExists(final String name)
|
||||
{
|
||||
return keys.contains(Util.sanitizeFileName(name));
|
||||
}
|
||||
|
||||
public User getUser(final String name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return users.get(name);
|
||||
}
|
||||
catch (ExecutionException ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch (UncheckedExecutionException ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public User load(final String name) throws Exception
|
||||
{
|
||||
String sanitizedName = Util.sanitizeFileName(name);
|
||||
if (!sanitizedName.equals(name))
|
||||
{
|
||||
User user = getUser(sanitizedName);
|
||||
if (user == null)
|
||||
{
|
||||
throw new Exception("User not found!");
|
||||
}
|
||||
else
|
||||
{
|
||||
return user;
|
||||
}
|
||||
}
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
if (player.getName().equalsIgnoreCase(name))
|
||||
{
|
||||
keys.add(sanitizedName);
|
||||
return new User(player, ess);
|
||||
}
|
||||
}
|
||||
final File userFile = getUserFile2(sanitizedName);
|
||||
if (userFile.exists())
|
||||
{
|
||||
keys.add(sanitizedName);
|
||||
return new User(new OfflinePlayer(name, ess), ess);
|
||||
}
|
||||
throw new Exception("User not found!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
loadAllUsersAsync(ess);
|
||||
}
|
||||
|
||||
public void removeUser(final String name)
|
||||
{
|
||||
keys.remove(Util.sanitizeFileName(name));
|
||||
users.invalidate(Util.sanitizeFileName(name));
|
||||
users.invalidate(name);
|
||||
}
|
||||
|
||||
public Set<String> getAllUniqueUsers()
|
||||
{
|
||||
return Collections.unmodifiableSet(keys);
|
||||
}
|
||||
|
||||
public int getUniqueUsers()
|
||||
{
|
||||
return keys.size();
|
||||
}
|
||||
|
||||
public File getUserFile(final String name)
|
||||
{
|
||||
return getUserFile2(Util.sanitizeFileName(name));
|
||||
}
|
||||
|
||||
private File getUserFile2(final String name)
|
||||
{
|
||||
final File userFolder = new File(ess.getDataFolder(), "userdata");
|
||||
return new File(userFolder, name + ".yml");
|
||||
}
|
||||
}
|
||||
@@ -1,90 +1,33 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import com.earth2me.essentials.api.InvalidNameException;
|
||||
import com.earth2me.essentials.external.gnu.inet.encoding.Punycode;
|
||||
import com.earth2me.essentials.external.gnu.inet.encoding.PunycodeException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
|
||||
public final class Util
|
||||
public class Util
|
||||
{
|
||||
private Util()
|
||||
{
|
||||
}
|
||||
private final static Pattern INVALIDFILECHARS = Pattern.compile("[^\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");
|
||||
private final static Logger logger = Logger.getLogger("Minecraft");
|
||||
private final static Pattern INVALIDFILECHARS = Pattern.compile("[^a-z0-9]");
|
||||
private final static Pattern INVALIDCHARS = Pattern.compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");
|
||||
|
||||
public static String sanitizeFileName(String name) throws InvalidNameException
|
||||
public static String sanitizeFileName(final String name)
|
||||
{
|
||||
try
|
||||
{
|
||||
String r = name.toLowerCase(Locale.ENGLISH);
|
||||
r = r.replace('.', (char)('\ue200' + '.'));
|
||||
r = r.replace('\\', (char)('\ue200' + '\\'));
|
||||
r = r.replace('/', (char)('\ue200' + '/'));
|
||||
r = r.replace('"', (char)('\ue200' + '"'));
|
||||
r = r.replace('<', (char)('\ue200' + '<'));
|
||||
r = r.replace('>', (char)('\ue200' + '>'));
|
||||
r = r.replace('|', (char)('\ue200' + '|'));
|
||||
r = r.replace('?', (char)('\ue200' + '?'));
|
||||
r = r.replace('*', (char)('\ue200' + '*'));
|
||||
r = r.replace(':', (char)('\ue200' + ':'));
|
||||
r = r.replace('-', (char)('\ue200' + '-'));
|
||||
r = INVALIDFILECHARS.matcher(r).replaceAll("");
|
||||
return Punycode.encode(r);
|
||||
}
|
||||
catch (PunycodeException ex)
|
||||
{
|
||||
throw new InvalidNameException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static String decodeFileName(String name) throws InvalidNameException
|
||||
{
|
||||
try
|
||||
{
|
||||
String r = Punycode.decode(name);
|
||||
r = r.replace((char)('\ue200' + '.'), '.');
|
||||
r = r.replace((char)('\ue200' + '\\'), '\\');
|
||||
r = r.replace((char)('\ue200' + '/'), '/');
|
||||
r = r.replace((char)('\ue200' + '"'), '"');
|
||||
r = r.replace((char)('\ue200' + '<'), '<');
|
||||
r = r.replace((char)('\ue200' + '>'), '>');
|
||||
r = r.replace((char)('\ue200' + '|'), '|');
|
||||
r = r.replace((char)('\ue200' + '?'), '?');
|
||||
r = r.replace((char)('\ue200' + '*'), '*');
|
||||
r = r.replace((char)('\ue200' + ':'), ':');
|
||||
r = r.replace((char)('\ue200' + '-'), '-');
|
||||
return r;
|
||||
}
|
||||
catch (PunycodeException ex)
|
||||
{
|
||||
throw new InvalidNameException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static String sanitizeKey(String name)
|
||||
{
|
||||
return INVALIDCHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_");
|
||||
final String newName = INVALIDFILECHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_");
|
||||
return newName;
|
||||
}
|
||||
|
||||
public static String sanitizeString(final String string)
|
||||
@@ -137,11 +80,17 @@ public final class Util
|
||||
_("second"),
|
||||
_("seconds")
|
||||
};
|
||||
int accuracy = 0;
|
||||
for (int i = 0; i < types.length; i++)
|
||||
{
|
||||
if (accuracy > 2)
|
||||
{
|
||||
break;
|
||||
}
|
||||
int diff = dateDiff(types[i], fromDate, toDate, future);
|
||||
if (diff > 0)
|
||||
{
|
||||
accuracy++;
|
||||
sb.append(" ").append(diff).append(" ").append(names[i * 2 + (diff > 1 ? 1 : 0)]);
|
||||
}
|
||||
}
|
||||
@@ -149,7 +98,7 @@ public final class Util
|
||||
{
|
||||
return "now";
|
||||
}
|
||||
return sb.toString();
|
||||
return sb.toString().trim();
|
||||
}
|
||||
|
||||
private static int dateDiff(int type, Calendar fromDate, Calendar toDate, boolean future)
|
||||
@@ -266,6 +215,13 @@ public final class Util
|
||||
{
|
||||
c.add(Calendar.SECOND, seconds * (future ? 1 : -1));
|
||||
}
|
||||
|
||||
Calendar max = new GregorianCalendar();
|
||||
max.add(Calendar.YEAR, 10);
|
||||
if (c.after(max))
|
||||
{
|
||||
return max.getTimeInMillis();
|
||||
}
|
||||
return c.getTimeInMillis();
|
||||
}
|
||||
// The player can stand inside these materials
|
||||
@@ -299,6 +255,7 @@ public final class Util
|
||||
AIR_MATERIALS.add(Material.REDSTONE_TORCH_OFF.getId());
|
||||
AIR_MATERIALS.add(Material.REDSTONE_TORCH_ON.getId());
|
||||
AIR_MATERIALS.add(Material.STONE_BUTTON.getId());
|
||||
AIR_MATERIALS.add(Material.SNOW.getId());
|
||||
AIR_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId());
|
||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId());
|
||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_ON.getId());
|
||||
@@ -306,8 +263,10 @@ public final class Util
|
||||
AIR_MATERIALS.add(Material.PUMPKIN_STEM.getId());
|
||||
AIR_MATERIALS.add(Material.MELON_STEM.getId());
|
||||
AIR_MATERIALS.add(Material.VINE.getId());
|
||||
AIR_MATERIALS.add(Material.NETHER_WARTS.getId());
|
||||
AIR_MATERIALS.add(Material.FENCE_GATE.getId());
|
||||
AIR_MATERIALS.add(Material.WATER_LILY.getId());
|
||||
AIR_MATERIALS.add(Material.NETHER_FENCE.getId());
|
||||
AIR_MATERIALS.add(Material.NETHER_WARTS.getId());
|
||||
|
||||
for (Integer integer : AIR_MATERIALS)
|
||||
{
|
||||
@@ -326,6 +285,46 @@ public final class Util
|
||||
}
|
||||
return block.getLocation();
|
||||
}
|
||||
public final static int RADIUS = 3;
|
||||
public final static Vector3D[] VOLUME;
|
||||
|
||||
|
||||
public static class Vector3D
|
||||
{
|
||||
public Vector3D(int x, int y, int z)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
public int x;
|
||||
public int y;
|
||||
public int z;
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
List<Vector3D> pos = new ArrayList<Vector3D>();
|
||||
for (int x = -RADIUS; x <= RADIUS; x++)
|
||||
{
|
||||
for (int y = -RADIUS; y <= RADIUS; y++)
|
||||
{
|
||||
for (int z = -RADIUS; z <= RADIUS; z++)
|
||||
{
|
||||
pos.add(new Vector3D(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(pos, new Comparator<Vector3D>()
|
||||
{
|
||||
@Override
|
||||
public int compare(Vector3D a, Vector3D b)
|
||||
{
|
||||
return (a.x * a.x + a.y * a.y + a.z * a.z) - (b.x * b.x + b.y * b.y + b.z * b.z);
|
||||
}
|
||||
});
|
||||
VOLUME = pos.toArray(new Vector3D[0]);
|
||||
}
|
||||
|
||||
public static Location getSafeDestination(final Location loc) throws Exception
|
||||
{
|
||||
@@ -337,33 +336,54 @@ public final class Util
|
||||
int x = loc.getBlockX();
|
||||
int y = (int)Math.round(loc.getY());
|
||||
int z = loc.getBlockZ();
|
||||
final int origX = x;
|
||||
final int origY = y;
|
||||
final int origZ = z;
|
||||
|
||||
while (isBlockAboveAir(world, x, y, z))
|
||||
{
|
||||
y -= 1;
|
||||
if (y < 0)
|
||||
{
|
||||
y = origY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
while (isBlockUnsafe(world, x, y, z))
|
||||
{
|
||||
i++;
|
||||
if (i >= VOLUME.length)
|
||||
{
|
||||
x = origX;
|
||||
y = origY + RADIUS;
|
||||
z = origZ;
|
||||
break;
|
||||
}
|
||||
x = origX + VOLUME[i].x;
|
||||
y = origY + VOLUME[i].y;
|
||||
z = origZ + VOLUME[i].z;
|
||||
}
|
||||
|
||||
while (isBlockUnsafe(world, x, y, z))
|
||||
{
|
||||
y += 1;
|
||||
if (y >= world.getMaxHeight())
|
||||
{
|
||||
x += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (isBlockUnsafe(world, x, y, z))
|
||||
{
|
||||
y += 1;
|
||||
if (y >= 127)
|
||||
{
|
||||
x += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (isBlockUnsafe(world, x, y, z))
|
||||
{
|
||||
y -= 1;
|
||||
if (y <= 1)
|
||||
{
|
||||
y = 127;
|
||||
x += 1;
|
||||
if (x - 32 > loc.getBlockX())
|
||||
y = world.getHighestBlockYAt(x, z);
|
||||
if (x - 48 > loc.getBlockX())
|
||||
{
|
||||
throw new Exception(_("holeInFloor"));
|
||||
}
|
||||
@@ -378,6 +398,15 @@ public final class Util
|
||||
}
|
||||
|
||||
public static boolean isBlockUnsafe(final World world, final int x, final int y, final int z)
|
||||
{
|
||||
if (isBlockDamaging(world, x, y, z))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return isBlockAboveAir(world, x, y, z);
|
||||
}
|
||||
|
||||
public static boolean isBlockDamaging(final World world, final int x, final int y, final int z)
|
||||
{
|
||||
final Block below = world.getBlockAt(x, y - 1, z);
|
||||
if (below.getType() == Material.LAVA || below.getType() == Material.STATIONARY_LAVA)
|
||||
@@ -390,12 +419,17 @@ public final class Util
|
||||
return true;
|
||||
}
|
||||
|
||||
if (below.getType() == Material.BED_BLOCK)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((!AIR_MATERIALS.contains(world.getBlockAt(x, y, z).getType().getId()))
|
||||
|| (!AIR_MATERIALS.contains(world.getBlockAt(x, y + 1, z).getType().getId())))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return isBlockAboveAir(world, x, y, z);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ItemStack convertBlockToItem(final Block block)
|
||||
@@ -479,14 +513,11 @@ public final class Util
|
||||
}
|
||||
return is;
|
||||
}
|
||||
private static DecimalFormat df = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
|
||||
private static DecimalFormat dFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
|
||||
|
||||
public static String formatCurrency(final double value, final IEssentials ess)
|
||||
public static String formatAsCurrency(final double value)
|
||||
{
|
||||
@Cleanup
|
||||
final ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
String str = settings.getData().getEconomy().getCurrencySymbol() + df.format(value);
|
||||
String str = dFormat.format(value);
|
||||
if (str.endsWith(".00"))
|
||||
{
|
||||
str = str.substring(0, str.length() - 3);
|
||||
@@ -494,6 +525,16 @@ public final class Util
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String displayCurrency(final double value, final IEssentials ess)
|
||||
{
|
||||
return _("currency", ess.getSettings().getCurrencySymbol(), formatAsCurrency(value));
|
||||
}
|
||||
|
||||
public static String shortCurrency(final double value, final IEssentials ess)
|
||||
{
|
||||
return ess.getSettings().getCurrencySymbol() + formatAsCurrency(value);
|
||||
}
|
||||
|
||||
public static double roundDouble(final double d)
|
||||
{
|
||||
return Math.round(d * 100.0) / 100.0;
|
||||
@@ -546,104 +587,112 @@ public final class Util
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public static void registerPermissions(String path, Collection<String> nodes, boolean hasDefault, IEssentials ess)
|
||||
public static String lastCode(final String input)
|
||||
{
|
||||
if (nodes == null || nodes.isEmpty())
|
||||
int pos = input.lastIndexOf("§");
|
||||
if (pos == -1 || (pos + 1) == input.length())
|
||||
{
|
||||
return;
|
||||
return "";
|
||||
}
|
||||
final PluginManager pluginManager = ess.getServer().getPluginManager();
|
||||
Permission basePerm = pluginManager.getPermission(path + ".*");
|
||||
if (basePerm != null && !basePerm.getChildren().isEmpty())
|
||||
{
|
||||
basePerm.getChildren().clear();
|
||||
}
|
||||
if (basePerm == null)
|
||||
{
|
||||
basePerm = new Permission(path + ".*", PermissionDefault.OP);
|
||||
pluginManager.addPermission(basePerm);
|
||||
Permission mainPerm = pluginManager.getPermission("essentials.*");
|
||||
if (mainPerm == null)
|
||||
{
|
||||
mainPerm = new Permission("essentials.*", PermissionDefault.OP);
|
||||
pluginManager.addPermission(mainPerm);
|
||||
}
|
||||
mainPerm.getChildren().put(basePerm.getName(), Boolean.TRUE);
|
||||
}
|
||||
|
||||
for (String nodeName : nodes)
|
||||
{
|
||||
final String permissionName = path + "." + nodeName;
|
||||
Permission perm = pluginManager.getPermission(permissionName);
|
||||
if (perm == null)
|
||||
{
|
||||
final PermissionDefault defaultPerm = hasDefault && nodeName.equalsIgnoreCase("default") ? PermissionDefault.TRUE : PermissionDefault.OP;
|
||||
perm = new Permission(permissionName, defaultPerm);
|
||||
pluginManager.addPermission(perm);
|
||||
}
|
||||
basePerm.getChildren().put(permissionName, Boolean.TRUE);
|
||||
}
|
||||
basePerm.recalculatePermissibles();
|
||||
return input.substring(pos, pos + 2);
|
||||
}
|
||||
private static transient final Pattern DOT_PATTERN = Pattern.compile("\\.");
|
||||
private static transient final Pattern URL_PATTERN = Pattern.compile("((?:(?:https?)://)?[\\w-_\\.]{2,})\\.([a-z]{2,3}(?:/\\S+)?)");
|
||||
private static transient final Pattern VANILLA_PATTERN = Pattern.compile("\u00A7+[0-9A-FK-ORa-fk-or]");
|
||||
private static transient final Pattern REPLACE_PATTERN = Pattern.compile("&([0-9a-fk-or])");
|
||||
private static transient final Pattern VANILLA_COLOR_PATTERN = Pattern.compile("\u00A7+[0-9A-Fa-f]");
|
||||
private static transient final Pattern VANILLA_MAGIC_PATTERN = Pattern.compile("\u00A7+[Kk]");
|
||||
private static transient final Pattern VANILLA_FORMAT_PATTERN = Pattern.compile("\u00A7+[L-ORl-or]");
|
||||
private static transient final Pattern REPLACE_COLOR_PATTERN = Pattern.compile("&([0-9a-f])");
|
||||
private static transient final Pattern REPLACE_MAGIC_PATTERN = Pattern.compile("&(k)");
|
||||
private static transient final Pattern REPLACE_FORMAT_PATTERN = Pattern.compile("&([l-or])");
|
||||
|
||||
public static Permission registerPermission(String permission, PermissionDefault defaultPerm)
|
||||
{
|
||||
final PluginManager pluginManager = Bukkit.getServer().getPluginManager();
|
||||
final String[] parts = DOT_PATTERN.split(permission);
|
||||
final StringBuilder builder = new StringBuilder(permission.length());
|
||||
Permission parent = null;
|
||||
for (int i = 0; i < parts.length - 1; i++)
|
||||
{
|
||||
builder.append(parts[i]).append(".*");
|
||||
String permString = builder.toString();
|
||||
Permission perm = pluginManager.getPermission(permString);
|
||||
if (perm == null)
|
||||
{
|
||||
perm = new Permission(permString, PermissionDefault.FALSE);
|
||||
pluginManager.addPermission(perm);
|
||||
if (parent != null)
|
||||
{
|
||||
parent.getChildren().put(perm.getName(), Boolean.TRUE);
|
||||
}
|
||||
parent = perm;
|
||||
}
|
||||
builder.deleteCharAt(builder.length() - 1);
|
||||
}
|
||||
Permission perm = pluginManager.getPermission(permission);
|
||||
if (perm == null)
|
||||
{
|
||||
perm = new Permission(permission, defaultPerm);
|
||||
pluginManager.addPermission(perm);
|
||||
if (parent != null)
|
||||
{
|
||||
parent.getChildren().put(perm.getName(), Boolean.TRUE);
|
||||
}
|
||||
parent = perm;
|
||||
}
|
||||
perm.recalculatePermissibles();
|
||||
return perm;
|
||||
}
|
||||
private static transient final Pattern VANILLA_COLOR_PATTERN = Pattern.compile("\u00A7+[0-9A-FKa-fk]");
|
||||
private static transient final Pattern EASY_COLOR_PATTERN = Pattern.compile("&([0-9a-fk])");
|
||||
|
||||
public static String stripColor(final String input)
|
||||
public static String stripFormat(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return VANILLA_COLOR_PATTERN.matcher(input).replaceAll("");
|
||||
return VANILLA_PATTERN.matcher(input).replaceAll("");
|
||||
}
|
||||
|
||||
public static String replaceColor(final String input)
|
||||
public static String replaceFormat(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return REPLACE_PATTERN.matcher(input).replaceAll("\u00a7$1");
|
||||
}
|
||||
|
||||
return EASY_COLOR_PATTERN.matcher(input).replaceAll("\u00a7$1");
|
||||
public static String blockURL(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String text = URL_PATTERN.matcher(input).replaceAll("$1 $2");
|
||||
while (URL_PATTERN.matcher(text).find())
|
||||
{
|
||||
text = URL_PATTERN.matcher(text).replaceAll("$1 $2");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
public static String formatString(final IUser user, final String permBase, final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String message;
|
||||
if (user.isAuthorized(permBase + ".color"))
|
||||
{
|
||||
message = Util.replaceColor(input, REPLACE_COLOR_PATTERN);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.stripColor(input, VANILLA_COLOR_PATTERN);
|
||||
}
|
||||
if (user.isAuthorized(permBase + ".magic"))
|
||||
{
|
||||
message = Util.replaceColor(message, REPLACE_MAGIC_PATTERN);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.stripColor(message, VANILLA_MAGIC_PATTERN);
|
||||
}
|
||||
if (user.isAuthorized(permBase + ".format"))
|
||||
{
|
||||
message = Util.replaceColor(message, REPLACE_FORMAT_PATTERN);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.stripColor(message, VANILLA_FORMAT_PATTERN);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public static String formatMessage(final IUser user, final String permBase, final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String message = formatString(user, permBase, input);
|
||||
if (!user.isAuthorized(permBase + ".url"))
|
||||
{
|
||||
message = Util.blockURL(message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
private static String stripColor(final String input, final Pattern pattern)
|
||||
{
|
||||
return pattern.matcher(input).replaceAll("");
|
||||
}
|
||||
|
||||
private static String replaceColor(final String input, final Pattern pattern)
|
||||
{
|
||||
return pattern.matcher(input).replaceAll("\u00a7$1");
|
||||
}
|
||||
}
|
||||
@@ -1,121 +1,121 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IWarp;
|
||||
import com.earth2me.essentials.api.IWarps;
|
||||
import com.earth2me.essentials.api.InvalidNameException;
|
||||
import com.earth2me.essentials.commands.WarpNotFoundException;
|
||||
import com.earth2me.essentials.settings.WarpHolder;
|
||||
import com.earth2me.essentials.storage.StorageObjectMap;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
|
||||
|
||||
public class Warps extends StorageObjectMap<IWarp> implements IWarps
|
||||
public class Warps implements IConf
|
||||
{
|
||||
private static final Logger logger = Bukkit.getLogger();
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private final Map<StringIgnoreCase, EssentialsConf> warpPoints = new HashMap<StringIgnoreCase, EssentialsConf>();
|
||||
private final File warpsFolder;
|
||||
private final Server server;
|
||||
|
||||
public Warps(IEssentials ess)
|
||||
public Warps(Server server, File dataFolder)
|
||||
{
|
||||
super(ess, "warps");
|
||||
this.server = server;
|
||||
warpsFolder = new File(dataFolder, "warps");
|
||||
if (!warpsFolder.exists())
|
||||
{
|
||||
warpsFolder.mkdirs();
|
||||
}
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return getKeySize() == 0;
|
||||
return warpPoints.isEmpty();
|
||||
}
|
||||
|
||||
public Collection<String> getWarpNames()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
public Location getWarp(String warp) throws Exception
|
||||
{
|
||||
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(warp));
|
||||
if (conf == null)
|
||||
{
|
||||
throw new WarpNotFoundException();
|
||||
}
|
||||
return conf.getLocation(null, server);
|
||||
}
|
||||
|
||||
public void setWarp(String name, Location loc) throws Exception
|
||||
{
|
||||
String filename = Util.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);
|
||||
conf.save();
|
||||
}
|
||||
|
||||
public void delWarp(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 Collection<String> getList()
|
||||
public final void reloadConfig()
|
||||
{
|
||||
final List<String> names = new ArrayList<String>();
|
||||
for (String key : getAllKeys())
|
||||
warpPoints.clear();
|
||||
File[] listOfFiles = warpsFolder.listFiles();
|
||||
if (listOfFiles.length >= 1)
|
||||
{
|
||||
IWarp warp = getObject(key);
|
||||
if (warp == null)
|
||||
for (int i = 0; i < listOfFiles.length; i++)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
warp.acquireReadLock();
|
||||
try
|
||||
{
|
||||
names.add(warp.getData().getName());
|
||||
}
|
||||
finally
|
||||
{
|
||||
warp.unlock();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(names, String.CASE_INSENSITIVE_ORDER);
|
||||
return names;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getWarp(final String name) throws Exception
|
||||
{
|
||||
IWarp warp = getObject(name);
|
||||
if (warp == null)
|
||||
{
|
||||
throw new WarpNotFoundException(_("warpNotExist"));
|
||||
}
|
||||
warp.acquireReadLock();
|
||||
try
|
||||
{
|
||||
return warp.getData().getLocation().getBukkitLocation();
|
||||
}
|
||||
finally
|
||||
{
|
||||
warp.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWarp(final String name, final Location loc) throws Exception
|
||||
{
|
||||
setWarp(name, new com.earth2me.essentials.storage.Location(loc));
|
||||
}
|
||||
|
||||
public void setWarp(final String name, final com.earth2me.essentials.storage.Location loc) throws Exception
|
||||
{
|
||||
IWarp warp = getObject(name);
|
||||
if (warp == null)
|
||||
{
|
||||
warp = new WarpHolder(name, ess);
|
||||
}
|
||||
warp.acquireWriteLock();
|
||||
try
|
||||
{
|
||||
warp.getData().setLocation(loc);
|
||||
}
|
||||
finally
|
||||
{
|
||||
warp.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeWarp(final String name) throws Exception
|
||||
{
|
||||
removeObject(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getWarpFile(String name) throws InvalidNameException
|
||||
{
|
||||
return getStorageFile(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWarp load(String name) throws Exception
|
||||
{
|
||||
final IWarp warp = new WarpHolder(name, ess);
|
||||
warp.onReload();
|
||||
return warp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,86 +1,61 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IWorth;
|
||||
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
|
||||
import com.earth2me.essentials.storage.EnchantmentLevel;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
|
||||
public class Worth extends AsyncStorageObjectHolder<com.earth2me.essentials.settings.Worth> implements IWorth
|
||||
public class Worth implements IConf
|
||||
{
|
||||
public Worth(final IEssentials ess)
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private final EssentialsConf config;
|
||||
|
||||
public Worth(File dataFolder)
|
||||
{
|
||||
super(ess, com.earth2me.essentials.settings.Worth.class);
|
||||
onReload(false);
|
||||
config = new EssentialsConf(new File(dataFolder, "worth.yml"));
|
||||
config.setTemplateName("/worth.yml");
|
||||
config.load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPrice(final ItemStack itemStack)
|
||||
public double getPrice(ItemStack itemStack)
|
||||
{
|
||||
this.acquireReadLock();
|
||||
try
|
||||
String itemname = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
double result;
|
||||
result = config.getDouble("worth." + itemname + "." + itemStack.getDurability(), Double.NaN);
|
||||
if (Double.isNaN(result))
|
||||
{
|
||||
final Map<MaterialData, Double> prices = this.getData().getSell();
|
||||
if (prices == null || itemStack == null)
|
||||
{
|
||||
return Double.NaN;
|
||||
}
|
||||
final Double basePrice = prices.get(itemStack.getData());
|
||||
if (basePrice == null || Double.isNaN(basePrice))
|
||||
{
|
||||
return Double.NaN;
|
||||
}
|
||||
double multiplier = 1.0;
|
||||
if (itemStack.getType().getMaxDurability() > 0) {
|
||||
multiplier *= (double)itemStack.getDurability() / (double)itemStack.getType().getMaxDurability();
|
||||
}
|
||||
if (itemStack.getEnchantments() != null && !itemStack.getEnchantments().isEmpty())
|
||||
{
|
||||
final Map<EnchantmentLevel, Double> enchantmentMultipliers = this.getData().getEnchantmentMultiplier();
|
||||
if (enchantmentMultipliers != null)
|
||||
{
|
||||
for (Map.Entry<Enchantment, Integer> entry : itemStack.getEnchantments().entrySet())
|
||||
{
|
||||
final Double enchMult = enchantmentMultipliers.get(new EnchantmentLevel(entry.getKey(), entry.getValue()));
|
||||
if (enchMult != null)
|
||||
{
|
||||
multiplier *= enchMult;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return basePrice * multiplier;
|
||||
result = config.getDouble("worth." + itemname + ".0", Double.NaN);
|
||||
}
|
||||
finally
|
||||
if (Double.isNaN(result))
|
||||
{
|
||||
this.unlock();
|
||||
result = config.getDouble("worth." + itemname, Double.NaN);
|
||||
}
|
||||
if (Double.isNaN(result))
|
||||
{
|
||||
result = config.getDouble("worth-" + itemStack.getTypeId(), Double.NaN);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrice(final ItemStack itemStack, final double price)
|
||||
public void reloadConfig()
|
||||
{
|
||||
acquireWriteLock();
|
||||
try {
|
||||
if (getData().getSell() == null) {
|
||||
getData().setSell(new HashMap<MaterialData, Double>());
|
||||
}
|
||||
getData().getSell().put(itemStack.getData(), price);
|
||||
} finally {
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getStorageFile() throws IOException
|
||||
{
|
||||
return new File(ess.getDataFolder(), "worth.yml");
|
||||
config.load();
|
||||
}
|
||||
}
|
||||
+102
-22
@@ -1,6 +1,14 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.EssentialsConf;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
/**
|
||||
@@ -12,9 +20,71 @@ public final class Economy
|
||||
private Economy()
|
||||
{
|
||||
}
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private static IEssentials ess;
|
||||
private static final String noCallBeforeLoad = "Essentials API is called before Essentials is loaded.";
|
||||
|
||||
/**
|
||||
* @param aEss the ess to set
|
||||
*/
|
||||
public static void setEss(IEssentials aEss)
|
||||
{
|
||||
ess = aEss;
|
||||
}
|
||||
|
||||
private static void createNPCFile(String name)
|
||||
{
|
||||
File folder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!folder.exists())
|
||||
{
|
||||
folder.mkdirs();
|
||||
}
|
||||
EssentialsConf npcConfig = new EssentialsConf(new File(folder, Util.sanitizeFileName(name) + ".yml"));
|
||||
npcConfig.load();
|
||||
npcConfig.setProperty("npc", true);
|
||||
npcConfig.setProperty("money", ess.getSettings().getStartingBalance());
|
||||
npcConfig.save();
|
||||
}
|
||||
|
||||
private static void deleteNPC(String name)
|
||||
{
|
||||
File folder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!folder.exists())
|
||||
{
|
||||
folder.mkdirs();
|
||||
}
|
||||
File config = new File(folder, Util.sanitizeFileName(name) + ".yml");
|
||||
EssentialsConf npcConfig = new EssentialsConf(config);
|
||||
npcConfig.load();
|
||||
if (npcConfig.hasProperty("npc") && npcConfig.getBoolean("npc", false))
|
||||
{
|
||||
if (!config.delete())
|
||||
{
|
||||
logger.log(Level.WARNING, _("deleteFileError", config));
|
||||
}
|
||||
ess.getUserMap().removeUser(name);
|
||||
}
|
||||
}
|
||||
|
||||
private static User getUserByName(String name)
|
||||
{
|
||||
if (ess == null)
|
||||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
}
|
||||
User user;
|
||||
Player player = ess.getServer().getPlayer(name);
|
||||
if (player != null)
|
||||
{
|
||||
user = ess.getUser(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
user = ess.getOfflineUser(name);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the balance of a user
|
||||
* @param name Name of the user
|
||||
@@ -23,11 +93,12 @@ public final class Economy
|
||||
*/
|
||||
public static double getMoney(String name) throws UserDoesNotExistException
|
||||
{
|
||||
if (ess == null)
|
||||
User user = getUserByName(name);
|
||||
if (user == null)
|
||||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
return ess.getEconomy().getMoney(name);
|
||||
return user.getMoney();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,11 +110,20 @@ public final class Economy
|
||||
*/
|
||||
public static void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException
|
||||
{
|
||||
if (ess == null)
|
||||
User user = getUserByName(name);
|
||||
if (user == null)
|
||||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
ess.getEconomy().setMoney(name, balance);
|
||||
if (balance < ess.getSettings().getMinMoney())
|
||||
{
|
||||
throw new NoLoanPermittedException();
|
||||
}
|
||||
if (balance < 0.0 && !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new NoLoanPermittedException();
|
||||
}
|
||||
user.setMoney(balance);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,7 +190,7 @@ public final class Economy
|
||||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
}
|
||||
ess.getEconomy().resetBalance(name);
|
||||
setMoney(name, ess.getSettings().getStartingBalance());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,7 +249,7 @@ public final class Economy
|
||||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
}
|
||||
return Util.formatCurrency(amount, ess);
|
||||
return Util.displayCurrency(amount, ess);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,11 +259,7 @@ public final class Economy
|
||||
*/
|
||||
public static boolean playerExists(String name)
|
||||
{
|
||||
if (ess == null)
|
||||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
}
|
||||
return ess.getEconomy().playerExists(name);
|
||||
return getUserByName(name) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,11 +270,12 @@ public final class Economy
|
||||
*/
|
||||
public static boolean isNPC(String name) throws UserDoesNotExistException
|
||||
{
|
||||
if (ess == null)
|
||||
User user = getUserByName(name);
|
||||
if (user == null)
|
||||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
return ess.getEconomy().isNPC(name);
|
||||
return user.isNPC();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,11 +285,13 @@ public final class Economy
|
||||
*/
|
||||
public static boolean createNPC(String name)
|
||||
{
|
||||
if (ess == null)
|
||||
User user = getUserByName(name);
|
||||
if (user == null)
|
||||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
createNPCFile(name);
|
||||
return true;
|
||||
}
|
||||
return ess.getEconomy().createNPC(name);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,10 +301,11 @@ public final class Economy
|
||||
*/
|
||||
public static void removeNPC(String name) throws UserDoesNotExistException
|
||||
{
|
||||
if (ess == null)
|
||||
User user = getUserByName(name);
|
||||
if (user == null)
|
||||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
ess.getEconomy().removeNPC(name);
|
||||
deleteNPC(name);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
|
||||
public interface IBackup extends Runnable
|
||||
{
|
||||
public void startTask();
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.util.Map;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public interface ICommandHandler extends IReload
|
||||
{
|
||||
Map<String, String> disabledCommands();
|
||||
|
||||
public void removePlugin(Plugin plugin);
|
||||
|
||||
public void addPlugin(Plugin plugin);
|
||||
|
||||
boolean handleCommand(CommandSender sender, Command command, String commandLabel, String[] args);
|
||||
|
||||
void showCommandError(CommandSender sender, String commandLabel, Throwable exception);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
|
||||
public interface IEconomy extends IReload
|
||||
{
|
||||
public double getMoney(String name) throws UserDoesNotExistException;
|
||||
|
||||
public void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
public void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
public String format(double amount);
|
||||
|
||||
public boolean playerExists(String name);
|
||||
|
||||
public boolean isNPC(String name) throws UserDoesNotExistException;
|
||||
|
||||
public boolean createNPC(String name);
|
||||
|
||||
public void removeNPC(String name) throws UserDoesNotExistException;
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.listener.TntExplodeListener;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public interface IEssentials extends Plugin
|
||||
{
|
||||
void addReloadListener(IReload listener);
|
||||
|
||||
IUser getUser(Player player);
|
||||
|
||||
IUser getUser(String playerName);
|
||||
|
||||
int broadcastMessage(IUser sender, String message);
|
||||
|
||||
II18n getI18n();
|
||||
|
||||
ISettings getSettings();
|
||||
|
||||
IGroups getGroups();
|
||||
|
||||
IJails getJails();
|
||||
|
||||
IKits getKits();
|
||||
|
||||
IWarps getWarps();
|
||||
|
||||
IWorth getWorth();
|
||||
|
||||
IItemDb getItemDb();
|
||||
|
||||
IUserMap getUserMap();
|
||||
|
||||
IBackup getBackup();
|
||||
|
||||
ICommandHandler getCommandHandler();
|
||||
|
||||
World getWorld(String name);
|
||||
|
||||
Methods getPaymentMethod();
|
||||
|
||||
int scheduleAsyncDelayedTask(Runnable run);
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run);
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run, long delay);
|
||||
|
||||
int scheduleSyncRepeatingTask(Runnable run, long delay, long period);
|
||||
|
||||
//IPermissionsHandler getPermissionsHandler();
|
||||
void reload();
|
||||
|
||||
TntExplodeListener getTNTListener();
|
||||
|
||||
void setGroups(IGroups groups);
|
||||
|
||||
void removeReloadListener(IReload groups);
|
||||
|
||||
IEconomy getEconomy();
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
|
||||
public interface IGroups
|
||||
{
|
||||
String getMainGroup(IUser player);
|
||||
|
||||
boolean inGroup(IUser player, String groupname);
|
||||
|
||||
double getHealCooldown(IUser player);
|
||||
|
||||
double getTeleportCooldown(IUser player);
|
||||
|
||||
double getTeleportDelay(IUser player);
|
||||
|
||||
String getPrefix(IUser player);
|
||||
|
||||
String getSuffix(IUser player);
|
||||
|
||||
int getHomeLimit(IUser player);
|
||||
|
||||
MessageFormat getChatFormat(IUser player);
|
||||
}
|
||||
@@ -3,11 +3,9 @@ package com.earth2me.essentials.api;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public interface IItemDb extends IReload
|
||||
public interface IItemDb
|
||||
{
|
||||
ItemStack get(final String name, final IUser user) throws Exception;
|
||||
|
||||
ItemStack get(final String name, final int quantity) throws Exception;
|
||||
|
||||
|
||||
ItemStack get(final String name) throws Exception;
|
||||
}
|
||||
@@ -10,9 +10,11 @@ public interface IJails extends IReload
|
||||
|
||||
Collection<String> getList() throws Exception;
|
||||
|
||||
int getCount();
|
||||
|
||||
void removeJail(String jail) throws Exception;
|
||||
|
||||
void sendToJail(IUser user, String jail) throws Exception;
|
||||
void sendToJail(com.earth2me.essentials.IUser user, String jail) throws Exception;
|
||||
|
||||
void setJail(String jailName, Location loc) throws Exception;
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.settings.Kit;
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
public interface IKits extends IReload
|
||||
{
|
||||
Kit getKit(String kit) throws Exception;
|
||||
|
||||
void sendKit(IUser user, String kit) throws Exception;
|
||||
|
||||
void sendKit(IUser user, Kit kit) throws Exception;
|
||||
|
||||
Collection<String> getList() throws Exception;
|
||||
|
||||
boolean isEmpty();
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
|
||||
public interface IPermission
|
||||
{
|
||||
String getPermission();
|
||||
|
||||
boolean isAuthorized(CommandSender sender);
|
||||
|
||||
Permission getBukkitPermission();
|
||||
|
||||
PermissionDefault getPermissionDefault();
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public interface IReplyTo
|
||||
{
|
||||
void setReplyTo(CommandSender user);
|
||||
|
||||
CommandSender getReplyTo();
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.settings.Settings;
|
||||
import com.earth2me.essentials.storage.IStorageObjectHolder;
|
||||
|
||||
|
||||
public interface ISettings extends IStorageObjectHolder<Settings>
|
||||
{
|
||||
public String getLocale();
|
||||
|
||||
public boolean isDebug();
|
||||
|
||||
public void setDebug(boolean b);
|
||||
}
|
||||
@@ -1,28 +1,10 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.Trade;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
|
||||
public interface ITeleport
|
||||
{
|
||||
void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception;
|
||||
|
||||
void now(Entity entity, boolean cooldown, TeleportCause cause) throws Exception;
|
||||
|
||||
void back(Trade chargeFor) throws Exception;
|
||||
|
||||
void teleport(Location bed, Trade charge, TeleportCause teleportCause) throws Exception;
|
||||
|
||||
void teleport(Entity entity, Trade chargeFor, TeleportCause cause) throws Exception;
|
||||
|
||||
void home(IUser player, String toLowerCase, Trade charge) throws Exception;
|
||||
|
||||
void respawn(Trade charge, TeleportCause teleportCause) throws Exception;
|
||||
|
||||
void back() throws Exception;
|
||||
|
||||
public void warp(String name, Trade charge, TeleportCause teleportCause) throws Exception;
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.storage.IStorageObjectHolder;
|
||||
import com.earth2me.essentials.user.CooldownException;
|
||||
import com.earth2me.essentials.user.UserData;
|
||||
import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public interface IUser extends Player, IStorageObjectHolder<UserData>, IReload, IReplyTo, Comparable<IUser>
|
||||
{
|
||||
Player getBase();
|
||||
|
||||
double getMoney();
|
||||
|
||||
void takeMoney(double value);
|
||||
|
||||
void takeMoney(double value, CommandSender initiator);
|
||||
|
||||
void giveMoney(double value);
|
||||
|
||||
void giveMoney(double value, CommandSender initiator);
|
||||
|
||||
void giveItems(ItemStack itemStack, Boolean canSpew) throws ChargeException;
|
||||
|
||||
void giveItems(List<ItemStack> itemStacks, Boolean canSpew) throws ChargeException;
|
||||
|
||||
void setMoney(double value);
|
||||
|
||||
void payUser(final IUser reciever, final double value) throws Exception;
|
||||
|
||||
void setLastLocation();
|
||||
|
||||
Location getHome(String name) throws Exception;
|
||||
|
||||
Location getHome(Location loc);
|
||||
|
||||
boolean isHidden();
|
||||
|
||||
ITeleport getTeleport();
|
||||
|
||||
void checkCooldown(UserData.TimestampType cooldownType, double cooldown, boolean set, IPermission bypassPermission) throws CooldownException;
|
||||
|
||||
boolean toggleAfk();
|
||||
|
||||
void updateActivity(boolean broadcast);
|
||||
|
||||
void updateDisplayName();
|
||||
|
||||
boolean checkJailTimeout(long currentTime);
|
||||
|
||||
boolean checkMuteTimeout(long currentTime);
|
||||
|
||||
boolean checkBanTimeout(long currentTime);
|
||||
|
||||
long getTimestamp(UserData.TimestampType name);
|
||||
|
||||
void setTimestamp(UserData.TimestampType name, long value);
|
||||
|
||||
void setLastOnlineActivity(long currentTime);
|
||||
|
||||
void checkActivity();
|
||||
|
||||
long getLastOnlineActivity();
|
||||
|
||||
boolean isGodModeEnabled();
|
||||
|
||||
boolean isIgnoringPlayer(String name);
|
||||
|
||||
void setIgnoredPlayer(String name, boolean set);
|
||||
|
||||
Location getAfkPosition();
|
||||
|
||||
boolean toggleGodModeEnabled();
|
||||
|
||||
void dispose();
|
||||
|
||||
void updateCompass();
|
||||
|
||||
List<String> getHomes();
|
||||
|
||||
void addMail(String string);
|
||||
|
||||
boolean toggleMuted();
|
||||
|
||||
boolean toggleSocialSpy();
|
||||
|
||||
void requestTeleport(IUser user, boolean b);
|
||||
|
||||
boolean isTeleportRequestHere();
|
||||
|
||||
IUser getTeleportRequester();
|
||||
|
||||
boolean toggleTeleportEnabled();
|
||||
|
||||
long getTeleportRequestTime();
|
||||
|
||||
boolean gotMailInfo();
|
||||
|
||||
List<String> getMails();
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public interface IUserMap extends IReload
|
||||
{
|
||||
boolean userExists(final String name);
|
||||
|
||||
IUser getUser(final Player player);
|
||||
|
||||
IUser getUser(final String playerName);
|
||||
|
||||
void removeUser(final String name) throws InvalidNameException;
|
||||
|
||||
Set<String> getAllUniqueUsers();
|
||||
|
||||
int getUniqueUsers();
|
||||
|
||||
File getUserFile(final String name) throws InvalidNameException;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.settings.Warp;
|
||||
import com.earth2me.essentials.storage.IStorageObjectHolder;
|
||||
|
||||
|
||||
public interface IWarp extends IStorageObjectHolder<Warp>
|
||||
{
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import org.bukkit.Location;
|
||||
|
||||
|
||||
public interface IWarps extends IReload
|
||||
{
|
||||
Location getWarp(String warp) throws Exception;
|
||||
|
||||
Collection<String> getList();
|
||||
|
||||
void removeWarp(String name) throws Exception;
|
||||
|
||||
void setWarp(String name, Location loc) throws Exception;
|
||||
|
||||
public boolean isEmpty();
|
||||
|
||||
public File getWarpFile(String name) throws InvalidNameException;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public interface IWorth extends IReload
|
||||
{
|
||||
double getPrice(ItemStack itemStack);
|
||||
|
||||
void setPrice(ItemStack itemStack, double price);
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
|
||||
public class InvalidNameException extends Exception
|
||||
{
|
||||
public InvalidNameException(Throwable thrwbl)
|
||||
{
|
||||
super(thrwbl);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,23 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
|
||||
|
||||
public class Commandafk extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
public Commandafk()
|
||||
{
|
||||
if (args.length > 0 && Permissions.AFK_OTHERS.isAuthorized(user))
|
||||
super("afk");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && user.isAuthorized("essentials.afk.others"))
|
||||
{
|
||||
IUser afkUser = ess.getUser((Player)ess.getServer().matchPlayer(args[0]));
|
||||
User afkUser = ess.getUser(ess.getServer().matchPlayer(args[0]));
|
||||
if (afkUser != null)
|
||||
{
|
||||
toggleAfk(afkUser);
|
||||
@@ -26,8 +29,9 @@ public class Commandafk extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleAfk(IUser user)
|
||||
private void toggleAfk(User user)
|
||||
{
|
||||
user.setDisplayNick();
|
||||
if (!user.toggleAfk())
|
||||
{
|
||||
//user.sendMessage(_("markedAsNotAway"));
|
||||
@@ -46,10 +50,4 @@ public class Commandafk extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionDefault getPermissionDefault()
|
||||
{
|
||||
return PermissionDefault.TRUE;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,27 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
||||
|
||||
public class Commandantioch extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
public Commandantioch()
|
||||
{
|
||||
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.");
|
||||
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.");
|
||||
}
|
||||
|
||||
final Location loc = Util.getTarget(user);
|
||||
loc.getWorld().spawn(loc, TNTPrimed.class);
|
||||
|
||||
@@ -2,15 +2,26 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
|
||||
|
||||
public class Commandback extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
public Commandback()
|
||||
{
|
||||
final Trade charge = new Trade(commandName, ess);
|
||||
super("back");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (user.getWorld() != user.getLastLocation().getWorld() && ess.getSettings().isWorldTeleportPermissions()
|
||||
&& !user.isAuthorized("essentials.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.sendMessage(_("backUsageMsg"));
|
||||
user.getTeleport().back(charge);
|
||||
|
||||
@@ -1,16 +1,31 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Backup;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IBackup;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandbackup extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public Commandbackup()
|
||||
{
|
||||
final IBackup backup = ess.getBackup();
|
||||
super("backup");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender 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"));
|
||||
}
|
||||
|
||||
@@ -1,31 +1,37 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandbalance extends EssentialsCommand
|
||||
{
|
||||
public Commandbalance()
|
||||
{
|
||||
super("balance");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
sender.sendMessage(_("balance", Util.formatCurrency(getPlayer(args, 0, true).getMoney(), ess)));
|
||||
sender.sendMessage(_("balance", Util.displayCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final double bal = (args.length < 1
|
||||
|| !Permissions.BALANCE_OTHERS.isAuthorized(user)
|
||||
|| !(user.isAuthorized("essentials.balance.others")
|
||||
|| user.isAuthorized("essentials.balance.other"))
|
||||
? user
|
||||
: getPlayer(args, 0, true)).getMoney();
|
||||
user.sendMessage(_("balance", Util.formatCurrency(bal, ess)));
|
||||
: getPlayer(server, args, 0, true)).getMoney();
|
||||
user.sendMessage(_("balance", Util.displayCurrency(bal, ess)));
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,24 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.textreader.ArrayListInput;
|
||||
import com.earth2me.essentials.textreader.TextPager;
|
||||
import java.text.DateFormat;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
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 ArrayListInput cache = new ArrayListInput();
|
||||
@@ -21,7 +26,7 @@ public class Commandbalancetop extends EssentialsCommand
|
||||
private static ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
int page = 0;
|
||||
boolean force = false;
|
||||
@@ -100,14 +105,18 @@ public class Commandbalancetop extends EssentialsCommand
|
||||
{
|
||||
if (force || cacheage <= System.currentTimeMillis() - CACHETIME)
|
||||
{
|
||||
cache.getLines().clear();
|
||||
cache.getLines().clear();
|
||||
final Map<String, Double> balances = new HashMap<String, Double>();
|
||||
double totalMoney = 0d;
|
||||
for (String u : ess.getUserMap().getAllUniqueUsers())
|
||||
{
|
||||
final IUser user = ess.getUserMap().getUser(u);
|
||||
final User user = ess.getUserMap().getUser(u);
|
||||
if (user != null)
|
||||
{
|
||||
balances.put(user.getDisplayName(), user.getMoney());
|
||||
final double userMoney = user.getMoney();
|
||||
user.updateMoneyCache(userMoney);
|
||||
totalMoney += userMoney;
|
||||
balances.put(user.getDisplayName(), userMoney);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,10 +129,12 @@ public class Commandbalancetop extends EssentialsCommand
|
||||
return -entry1.getValue().compareTo(entry2.getValue());
|
||||
}
|
||||
});
|
||||
|
||||
cache.getLines().add(_("serverTotal", Util.displayCurrency(totalMoney, ess)));
|
||||
int pos = 1;
|
||||
for (Map.Entry<String, Double> entry : sortedEntries)
|
||||
{
|
||||
cache.getLines().add(pos + ". " + entry.getKey() + ", " + Util.formatCurrency(entry.getValue(), ess));
|
||||
cache.getLines().add(pos + ". " + entry.getKey() + ", " + Util.displayCurrency(entry.getValue(), ess));
|
||||
pos++;
|
||||
}
|
||||
cacheage = System.currentTimeMillis();
|
||||
|
||||
@@ -2,28 +2,41 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Console;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import com.earth2me.essentials.user.Ban;
|
||||
import lombok.Cleanup;
|
||||
import com.earth2me.essentials.OfflinePlayer;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandban extends EssentialsCommand
|
||||
{
|
||||
public Commandban()
|
||||
{
|
||||
super("ban");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
@Cleanup
|
||||
final IUser user = getPlayer(args, 0, true);
|
||||
if (user.isOnline())
|
||||
User user;
|
||||
try
|
||||
{
|
||||
if (Permissions.BAN_EXEMPT.isAuthorized(user))
|
||||
user = getPlayer(server, args, 0, true);
|
||||
}
|
||||
catch (NoSuchFieldException e)
|
||||
{
|
||||
user = ess.getUser(new OfflinePlayer(args[0], ess));
|
||||
}
|
||||
if (!user.isOnline())
|
||||
{
|
||||
if (sender instanceof Player
|
||||
&& !ess.getUser(sender).isAuthorized("essentials.ban.offline"))
|
||||
{
|
||||
sender.sendMessage(_("banExempt"));
|
||||
return;
|
||||
@@ -31,33 +44,34 @@ public class Commandban extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Permissions.BAN_OFFLINE.isAuthorized(sender))
|
||||
if (user.isAuthorized("essentials.ban.exempt"))
|
||||
{
|
||||
sender.sendMessage(_("banExempt"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
user.acquireWriteLock();
|
||||
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
String banReason;
|
||||
user.getData().setBan(new Ban());
|
||||
if (args.length > 1)
|
||||
{
|
||||
banReason = getFinalArg(args, 1);
|
||||
user.getData().getBan().setReason(banReason);
|
||||
banReason = _("banFormat", getFinalArg(args, 1), senderName);
|
||||
}
|
||||
else
|
||||
{
|
||||
banReason = _("defaultBanReason");
|
||||
banReason = _("banFormat", _("defaultBanReason"), senderName);
|
||||
}
|
||||
|
||||
user.setBanReason(banReason);
|
||||
user.setBanned(true);
|
||||
user.kickPlayer(banReason);
|
||||
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
|
||||
server.getLogger().log(Level.INFO, _("playerBanned", senderName, user.getName(), banReason));
|
||||
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final IUser player = ess.getUser(onlinePlayer);
|
||||
if (Permissions.BAN_NOTIFY.isAuthorized(player))
|
||||
final User player = ess.getUser(onlinePlayer);
|
||||
if (player.isAuthorized("essentials.ban.notify"))
|
||||
{
|
||||
onlinePlayer.sendMessage(_("playerBanned", senderName, user.getName(), banReason));
|
||||
}
|
||||
|
||||
@@ -1,24 +1,27 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import lombok.Cleanup;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandbanip extends EssentialsCommand
|
||||
{
|
||||
public Commandbanip()
|
||||
{
|
||||
super("banip");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
@Cleanup
|
||||
final IUser player = ess.getUser(args[0]);
|
||||
player.acquireReadLock();
|
||||
final User player = ess.getUser(args[0]);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
@@ -27,12 +30,12 @@ public class Commandbanip extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
final String ipAddress = player.getData().getIpAddress();
|
||||
final String ipAddress = player.getLastLoginAddress();
|
||||
if (ipAddress.length() == 0)
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
ess.getServer().banIP(player.getData().getIpAddress());
|
||||
ess.getServer().banIP(player.getLastLoginAddress());
|
||||
sender.sendMessage(_("banIpAddress"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.TreeType;
|
||||
|
||||
|
||||
public class Commandbigtree extends EssentialsCommand
|
||||
{
|
||||
public Commandbigtree()
|
||||
{
|
||||
super("bigtree");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
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"))
|
||||
@@ -21,6 +27,10 @@ public class Commandbigtree extends EssentialsCommand
|
||||
{
|
||||
tree = TreeType.BIG_TREE;
|
||||
}
|
||||
else if (args.length > 0 && args[0].equalsIgnoreCase("jungle"))
|
||||
{
|
||||
tree = TreeType.JUNGLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
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;
|
||||
|
||||
|
||||
public class Commandbreak extends EssentialsCommand
|
||||
{
|
||||
public Commandbreak()
|
||||
{
|
||||
super("break");
|
||||
}
|
||||
|
||||
//TODO: Switch to use util class
|
||||
@Override
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
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)
|
||||
@@ -22,10 +28,12 @@ public class Commandbreak extends EssentialsCommand
|
||||
{
|
||||
throw new NoChargeException();
|
||||
}
|
||||
if (block.getType() == Material.BEDROCK && !Permissions.BREAK_BEDROCK.isAuthorized(user))
|
||||
if (block.getType() == Material.BEDROCK && !user.isAuthorized("essentials.break.bedrock"))
|
||||
{
|
||||
throw new Exception("You are not allowed to destroy bedrock."); //TODO: Translation
|
||||
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())
|
||||
|
||||
@@ -1,19 +1,26 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandbroadcast extends EssentialsCommand
|
||||
{
|
||||
public Commandbroadcast()
|
||||
{
|
||||
super("broadcast");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
ess.broadcastMessage(null, _("broadcast", getFinalArg(args, 0)));
|
||||
ess.broadcastMessage(null, _("broadcast", Util.replaceFormat(getFinalArg(args, 0))));
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,31 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandburn extends EssentialsCommand
|
||||
{
|
||||
public Commandburn()
|
||||
{
|
||||
super("burn");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
//TODO: TL this
|
||||
if (args[0].trim().length() < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException("You need to specify a player to burn.");
|
||||
}
|
||||
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
{
|
||||
|
||||
@@ -1,20 +1,25 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.List;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandclearinventory extends EssentialsCommand
|
||||
{
|
||||
public Commandclearinventory()
|
||||
{
|
||||
super("clearinventory");
|
||||
}
|
||||
|
||||
//TODO: Cleanup
|
||||
@Override
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && Permissions.CLEARINVENTORY_OTHERS.isAuthorized(user))
|
||||
if (args.length > 0 && user.isAuthorized("essentials.clearinventory.others"))
|
||||
{
|
||||
//TODO: Fix fringe user match case.
|
||||
if (args[0].length() >= 3)
|
||||
@@ -54,7 +59,7 @@ public class Commandclearinventory extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
|
||||
|
||||
public class Commandcompass extends EssentialsCommand
|
||||
{
|
||||
public Commandcompass()
|
||||
{
|
||||
super("compass");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final int bearing = (int)(user.getLocation().getYaw() + 180 + 360) % 360;
|
||||
String dir;
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.Locale;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commanddelhome extends EssentialsCommand
|
||||
{
|
||||
public Commanddelhome()
|
||||
{
|
||||
super("delhome");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
@Cleanup
|
||||
IUser user = sender instanceof Player ? ess.getUser((Player)sender) : null;
|
||||
User user = ess.getUser(sender);
|
||||
String name;
|
||||
String[] expandedArg;
|
||||
|
||||
@@ -35,9 +37,9 @@ public class Commanddelhome extends EssentialsCommand
|
||||
expandedArg = args;
|
||||
}
|
||||
|
||||
if (expandedArg.length > 1 && (user == null || Permissions.DELHOME_OTHERS.isAuthorized(user)))
|
||||
if (expandedArg.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others")))
|
||||
{
|
||||
user = getPlayer(expandedArg, 0, true);
|
||||
user = getPlayer(server, expandedArg, 0, true);
|
||||
name = expandedArg[1];
|
||||
}
|
||||
else if (user == null)
|
||||
@@ -52,8 +54,7 @@ public class Commanddelhome extends EssentialsCommand
|
||||
/*
|
||||
* if (name.equalsIgnoreCase("bed")) { throw new Exception("You cannot remove the vanilla home point"); }
|
||||
*/
|
||||
user.acquireWriteLock();
|
||||
user.getData().removeHome(name.toLowerCase(Locale.ENGLISH));
|
||||
user.delHome(name.toLowerCase(Locale.ENGLISH));
|
||||
sender.sendMessage(_("deleteHome", name));
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,19 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commanddeljail extends EssentialsCommand
|
||||
{
|
||||
public Commanddeljail()
|
||||
{
|
||||
super("deljail");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commanddelwarp extends EssentialsCommand
|
||||
{
|
||||
public Commanddelwarp()
|
||||
{
|
||||
super("delwarp");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
ess.getWarps().removeWarp(args[0]);
|
||||
ess.getWarps().delWarp(args[0]);
|
||||
sender.sendMessage(_("deleteWarp", args[0]));
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,19 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
|
||||
|
||||
public class Commanddepth extends EssentialsCommand
|
||||
{
|
||||
public Commanddepth()
|
||||
{
|
||||
super("depth");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final int depth = user.getLocation().getBlockY() - 63;
|
||||
if (depth > 0)
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.Locale;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandeco extends EssentialsCommand
|
||||
{
|
||||
public Commandeco()
|
||||
{
|
||||
super("eco");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
@@ -29,11 +34,11 @@ public class Commandeco extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException(ex);
|
||||
}
|
||||
|
||||
if (args[1].contentEquals("*"))
|
||||
if (args[1].contentEquals("**"))
|
||||
{
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
for (String sUser : ess.getUserMap().getAllUniqueUsers())
|
||||
{
|
||||
final IUser player = ess.getUser(onlinePlayer);
|
||||
final User player = ess.getUser(sUser);
|
||||
switch (cmd)
|
||||
{
|
||||
case GIVE:
|
||||
@@ -41,21 +46,46 @@ public class Commandeco extends EssentialsCommand
|
||||
break;
|
||||
|
||||
case TAKE:
|
||||
if (player.canAfford(amount, false))
|
||||
{
|
||||
player.takeMoney(amount);
|
||||
}
|
||||
break;
|
||||
|
||||
case RESET:
|
||||
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (args[1].contentEquals("*"))
|
||||
{
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final User player = ess.getUser(onlinePlayer);
|
||||
switch (cmd)
|
||||
{
|
||||
case GIVE:
|
||||
player.giveMoney(amount);
|
||||
break;
|
||||
|
||||
case TAKE:
|
||||
if (!player.canAfford(amount, false))
|
||||
{
|
||||
throw new Exception(_("notEnoughMoney"));
|
||||
}
|
||||
player.takeMoney(amount);
|
||||
break;
|
||||
|
||||
case RESET:
|
||||
@Cleanup
|
||||
ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
player.setMoney(amount == 0 ? settings.getData().getEconomy().getStartingBalance() : amount);
|
||||
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final IUser player = getPlayer(args, 1, true);
|
||||
final User player = getPlayer(server, args, 1, true);
|
||||
switch (cmd)
|
||||
{
|
||||
case GIVE:
|
||||
@@ -63,13 +93,15 @@ public class Commandeco extends EssentialsCommand
|
||||
break;
|
||||
|
||||
case TAKE:
|
||||
if (!player.canAfford(amount, false))
|
||||
{
|
||||
throw new Exception(_("notEnoughMoney"));
|
||||
}
|
||||
player.takeMoney(amount, sender);
|
||||
break;
|
||||
|
||||
case RESET:
|
||||
@Cleanup ISettings settings = ess.getSettings();
|
||||
settings.acquireReadLock();
|
||||
player.setMoney(amount == 0 ? settings.getData().getEconomy().getStartingBalance() : amount);
|
||||
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,22 +2,27 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Enchantments;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.EnchantPermissions;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Commandenchant extends EssentialsCommand
|
||||
{
|
||||
public Commandenchant()
|
||||
{
|
||||
super("enchant");
|
||||
}
|
||||
|
||||
//TODO: Implement charge costs: final Trade charge = new Trade("enchant-" + enchantmentName, ess);
|
||||
@Override
|
||||
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final ItemStack stack = user.getItemInHand();
|
||||
if (stack == null)
|
||||
@@ -30,7 +35,7 @@ public class Commandenchant extends EssentialsCommand
|
||||
for (Map.Entry<String, Enchantment> entry : Enchantments.entrySet())
|
||||
{
|
||||
final String enchantmentName = entry.getValue().getName().toLowerCase(Locale.ENGLISH);
|
||||
if (enchantmentslist.contains(enchantmentName) || EnchantPermissions.getPermission(enchantmentName).isAuthorized(user))
|
||||
if (enchantmentslist.contains(enchantmentName) || user.isAuthorized("essentials.enchant." + enchantmentName))
|
||||
{
|
||||
enchantmentslist.add(entry.getKey());
|
||||
//enchantmentslist.add(enchantmentName);
|
||||
@@ -76,7 +81,7 @@ public class Commandenchant extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
public static Enchantment getEnchantment(final String name, final IUser user) throws Exception
|
||||
public static Enchantment getEnchantment(final String name, final User user) throws Exception
|
||||
{
|
||||
|
||||
final Enchantment enchantment = Enchantments.getByName(name);
|
||||
@@ -85,7 +90,7 @@ public class Commandenchant extends EssentialsCommand
|
||||
throw new Exception(_("enchantmentNotFound"));
|
||||
}
|
||||
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
|
||||
if (user != null && !EnchantPermissions.getPermission(enchantmentName).isAuthorized(user))
|
||||
if (user != null && !user.isAuthorized("essentials.enchant." + enchantmentName))
|
||||
{
|
||||
throw new Exception(_("enchantmentPerm", enchantmentName));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
|
||||
|
||||
public class Commandenderchest extends EssentialsCommand
|
||||
{
|
||||
public Commandenderchest()
|
||||
{
|
||||
super("enderchest");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && user.isAuthorized("essentials.enderchest.others"))
|
||||
{
|
||||
final User invUser = getPlayer(server, args, 0);
|
||||
user.openInventory(invUser.getEnderChest());
|
||||
user.setEnderSee(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.openInventory(user.getEnderChest());
|
||||
user.setEnderSee(false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,71 +1,103 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.metrics.Metrics;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandessentials extends EssentialsCommand
|
||||
{
|
||||
public Commandessentials()
|
||||
{
|
||||
super("essentials");
|
||||
}
|
||||
private transient int taskid;
|
||||
private final transient Map<Player, Block> noteBlocks = new HashMap<Player, Block>();
|
||||
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
run_disabled(sender, args);
|
||||
if (args.length == 0) {
|
||||
run_disabled(server, sender, commandLabel, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("debug"))
|
||||
{
|
||||
run_debug(sender, args);
|
||||
run_debug(server, sender, commandLabel, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("nya"))
|
||||
{
|
||||
run_nya(sender, args);
|
||||
run_nya(server, sender, commandLabel, args);
|
||||
}
|
||||
else
|
||||
else if (args[0].equalsIgnoreCase("moo"))
|
||||
{
|
||||
run_reload(sender, args);
|
||||
run_moo(server, sender, commandLabel, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("reset"))
|
||||
{
|
||||
run_reset(server, sender, commandLabel, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("opt-out"))
|
||||
{
|
||||
run_optout(server, sender, commandLabel, args);
|
||||
}
|
||||
else {
|
||||
run_reload(server, sender, commandLabel, args);
|
||||
}
|
||||
}
|
||||
|
||||
private void run_disabled(final CommandSender sender, final String[] args) throws Exception
|
||||
|
||||
private void run_disabled(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
sender.sendMessage("Essentials " + ess.getDescription().getVersion());
|
||||
sender.sendMessage("/<command> <reload/debug>");
|
||||
sender.sendMessage(_("blockList"));
|
||||
|
||||
final StringBuilder disabledCommands = new StringBuilder();
|
||||
for (Map.Entry<String, String> entry : ess.getCommandHandler().disabledCommands().entrySet())
|
||||
for (Map.Entry<String, String> entry : ess.getAlternativeCommandsHandler().disabledCommands().entrySet())
|
||||
{
|
||||
if (disabledCommands.length() > 0)
|
||||
{
|
||||
if (disabledCommands.length() > 0) {
|
||||
disabledCommands.append(", ");
|
||||
}
|
||||
disabledCommands.append(entry.getKey()).append(" => ").append(entry.getValue());
|
||||
}
|
||||
sender.sendMessage(disabledCommands.toString());
|
||||
if (disabledCommands.length() > 0) {
|
||||
sender.sendMessage(_("blockList"));
|
||||
sender.sendMessage(disabledCommands.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private void run_debug(final CommandSender sender, final String[] args) throws Exception
|
||||
|
||||
private void run_reset(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException("/<command> reset <player>");
|
||||
}
|
||||
final User user = getPlayer(server, args, 1, true);
|
||||
user.reset();
|
||||
sender.sendMessage("Reset Essentials userdata for player: " + user.getDisplayName());
|
||||
}
|
||||
|
||||
private void run_debug(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
ess.getSettings().setDebug(!ess.getSettings().isDebug());
|
||||
sender.sendMessage("Essentials " + ess.getDescription().getVersion() + " debug mode " + (ess.getSettings().isDebug() ? "enabled" : "disabled"));
|
||||
}
|
||||
|
||||
private void run_reload(final CommandSender sender, final String[] args) throws Exception
|
||||
|
||||
private void run_reload(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
ess.reload();
|
||||
sender.sendMessage(_("essentialsReload", ess.getDescription().getVersion()));
|
||||
}
|
||||
|
||||
private void run_nya(final CommandSender sender, final String[] args) throws Exception
|
||||
|
||||
private void run_nya(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final Map<String, Byte> noteMap = new HashMap<String, Byte>();
|
||||
noteMap.put("1F#", (byte)0x0);
|
||||
@@ -92,61 +124,60 @@ public class Commandessentials extends EssentialsCommand
|
||||
noteMap.put("2D#", (byte)(0x9 + 0xC));
|
||||
noteMap.put("2E", (byte)(0xA + 0xC));
|
||||
noteMap.put("2F", (byte)(0xB + 0xC));
|
||||
if (!noteBlocks.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final String tuneStr = "1D#,1E,2F#,,2A#,1E,1D#,1E,2F#,2B,2D#,2E,2D#,2A#,2B,,2F#,,1D#,1E,2F#,2B,2C#,2A#,2B,2C#,2E,2D#,2E,2C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1B,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1B,,";
|
||||
final String[] tune = tuneStr.split(",");
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
final Location loc = player.getLocation();
|
||||
loc.add(0, 3, 0);
|
||||
while (loc.getBlockY() < player.getLocation().getBlockY() + 10 && loc.getBlock().getTypeId() != 0)
|
||||
if (!noteBlocks.isEmpty())
|
||||
{
|
||||
loc.add(0, 1, 0);
|
||||
return;
|
||||
}
|
||||
if (loc.getBlock().getTypeId() == 0)
|
||||
final String tuneStr = "1D#,1E,2F#,,2A#,1E,1D#,1E,2F#,2B,2D#,2E,2D#,2A#,2B,,2F#,,1D#,1E,2F#,2B,2C#,2A#,2B,2C#,2E,2D#,2E,2C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1B,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1B,,";
|
||||
final String[] tune = tuneStr.split(",");
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
noteBlocks.put(player, loc.getBlock());
|
||||
loc.getBlock().setType(Material.NOTE_BLOCK);
|
||||
final Location loc = player.getLocation();
|
||||
loc.add(0, 3, 0);
|
||||
while (loc.getBlockY() < player.getLocation().getBlockY() + 10 && loc.getBlock().getTypeId() != 0)
|
||||
{
|
||||
loc.add(0, 1, 0);
|
||||
}
|
||||
if (loc.getBlock().getTypeId() == 0)
|
||||
{
|
||||
noteBlocks.put(player, loc.getBlock());
|
||||
loc.getBlock().setType(Material.NOTE_BLOCK);
|
||||
}
|
||||
}
|
||||
}
|
||||
taskid = ess.scheduleSyncRepeatingTask(new Runnable()
|
||||
{
|
||||
int i = 0;
|
||||
taskid = ess.scheduleSyncRepeatingTask(new Runnable()
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final String note = tune[i];
|
||||
i++;
|
||||
if (i >= tune.length)
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Commandessentials.this.stopTune();
|
||||
}
|
||||
if (note.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Map<Player, Block> noteBlocks = Commandessentials.this.noteBlocks;
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final Block block = noteBlocks.get(onlinePlayer);
|
||||
if (block == null || block.getType() != Material.NOTE_BLOCK)
|
||||
final String note = tune[i];
|
||||
i++;
|
||||
if (i >= tune.length)
|
||||
{
|
||||
continue;
|
||||
Commandessentials.this.stopTune();
|
||||
}
|
||||
if (note.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Map<Player, Block> noteBlocks = Commandessentials.this.noteBlocks;
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final Block block = noteBlocks.get(onlinePlayer);
|
||||
if (block == null || block.getType() != Material.NOTE_BLOCK)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
onlinePlayer.playNote(block.getLocation(), (byte)0, noteMap.get(note));
|
||||
}
|
||||
onlinePlayer.playNote(block.getLocation(), (byte)0, noteMap.get(note));
|
||||
}
|
||||
}
|
||||
}, 20, 2);
|
||||
return;
|
||||
}, 20, 2);
|
||||
}
|
||||
|
||||
private void stopTune()
|
||||
{
|
||||
ess.getServer().getScheduler().cancelTask(taskid);
|
||||
ess.getScheduler().cancelTask(taskid);
|
||||
for (Block block : noteBlocks.values())
|
||||
{
|
||||
if (block.getType() == Material.NOTE_BLOCK)
|
||||
@@ -156,4 +187,31 @@ public class Commandessentials extends EssentialsCommand
|
||||
}
|
||||
noteBlocks.clear();
|
||||
}
|
||||
|
||||
private void run_moo(final Server server, final CommandSender sender, final String command, final String args[])
|
||||
{
|
||||
if(sender instanceof ConsoleCommandSender)
|
||||
sender.sendMessage(new String[]{" (__)", " (oo)", " /------\\/", " / | ||", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..." } );
|
||||
else
|
||||
sender.sendMessage(new String[]{" (__)", " (oo)", " /------\\/", " / | | |", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..." } );
|
||||
}
|
||||
|
||||
private void run_optout(final Server server, final CommandSender sender, final String command, final String args[])
|
||||
{
|
||||
final Metrics metrics = ess.getMetrics();
|
||||
try
|
||||
{
|
||||
sender.sendMessage("Essentials collects simple metrics to highlight which features to concentrate work on in the future.");
|
||||
if (metrics.isOptOut()) {
|
||||
metrics.enable();
|
||||
} else {
|
||||
metrics.disable();
|
||||
}
|
||||
sender.sendMessage("Anonymous Metrics are now: " + (metrics.isOptOut() ? "disabled" : "enabled"));
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
sender.sendMessage("Unable to modify 'plugins/PluginMetrics/config.yml': " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.craftbukkit.SetExpFix;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandexp extends EssentialsCommand
|
||||
{
|
||||
public Commandexp()
|
||||
{
|
||||
super("exp");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
showExp(user, user);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("set") && user.isAuthorized("essentials.exp.set"))
|
||||
{
|
||||
if (args.length == 3 && user.isAuthorized("essentials.exp.set.others"))
|
||||
{
|
||||
expMatch(server, user, args[1], args[2], false);
|
||||
}
|
||||
else
|
||||
{
|
||||
setExp(user, user, args[1], false);
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("give") && user.isAuthorized("essentials.exp.give"))
|
||||
{
|
||||
if (args.length == 3 && user.isAuthorized("essentials.exp.give.others"))
|
||||
{
|
||||
expMatch(server, user, args[1], args[2], true);
|
||||
}
|
||||
else
|
||||
{
|
||||
setExp(user, user, args[1], true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
String match = args[0].trim();
|
||||
if (args.length == 2)
|
||||
{
|
||||
match = args[1].trim();
|
||||
}
|
||||
if (match.equalsIgnoreCase("show") || !user.isAuthorized("essentials.exp.others"))
|
||||
{
|
||||
showExp(user, user);
|
||||
}
|
||||
else
|
||||
{
|
||||
showMatch(server, user, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
else if (args.length > 2 && args[0].equalsIgnoreCase("set"))
|
||||
{
|
||||
expMatch(server, sender, args[1], args[2], false);
|
||||
}
|
||||
else if (args.length > 2 && args[0].equalsIgnoreCase("give"))
|
||||
{
|
||||
expMatch(server, sender, args[1], args[2], true);
|
||||
}
|
||||
else
|
||||
{
|
||||
String match = args[0].trim();
|
||||
if (args.length == 2)
|
||||
{
|
||||
match = args[1].trim();
|
||||
}
|
||||
showMatch(server, sender, match);
|
||||
}
|
||||
}
|
||||
|
||||
private void showMatch(final Server server, final CommandSender sender, final String match) throws NotEnoughArgumentsException
|
||||
{
|
||||
boolean foundUser = false;
|
||||
for (Player matchPlayer : server.matchPlayer(match))
|
||||
{
|
||||
foundUser = true;
|
||||
final User target = ess.getUser(matchPlayer);
|
||||
showExp(sender, target);
|
||||
}
|
||||
if (!foundUser)
|
||||
{
|
||||
throw new NotEnoughArgumentsException(_("playerNotFound"));
|
||||
}
|
||||
}
|
||||
|
||||
private void expMatch(final Server server, final CommandSender sender, final String match, String amount, final boolean toggle) throws NotEnoughArgumentsException
|
||||
{
|
||||
boolean foundUser = false;
|
||||
for (Player matchPlayer : server.matchPlayer(match))
|
||||
{
|
||||
final User target = ess.getUser(matchPlayer);
|
||||
setExp(sender, target, amount, toggle);
|
||||
foundUser = true;
|
||||
}
|
||||
if (!foundUser)
|
||||
{
|
||||
throw new NotEnoughArgumentsException(_("playerNotFound"));
|
||||
}
|
||||
}
|
||||
|
||||
private void showExp(final CommandSender sender, final User target)
|
||||
{
|
||||
final int totalExp = SetExpFix.getTotalExperience(target);
|
||||
sender.sendMessage(_("exp", target.getDisplayName(), SetExpFix.getTotalExperience(target), target.getLevel(), SetExpFix.getExpUntilNextLevel(target)));
|
||||
}
|
||||
|
||||
private void setExp(final CommandSender sender, final User target, String strAmount, final boolean give)
|
||||
{
|
||||
Long amount;
|
||||
strAmount = strAmount.toLowerCase(Locale.ENGLISH);
|
||||
if (strAmount.startsWith("l"))
|
||||
{
|
||||
strAmount = strAmount.substring(1);
|
||||
int neededLevel = Integer.parseInt(strAmount);
|
||||
if (give)
|
||||
{
|
||||
neededLevel += target.getLevel();
|
||||
}
|
||||
amount = (long)SetExpFix.getExpToLevel(neededLevel);
|
||||
SetExpFix.setTotalExperience(target, 0);
|
||||
}
|
||||
else {
|
||||
amount = Long.parseLong(strAmount);
|
||||
}
|
||||
|
||||
if (give)
|
||||
{
|
||||
amount += SetExpFix.getTotalExperience(target);
|
||||
}
|
||||
if (amount > Integer.MAX_VALUE)
|
||||
{
|
||||
amount = (long)Integer.MAX_VALUE;
|
||||
}
|
||||
SetExpFix.setTotalExperience(target, amount.intValue());
|
||||
sender.sendMessage(_("expSet", target.getDisplayName(), amount));
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,32 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandext extends EssentialsCommand
|
||||
{
|
||||
public Commandext()
|
||||
{
|
||||
super("ext");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
extinguishPlayers(sender, args[0]);
|
||||
extinguishPlayers(server, sender, args[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
@@ -29,10 +35,10 @@ public class Commandext extends EssentialsCommand
|
||||
return;
|
||||
}
|
||||
|
||||
extinguishPlayers(user, args[0]);
|
||||
extinguishPlayers(server, user, commandLabel);
|
||||
}
|
||||
|
||||
private void extinguishPlayers(final CommandSender sender, final String name) throws Exception
|
||||
private void extinguishPlayers(final Server server, final CommandSender sender, final String name) throws Exception
|
||||
{
|
||||
for (Player matchPlayer : server.matchPlayer(name))
|
||||
{
|
||||
|
||||
@@ -1,21 +1,26 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.List;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandfeed extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
public Commandfeed()
|
||||
{
|
||||
if (args.length > 0 && Permissions.FEED_OTHERS.isAuthorized(user))
|
||||
super("feed");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && user.isAuthorized("essentials.feed.others"))
|
||||
{
|
||||
feedOtherPlayers(user, args[0]);
|
||||
feedOtherPlayers(server,user,args[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -24,8 +29,8 @@ public class Commandfeed extends EssentialsCommand
|
||||
user.sendMessage(_("feed"));
|
||||
}
|
||||
}
|
||||
|
||||
private void feedOtherPlayers(final CommandSender sender, final String name)
|
||||
|
||||
private void feedOtherPlayers(final Server server, final CommandSender sender, final String name)
|
||||
{
|
||||
final List<Player> players = server.matchPlayer(name);
|
||||
if (players.isEmpty())
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.SmallFireball;
|
||||
import org.bukkit.util.Vector;
|
||||
@@ -8,8 +9,13 @@ import org.bukkit.util.Vector;
|
||||
|
||||
public class Commandfireball extends EssentialsCommand
|
||||
{
|
||||
public Commandfireball()
|
||||
{
|
||||
super("fireball");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
boolean small = false;
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("small"))
|
||||
@@ -17,7 +23,7 @@ public class Commandfireball extends EssentialsCommand
|
||||
small = true;
|
||||
}
|
||||
final Vector direction = user.getEyeLocation().getDirection().multiply(2);
|
||||
final Fireball fireball = user.getWorld().spawn(user.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), small ? SmallFireball.class : Fireball.class);
|
||||
Fireball fireball = user.getWorld().spawn(user.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), small ? SmallFireball.class : Fireball.class);
|
||||
fireball.setShooter(user.getBase());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandfly extends EssentialsCommand
|
||||
{
|
||||
public Commandfly()
|
||||
{
|
||||
super("fly");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
flyOtherPlayers(server, sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && args[0].trim().length() > 2 && user.isAuthorized("essentials.fly.others"))
|
||||
{
|
||||
flyOtherPlayers(server, user, args);
|
||||
return;
|
||||
}
|
||||
user.setAllowFlight(!user.getAllowFlight());
|
||||
if (!user.getAllowFlight())
|
||||
{
|
||||
user.setFlying(false);
|
||||
}
|
||||
user.sendMessage(_("flyMode", _(user.getAllowFlight() ? "enabled" : "disabled"), user.getDisplayName()));
|
||||
}
|
||||
|
||||
private void flyOtherPlayers(final Server server, final CommandSender sender, final String[] args)
|
||||
{
|
||||
for (Player matchPlayer : server.matchPlayer(args[0]))
|
||||
{
|
||||
final User player = ess.getUser(matchPlayer);
|
||||
if (player.isHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
if (args[1].contains("on") || args[1].contains("ena") || args[1].equalsIgnoreCase("1"))
|
||||
{
|
||||
player.setAllowFlight(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setAllowFlight(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setAllowFlight(!player.getAllowFlight());
|
||||
}
|
||||
|
||||
if (!player.getAllowFlight())
|
||||
{
|
||||
player.setFlying(false);
|
||||
}
|
||||
sender.sendMessage(_("flyMode", _(player.getAllowFlight() ? "enabled" : "disabled"), player.getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,52 +1,116 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandgamemode extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public Commandgamemode()
|
||||
{
|
||||
if (args.length < 1)
|
||||
super("gamemode");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
gamemodeOtherPlayers(sender, args[0]);
|
||||
GameMode gameMode = matchGameMode(args[0].toLowerCase(Locale.ENGLISH));
|
||||
gamemodeOtherPlayers(server, sender, gameMode, args[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && !args[0].trim().isEmpty() && Permissions.GAMEMODE_OTHERS.isAuthorized(user))
|
||||
GameMode gameMode;
|
||||
if (args.length == 0)
|
||||
{
|
||||
gamemodeOtherPlayers(user, args[0]);
|
||||
gameMode = matchGameMode(commandLabel);
|
||||
}
|
||||
else if (args.length > 1 && args[1].trim().length() > 2 && user.isAuthorized("essentials.gamemode.others"))
|
||||
{
|
||||
gameMode = matchGameMode(args[0].toLowerCase(Locale.ENGLISH));
|
||||
gamemodeOtherPlayers(server, user, gameMode, args[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
user.setGameMode(user.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
|
||||
else
|
||||
{
|
||||
try {
|
||||
gameMode = matchGameMode(args[0].toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
catch (NotEnoughArgumentsException e) {
|
||||
gameMode = matchGameMode(commandLabel);
|
||||
gamemodeOtherPlayers(server, user, gameMode, args[0]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (gameMode == null) {
|
||||
gameMode = user.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : user.getGameMode() == GameMode.CREATIVE ? GameMode.ADVENTURE : GameMode.SURVIVAL;
|
||||
}
|
||||
user.setGameMode(gameMode);
|
||||
user.sendMessage(_("gameMode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName()));
|
||||
}
|
||||
|
||||
private void gamemodeOtherPlayers(final CommandSender sender, final String name)
|
||||
private void gamemodeOtherPlayers(final Server server, final CommandSender sender, final GameMode gameMode, final String player) throws NotEnoughArgumentsException
|
||||
{
|
||||
for (Player matchPlayer : server.matchPlayer(name))
|
||||
//TODO: TL this
|
||||
if (player.trim().length() < 2 || gameMode == null)
|
||||
{
|
||||
final IUser player = ess.getUser(matchPlayer);
|
||||
if (player.isHidden())
|
||||
throw new NotEnoughArgumentsException("You need to specify a valid player/mode.");
|
||||
}
|
||||
|
||||
boolean foundUser = false;
|
||||
for (Player matchPlayer : server.matchPlayer(player))
|
||||
{
|
||||
final User user = ess.getUser(matchPlayer);
|
||||
if (user.isHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
|
||||
sender.sendMessage(_("gameMode", _(player.getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName()));
|
||||
user.setGameMode(gameMode);
|
||||
sender.sendMessage(_("gameMode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName()));
|
||||
foundUser = true;
|
||||
}
|
||||
if (!foundUser)
|
||||
{
|
||||
throw new NotEnoughArgumentsException(_("playerNotFound"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private GameMode matchGameMode(String modeString) throws NotEnoughArgumentsException
|
||||
{
|
||||
GameMode mode = null;
|
||||
if (modeString.equalsIgnoreCase("gmc") || modeString.equalsIgnoreCase("egmc")
|
||||
|| modeString.contains("creat") || modeString.equalsIgnoreCase("1") || modeString.equalsIgnoreCase("c"))
|
||||
{
|
||||
mode = GameMode.CREATIVE;
|
||||
}
|
||||
else if (modeString.equalsIgnoreCase("gms") || modeString.equalsIgnoreCase("egms")
|
||||
|| modeString.contains("survi") || modeString.equalsIgnoreCase("0") || modeString.equalsIgnoreCase("s"))
|
||||
{
|
||||
mode = GameMode.SURVIVAL;
|
||||
}
|
||||
else if (modeString.equalsIgnoreCase("gma") || modeString.equalsIgnoreCase("egma")
|
||||
|| modeString.contains("advent") || modeString.equalsIgnoreCase("2") || modeString.equalsIgnoreCase("a"))
|
||||
{
|
||||
mode = GameMode.ADVENTURE;
|
||||
}
|
||||
else if (modeString.equalsIgnoreCase("gmt") || modeString.equalsIgnoreCase("egmt")
|
||||
|| modeString.contains("toggle") || modeString.contains("cycle") || modeString.equalsIgnoreCase("t"))
|
||||
{
|
||||
mode = null;
|
||||
}
|
||||
else {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,60 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandgc extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public Commandgc()
|
||||
{
|
||||
super("gc");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
float tps = ess.getTimer().getAverageTPS();
|
||||
ChatColor color;
|
||||
if (tps >= 18)
|
||||
{
|
||||
color = ChatColor.GREEN;
|
||||
}
|
||||
else if (tps >= 15)
|
||||
{
|
||||
color = ChatColor.YELLOW;
|
||||
}
|
||||
else
|
||||
{
|
||||
color = ChatColor.RED;
|
||||
}
|
||||
|
||||
sender.sendMessage(_("uptime", Util.formatDateDiff(ManagementFactory.getRuntimeMXBean().getStartTime())));
|
||||
sender.sendMessage(_("tps", "" + color + tps));
|
||||
sender.sendMessage(_("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(_("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(_("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(_("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
|
||||
|
||||
for (World w : server.getWorlds())
|
||||
{
|
||||
sender.sendMessage(
|
||||
(w.getEnvironment() == World.Environment.NETHER ? "Nether" : "World") + " \"" + w.getName() + "\": "
|
||||
+ w.getLoadedChunks().length + _("gcchunks")
|
||||
+ w.getEntities().size() + _("gcentities"));
|
||||
String worldType = "World";
|
||||
switch (w.getEnvironment())
|
||||
{
|
||||
case NETHER:
|
||||
worldType = "Nether";
|
||||
break;
|
||||
case THE_END:
|
||||
worldType = "The End";
|
||||
break;
|
||||
}
|
||||
|
||||
sender.sendMessage(_("gcWorld", worldType, w.getName(), w.getLoadedChunks().length, w.getEntities().size()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,50 +1,57 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.Permissions;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandgetpos extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
public Commandgetpos()
|
||||
{
|
||||
if (args.length > 0 && Permissions.GETPOS_OTHERS.isAuthorized(user))
|
||||
{
|
||||
final IUser otherUser = getPlayer(args, 0);
|
||||
outputPosition(user, otherUser.getLocation(), user.getLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
outputPosition(user, user.getLocation(), null);
|
||||
}
|
||||
super("getpos");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && user.isAuthorized("essentials.getpos.others"))
|
||||
{
|
||||
final User otherUser = getPlayer(server, args, 0);
|
||||
if (!otherUser.isHidden() || user.isAuthorized("essentials.list.hidden"))
|
||||
{
|
||||
outputPosition(user, otherUser.getLocation(), user.getLocation());
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
outputPosition(user, user.getLocation(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
final IUser user = getPlayer(args, 0);
|
||||
final User user = getPlayer(server, args, 0);
|
||||
outputPosition(sender, user.getLocation(), null);
|
||||
}
|
||||
|
||||
//TODO: Translate
|
||||
private void outputPosition(final CommandSender sender, final Location coords, final Location distance)
|
||||
{
|
||||
sender.sendMessage("§7World: " + coords.getWorld().getName());
|
||||
sender.sendMessage("§7X: " + coords.getBlockX() + " (+East <-> -West)");
|
||||
sender.sendMessage("§7Y: " + coords.getBlockY() + " (+Up <-> -Down)");
|
||||
sender.sendMessage("§7Z: " + coords.getBlockZ() + " (+South <-> -North)");
|
||||
sender.sendMessage("§7Yaw: " + (coords.getYaw() + 180 + 360) % 360 + " (Rotation)");
|
||||
sender.sendMessage("§7Pitch: " + coords.getPitch() + " (Head angle)");
|
||||
sender.sendMessage(_("currentWorld", coords.getWorld().getName()));
|
||||
sender.sendMessage(_("posX", coords.getBlockX()));
|
||||
sender.sendMessage(_("posY", coords.getBlockY()));
|
||||
sender.sendMessage(_("posZ", coords.getBlockZ()));
|
||||
sender.sendMessage(_("posYaw", (coords.getYaw() + 180 + 360) % 360));
|
||||
sender.sendMessage(_("posPitch", coords.getPitch()));
|
||||
if (distance != null && coords.getWorld().equals(distance.getWorld()))
|
||||
{
|
||||
sender.sendMessage("§7Distance: " + coords.distance(distance));
|
||||
sender.sendMessage(_("distance", coords.distance(distance)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.perm.GivePermissions;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -13,40 +15,63 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class Commandgive extends EssentialsCommand
|
||||
{
|
||||
//TODO: move these messages to message file
|
||||
public Commandgive()
|
||||
{
|
||||
super("give");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
final IUser giveTo = getPlayer(args, 0);
|
||||
|
||||
final ItemStack stack = ess.getItemDb().get(args[1], giveTo);
|
||||
final ItemStack stack = ess.getItemDb().get(args[1]);
|
||||
|
||||
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
if (!GivePermissions.getPermission(stack.getType()).isAuthorized(sender))
|
||||
if (sender instanceof Player
|
||||
&& (ess.getSettings().permissionBasedItemSpawn()
|
||||
? (!ess.getUser(sender).isAuthorized("essentials.give.item-all")
|
||||
&& !ess.getUser(sender).isAuthorized("essentials.give.item-" + itemname)
|
||||
&& !ess.getUser(sender).isAuthorized("essentials.give.item-" + stack.getTypeId()))
|
||||
: (!ess.getUser(sender).isAuthorized("essentials.itemspawn.exempt")
|
||||
&& !ess.getUser(sender).canSpawnItem(stack.getTypeId()))))
|
||||
{
|
||||
throw new Exception(ChatColor.RED + "You are not allowed to spawn the item " + itemname);
|
||||
}
|
||||
throw new Exception(_("cantSpawnItem", itemname));
|
||||
}
|
||||
|
||||
if (args.length > 2 && Integer.parseInt(args[2]) > 0)
|
||||
final User giveTo = getPlayer(server, args, 0);
|
||||
|
||||
if (args.length > 3 && Util.isInt(args[2]) && Util.isInt(args[3]))
|
||||
{
|
||||
stack.setAmount(Integer.parseInt(args[2]));
|
||||
}
|
||||
stack.setDurability(Short.parseShort(args[3]));
|
||||
}
|
||||
else if (args.length > 2 && Integer.parseInt(args[2]) > 0)
|
||||
{
|
||||
stack.setAmount(Integer.parseInt(args[2]));
|
||||
}
|
||||
else if (ess.getSettings().getDefaultStackSize() > 0)
|
||||
{
|
||||
stack.setAmount(ess.getSettings().getDefaultStackSize());
|
||||
}
|
||||
else if (ess.getSettings().getOversizedStackSize() > 0 && giveTo.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
stack.setAmount(ess.getSettings().getOversizedStackSize());
|
||||
}
|
||||
|
||||
if (args.length > 3)
|
||||
{
|
||||
for (int i = 3; i < args.length; i++)
|
||||
for (int i = Util.isInt(args[3]) ? 4 : 3; i < args.length; i++)
|
||||
{
|
||||
final String[] split = args[i].split("[:+',;.]", 2);
|
||||
if (split.length < 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final Enchantment enchantment = Commandenchant.getEnchantment(split[0], sender instanceof Player ? ess.getUser((Player)sender) : null);
|
||||
final Enchantment enchantment = Commandenchant.getEnchantment(split[0], sender instanceof Player ? ess.getUser(sender) : null);
|
||||
int level;
|
||||
if (split.length > 1)
|
||||
{
|
||||
@@ -62,13 +87,19 @@ public class Commandgive extends EssentialsCommand
|
||||
|
||||
if (stack.getType() == Material.AIR)
|
||||
{
|
||||
throw new Exception(ChatColor.RED + "You can't give air.");
|
||||
throw new Exception(_("cantSpawnItem", "Air"));
|
||||
}
|
||||
|
||||
giveTo.giveItems(stack, false);
|
||||
|
||||
final String itemName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
|
||||
sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + ".");
|
||||
|
||||
sender.sendMessage(_("giveSpawn", stack.getAmount(), itemName, giveTo.getDisplayName()));
|
||||
if (giveTo.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
InventoryWorkaround.addItem(giveTo.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
|
||||
}
|
||||
else
|
||||
{
|
||||
InventoryWorkaround.addItem(giveTo.getInventory(), true, stack);
|
||||
}
|
||||
giveTo.updateInventory();
|
||||
}
|
||||
}
|
||||
Loaded 100 of 550 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user