mirror of
https://github.com/essentials/Essentials.git
synced 2025-09-20 03:11:30 +02:00
Compare commits
699 Commits
stable-2.8
...
stable-2.9
Author | SHA1 | Date | |
---|---|---|---|
|
03a93bfeff | ||
|
86749c433c | ||
|
17adafecf9 | ||
|
dd12e5db66 | ||
|
94947ecc21 | ||
|
8e50158af8 | ||
|
610fae63d2 | ||
|
ee072e844b | ||
|
0319415f1b | ||
|
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 | ||
|
cf7da7a83f | ||
|
f46948249e | ||
|
3b81593ebb | ||
|
8042cefd3d | ||
|
514f07ce57 | ||
|
4f4d9f6209 | ||
|
3077ea4ef1 | ||
|
945ae71480 | ||
|
3d1c0fd157 | ||
|
fab9688abb | ||
|
b2dbb3f9e3 | ||
|
16a0f44b4d | ||
|
7633b136e3 | ||
|
0252d756f6 | ||
|
ad05516fd5 | ||
|
6d127012d8 | ||
|
c064da9af8 | ||
|
d05f2d7a32 | ||
|
3fc6bb4e4f | ||
|
59679e0423 | ||
|
1a2acb43ae | ||
|
f0c0ee1a8d | ||
|
3c98718387 | ||
|
cfdb2a36c1 | ||
|
3b7d194902 | ||
|
72d514d52f | ||
|
9fe119e720 | ||
|
4a5c431163 | ||
|
a6ac333a74 | ||
|
bc2578b788 | ||
|
36d07cb539 | ||
|
effe0d5ec5 | ||
|
0ab2e745cf | ||
|
57a2ef08d4 | ||
|
2699e02f96 | ||
|
62cd219b4e | ||
|
2d56de1483 | ||
|
bbc6da5106 | ||
|
b0d06ce6ed | ||
|
de1554cb68 | ||
|
c890ea8f87 | ||
|
c0517c1203 | ||
|
9efd0eb6f9 | ||
|
f0ee026fb9 | ||
|
b3fc790000 | ||
|
83f9209bcc | ||
|
691a0ef4ce | ||
|
97bd49e598 | ||
|
e93e50f6d2 | ||
|
76ba5caeec | ||
|
a0103afde3 | ||
|
dbf30740fb | ||
|
3f02bcd702 | ||
|
fe050dd725 | ||
|
5b4966c888 | ||
|
2c8aa20542 |
@@ -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>
|
||||
|
@@ -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="BuildAll" 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 BuildAll -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
|
||||
@@ -854,7 +1164,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}"/>
|
||||
@@ -862,8 +1176,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}"/>
|
||||
@@ -871,12 +1186,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}"/>
|
||||
@@ -888,12 +1199,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}"/>
|
||||
@@ -915,6 +1222,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
|
||||
@@ -958,7 +1301,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">
|
||||
@@ -1001,14 +1344,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>
|
||||
@@ -1021,39 +1364,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>
|
||||
@@ -1174,9 +1518,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,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.44.1.45
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=51b33957
|
||||
nbproject/build-impl.xml.script.CRC32=c5170bed
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46
|
||||
nbproject/build-impl.xml.script.CRC32=2a17f1e9
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46
|
||||
|
@@ -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
|
||||
|
@@ -66,6 +66,7 @@ endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar
|
||||
file.reference.bPermissions.jar=../lib/bPermissions.jar
|
||||
file.reference.bpermissions2.jar=../lib/bpermissions2.jar
|
||||
file.reference.bukkit.jar=../lib/bukkit.jar
|
||||
file.reference.craftbukkit.jar=../lib/craftbukkit.jar
|
||||
file.reference.iCo4.jar=../lib/iCo4.jar
|
||||
@@ -76,6 +77,7 @@ file.reference.MultiCurrency.jar=../lib/MultiCurrency.jar
|
||||
file.reference.Permissions3.jar=../lib/Permissions3.jar
|
||||
file.reference.PermissionsBukkit-1.2.jar=../lib/PermissionsBukkit-1.2.jar
|
||||
file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar
|
||||
file.reference.Privileges.jar=..\\lib\\Privileges.jar
|
||||
file.reference.Vault.jar=../lib/Vault.jar
|
||||
includes=**
|
||||
jar.archive.disabled=${jnlp.enabled}
|
||||
@@ -95,7 +97,9 @@ javac.classpath=\
|
||||
${reference.EssentialsGroupManager.jar}:\
|
||||
${file.reference.bukkit.jar}:\
|
||||
${file.reference.craftbukkit.jar}:\
|
||||
${file.reference.Vault.jar}
|
||||
${file.reference.Vault.jar}:\
|
||||
${file.reference.Privileges.jar}:\
|
||||
${file.reference.bpermissions2.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
|
@@ -61,6 +61,12 @@ public class Backup implements Runnable
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ("save-all".equalsIgnoreCase(command)) {
|
||||
final CommandSender cs = server.getConsoleSender();
|
||||
server.dispatchCommand(cs, "save-all");
|
||||
active = false;
|
||||
return;
|
||||
}
|
||||
LOGGER.log(Level.INFO, _("backupStarted"));
|
||||
final CommandSender cs = server.getConsoleSender();
|
||||
server.dispatchCommand(cs, "save-all");
|
||||
|
@@ -6,12 +6,11 @@ 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
|
||||
@@ -156,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
|
||||
{
|
||||
|
@@ -19,47 +19,95 @@ public class Enchantments
|
||||
ENCHANTMENTS.put("alldamage", Enchantment.DAMAGE_ALL);
|
||||
ENCHANTMENTS.put("alldmg", Enchantment.DAMAGE_ALL);
|
||||
ENCHANTMENTS.put("sharpness", Enchantment.DAMAGE_ALL);
|
||||
ENCHANTMENTS.put("sharp", Enchantment.DAMAGE_ALL);
|
||||
|
||||
ENCHANTMENTS.put("arthropodsdamage", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ENCHANTMENTS.put("ardmg", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ENCHANTMENTS.put("baneofarthropods", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ENCHANTMENTS.put("baneofarthropod", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ENCHANTMENTS.put("arthropod", Enchantment.DAMAGE_ARTHROPODS);
|
||||
|
||||
ENCHANTMENTS.put("undeaddamage", Enchantment.DAMAGE_UNDEAD);
|
||||
ENCHANTMENTS.put("smite", Enchantment.DAMAGE_UNDEAD);
|
||||
|
||||
ENCHANTMENTS.put("digspeed", Enchantment.DIG_SPEED);
|
||||
ENCHANTMENTS.put("efficiency", Enchantment.DIG_SPEED);
|
||||
ENCHANTMENTS.put("minespeed", Enchantment.DIG_SPEED);
|
||||
ENCHANTMENTS.put("cutspeed", Enchantment.DIG_SPEED);
|
||||
|
||||
ENCHANTMENTS.put("durability", Enchantment.DURABILITY);
|
||||
ENCHANTMENTS.put("dura", Enchantment.DURABILITY);
|
||||
ENCHANTMENTS.put("unbreaking", Enchantment.DURABILITY);
|
||||
|
||||
ENCHANTMENTS.put("fireaspect", Enchantment.FIRE_ASPECT);
|
||||
ENCHANTMENTS.put("fire", Enchantment.FIRE_ASPECT);
|
||||
ENCHANTMENTS.put("meleefire", Enchantment.FIRE_ASPECT);
|
||||
ENCHANTMENTS.put("meleeflame", Enchantment.FIRE_ASPECT);
|
||||
|
||||
ENCHANTMENTS.put("knockback", Enchantment.KNOCKBACK);
|
||||
|
||||
ENCHANTMENTS.put("blockslootbonus", Enchantment.LOOT_BONUS_BLOCKS);
|
||||
ENCHANTMENTS.put("fortune", Enchantment.LOOT_BONUS_BLOCKS);
|
||||
|
||||
ENCHANTMENTS.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);
|
||||
ENCHANTMENTS.put("respiration", Enchantment.OXYGEN);
|
||||
ENCHANTMENTS.put("breathing", Enchantment.OXYGEN);
|
||||
ENCHANTMENTS.put("breath", Enchantment.OXYGEN);
|
||||
|
||||
ENCHANTMENTS.put("protection", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
ENCHANTMENTS.put("prot", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
ENCHANTMENTS.put("protect", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
|
||||
ENCHANTMENTS.put("explosionsprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ENCHANTMENTS.put("explosionprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ENCHANTMENTS.put("expprot", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ENCHANTMENTS.put("blastprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ENCHANTMENTS.put("blastprotect", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
|
||||
ENCHANTMENTS.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);
|
||||
ENCHANTMENTS.put("flameprotection", Enchantment.PROTECTION_FIRE);
|
||||
ENCHANTMENTS.put("fireprotect", Enchantment.PROTECTION_FIRE);
|
||||
ENCHANTMENTS.put("flameprotect", Enchantment.PROTECTION_FIRE);
|
||||
ENCHANTMENTS.put("fireprot", Enchantment.PROTECTION_FIRE);
|
||||
ENCHANTMENTS.put("flameprot", Enchantment.PROTECTION_FIRE);
|
||||
|
||||
ENCHANTMENTS.put("projectileprotection", Enchantment.PROTECTION_PROJECTILE);
|
||||
ENCHANTMENTS.put("projprot", Enchantment.PROTECTION_PROJECTILE);
|
||||
|
||||
ENCHANTMENTS.put("silktouch", Enchantment.SILK_TOUCH);
|
||||
ENCHANTMENTS.put("softtouch", Enchantment.SILK_TOUCH);
|
||||
|
||||
ENCHANTMENTS.put("waterworker", Enchantment.WATER_WORKER);
|
||||
ENCHANTMENTS.put("aquaaffinity", Enchantment.WATER_WORKER);
|
||||
|
||||
ENCHANTMENTS.put("firearrow", Enchantment.ARROW_FIRE);
|
||||
ENCHANTMENTS.put("flame", Enchantment.ARROW_FIRE);
|
||||
ENCHANTMENTS.put("flamearrow", Enchantment.ARROW_FIRE);
|
||||
|
||||
ENCHANTMENTS.put("arrowdamage", Enchantment.ARROW_DAMAGE);
|
||||
ENCHANTMENTS.put("power", Enchantment.ARROW_DAMAGE);
|
||||
ENCHANTMENTS.put("arrowpower", Enchantment.ARROW_DAMAGE);
|
||||
|
||||
ENCHANTMENTS.put("arrowknockback", Enchantment.ARROW_KNOCKBACK);
|
||||
ENCHANTMENTS.put("arrowkb", Enchantment.ARROW_KNOCKBACK);
|
||||
ENCHANTMENTS.put("punch", Enchantment.ARROW_KNOCKBACK);
|
||||
ENCHANTMENTS.put("arrowpunch", Enchantment.ARROW_KNOCKBACK);
|
||||
|
||||
ENCHANTMENTS.put("infinitearrows", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("infarrows", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("infinity", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("infinite", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("unlimited", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("unlimitedarrows", Enchantment.ARROW_INFINITE);
|
||||
}
|
||||
|
||||
public static Enchantment getByName(String name) {
|
||||
|
@@ -24,6 +24,9 @@ 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 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.signs.SignBlockListener;
|
||||
@@ -33,11 +36,14 @@ import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
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;
|
||||
@@ -61,7 +67,7 @@ import org.yaml.snakeyaml.error.YAMLException;
|
||||
|
||||
public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
public static final int BUKKIT_VERSION = 1846;
|
||||
public static final int BUKKIT_VERSION = 2317;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient ISettings settings;
|
||||
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);
|
||||
@@ -77,6 +83,9 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
private transient UserMap userMap;
|
||||
private transient ExecuteTimer execTimer;
|
||||
private transient I18n i18n;
|
||||
private transient Metrics metrics;
|
||||
private transient EssentialsTimer timer;
|
||||
private transient List<String> vanishedPlayers = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
public ISettings getSettings()
|
||||
@@ -119,19 +128,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;
|
||||
}
|
||||
@@ -218,7 +230,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
|
||||
final EssentialsEntityListener entityListener = new EssentialsEntityListener(this);
|
||||
pm.registerEvents(entityListener, this);
|
||||
|
||||
|
||||
final EssentialsWorldListener worldListener = new EssentialsWorldListener(this);
|
||||
pm.registerEvents(worldListener, this);
|
||||
|
||||
@@ -228,10 +240,23 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
|
||||
pm.registerEvents(tntListener, this);
|
||||
|
||||
final EssentialsTimer timer = new EssentialsTimer(this);
|
||||
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100);
|
||||
timer = new EssentialsTimer(this);
|
||||
getScheduler().scheduleSyncRepeatingTask(this, timer, 100, 100);
|
||||
|
||||
Economy.setEss(this);
|
||||
execTimer.mark("RegListeners");
|
||||
|
||||
final MetricsStarter metricsStarter = new MetricsStarter(this);
|
||||
if (metricsStarter.getStart() != null && metricsStarter.getStart() == true)
|
||||
{
|
||||
getScheduler().scheduleAsyncDelayedTask(this, metricsStarter, 1);
|
||||
}
|
||||
else if (metricsStarter.getStart() != null && metricsStarter.getStart() == false)
|
||||
{
|
||||
final MetricsListener metricsListener = new MetricsListener(this, metricsStarter);
|
||||
pm.registerEvents(metricsListener, this);
|
||||
}
|
||||
|
||||
final String timeroutput = execTimer.end();
|
||||
if (getSettings().isDebug())
|
||||
{
|
||||
@@ -242,6 +267,15 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
@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();
|
||||
@@ -277,7 +311,16 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
if (pc != null)
|
||||
{
|
||||
alternativeCommandsHandler.executed(commandLabel, pc.getLabel());
|
||||
return pc.execute(sender, commandLabel, args);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,6 +451,16 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
return backup;
|
||||
}
|
||||
|
||||
public Metrics getMetrics()
|
||||
{
|
||||
return metrics;
|
||||
}
|
||||
|
||||
public void setMetrics(Metrics metrics)
|
||||
{
|
||||
this.metrics = metrics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getUser(final Object base)
|
||||
{
|
||||
@@ -438,6 +491,12 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
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)
|
||||
@@ -504,7 +563,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
for (Player player : players)
|
||||
{
|
||||
final User user = getUser(player);
|
||||
if (!user.isIgnoredPlayer(sender.getName()))
|
||||
if (!user.isIgnoredPlayer(sender))
|
||||
{
|
||||
player.sendMessage(message);
|
||||
}
|
||||
@@ -572,15 +631,27 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
return i18n;
|
||||
}
|
||||
|
||||
private static class EssentialsWorldListener implements Listener, Runnable {
|
||||
|
||||
@Override
|
||||
public EssentialsTimer getTimer()
|
||||
{
|
||||
return timer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVanishedPlayers()
|
||||
{
|
||||
return vanishedPlayers;
|
||||
}
|
||||
|
||||
private static class EssentialsWorldListener implements Listener, Runnable
|
||||
{
|
||||
private transient final IEssentials ess;
|
||||
|
||||
public EssentialsWorldListener(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onWorldLoad(final WorldLoadEvent event)
|
||||
@@ -589,7 +660,8 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
ess.getWarps().reloadConfig();
|
||||
for (IConf iConf : ((Essentials)ess).confList)
|
||||
{
|
||||
if (iConf instanceof IEssentialsModule) {
|
||||
if (iConf instanceof IEssentialsModule)
|
||||
{
|
||||
iConf.reloadConfig();
|
||||
}
|
||||
}
|
||||
@@ -602,7 +674,8 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
ess.getWarps().reloadConfig();
|
||||
for (IConf iConf : ((Essentials)ess).confList)
|
||||
{
|
||||
if (iConf instanceof IEssentialsModule) {
|
||||
if (iConf instanceof IEssentialsModule)
|
||||
{
|
||||
iConf.reloadConfig();
|
||||
}
|
||||
}
|
||||
|
@@ -17,22 +17,18 @@ public class EssentialsBlockListener implements Listener
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockPlace(final BlockPlaceEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
// Do not rely on getItemInHand();
|
||||
// http://leaky.bukkit.org/issues/663
|
||||
// http://leaky.bukkit.org/issues/663
|
||||
final ItemStack is = Util.convertBlockToItem(event.getBlockPlaced());
|
||||
if (is == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
boolean unlimitedForUser = user.hasUnlimited(is);
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final boolean unlimitedForUser = user.hasUnlimited(is);
|
||||
if (unlimitedForUser && user.getGameMode() == GameMode.SURVIVAL)
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
|
@@ -1,9 +1,16 @@
|
||||
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.channels.ClosedByInterruptException;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
@@ -12,30 +19,29 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
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.config.Configuration;
|
||||
|
||||
|
||||
public class EssentialsConf extends Configuration
|
||||
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(configFile);
|
||||
super();
|
||||
this.configFile = configFile;
|
||||
if (this.root == null)
|
||||
{
|
||||
this.root = new HashMap<String, Object>();
|
||||
}
|
||||
}
|
||||
private final byte[] bytebuffer = new byte[1024];
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
public synchronized void load()
|
||||
{
|
||||
configFile = configFile.getAbsoluteFile();
|
||||
if (!configFile.getParentFile().exists())
|
||||
@@ -105,20 +111,60 @@ public class EssentialsConf extends Configuration
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
super.load();
|
||||
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 (RuntimeException e)
|
||||
{
|
||||
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(), e.getCause());
|
||||
}
|
||||
|
||||
if (this.root == null)
|
||||
{
|
||||
this.root = new HashMap<String, Object>();
|
||||
LOGGER.log(Level.SEVERE, "The file " + configFile.toString() + " is broken, it has been renamed to " + broken.toString(), ex.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +239,7 @@ public class EssentialsConf extends Configuration
|
||||
|
||||
public boolean hasProperty(final String path)
|
||||
{
|
||||
return getProperty(path) != null;
|
||||
return isSet(path);
|
||||
}
|
||||
|
||||
public Location getLocation(final String path, final Server server) throws Exception
|
||||
@@ -218,24 +264,25 @@ public class EssentialsConf extends Configuration
|
||||
|
||||
public void setProperty(final String path, final Location loc)
|
||||
{
|
||||
setProperty((path == null ? "" : path + ".") + "world", loc.getWorld().getName());
|
||||
setProperty((path == null ? "" : path + ".") + "x", loc.getX());
|
||||
setProperty((path == null ? "" : path + ".") + "y", loc.getY());
|
||||
setProperty((path == null ? "" : path + ".") + "z", loc.getZ());
|
||||
setProperty((path == null ? "" : path + ".") + "yaw", loc.getYaw());
|
||||
setProperty((path == null ? "" : path + ".") + "pitch", loc.getPitch());
|
||||
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 List<String> enchants = getKeys(path + ".enchant");
|
||||
final ConfigurationSection enchants = getConfigurationSection(path + ".enchant");
|
||||
if (enchants != null)
|
||||
{
|
||||
for (String enchant : enchants)
|
||||
for (String enchant : enchants.getKeys(false))
|
||||
{
|
||||
final Enchantment enchantment = Enchantment.getByName(enchant.toUpperCase(Locale.ENGLISH));
|
||||
if (enchantment == null)
|
||||
@@ -271,14 +318,14 @@ public class EssentialsConf extends Configuration
|
||||
}
|
||||
// getData().getData() is broken
|
||||
//map.put("data", stack.getDurability());
|
||||
setProperty(path, map);
|
||||
set(path, map);
|
||||
}
|
||||
|
||||
public long getLong(final String path, final long def)
|
||||
{
|
||||
try
|
||||
{
|
||||
final Number num = (Number)getProperty(path);
|
||||
final Number num = (Number)get(path);
|
||||
return num == null ? def : num.longValue();
|
||||
}
|
||||
catch (ClassCastException ex)
|
||||
@@ -292,7 +339,7 @@ public class EssentialsConf extends Configuration
|
||||
{
|
||||
try
|
||||
{
|
||||
Number num = (Number)getProperty(path);
|
||||
Number num = (Number)get(path);
|
||||
return num == null ? def : num.doubleValue();
|
||||
}
|
||||
catch (ClassCastException ex)
|
||||
@@ -300,4 +347,55 @@ public class EssentialsConf extends Configuration
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
try
|
||||
{
|
||||
save(configFile);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void save(final File file) throws IOException
|
||||
{
|
||||
if (file == null)
|
||||
{
|
||||
throw new IllegalArgumentException("File cannot be null");
|
||||
}
|
||||
|
||||
Files.createParentDirs(file);
|
||||
|
||||
final String data = saveToString();
|
||||
|
||||
final OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), UTF8);
|
||||
|
||||
try
|
||||
{
|
||||
writer.write(data);
|
||||
}
|
||||
finally
|
||||
{
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -3,14 +3,14 @@ package com.earth2me.essentials;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.List;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.Entity;
|
||||
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.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@@ -23,49 +23,69 @@ public class EssentialsEntityListener implements Listener
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityDamage(EntityDamageEvent event)
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onEntityDamage(final EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (event instanceof EntityDamageByEntityEvent)
|
||||
final Entity eAttack = event.getDamager();
|
||||
final Entity eDefend = event.getEntity();
|
||||
if (eDefend instanceof Player && eAttack instanceof Player)
|
||||
{
|
||||
EntityDamageByEntityEvent edEvent = (EntityDamageByEntityEvent)event;
|
||||
Entity eAttack = edEvent.getDamager();
|
||||
Entity eDefend = edEvent.getEntity();
|
||||
if (eDefend instanceof Player && eAttack instanceof Player)
|
||||
{
|
||||
User defender = ess.getUser(eDefend);
|
||||
User attacker = ess.getUser(eAttack);
|
||||
attacker.updateActivity(true);
|
||||
ItemStack is = attacker.getItemInHand();
|
||||
List<String> commandList = attacker.getPowertool(is);
|
||||
if (commandList != null && !commandList.isEmpty())
|
||||
{
|
||||
for (String command : commandList)
|
||||
{
|
||||
final User defender = ess.getUser(eDefend);
|
||||
final User attacker = ess.getUser(eAttack);
|
||||
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", defender.getName()));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
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()));
|
||||
}
|
||||
});
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (eDefend instanceof Animals && eAttack instanceof Player)
|
||||
}
|
||||
else if (eDefend instanceof Ageable && eAttack instanceof Player)
|
||||
{
|
||||
final Player player = (Player)eAttack;
|
||||
final ItemStack hand = player.getItemInHand();
|
||||
if (hand != null && hand.getType() == Material.MILK_BUCKET)
|
||||
{
|
||||
User player = ess.getUser(eAttack);
|
||||
ItemStack hand = player.getItemInHand();
|
||||
if (hand != null && hand.getType() == Material.MILK_BUCKET)
|
||||
{
|
||||
((Animals)eDefend).setAge(-24000);
|
||||
hand.setType(Material.BUCKET);
|
||||
player.setItemInHand(hand);
|
||||
player.updateInventory();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
((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();
|
||||
@@ -75,8 +95,8 @@ public class EssentialsEntityListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityCombust(EntityCombustEvent event)
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityCombust(final EntityCombustEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
@@ -85,26 +105,33 @@ public class EssentialsEntityListener implements Listener
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityDeath(final EntityDeathEvent event)
|
||||
public void onPlayerDeathEvent(final PlayerDeathEvent event)
|
||||
{
|
||||
if (event instanceof PlayerDeathEvent)
|
||||
final User user = ess.getUser(event.getEntity());
|
||||
if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back"))
|
||||
{
|
||||
final PlayerDeathEvent pdevent = (PlayerDeathEvent)event;
|
||||
final User user = ess.getUser(pdevent.getEntity());
|
||||
if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back"))
|
||||
{
|
||||
user.setLastLocation();
|
||||
user.sendMessage(_("backAfterDeath"));
|
||||
}
|
||||
if (!ess.getSettings().areDeathMessagesEnabled())
|
||||
{
|
||||
pdevent.setDeathMessage("");
|
||||
}
|
||||
user.setLastLocation();
|
||||
user.sendMessage(_("backAfterDeath"));
|
||||
}
|
||||
if (!ess.getSettings().areDeathMessagesEnabled())
|
||||
{
|
||||
event.setDeathMessage("");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event)
|
||||
@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())
|
||||
{
|
||||
@@ -112,8 +139,8 @@ public class EssentialsEntityListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityRegainHealth(EntityRegainHealthEvent event)
|
||||
@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())
|
||||
|
@@ -14,28 +14,31 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.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.block.Action;
|
||||
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 Server server;
|
||||
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;
|
||||
this.server = parent.getServer();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@@ -43,14 +46,11 @@ public class EssentialsPlayerListener implements Listener
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
updateCompass(user);
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayNick();
|
||||
}
|
||||
user.setDisplayNick();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerChat(final PlayerChatEvent event)
|
||||
public void onPlayerChat(final AsyncPlayerChatEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isMuted())
|
||||
@@ -63,27 +63,27 @@ public class EssentialsPlayerListener implements Listener
|
||||
while (it.hasNext())
|
||||
{
|
||||
final User u = ess.getUser(it.next());
|
||||
if (u.isIgnoredPlayer(user.getName()))
|
||||
if (u.isIgnoredPlayer(user))
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
user.updateActivity(true);
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayNick();
|
||||
}
|
||||
user.setDisplayNick();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerMove(final PlayerMoveEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
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());
|
||||
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
final Location from = event.getFrom();
|
||||
@@ -101,7 +101,6 @@ public class EssentialsPlayerListener implements Listener
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final Location afk = user.getAfkPosition();
|
||||
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9)
|
||||
{
|
||||
@@ -115,13 +114,13 @@ public class EssentialsPlayerListener implements Listener
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (ess.getSettings().removeGodOnDisconnect() && user.isGodModeEnabled())
|
||||
{
|
||||
user.toggleGodModeEnabled();
|
||||
user.setGodModeEnabled(false);
|
||||
}
|
||||
if (user.getSavedInventory() != null)
|
||||
if (user.isVanished())
|
||||
{
|
||||
user.getInventory().setContents(user.getSavedInventory());
|
||||
user.setSavedInventory(null);
|
||||
user.toggleVanished();
|
||||
}
|
||||
user.setLastLocation();
|
||||
user.updateActivity(false);
|
||||
user.dispose();
|
||||
}
|
||||
@@ -129,15 +128,37 @@ public class EssentialsPlayerListener implements Listener
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
ess.getBackup().onPlayerJoin();
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
ess.scheduleAsyncDelayedTask(new Runnable()
|
||||
{
|
||||
user.setDisplayNick();
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
delayedJoin(event.getPlayer());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void delayedJoin(final Player player)
|
||||
{
|
||||
if (!player.isOnline())
|
||||
{
|
||||
return;
|
||||
}
|
||||
user.setLastLoginAddress(user.getAddress().getAddress().getHostAddress());
|
||||
ess.getBackup().onPlayerJoin();
|
||||
final User user = ess.getUser(player);
|
||||
user.setDisplayNick();
|
||||
updateCompass(user);
|
||||
user.setLastLogin(System.currentTimeMillis());
|
||||
user.updateActivity(false);
|
||||
|
||||
for (String p : ess.getVanishedPlayers())
|
||||
{
|
||||
if (!user.isAuthorized("essentials.vanish.see"))
|
||||
{
|
||||
user.hidePlayer(ess.getUser(p).getBase());
|
||||
}
|
||||
}
|
||||
|
||||
if (user.isAuthorized("essentials.sleepingignored"))
|
||||
{
|
||||
user.setSleepingIgnored(true);
|
||||
@@ -179,39 +200,6 @@ public class EssentialsPlayerListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerLogin(final PlayerLoginEvent event)
|
||||
{
|
||||
if (event.getResult() != Result.ALLOWED && event.getResult() != Result.KICK_FULL && event.getResult() != Result.KICK_BANNED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
user.setNPC(false);
|
||||
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
final boolean banExpired = user.checkBanTimeout(currentTime);
|
||||
user.checkMuteTimeout(currentTime);
|
||||
user.checkJailTimeout(currentTime);
|
||||
|
||||
if (banExpired == false && (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 (server.getOnlinePlayers().length >= server.getMaxPlayers() && !user.isAuthorized("essentials.joinfullserver"))
|
||||
{
|
||||
event.disallow(Result.KICK_FULL, _("serverFull"));
|
||||
return;
|
||||
}
|
||||
event.allow();
|
||||
|
||||
user.setLastLogin(System.currentTimeMillis());
|
||||
updateCompass(user);
|
||||
}
|
||||
|
||||
private void updateCompass(final User user)
|
||||
{
|
||||
Location loc = user.getHome(user.getLocation());
|
||||
@@ -221,33 +209,78 @@ public class EssentialsPlayerListener implements Listener
|
||||
}
|
||||
if (loc != null)
|
||||
{
|
||||
user.setCompassTarget(loc);
|
||||
final Location updateLoc = loc;
|
||||
ess.scheduleSyncDelayedTask(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
user.setCompassTarget(updateLoc);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerTeleport(final PlayerTeleportEvent event)
|
||||
public void onPlayerLogin(final PlayerLoginEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
switch (event.getResult())
|
||||
{
|
||||
case ALLOWED:
|
||||
case KICK_FULL:
|
||||
case KICK_BANNED:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
//There is TeleportCause.COMMMAND but plugins have to actively pass the cause in on their teleports.
|
||||
if ((event.getCause() == TeleportCause.PLUGIN || event.getCause() == TeleportCause.COMMAND) && ess.getSettings().registerBackInListener())
|
||||
if (user.isNPC())
|
||||
{
|
||||
user.setLastLocation();
|
||||
user.setNPC(false);
|
||||
}
|
||||
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
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))
|
||||
{
|
||||
user.setDisplayNick();
|
||||
final String banReason = user.getBanReason();
|
||||
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : _("defaultBanReason"));
|
||||
return;
|
||||
}
|
||||
updateCompass(user);
|
||||
|
||||
if (event.getResult() == Result.KICK_FULL && !user.isAuthorized("essentials.joinfullserver"))
|
||||
{
|
||||
event.disallow(Result.KICK_FULL, _("serverFull"));
|
||||
return;
|
||||
}
|
||||
event.allow();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@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());
|
||||
@@ -259,7 +292,7 @@ public class EssentialsPlayerListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
@@ -276,75 +309,27 @@ public class EssentialsPlayerListener implements Listener
|
||||
});
|
||||
}
|
||||
}
|
||||
private final static List<String> COMMANDS = Arrays.asList("msg", "r", "mail", "m", "t", "whisper", "emsg", "tell", "er", "reply", "ereply", "email", "action", "describe", "eme", "eaction", "edescribe", "etell", "ewhisper", "pm");
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerAnimation(final PlayerAnimationEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.updateActivity(true);
|
||||
if (event.getAnimationType() == PlayerAnimationType.ARM_SWING
|
||||
&& user.hasPowerTools() && user.arePowerToolsEnabled())
|
||||
{
|
||||
usePowertools(user);
|
||||
}
|
||||
}
|
||||
|
||||
private void usePowertools(final User user)
|
||||
{
|
||||
final ItemStack is = user.getItemInHand();
|
||||
int id;
|
||||
if (is == null || (id = is.getTypeId()) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final List<String> commandList = user.getPowertool(id);
|
||||
if (commandList == null || commandList.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// We need to loop through each command and execute
|
||||
for (String command : commandList)
|
||||
{
|
||||
if (command.matches(".*\\{player\\}.*"))
|
||||
{
|
||||
//user.sendMessage("Click a player to use this command");
|
||||
continue;
|
||||
}
|
||||
else if (command.startsWith("c:"))
|
||||
{
|
||||
user.chat(command.substring(2));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.getServer().dispatchCommand(user.getBase(), command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final Player player = event.getPlayer();
|
||||
final String cmd = event.getMessage().toLowerCase(Locale.ENGLISH).split(" ")[0].replace("/", "").toLowerCase(Locale.ENGLISH);
|
||||
final List<String> commands = Arrays.asList("msg", "r", "mail", "m", "t", "emsg", "tell", "er", "reply", "ereply", "email");
|
||||
if (commands.contains(cmd))
|
||||
if (COMMANDS.contains(cmd))
|
||||
{
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
for (Player onlinePlayer : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
User spyer = ess.getUser(player);
|
||||
if (spyer.isSocialSpyEnabled() && !user.equals(spyer))
|
||||
final User spyer = ess.getUser(onlinePlayer);
|
||||
if (spyer.isSocialSpyEnabled() && !player.equals(onlinePlayer))
|
||||
{
|
||||
player.sendMessage(user.getDisplayName() + " : " + event.getMessage());
|
||||
onlinePlayer.sendMessage(player.getDisplayName() + " : " + event.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!cmd.equalsIgnoreCase("afk"))
|
||||
else if (!cmd.equalsIgnoreCase("afk"))
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
user.updateActivity(true);
|
||||
}
|
||||
}
|
||||
@@ -352,45 +337,126 @@ public class EssentialsPlayerListener implements Listener
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerChangedWorld(final PlayerChangedWorldEvent event)
|
||||
{
|
||||
if (ess.getSettings().getNoGodWorlds().contains(event.getPlayer().getLocation().getWorld().getName()))
|
||||
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 user = ess.getUser(event.getPlayer());
|
||||
if (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())
|
||||
{
|
||||
user.sendMessage(_("noGodWorldWarning"));
|
||||
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:
|
||||
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 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
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)
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event)
|
||||
public void onInventoryCloseEvent(final InventoryCloseEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
if (event.getView().getTopInventory().getType() == InventoryType.PLAYER)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ess.getSettings().getUpdateBedAtDaytime() && event.getClickedBlock().getType() == Material.BED_BLOCK)
|
||||
{
|
||||
event.getPlayer().setBedSpawnLocation(event.getClickedBlock().getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerPickupItem(PlayerPickupItemEvent event)
|
||||
{
|
||||
if (event.isCancelled() || !ess.getSettings().getDisableItemPickupWhileAfk())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isAfk())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.setInvSee(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ public class EssentialsPluginListener implements Listener, IConf
|
||||
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().getName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
|
||||
ess.getLogger().log(Level.INFO, "Payment method found (" + ess.getPaymentMethod().getMethod().getLongName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,6 +2,7 @@ package com.earth2me.essentials;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -11,6 +12,8 @@ public class EssentialsTimer implements Runnable
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
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)
|
||||
{
|
||||
@@ -21,6 +24,21 @@ 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
|
||||
@@ -48,6 +66,20 @@ public class EssentialsTimer implements Runnable
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@@ -95,7 +95,7 @@ public class EssentialsUpgrade
|
||||
}
|
||||
final EssentialsConf conf = new EssentialsConf(configFile);
|
||||
conf.load();
|
||||
List<String> lines = conf.getStringList(name, null);
|
||||
List<String> lines = conf.getStringList(name);
|
||||
if (lines != null && !lines.isEmpty())
|
||||
{
|
||||
if (!file.createNewFile())
|
||||
@@ -271,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();
|
||||
@@ -332,7 +332,7 @@ public class EssentialsUpgrade
|
||||
config.setProperty("homes.home", defloc);
|
||||
}
|
||||
|
||||
List<String> worlds = config.getKeys("home.worlds");
|
||||
Set<String> worlds = config.getConfigurationSection("home.worlds").getKeys(false);
|
||||
Location loc;
|
||||
String worldName;
|
||||
|
||||
@@ -381,7 +381,7 @@ public class EssentialsUpgrade
|
||||
}
|
||||
final EssentialsConf usersConfig = new EssentialsConf(usersFile);
|
||||
usersConfig.load();
|
||||
for (String username : usersConfig.getKeys(null))
|
||||
for (String username : usersConfig.getKeys(false))
|
||||
{
|
||||
final User user = new User(new OfflinePlayer(username, ess), ess);
|
||||
final String nickname = usersConfig.getString(username + ".nickname");
|
||||
@@ -389,7 +389,7 @@ public class EssentialsUpgrade
|
||||
{
|
||||
user.setNickname(nickname);
|
||||
}
|
||||
final List<String> mails = usersConfig.getStringList(username + ".mail", null);
|
||||
final List<String> mails = usersConfig.getStringList(username + ".mail");
|
||||
if (mails != null && !mails.isEmpty())
|
||||
{
|
||||
user.setMails(mails);
|
||||
@@ -701,7 +701,7 @@ public class EssentialsUpgrade
|
||||
if (!config.hasProperty("spawns"))
|
||||
{
|
||||
final Spawns spawns = new Spawns();
|
||||
List<String> keys = config.getKeys();
|
||||
Set<String> keys = config.getKeys(false);
|
||||
for (String group : keys)
|
||||
{
|
||||
Location loc = getFakeLocation(config, group);
|
||||
@@ -730,7 +730,7 @@ public class EssentialsUpgrade
|
||||
doneFile.setProperty("updateSpawnsToNewSpawnsConfig", true);
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
|
||||
private void updateJailsToNewJailsConfig()
|
||||
{
|
||||
if (doneFile.getBoolean("updateJailsToNewJailsConfig", false))
|
||||
@@ -748,7 +748,7 @@ public class EssentialsUpgrade
|
||||
if (!config.hasProperty("jails"))
|
||||
{
|
||||
final com.earth2me.essentials.settings.Jails jails = new com.earth2me.essentials.settings.Jails();
|
||||
List<String> keys = config.getKeys();
|
||||
Set<String> keys = config.getKeys(false);
|
||||
for (String jailName : keys)
|
||||
{
|
||||
Location loc = getFakeLocation(config, jailName);
|
||||
@@ -778,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())
|
||||
@@ -800,5 +811,6 @@ public class EssentialsUpgrade
|
||||
deleteOldItemsCsv();
|
||||
updateSpawnsToNewSpawnsConfig();
|
||||
updateJailsToNewJailsConfig();
|
||||
warnMetrics();
|
||||
}
|
||||
}
|
||||
|
@@ -114,6 +114,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);
|
||||
|
@@ -1,14 +1,17 @@
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated This will be moved to the api package soon
|
||||
*/
|
||||
@@ -64,4 +67,12 @@ public interface IEssentials extends Plugin
|
||||
ItemDb getItemDb();
|
||||
|
||||
UserMap getUserMap();
|
||||
|
||||
Metrics getMetrics();
|
||||
|
||||
void setMetrics(Metrics metrics);
|
||||
|
||||
EssentialsTimer getTimer();
|
||||
|
||||
List<String> getVanishedPlayers();
|
||||
}
|
||||
|
@@ -2,11 +2,13 @@ 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;
|
||||
|
||||
|
||||
@@ -14,12 +16,12 @@ public interface ISettings extends IConf
|
||||
{
|
||||
boolean areSignsDisabled();
|
||||
|
||||
String format(String format, IUser user);
|
||||
|
||||
String getAnnounceNewPlayerFormat(IUser user);
|
||||
IText getAnnounceNewPlayerFormat();
|
||||
|
||||
boolean getAnnounceNewPlayers();
|
||||
|
||||
String getNewPlayerKit();
|
||||
|
||||
String getBackupCommand();
|
||||
|
||||
long getBackupInterval();
|
||||
@@ -35,14 +37,14 @@ public interface ISettings extends IConf
|
||||
String getCurrencySymbol();
|
||||
|
||||
int getOversizedStackSize();
|
||||
|
||||
|
||||
int getDefaultStackSize();
|
||||
|
||||
double getHealCooldown();
|
||||
|
||||
Object getKit(String name);
|
||||
Map<String, Object> getKit(String name);
|
||||
|
||||
Map<String, Object> getKits();
|
||||
ConfigurationSection getKits();
|
||||
|
||||
String getLocale();
|
||||
|
||||
@@ -66,7 +68,7 @@ public interface ISettings extends IConf
|
||||
|
||||
boolean getRespawnAtHome();
|
||||
|
||||
List getMultipleHomes();
|
||||
Set getMultipleHomes();
|
||||
|
||||
int getHomeLimit(String set);
|
||||
|
||||
@@ -101,7 +103,7 @@ public interface ISettings extends IConf
|
||||
boolean isTradeInStacks(int id);
|
||||
|
||||
List<Integer> itemSpawnBlacklist();
|
||||
|
||||
|
||||
List<EssentialsSign> enabledSigns();
|
||||
|
||||
boolean permissionBasedItemSpawn();
|
||||
@@ -116,12 +118,18 @@ public interface ISettings extends IConf
|
||||
|
||||
double getMaxMoney();
|
||||
|
||||
double getMinMoney();
|
||||
|
||||
boolean isEcoLogEnabled();
|
||||
|
||||
boolean isEcoLogUpdateEnabled();
|
||||
|
||||
boolean removeGodOnDisconnect();
|
||||
|
||||
boolean changeDisplayName();
|
||||
|
||||
boolean changePlayerListName();
|
||||
|
||||
boolean isPlayerCommand(String string);
|
||||
|
||||
boolean useBukkitPermissions();
|
||||
@@ -138,23 +146,39 @@ public interface ISettings extends IConf
|
||||
|
||||
boolean getFreezeAfkPlayers();
|
||||
|
||||
boolean cancelAfkOnMove();
|
||||
|
||||
boolean areDeathMessagesEnabled();
|
||||
|
||||
public void setDebug(boolean debug);
|
||||
|
||||
Set<String> getNoGodWorlds();
|
||||
|
||||
|
||||
boolean getUpdateBedAtDaytime();
|
||||
|
||||
|
||||
boolean getRepairEnchanted();
|
||||
|
||||
boolean isWorldTeleportPermissions();
|
||||
|
||||
boolean getIsWorldTeleportPermissions();
|
||||
|
||||
boolean isWorldHomePermissions();
|
||||
|
||||
boolean registerBackInListener();
|
||||
|
||||
boolean getDisableItemPickupWhileAfk();
|
||||
|
||||
EventPriority getRespawnPriority();
|
||||
|
||||
|
||||
long getTpaAcceptCancellation();
|
||||
|
||||
boolean isMetricsEnabled();
|
||||
|
||||
void setMetricsEnabled(boolean metricsEnabled);
|
||||
|
||||
long getTeleportInvulnerability();
|
||||
|
||||
boolean isTeleportInvulnerability();
|
||||
|
||||
long getLoginAttackDelay();
|
||||
|
||||
int getSignUsePerSecond();
|
||||
}
|
||||
|
@@ -1,10 +1,8 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import java.net.InetSocketAddress;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
|
||||
/**
|
||||
@@ -32,6 +30,8 @@ public interface IUser extends Player
|
||||
void takeMoney(double value);
|
||||
|
||||
void giveMoney(double value);
|
||||
|
||||
boolean canAfford(double value);
|
||||
|
||||
String getGroup();
|
||||
|
||||
|
@@ -9,12 +9,16 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
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;
|
||||
@@ -26,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);
|
||||
reloadConfig();
|
||||
registerListeners();
|
||||
}
|
||||
|
||||
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
|
||||
@@ -49,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
|
||||
{
|
||||
@@ -115,7 +136,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
acquireReadLock();
|
||||
try
|
||||
{
|
||||
if (!(user.getBase() instanceof OfflinePlayer))
|
||||
if (user.isOnline())
|
||||
{
|
||||
Location loc = getJail(jail);
|
||||
user.getTeleport().now(loc, false, TeleportCause.COMMAND);
|
||||
@@ -146,10 +167,23 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class JailBlockListener implements Listener
|
||||
@Override
|
||||
public int getCount()
|
||||
{
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
try
|
||||
{
|
||||
return getList().size();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class JailListener implements Listener
|
||||
{
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockBreak(final BlockBreakEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
@@ -159,7 +193,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockPlace(final BlockPlaceEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
@@ -169,7 +203,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockDamage(final BlockDamageEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
@@ -178,12 +212,26 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class JailPlayerListener implements Listener
|
||||
{
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
@@ -193,7 +241,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerRespawn(final PlayerRespawnEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
@@ -246,7 +294,7 @@ 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)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
|
@@ -1,10 +1,14 @@
|
||||
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;
|
||||
|
||||
|
||||
@@ -15,60 +19,74 @@ public class Kit
|
||||
{
|
||||
try
|
||||
{
|
||||
final Map<String, Object> kits = ess.getSettings().getKits();
|
||||
final ConfigurationSection kits = ess.getSettings().getKits();
|
||||
final StringBuilder list = new StringBuilder();
|
||||
for (String kiteItem : kits.keySet())
|
||||
for (String kiteItem : kits.getKeys(false))
|
||||
{
|
||||
if (user.isAuthorized("essentials.kit." + kiteItem.toLowerCase(Locale.ENGLISH)))
|
||||
if (user == null || user.isAuthorized("essentials.kit." + kiteItem.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
list.append(" ").append(kiteItem);
|
||||
list.append(" ").append(capitalCase(kiteItem));
|
||||
}
|
||||
}
|
||||
return list.toString();
|
||||
return list.toString().trim();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(_("kitError"));
|
||||
throw new Exception(_("kitError"), ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void checkTime(final User user, final String kitName, final Map<String, Object> els) throws NoChargeException
|
||||
{
|
||||
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 c = new GregorianCalendar();
|
||||
c.add(Calendar.SECOND, -(int)delay);
|
||||
c.add(Calendar.MILLISECOND, -(int)((delay * 1000.0) % 1000.0));
|
||||
|
||||
final long mintime = c.getTimeInMillis();
|
||||
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 == null || lastTime < mintime)
|
||||
|
||||
if (lastTime == null || lastTime < earliestLong)
|
||||
{
|
||||
final Calendar now = new GregorianCalendar();
|
||||
user.setKitTimestamp(kitName, now.getTimeInMillis());
|
||||
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
|
||||
{
|
||||
final Calendar future = new GregorianCalendar();
|
||||
future.setTimeInMillis(lastTime);
|
||||
future.add(Calendar.SECOND, (int)delay);
|
||||
future.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
|
||||
user.sendMessage(_("kitTimed", Util.formatDateDiff(future.getTimeInMillis())));
|
||||
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> els) throws Exception
|
||||
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>)els.get("items");
|
||||
return (List<String>)kit.get("items");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
user.sendMessage(_("kitError2"));
|
||||
throw new Exception(_("kitErrorHelp"));
|
||||
throw new Exception(_("kitErrorHelp"), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,18 +97,55 @@ public class Kit
|
||||
boolean spew = false;
|
||||
for (String d : items)
|
||||
{
|
||||
final String[] parts = d.split("[^0-9]+", 3);
|
||||
final int id = Material.getMaterial(Integer.parseInt(parts[0])).getId();
|
||||
final int amount = parts.length > 1 ? Integer.parseInt(parts[parts.length > 2 ? 2 : 1]) : 1;
|
||||
final short data = parts.length > 2 ? Short.parseShort(parts[1]) : 0;
|
||||
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(), new ItemStack(id, amount, data));
|
||||
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
|
||||
}
|
||||
else
|
||||
{
|
||||
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, new ItemStack(id, amount, data));
|
||||
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, 0, stack);
|
||||
}
|
||||
for (ItemStack itemStack : overfilled.values())
|
||||
{
|
||||
@@ -107,7 +162,15 @@ public class Kit
|
||||
catch (Exception e)
|
||||
{
|
||||
user.updateInventory();
|
||||
throw new Exception(_("kitError2"));
|
||||
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,6 +1,7 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -9,40 +10,42 @@ 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 +53,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 +62,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 +74,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 +102,7 @@ public enum Mob
|
||||
final protected String type;
|
||||
}
|
||||
|
||||
public CreatureType getType()
|
||||
public EntityType getType()
|
||||
{
|
||||
return bukkitType;
|
||||
}
|
||||
|
@@ -1,25 +1,31 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.craftbukkit.OfflineBedLocation;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.*;
|
||||
import lombok.Delegate;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.conversations.ConversationAbandonedEvent;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.InventoryView.Property;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.map.MapView;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
|
||||
public class OfflinePlayer implements Player
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
@@ -170,11 +176,6 @@ public class OfflinePlayer implements Player
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isPlayer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRemainingAir()
|
||||
{
|
||||
@@ -664,18 +665,6 @@ public class OfflinePlayer implements Player
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getExperience()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExperience(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel()
|
||||
{
|
||||
@@ -857,4 +846,227 @@ public class OfflinePlayer implements Player
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hidePlayer(Player player)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showPlayer(Player player)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSee(Player player)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPotionEffect(PotionEffect pe)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPotionEffect(PotionEffect pe, boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPotionEffects(Collection<PotionEffect> clctn)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPotionEffect(PotionEffectType pet)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePotionEffect(PotionEffectType pet)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PotionEffect> getActivePotionEffects()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Projectile> T launchProjectile(Class<? extends T> arg0)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType()
|
||||
{
|
||||
return EntityType.PLAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void playEffect(Location lctn, Effect effect, T t)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setWindowProperty(Property prprt, int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryView getOpenInventory()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryView openInventory(Inventory invntr)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryView openWorkbench(Location lctn, boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryView openEnchanting(Location lctn, boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(InventoryView iv)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemOnCursor()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemOnCursor(ItemStack is)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetadata(String string, MetadataValue mv)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MetadataValue> getMetadata(String string)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMetadata(String string)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMetadata(String string, Plugin plugin)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isConversing()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptConversationInput(String string)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean beginConversation(Conversation c)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abandonConversation(Conversation c)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String[] strings)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlocking()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abandonConversation(Conversation arg0, ConversationAbandonedEvent arg1)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlying()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlying(boolean arg0)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getExpToLevel()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLineOfSight(Entity entity)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
||||
|
@@ -4,12 +4,16 @@ 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;
|
||||
|
||||
@@ -19,6 +23,7 @@ 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)
|
||||
{
|
||||
@@ -41,15 +46,15 @@ public class Settings implements ISettings
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMultipleHomes()
|
||||
public Set<String> getMultipleHomes()
|
||||
{
|
||||
return config.getKeys("sethome-multiple");
|
||||
return config.getConfigurationSection("sethome-multiple").getKeys(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHomeLimit(final User user)
|
||||
{
|
||||
final List<String> homeList = getMultipleHomes();
|
||||
final Set<String> homeList = getMultipleHomes();
|
||||
if (homeList == null)
|
||||
{
|
||||
//TODO: Replace this code to remove backwards compat, after settings are automatically updated
|
||||
@@ -72,11 +77,17 @@ public class Settings implements ISettings
|
||||
{
|
||||
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 config.getInt("chat.radius", config.getInt("chat-radius", 0));
|
||||
return chatRadius;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,19 +119,29 @@ public class Settings implements ISettings
|
||||
{
|
||||
return isCommandDisabled(cmd.getName());
|
||||
}
|
||||
private Set<String> disabledCommands = new HashSet<String>();
|
||||
|
||||
@Override
|
||||
public boolean isCommandDisabled(String label)
|
||||
{
|
||||
for (String c : config.getStringList("disabled-commands", new ArrayList<String>(0)))
|
||||
return disabledCommands.contains(label);
|
||||
}
|
||||
|
||||
private Set<String> getDisabledCommands()
|
||||
{
|
||||
Set<String> disCommands = new HashSet<String>();
|
||||
for (String c : config.getStringList("disabled-commands"))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(label))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
disCommands.add(c.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
return config.getBoolean("disable-" + label.toLowerCase(Locale.ENGLISH), false);
|
||||
for (String c : config.getKeys(false))
|
||||
{
|
||||
if (c.startsWith("disable-"))
|
||||
{
|
||||
disCommands.add(c.substring(8).toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
}
|
||||
return disCommands;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -132,7 +153,7 @@ public class Settings implements ISettings
|
||||
@Override
|
||||
public boolean isCommandRestricted(String label)
|
||||
{
|
||||
for (String c : config.getStringList("restricted-commands", new ArrayList<String>(0)))
|
||||
for (String c : config.getStringList("restricted-commands"))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(label))
|
||||
{
|
||||
@@ -146,7 +167,7 @@ public class Settings implements ISettings
|
||||
@Override
|
||||
public boolean isPlayerCommand(String label)
|
||||
{
|
||||
for (String c : config.getStringList("player-commands", new ArrayList<String>(0)))
|
||||
for (String c : config.getStringList("player-commands"))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(label))
|
||||
{
|
||||
@@ -160,9 +181,7 @@ public class Settings implements ISettings
|
||||
@Override
|
||||
public boolean isCommandOverridden(String name)
|
||||
{
|
||||
List<String> defaultList = new ArrayList<String>(1);
|
||||
defaultList.add("god");
|
||||
for (String c : config.getStringList("overridden-commands", defaultList))
|
||||
for (String c : config.getStringList("overridden-commands"))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(name))
|
||||
{
|
||||
@@ -189,11 +208,17 @@ public class Settings implements ISettings
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
private String nicknamePrefix = "~";
|
||||
|
||||
private String _getNicknamePrefix()
|
||||
{
|
||||
return config.getString("nickname-prefix", "~");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNicknamePrefix()
|
||||
{
|
||||
return config.getString("nickname-prefix", "~");
|
||||
return nicknamePrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -207,29 +232,55 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getDouble("heal-cooldown", 0);
|
||||
}
|
||||
private ConfigurationSection kits;
|
||||
|
||||
@Override
|
||||
public Object getKit(String name)
|
||||
public ConfigurationSection _getKits()
|
||||
{
|
||||
Map<String, Object> kits = (Map<String, Object>)config.getProperty("kits");
|
||||
for (Map.Entry<String, Object> entry : kits.entrySet())
|
||||
if (config.isConfigurationSection("kits"))
|
||||
{
|
||||
if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_')))
|
||||
final ConfigurationSection section = config.getConfigurationSection("kits");
|
||||
final ConfigurationSection newSection = new MemoryConfiguration();
|
||||
for (String kitItem : section.getKeys(false))
|
||||
{
|
||||
return entry.getValue();
|
||||
if (section.isConfigurationSection(kitItem))
|
||||
{
|
||||
newSection.set(kitItem.toLowerCase(Locale.ENGLISH), section.getConfigurationSection(kitItem));
|
||||
}
|
||||
}
|
||||
return newSection;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getKits()
|
||||
public ConfigurationSection getKits()
|
||||
{
|
||||
return (Map<String, Object>)config.getProperty("kits");
|
||||
return kits;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatColor getOperatorColor() throws Exception
|
||||
public Map<String, Object> getKit(String name)
|
||||
{
|
||||
name = name.replace('.', '_').replace('/', '_');
|
||||
if (config.isConfigurationSection("kits"))
|
||||
{
|
||||
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);
|
||||
|
||||
@@ -239,7 +290,7 @@ public class Settings implements ISettings
|
||||
}
|
||||
if ("none".equalsIgnoreCase(colorName) || colorName.isEmpty())
|
||||
{
|
||||
throw new Exception();
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
@@ -250,7 +301,7 @@ public class Settings implements ISettings
|
||||
{
|
||||
}
|
||||
|
||||
return ChatColor.getByCode(Integer.parseInt(colorName, 16));
|
||||
return ChatColor.getByChar(colorName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -280,7 +331,7 @@ public class Settings implements ISettings
|
||||
@Override
|
||||
public boolean areSignsDisabled()
|
||||
{
|
||||
return enabledSigns.isEmpty();
|
||||
return !signsEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -294,7 +345,7 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getString("backup.command", null);
|
||||
}
|
||||
private Map<String, MessageFormat> chatFormats = new HashMap<String, MessageFormat>();
|
||||
private Map<String, MessageFormat> chatFormats = Collections.synchronizedMap(new HashMap<String, MessageFormat>());
|
||||
|
||||
@Override
|
||||
public MessageFormat getChatFormat(String group)
|
||||
@@ -304,13 +355,13 @@ public class Settings implements ISettings
|
||||
{
|
||||
String format = config.getString("chat.group-formats." + (group == null ? "Default" : group),
|
||||
config.getString("chat.format", "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}"));
|
||||
format = Util.replaceColor(format);
|
||||
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 = format.replaceAll("\\{(\\D*?)\\}", "\\[$1\\]");
|
||||
mFormat = new MessageFormat(format);
|
||||
chatFormats.put(group, mFormat);
|
||||
}
|
||||
@@ -324,15 +375,15 @@ public class Settings implements ISettings
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAnnounceNewPlayerFormat(IUser user)
|
||||
public IText getAnnounceNewPlayerFormat()
|
||||
{
|
||||
return format(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!"), user);
|
||||
return new SimpleTextInput(Util.replaceFormat(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(String format, IUser user)
|
||||
public String getNewPlayerKit()
|
||||
{
|
||||
return format.replace('&', '§').replace("§§", "&").replace("{PLAYER}", user.getDisplayName()).replace("{DISPLAYNAME}", user.getDisplayName()).replace("{GROUP}", user.getGroup()).replace("{USERNAME}", user.getName()).replace("{ADDRESS}", user.getAddress().toString());
|
||||
return config.getString("newbies.kit", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -357,24 +408,43 @@ public class Settings implements ISettings
|
||||
public void reloadConfig()
|
||||
{
|
||||
config.load();
|
||||
noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds", Collections.<String>emptyList()));
|
||||
enabledSigns = getEnabledSigns();
|
||||
itemSpawnBl = getItemSpawnBlacklist();
|
||||
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();
|
||||
}
|
||||
|
||||
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
|
||||
|
||||
|
||||
@Override
|
||||
public List<Integer> itemSpawnBlacklist()
|
||||
{
|
||||
return itemSpawnBl;
|
||||
}
|
||||
|
||||
private List<Integer> getItemSpawnBlacklist()
|
||||
|
||||
private List<Integer> _getItemSpawnBlacklist()
|
||||
{
|
||||
final List<Integer> epItemSpwn = new ArrayList<Integer>();
|
||||
if (ess.getItemDb() == null) {
|
||||
if (ess.getItemDb() == null)
|
||||
{
|
||||
logger.log(Level.FINE, "Aborting ItemSpawnBL read, itemDB not yet loaded.");
|
||||
return epItemSpwn;
|
||||
}
|
||||
@@ -384,7 +454,7 @@ public class Settings implements ISettings
|
||||
if (itemName.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
final ItemStack iStack = ess.getItemDb().get(itemName);
|
||||
@@ -397,26 +467,31 @@ public class Settings implements ISettings
|
||||
}
|
||||
return epItemSpwn;
|
||||
}
|
||||
|
||||
private List<EssentialsSign> enabledSigns = new ArrayList<EssentialsSign>();
|
||||
|
||||
private boolean signsEnabled = false;
|
||||
|
||||
@Override
|
||||
public List<EssentialsSign> enabledSigns()
|
||||
{
|
||||
return enabledSigns;
|
||||
}
|
||||
|
||||
private List<EssentialsSign> getEnabledSigns()
|
||||
|
||||
private List<EssentialsSign> _getEnabledSigns()
|
||||
{
|
||||
List<EssentialsSign> newSigns = new ArrayList<EssentialsSign>();
|
||||
|
||||
for (String signName : config.getStringList("enabledSigns", null))
|
||||
|
||||
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());
|
||||
@@ -424,7 +499,9 @@ public class Settings implements ISettings
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, _("unknownItemInList", signName, "enabledSigns"));
|
||||
continue;
|
||||
}
|
||||
signsEnabled = true;
|
||||
}
|
||||
return newSigns;
|
||||
}
|
||||
@@ -441,11 +518,17 @@ public class Settings implements ISettings
|
||||
return config.getBoolean("protect.disable.warn-on-build-disallow", false);
|
||||
}
|
||||
private boolean debug = false;
|
||||
private boolean configDebug = false;
|
||||
|
||||
private boolean _isDebug()
|
||||
{
|
||||
return config.getBoolean("debug", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebug()
|
||||
{
|
||||
return debug || config.getBoolean("debug", false);
|
||||
return debug || configDebug;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -538,6 +621,22 @@ public class Settings implements ISettings
|
||||
}
|
||||
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()
|
||||
@@ -545,16 +644,40 @@ public class Settings implements ISettings
|
||||
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 config.getBoolean("change-displayname", true);
|
||||
return changeDisplayName;
|
||||
}
|
||||
private boolean changePlayerListName = false;
|
||||
|
||||
private boolean _changePlayerListName()
|
||||
{
|
||||
return config.getBoolean("change-playerlist", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean changePlayerListName()
|
||||
{
|
||||
return changePlayerListName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -562,25 +685,49 @@ public class Settings implements ISettings
|
||||
{
|
||||
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 config.getBoolean("add-prefix-suffix", ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat"));
|
||||
return prefixsuffixconfigured ? addprefixsuffix : ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat");
|
||||
}
|
||||
private boolean disablePrefix = false;
|
||||
|
||||
@Override
|
||||
public boolean disablePrefix()
|
||||
private boolean _disablePrefix()
|
||||
{
|
||||
return config.getBoolean("disablePrefix", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableSuffix()
|
||||
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()
|
||||
{
|
||||
@@ -592,19 +739,36 @@ public class Settings implements ISettings
|
||||
{
|
||||
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
|
||||
@@ -626,21 +790,39 @@ public class Settings implements ISettings
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsWorldTeleportPermissions()
|
||||
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 config.getBoolean("disable-item-pickup-while-afk", true);
|
||||
return disableItemPickupWhileAfk;
|
||||
}
|
||||
|
||||
private boolean _getDisableItemPickupWhileAfk()
|
||||
{
|
||||
return config.getBoolean("disable-item-pickup-while-afk", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -675,4 +857,59 @@ public class Settings implements ISettings
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.craftbukkit.FakeExplosion;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -46,8 +45,12 @@ 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
|
||||
|
@@ -2,7 +2,6 @@ package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.ITeleport;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.Logger;
|
||||
@@ -146,23 +145,39 @@ public class Teleport implements Runnable, ITeleport
|
||||
|
||||
public void cooldown(boolean check) throws Exception
|
||||
{
|
||||
Calendar now = new GregorianCalendar();
|
||||
final Calendar time = new GregorianCalendar();
|
||||
if (user.getLastTeleportTimestamp() > 0)
|
||||
{
|
||||
double cooldown = ess.getSettings().getTeleportCooldown();
|
||||
Calendar cooldownTime = new GregorianCalendar();
|
||||
cooldownTime.setTimeInMillis(user.getLastTeleportTimestamp());
|
||||
cooldownTime.add(Calendar.SECOND, (int)cooldown);
|
||||
cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
|
||||
if (cooldownTime.after(now) && !user.isAuthorized("essentials.teleport.cooldown.bypass"))
|
||||
// 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())
|
||||
{
|
||||
throw new Exception(_("timeBeforeTeleport", Util.formatDateDiff(cooldownTime.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(now.getTimeInMillis());
|
||||
user.setLastTeleportTimestamp(time.getTimeInMillis());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +205,7 @@ public class Teleport implements Runnable, ITeleport
|
||||
{
|
||||
cancel(false);
|
||||
}
|
||||
|
||||
|
||||
public void teleport(Location loc, Trade chargeFor) throws Exception
|
||||
{
|
||||
teleport(new Target(loc), chargeFor, TeleportCause.PLUGIN);
|
||||
@@ -278,13 +293,8 @@ public class Teleport implements Runnable, ITeleport
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -13,12 +13,14 @@ import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Trade
|
||||
{
|
||||
private final transient String command;
|
||||
private final transient String fallbackCommand;
|
||||
private final transient Double money;
|
||||
private final transient ItemStack itemStack;
|
||||
private final transient Integer exp;
|
||||
@@ -26,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 String 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);
|
||||
}
|
||||
|
||||
public Trade(final int exp, final IEssentials ess)
|
||||
{
|
||||
this(null, null, null, exp, ess);
|
||||
this(null, null, null, items, null, ess);
|
||||
}
|
||||
|
||||
private Trade(final String command, final Double money, final ItemStack item, final Integer exp, final IEssentials ess)
|
||||
public Trade(final int exp, final IEssentials ess)
|
||||
{
|
||||
this(null, null, null, null, exp, ess);
|
||||
}
|
||||
|
||||
private Trade(final String command, final String fallback, final Double money, final ItemStack item, final Integer exp, final IEssentials ess)
|
||||
{
|
||||
this.command = command;
|
||||
this.fallbackCommand = fallback;
|
||||
this.money = money;
|
||||
this.itemStack = item;
|
||||
this.exp = exp;
|
||||
@@ -55,11 +63,9 @@ public class Trade
|
||||
|
||||
public void isAffordableFor(final IUser user) throws ChargeException
|
||||
{
|
||||
final double mon = user.getMoney();
|
||||
if (getMoney() != null
|
||||
&& mon < getMoney()
|
||||
&& getMoney() > 0
|
||||
&& !user.isAuthorized("essentials.eco.loan"))
|
||||
&& !user.canAfford(getMoney()))
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
@@ -70,18 +76,17 @@ public class Trade
|
||||
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
|
||||
}
|
||||
|
||||
double money;
|
||||
if (command != null && !command.isEmpty()
|
||||
&& !user.isAuthorized("essentials.nocommandcost.all")
|
||||
&& !user.isAuthorized("essentials.nocommandcost." + command)
|
||||
&& mon < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
|
||||
&& 0 < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
|
||||
&& !user.isAuthorized("essentials.eco.loan"))
|
||||
&& 0 < (money = getCommandCost(user))
|
||||
&& !user.canAfford(money))
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
|
||||
if (exp != null && exp > 0
|
||||
&& SetExpFix.getTotalExperience(user) < exp) {
|
||||
|
||||
if (exp != null && exp > 0
|
||||
&& SetExpFix.getTotalExperience(user) < exp)
|
||||
{
|
||||
throw new ChargeException(_("notEnoughExperience"));
|
||||
}
|
||||
}
|
||||
@@ -103,9 +108,25 @@ public class Trade
|
||||
if (dropItems)
|
||||
{
|
||||
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItem(user.getInventory(), true, getItemStack());
|
||||
final Location loc = user.getLocation();
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
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 = itemStack.clone();
|
||||
stack.setAmount(maxStackSize);
|
||||
itemStacks[i] = loc.getWorld().dropItem(loc, stack);
|
||||
}
|
||||
if (leftover > 0)
|
||||
{
|
||||
final ItemStack stack = itemStack.clone();
|
||||
stack.setAmount(leftover);
|
||||
itemStacks[stacks] = loc.getWorld().dropItem(loc, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -125,8 +146,7 @@ public class Trade
|
||||
{
|
||||
if (getMoney() != null)
|
||||
{
|
||||
final double mon = user.getMoney();
|
||||
if (mon < getMoney() && getMoney() > 0 && !user.isAuthorized("essentials.eco.loan"))
|
||||
if (!user.canAfford(getMoney()) && getMoney() > 0)
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
@@ -141,13 +161,10 @@ public class Trade
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, true, getItemStack());
|
||||
user.updateInventory();
|
||||
}
|
||||
if (command != null && !command.isEmpty()
|
||||
&& !user.isAuthorized("essentials.nocommandcost.all")
|
||||
&& !user.isAuthorized("essentials.nocommandcost." + command))
|
||||
if (command != null)
|
||||
{
|
||||
final double mon = user.getMoney();
|
||||
final double cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
|
||||
if (mon < cost && cost > 0 && !user.isAuthorized("essentials.eco.loan"))
|
||||
final double cost = getCommandCost(user);
|
||||
if (!user.canAfford(cost) && cost > 0)
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
@@ -173,16 +190,33 @@ public class Trade
|
||||
{
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
|
||||
public Integer getExperience()
|
||||
{
|
||||
return exp;
|
||||
}
|
||||
|
||||
public Double getCommandCost(final IUser user)
|
||||
{
|
||||
double cost = 0d;
|
||||
if (command != null && !command.isEmpty()
|
||||
&& !user.isAuthorized("essentials.nocommandcost.all")
|
||||
&& !user.isAuthorized("essentials.nocommandcost." + command))
|
||||
{
|
||||
cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
|
||||
if (cost == 0.0 && fallbackCommand != null && !fallbackCommand.isEmpty())
|
||||
{
|
||||
cost = ess.getSettings().getCommandCost(fallbackCommand.charAt(0) == '/' ? fallbackCommand.substring(1) : fallbackCommand);
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
if (!ess.getSettings().isEcoLogEnabled())
|
||||
if ((loc == null && !ess.getSettings().isEcoLogUpdateEnabled())
|
||||
|| (loc != null && !ess.getSettings().isEcoLogEnabled()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@@ -18,12 +18,15 @@ 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 transient Location afkPosition = null;
|
||||
private boolean invSee = false;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
User(final Player base, final IEssentials ess)
|
||||
@@ -57,6 +60,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
@Override
|
||||
public boolean isAuthorized(final String node)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "checking if " + base.getName() + " has " + node);
|
||||
}
|
||||
if (base instanceof OfflinePlayer)
|
||||
{
|
||||
return false;
|
||||
@@ -72,7 +79,15 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return false;
|
||||
}
|
||||
|
||||
return ess.getPermissionsHandler().hasPermission(base, node);
|
||||
try
|
||||
{
|
||||
return ess.getPermissionsHandler().hasPermission(base, node);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ess.getLogger().log(Level.SEVERE, "Permission System Error: " + ess.getPermissionsHandler().getName() + " returned: " + ex.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void healCooldown() throws Exception
|
||||
@@ -106,10 +121,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return;
|
||||
}
|
||||
setMoney(getMoney() + value);
|
||||
sendMessage(_("addedToAccount", Util.formatCurrency(value, ess)));
|
||||
sendMessage(_("addedToAccount", Util.displayCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage(_("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
|
||||
initiator.sendMessage(_("addedToOthersAccount", Util.displayCurrency(value, ess), this.getDisplayName(), Util.displayCurrency(getMoney(), ess)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,8 +138,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
{
|
||||
setMoney(getMoney() - value);
|
||||
reciever.setMoney(reciever.getMoney() + value);
|
||||
sendMessage(_("moneySentTo", Util.formatCurrency(value, ess), reciever.getDisplayName()));
|
||||
reciever.sendMessage(_("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName()));
|
||||
sendMessage(_("moneySentTo", Util.displayCurrency(value, ess), reciever.getDisplayName()));
|
||||
reciever.sendMessage(_("moneyRecievedFrom", Util.displayCurrency(value, ess), getDisplayName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -145,17 +160,27 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return;
|
||||
}
|
||||
setMoney(getMoney() - value);
|
||||
sendMessage(_("takenFromAccount", Util.formatCurrency(value, ess)));
|
||||
sendMessage(_("takenFromAccount", Util.displayCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage(_("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
|
||||
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)
|
||||
{
|
||||
final double mon = getMoney();
|
||||
return mon >= cost || isAuthorized("essentials.eco.loan");
|
||||
if (!permcheck || isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
return (mon - cost) >= ess.getSettings().getMinMoney();
|
||||
}
|
||||
return cost <= mon;
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
@@ -178,7 +203,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
@Override
|
||||
public int compareTo(final User other)
|
||||
{
|
||||
return Util.stripColor(this.getDisplayName()).compareToIgnoreCase(Util.stripColor(other.getDisplayName()));
|
||||
return Util.stripFormat(this.getDisplayName()).compareToIgnoreCase(Util.stripFormat(other.getDisplayName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -236,92 +261,108 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return teleportRequester;
|
||||
}
|
||||
|
||||
public boolean isTeleportRequestHere()
|
||||
public boolean isTpRequestHere()
|
||||
{
|
||||
return teleportRequestHere;
|
||||
}
|
||||
|
||||
public String getNick(boolean addprefixsuffix)
|
||||
public String getNick(final boolean longnick)
|
||||
{
|
||||
final StringBuilder nickname = new StringBuilder();
|
||||
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.append(getName());
|
||||
nickname = getName();
|
||||
}
|
||||
else
|
||||
{
|
||||
nickname.append(ess.getSettings().getNicknamePrefix()).append(nick);
|
||||
nickname = ess.getSettings().getNicknamePrefix() + nick;
|
||||
}
|
||||
|
||||
if (isOp())
|
||||
{
|
||||
try
|
||||
{
|
||||
nickname.insert(0, ess.getSettings().getOperatorColor().toString());
|
||||
nickname.append("§f");
|
||||
final ChatColor opPrefix = ess.getSettings().getOperatorColor();
|
||||
if (opPrefix != null && opPrefix.toString().length() > 0)
|
||||
{
|
||||
prefix.insert(0, opPrefix.toString());
|
||||
suffix = "§f";
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (addprefixsuffix && ess.getSettings().addPrefixSuffix())
|
||||
if (ess.getSettings().addPrefixSuffix())
|
||||
{
|
||||
if (!ess.getSettings().disablePrefix())
|
||||
{
|
||||
final String prefix = ess.getPermissionsHandler().getPrefix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
||||
nickname.insert(0, prefix);
|
||||
final String ptext = ess.getPermissionsHandler().getPrefix(base).replace('&', '§');
|
||||
prefix.insert(0, ptext);
|
||||
suffix = "§f";
|
||||
}
|
||||
if (!ess.getSettings().disableSuffix())
|
||||
{
|
||||
final String suffix = ess.getPermissionsHandler().getSuffix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
||||
nickname.append(suffix);
|
||||
if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§"))
|
||||
{
|
||||
nickname.append("§f");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nickname.append("§f");
|
||||
final String stext = ess.getPermissionsHandler().getSuffix(base).replace('&', '§');
|
||||
suffix = stext + "§f";
|
||||
suffix = suffix.replace("§f§f", "§f");
|
||||
}
|
||||
}
|
||||
|
||||
return nickname.toString();
|
||||
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()
|
||||
{
|
||||
String name = getNick(true);
|
||||
setDisplayName(name);
|
||||
if (name.length() > 16)
|
||||
if (base.isOnline() && ess.getSettings().changeDisplayName())
|
||||
{
|
||||
name = getNick(false);
|
||||
}
|
||||
if (name.length() > 16)
|
||||
{
|
||||
name = name.substring(0, name.charAt(15) == '§' ? 15 : 16);
|
||||
}
|
||||
try
|
||||
{
|
||||
setPlayerListName(name);
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
logger.log(Level.INFO, "Playerlist for " + name + " was not updated. Use a shorter displayname prefix.");
|
||||
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()
|
||||
{
|
||||
if (!(base instanceof OfflinePlayer) && ess.getSettings().changeDisplayName())
|
||||
{
|
||||
setDisplayNick();
|
||||
}
|
||||
return super.getDisplayName() == null ? super.getName() : super.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Teleport getTeleport()
|
||||
{
|
||||
return teleport;
|
||||
@@ -379,6 +420,15 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
}
|
||||
}
|
||||
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
|
||||
@@ -413,6 +463,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
public void setHidden(final boolean hidden)
|
||||
{
|
||||
this.hidden = hidden;
|
||||
if (hidden == true)
|
||||
{
|
||||
setLastLogout(getLastOnlineActivity());
|
||||
}
|
||||
}
|
||||
|
||||
//Returns true if status expired during this check
|
||||
@@ -468,6 +522,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
setAfk(false);
|
||||
if (broadcast && !isHidden())
|
||||
{
|
||||
setDisplayNick();
|
||||
ess.broadcastMessage(this, _("userIsNotAway", getDisplayName()));
|
||||
}
|
||||
}
|
||||
@@ -500,6 +555,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
setAfk(true);
|
||||
if (!isHidden())
|
||||
{
|
||||
setDisplayNick();
|
||||
ess.broadcastMessage(this, _("userIsAway", getDisplayName()));
|
||||
}
|
||||
}
|
||||
@@ -510,16 +566,6 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return afkPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggleGodModeEnabled()
|
||||
{
|
||||
if (!isGodModeEnabled())
|
||||
{
|
||||
setFoodLevel(20);
|
||||
}
|
||||
return super.toggleGodModeEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGodModeEnabled()
|
||||
{
|
||||
@@ -532,6 +578,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return super.isGodModeEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup()
|
||||
{
|
||||
return ess.getPermissionsHandler().getGroup(base);
|
||||
@@ -555,4 +602,96 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
{
|
||||
return teleportRequestTime;
|
||||
}
|
||||
|
||||
public boolean isInvSee()
|
||||
{
|
||||
return invSee;
|
||||
}
|
||||
|
||||
public void setInvSee(final boolean set)
|
||||
{
|
||||
invSee = 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();;
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,9 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -13,7 +12,6 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
{
|
||||
protected final transient IEssentials ess;
|
||||
private final EssentialsConf config;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
protected UserData(Player base, IEssentials ess)
|
||||
{
|
||||
@@ -41,10 +39,9 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
lastHealTimestamp = _getLastHealTimestamp();
|
||||
jail = _getJail();
|
||||
mails = _getMails();
|
||||
savedInventory = _getSavedInventory();
|
||||
teleportEnabled = getTeleportEnabled();
|
||||
ignoredPlayers = getIgnoredPlayers();
|
||||
godmode = getGodModeEnabled();
|
||||
godmode = _getGodModeEnabled();
|
||||
muted = getMuted();
|
||||
muteTimeout = _getMuteTimeout();
|
||||
jailed = getJailed();
|
||||
@@ -58,6 +55,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
isNPC = _isNPC();
|
||||
arePowerToolsEnabled = _arePowerToolsEnabled();
|
||||
kitTimestamps = _getKitTimestamps();
|
||||
nickname = _getNickname();
|
||||
}
|
||||
private double money;
|
||||
|
||||
@@ -94,17 +92,11 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
private Map<String, Object> _getHomes()
|
||||
{
|
||||
Object o = config.getProperty("homes");
|
||||
|
||||
if (o instanceof Map)
|
||||
if (config.isConfigurationSection("homes"))
|
||||
{
|
||||
return (Map<String, Object>)o;
|
||||
return config.getConfigurationSection("homes").getValues(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
public Location getHome(String name) throws Exception
|
||||
@@ -154,7 +146,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
public List<String> getHomes()
|
||||
{
|
||||
return new ArrayList(homes.keySet());
|
||||
return new ArrayList<String>(homes.keySet());
|
||||
}
|
||||
|
||||
public void setHome(String name, Location loc)
|
||||
@@ -181,8 +173,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO: move this message to messages file
|
||||
throw new Exception("Home " + name + " doesn't exist");
|
||||
throw new Exception(_("invalidHome", name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,14 +185,21 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private String nickname;
|
||||
|
||||
public String getNickname()
|
||||
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();
|
||||
}
|
||||
@@ -209,7 +207,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
private List<Integer> _getUnlimited()
|
||||
{
|
||||
return config.getIntList("unlimited", new ArrayList<Integer>());
|
||||
return config.getIntegerList("unlimited");
|
||||
}
|
||||
|
||||
public List<Integer> getUnlimited()
|
||||
@@ -235,22 +233,15 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("unlimited", unlimited);
|
||||
config.save();
|
||||
}
|
||||
private Map<Integer, Object> powertools;
|
||||
private Map<String, Object> powertools;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<Integer, Object> _getPowertools()
|
||||
private Map<String, Object> _getPowertools()
|
||||
{
|
||||
Object o = config.getProperty("powertools");
|
||||
|
||||
if (o instanceof Map)
|
||||
if (config.isConfigurationSection("powertools"))
|
||||
{
|
||||
return (Map<Integer, Object>)o;
|
||||
return config.getConfigurationSection("powertools").getValues(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new HashMap<Integer, Object>();
|
||||
}
|
||||
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
public void clearAllPowertools()
|
||||
@@ -260,25 +251,27 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.save();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getPowertool(ItemStack stack)
|
||||
{
|
||||
return (List<String>)powertools.get(stack.getTypeId());
|
||||
return (List<String>)powertools.get("" + stack.getTypeId());
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getPowertool(int id)
|
||||
{
|
||||
return (List<String>)powertools.get(id);
|
||||
return (List<String>)powertools.get("" + id);
|
||||
}
|
||||
|
||||
public void setPowertool(ItemStack stack, List<String> commandList)
|
||||
{
|
||||
if (commandList == null || commandList.isEmpty())
|
||||
{
|
||||
powertools.remove(stack.getTypeId());
|
||||
powertools.remove("" + stack.getTypeId());
|
||||
}
|
||||
else
|
||||
{
|
||||
powertools.put(stack.getTypeId(), commandList);
|
||||
powertools.put("" + stack.getTypeId(), commandList);
|
||||
}
|
||||
config.setProperty("powertools", powertools);
|
||||
config.save();
|
||||
@@ -383,7 +376,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
private List<String> _getMails()
|
||||
{
|
||||
return config.getStringList("mail", new ArrayList<String>());
|
||||
return config.getStringList("mail");
|
||||
}
|
||||
|
||||
public List<String> getMails()
|
||||
@@ -411,50 +404,6 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
mails.add(mail);
|
||||
setMails(mails);
|
||||
}
|
||||
private ItemStack[] savedInventory;
|
||||
|
||||
public ItemStack[] getSavedInventory()
|
||||
{
|
||||
return savedInventory;
|
||||
}
|
||||
|
||||
private ItemStack[] _getSavedInventory()
|
||||
{
|
||||
int size = config.getInt("inventory.size", 0);
|
||||
if (size < 1 || (getInventory() != null && size > getInventory().getSize()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ItemStack[] is = new ItemStack[size];
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
is[i] = config.getItemStack("inventory." + i);
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
public void setSavedInventory(ItemStack[] is)
|
||||
{
|
||||
if (is == null || is.length == 0)
|
||||
{
|
||||
savedInventory = null;
|
||||
config.removeProperty("inventory");
|
||||
}
|
||||
else
|
||||
{
|
||||
savedInventory = is;
|
||||
config.setProperty("inventory.size", is.length);
|
||||
for (int i = 0; i < is.length; i++)
|
||||
{
|
||||
if (is[i] == null || is[i].getType() == Material.AIR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
config.setProperty("inventory." + i, is[i]);
|
||||
}
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
private boolean teleportEnabled;
|
||||
|
||||
private boolean getTeleportEnabled()
|
||||
@@ -491,14 +440,14 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
public List<String> getIgnoredPlayers()
|
||||
{
|
||||
return config.getStringList("ignore", new ArrayList<String>());
|
||||
return Collections.synchronizedList(config.getStringList("ignore"));
|
||||
}
|
||||
|
||||
public void setIgnoredPlayers(List<String> players)
|
||||
{
|
||||
if (players == null || players.isEmpty())
|
||||
{
|
||||
ignoredPlayers = new ArrayList<String>();
|
||||
ignoredPlayers = Collections.synchronizedList(new ArrayList<String>());
|
||||
config.removeProperty("ignore");
|
||||
}
|
||||
else
|
||||
@@ -509,26 +458,37 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean isIgnoredPlayer(String name)
|
||||
@Deprecated
|
||||
public boolean isIgnoredPlayer(final String userName)
|
||||
{
|
||||
return ignoredPlayers.contains(name.toLowerCase(Locale.ENGLISH));
|
||||
final IUser user = ess.getUser(userName);
|
||||
if (user == null || !user.isOnline())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return isIgnoredPlayer(user);
|
||||
}
|
||||
|
||||
public void setIgnoredPlayer(String name, boolean set)
|
||||
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(name.toLowerCase(Locale.ENGLISH));
|
||||
ignoredPlayers.add(user.getName().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
else
|
||||
{
|
||||
ignoredPlayers.remove(name.toLowerCase(Locale.ENGLISH));
|
||||
ignoredPlayers.remove(user.getName().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
setIgnoredPlayers(ignoredPlayers);
|
||||
}
|
||||
private boolean godmode;
|
||||
|
||||
private boolean getGodModeEnabled()
|
||||
private boolean _getGodModeEnabled()
|
||||
{
|
||||
return config.getBoolean("godmode", false);
|
||||
}
|
||||
@@ -544,16 +504,9 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("godmode", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean toggleGodModeEnabled()
|
||||
{
|
||||
boolean ret = !isGodModeEnabled();
|
||||
setGodModeEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
private boolean muted;
|
||||
|
||||
private boolean getMuted()
|
||||
public boolean getMuted()
|
||||
{
|
||||
return config.getBoolean("muted", false);
|
||||
}
|
||||
@@ -569,13 +522,6 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("muted", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean toggleMuted()
|
||||
{
|
||||
boolean ret = !isMuted();
|
||||
setMuted(ret);
|
||||
return ret;
|
||||
}
|
||||
private long muteTimeout;
|
||||
|
||||
private long _getMuteTimeout()
|
||||
@@ -645,7 +591,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
public void setBanReason(String reason)
|
||||
{
|
||||
config.setProperty("ban.reason", reason);
|
||||
config.setProperty("ban.reason", Util.sanitizeString(reason));
|
||||
config.save();
|
||||
}
|
||||
|
||||
@@ -671,10 +617,16 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
return lastLogin;
|
||||
}
|
||||
|
||||
public void setLastLogin(long time)
|
||||
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;
|
||||
@@ -707,11 +659,10 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
return lastLoginAddress;
|
||||
}
|
||||
|
||||
public void setLastLoginAddress(String address)
|
||||
private void _setLastLoginAddress(String address)
|
||||
{
|
||||
lastLoginAddress = address;
|
||||
config.setProperty("ipAddress", address);
|
||||
config.save();
|
||||
}
|
||||
private boolean afk;
|
||||
|
||||
@@ -739,7 +690,6 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
return ret;
|
||||
}
|
||||
private boolean newplayer;
|
||||
|
||||
private String geolocation;
|
||||
|
||||
private String _getGeoLocation()
|
||||
@@ -831,16 +781,12 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
private Map<String, Object> _getKitTimestamps()
|
||||
{
|
||||
final Object map = config.getProperty("timestamps.kits");
|
||||
|
||||
if (map instanceof Map)
|
||||
if (config.isConfigurationSection("timestamps.kits"))
|
||||
{
|
||||
return (Map<String, Object>)map;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new HashMap<String, Object>();
|
||||
return config.getConfigurationSection("timestamps.kits").getValues(false);
|
||||
}
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
public Long getKitTimestamp(final String name)
|
||||
|
@@ -61,7 +61,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
|
||||
{
|
||||
try
|
||||
{
|
||||
return users.get(Util.sanitizeFileName(name));
|
||||
return users.get(name);
|
||||
}
|
||||
catch (ExecutionException ex)
|
||||
{
|
||||
@@ -76,18 +76,31 @@ public class UserMap extends CacheLoader<String, User> implements IConf
|
||||
@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(Util.sanitizeFileName(name));
|
||||
keys.add(sanitizedName);
|
||||
return new User(player, ess);
|
||||
}
|
||||
}
|
||||
final File userFile = getUserFile(name);
|
||||
final File userFile = getUserFile2(sanitizedName);
|
||||
if (userFile.exists())
|
||||
{
|
||||
keys.add(Util.sanitizeFileName(name));
|
||||
keys.add(sanitizedName);
|
||||
return new User(new OfflinePlayer(name, ess), ess);
|
||||
}
|
||||
throw new Exception("User not found!");
|
||||
@@ -103,6 +116,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
|
||||
{
|
||||
keys.remove(Util.sanitizeFileName(name));
|
||||
users.invalidate(Util.sanitizeFileName(name));
|
||||
users.invalidate(name);
|
||||
}
|
||||
|
||||
public Set<String> getAllUniqueUsers()
|
||||
@@ -114,10 +128,15 @@ public class UserMap extends CacheLoader<String, User> implements IConf
|
||||
{
|
||||
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, Util.sanitizeFileName(name) + ".yml");
|
||||
return new File(userFolder, name + ".yml");
|
||||
}
|
||||
}
|
||||
|
@@ -22,11 +22,12 @@ public class Util
|
||||
}
|
||||
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]");;
|
||||
private final static Pattern INVALIDCHARS = Pattern.compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");
|
||||
|
||||
public static String sanitizeFileName(final String name)
|
||||
{
|
||||
return INVALIDFILECHARS.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)
|
||||
@@ -79,11 +80,17 @@ public 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)]);
|
||||
}
|
||||
}
|
||||
@@ -91,7 +98,7 @@ public class Util
|
||||
{
|
||||
return "now";
|
||||
}
|
||||
return sb.toString();
|
||||
return sb.toString().trim();
|
||||
}
|
||||
|
||||
private static int dateDiff(int type, Calendar fromDate, Calendar toDate, boolean future)
|
||||
@@ -208,6 +215,13 @@ public 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
|
||||
@@ -241,6 +255,7 @@ public 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());
|
||||
@@ -248,8 +263,10 @@ public 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)
|
||||
{
|
||||
@@ -268,6 +285,45 @@ public 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
|
||||
{
|
||||
@@ -279,33 +335,54 @@ public 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"));
|
||||
}
|
||||
@@ -332,6 +409,11 @@ public 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())))
|
||||
{
|
||||
@@ -421,11 +503,11 @@ public 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)
|
||||
{
|
||||
String str = ess.getSettings().getCurrencySymbol() + df.format(value);
|
||||
String str = dFormat.format(value);
|
||||
if (str.endsWith(".00"))
|
||||
{
|
||||
str = str.substring(0, str.length() - 3);
|
||||
@@ -433,6 +515,16 @@ public 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;
|
||||
@@ -484,26 +576,113 @@ public class Util
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
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 lastCode(final String input)
|
||||
{
|
||||
int pos = input.lastIndexOf("§");
|
||||
if (pos == -1 || (pos + 1) == input.length())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return input.substring(pos, pos + 2);
|
||||
}
|
||||
private static transient final Pattern URL_PATTERN = Pattern.compile("((?:(?:https?)://)?[\\w-_\\.]{2,})\\.([a-z]{2,3}(?:/\\S+)?)");
|
||||
private static transient final Pattern VANILLA_PATTERN = Pattern.compile("\u00A7+[0-9A-FK-ORa-fk-or]");
|
||||
private static transient final Pattern 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 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,6 +1,7 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.commands.WarpNotFoundException;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
@@ -48,7 +49,7 @@ public class Warps implements IConf
|
||||
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(warp));
|
||||
if (conf == null)
|
||||
{
|
||||
throw new Exception(_("warpNotExist"));
|
||||
throw new WarpNotFoundException();
|
||||
}
|
||||
return conf.getLocation(null, server);
|
||||
}
|
||||
|
@@ -115,6 +115,10 @@ public final class Economy
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
if (balance < ess.getSettings().getMinMoney())
|
||||
{
|
||||
throw new NoLoanPermittedException();
|
||||
}
|
||||
if (balance < 0.0 && !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new NoLoanPermittedException();
|
||||
@@ -245,7 +249,7 @@ public final class Economy
|
||||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
}
|
||||
return Util.formatCurrency(amount, ess);
|
||||
return Util.displayCurrency(amount, ess);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -10,6 +10,8 @@ public interface IJails extends IReload
|
||||
|
||||
Collection<String> getList() throws Exception;
|
||||
|
||||
int getCount();
|
||||
|
||||
void removeJail(String jail) throws Exception;
|
||||
|
||||
void sendToJail(com.earth2me.essentials.IUser user, String jail) throws Exception;
|
||||
|
@@ -31,6 +31,7 @@ public class Commandafk extends EssentialsCommand
|
||||
|
||||
private void toggleAfk(User user)
|
||||
{
|
||||
user.setDisplayNick();
|
||||
if (!user.toggleAfk())
|
||||
{
|
||||
//user.sendMessage(_("markedAsNotAway"));
|
||||
|
@@ -17,8 +17,11 @@ public class Commandantioch extends EssentialsCommand
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
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.");
|
||||
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);
|
||||
|
@@ -16,9 +16,15 @@ public class Commandback extends EssentialsCommand
|
||||
@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.world." + user.getLastLocation().getWorld().getName()))
|
||||
{
|
||||
throw new Exception(_("noPerm", "essentials.world." + user.getLastLocation().getWorld().getName()));
|
||||
}
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.sendMessage(_("backUsageMsg"));
|
||||
user.getTeleport().back(charge);
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
@@ -19,7 +19,12 @@ public class Commandbackup extends EssentialsCommand
|
||||
final Backup backup = ess.getBackup();
|
||||
if (backup == null)
|
||||
{
|
||||
throw new Exception();
|
||||
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"));
|
||||
|
@@ -21,7 +21,7 @@ public class Commandbalance extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
sender.sendMessage(_("balance", Util.formatCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
|
||||
sender.sendMessage(_("balance", Util.displayCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,6 +32,6 @@ public class Commandbalance extends EssentialsCommand
|
||||
|| user.isAuthorized("essentials.balance.other"))
|
||||
? user
|
||||
: getPlayer(server, args, 0, true)).getMoney();
|
||||
user.sendMessage(_("balance", Util.formatCurrency(bal, ess)));
|
||||
user.sendMessage(_("balance", Util.displayCurrency(bal, ess)));
|
||||
}
|
||||
}
|
||||
|
@@ -105,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 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,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,7 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Console;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.OfflinePlayer;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -24,7 +23,7 @@ public class Commandban extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
final User user = getPlayer(server, args, 0, true);
|
||||
if (user.getBase() instanceof OfflinePlayer)
|
||||
if (!user.isOnline())
|
||||
{
|
||||
if (sender instanceof Player
|
||||
&& !ess.getUser(sender).isAuthorized("essentials.ban.offline"))
|
||||
@@ -41,20 +40,21 @@ public class Commandban extends EssentialsCommand
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
String banReason;
|
||||
if (args.length > 1)
|
||||
{
|
||||
banReason = getFinalArg(args, 1);
|
||||
user.setBanReason(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;
|
||||
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
|
@@ -27,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,10 +1,14 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Commandbreak extends EssentialsCommand
|
||||
@@ -29,8 +33,10 @@ public class Commandbreak extends EssentialsCommand
|
||||
}
|
||||
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,6 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -20,6 +21,6 @@ public class Commandbroadcast extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
ess.broadcastMessage(null, _("broadcast", getFinalArg(args, 0)));
|
||||
ess.broadcastMessage(null, _("broadcast", Util.replaceFormat(getFinalArg(args, 0))));
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Server;
|
||||
@@ -33,7 +34,31 @@ public class Commandeco extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException(ex);
|
||||
}
|
||||
|
||||
if (args[1].contentEquals("*"))
|
||||
if (args[1].contentEquals("**"))
|
||||
{
|
||||
for (String sUser : ess.getUserMap().getAllUniqueUsers())
|
||||
{
|
||||
final User player = ess.getUser(sUser);
|
||||
switch (cmd)
|
||||
{
|
||||
case GIVE:
|
||||
player.giveMoney(amount);
|
||||
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())
|
||||
{
|
||||
@@ -45,6 +70,10 @@ public class Commandeco extends EssentialsCommand
|
||||
break;
|
||||
|
||||
case TAKE:
|
||||
if (!player.canAfford(amount, false))
|
||||
{
|
||||
throw new Exception(_("notEnoughMoney"));
|
||||
}
|
||||
player.takeMoney(amount);
|
||||
break;
|
||||
|
||||
@@ -64,6 +93,10 @@ public class Commandeco extends EssentialsCommand
|
||||
break;
|
||||
|
||||
case TAKE:
|
||||
if (!player.canAfford(amount, false))
|
||||
{
|
||||
throw new Exception(_("notEnoughMoney"));
|
||||
}
|
||||
player.takeMoney(amount, sender);
|
||||
break;
|
||||
|
||||
|
@@ -2,13 +2,18 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.metrics.Metrics;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@@ -35,6 +40,14 @@ public class Commandessentials extends EssentialsCommand
|
||||
{
|
||||
run_nya(server, sender, commandLabel, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("moo"))
|
||||
{
|
||||
run_moo(server, sender, commandLabel, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("opt-out"))
|
||||
{
|
||||
run_optout(server, sender, commandLabel, args);
|
||||
}
|
||||
else {
|
||||
run_reload(server, sender, commandLabel, args);
|
||||
}
|
||||
@@ -44,7 +57,7 @@ public class Commandessentials extends EssentialsCommand
|
||||
{
|
||||
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.getAlternativeCommandsHandler().disabledCommands().entrySet())
|
||||
{
|
||||
@@ -53,7 +66,10 @@ public class Commandessentials extends EssentialsCommand
|
||||
}
|
||||
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 Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
@@ -144,7 +160,6 @@ public class Commandessentials extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
}, 20, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
private void stopTune()
|
||||
@@ -159,4 +174,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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
158
Essentials/src/com/earth2me/essentials/commands/Commandexp.java
Normal file
158
Essentials/src/com/earth2me/essentials/commands/Commandexp.java
Normal file
@@ -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));
|
||||
}
|
||||
}
|
@@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
@@ -19,39 +19,57 @@ public class Commandgamemode extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
if (args.length < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
gamemodeOtherPlayers(server, sender, args[0]);
|
||||
gamemodeOtherPlayers(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().isEmpty() && user.isAuthorized("essentials.gamemode.others"))
|
||||
if (args.length < 1)
|
||||
{
|
||||
gamemodeOtherPlayers(server, user, args[0]);
|
||||
return;
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
user.setGameMode(user.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
|
||||
if (args.length > 1 && args[1].trim().length() > 2 && user.isAuthorized("essentials.gamemode.others"))
|
||||
{
|
||||
gamemodeOtherPlayers(server, user, args);
|
||||
return;
|
||||
}
|
||||
performSetMode(args[0].toLowerCase(Locale.ENGLISH), user);
|
||||
user.sendMessage(_("gameMode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName()));
|
||||
}
|
||||
|
||||
private void gamemodeOtherPlayers(final Server server, final CommandSender sender, final String name)
|
||||
private void gamemodeOtherPlayers(final Server server, final CommandSender sender, final String[] args)
|
||||
{
|
||||
for (Player matchPlayer : server.matchPlayer(name))
|
||||
for (Player matchPlayer : server.matchPlayer(args[1]))
|
||||
{
|
||||
final User player = ess.getUser(matchPlayer);
|
||||
if (player.isHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
|
||||
performSetMode(args[0].toLowerCase(Locale.ENGLISH), player);
|
||||
sender.sendMessage(_("gameMode", _(player.getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void performSetMode(String mode, Player player)
|
||||
{
|
||||
if (mode.contains("survi") || mode.equalsIgnoreCase("0") || mode.equalsIgnoreCase("s"))
|
||||
{
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
else if (mode.contains("creat") || mode.equalsIgnoreCase("1") || mode.equalsIgnoreCase("c"))
|
||||
{
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
}
|
||||
else if (mode.contains("advent") || mode.equalsIgnoreCase("2") || mode.equalsIgnoreCase("a"))
|
||||
{
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -16,14 +17,40 @@ public class Commandgc extends EssentialsCommand
|
||||
@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(_("tps", "" + color + tps));
|
||||
sender.sendMessage(_("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(_("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(_("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
|
||||
|
||||
for (World w : server.getWorlds())
|
||||
{
|
||||
String worldType = "World";
|
||||
switch (w.getEnvironment())
|
||||
{
|
||||
case NETHER:
|
||||
worldType = "Nether";
|
||||
break;
|
||||
case THE_END:
|
||||
worldType = "The End";
|
||||
break;
|
||||
}
|
||||
|
||||
sender.sendMessage(
|
||||
(w.getEnvironment() == World.Environment.NETHER ? "Nether" : "World") + " \"" + w.getName() + "\": "
|
||||
worldType + " \"" + w.getName() + "\": "
|
||||
+ w.getLoadedChunks().length + _("gcchunks")
|
||||
+ w.getEntities().size() + _("gcentities"));
|
||||
}
|
||||
|
@@ -12,21 +12,23 @@ public class Commandgetpos extends EssentialsCommand
|
||||
{
|
||||
super("getpos");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && user.isAuthorized("essentials.getpos.others"))
|
||||
{
|
||||
final User otherUser = getPlayer(server, args, 0);
|
||||
outputPosition(user, otherUser.getLocation(), user.getLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
outputPosition(user, user.getLocation(), null);
|
||||
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
|
||||
{
|
||||
@@ -37,7 +39,7 @@ public class Commandgetpos extends EssentialsCommand
|
||||
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)
|
||||
{
|
||||
|
@@ -1,7 +1,9 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@@ -19,7 +21,6 @@ public class Commandgive extends EssentialsCommand
|
||||
super("give");
|
||||
}
|
||||
|
||||
//TODO: move these messages to message file
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
@@ -39,12 +40,17 @@ public class Commandgive extends EssentialsCommand
|
||||
: (!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));
|
||||
}
|
||||
|
||||
final User giveTo = getPlayer(server, args, 0);
|
||||
|
||||
if (args.length > 2 && Integer.parseInt(args[2]) > 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]));
|
||||
}
|
||||
@@ -59,7 +65,7 @@ public class Commandgive extends EssentialsCommand
|
||||
|
||||
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)
|
||||
@@ -82,9 +88,10 @@ 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"));
|
||||
}
|
||||
|
||||
//TODO: TL this.
|
||||
final String itemName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
|
||||
sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + ".");
|
||||
if (giveTo.isAuthorized("essentials.oversizedstacks"))
|
||||
|
@@ -22,31 +22,53 @@ public class Commandgod extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
godOtherPlayers(server, sender, args[0]);
|
||||
godOtherPlayers(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().isEmpty() && user.isAuthorized("essentials.god.others"))
|
||||
if (args.length > 0 && args[0].trim().length() > 2 && user.isAuthorized("essentials.god.others"))
|
||||
{
|
||||
godOtherPlayers(server, user, args[0]);
|
||||
godOtherPlayers(server, user, args);
|
||||
return;
|
||||
}
|
||||
|
||||
user.sendMessage(_("godMode", (user.toggleGodModeEnabled() ? _("enabled") : _("disabled"))));
|
||||
user.setGodModeEnabled(!user.isGodModeEnabled());
|
||||
user.sendMessage(_("godMode", (user.isGodModeEnabled() ? _("enabled") : _("disabled"))));
|
||||
}
|
||||
|
||||
private void godOtherPlayers(final Server server, final CommandSender sender, final String name)
|
||||
private void godOtherPlayers(final Server server, final CommandSender sender, final String[] args)
|
||||
{
|
||||
for (Player matchPlayer : server.matchPlayer(name))
|
||||
for (Player matchPlayer : server.matchPlayer(args[0]))
|
||||
{
|
||||
final User player = ess.getUser(matchPlayer);
|
||||
if (player.isHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final boolean enabled = player.toggleGodModeEnabled();
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
if (args[1].contains("on") || args[1].contains("ena") || args[1].equalsIgnoreCase("1"))
|
||||
{
|
||||
player.setGodModeEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setGodModeEnabled(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setGodModeEnabled(!player.isGodModeEnabled());
|
||||
}
|
||||
|
||||
final boolean enabled = player.isGodModeEnabled();
|
||||
if (enabled)
|
||||
{
|
||||
player.setFoodLevel(20);
|
||||
}
|
||||
|
||||
player.sendMessage(_("godMode", (enabled ? _("enabled") : _("disabled"))));
|
||||
sender.sendMessage(_("godMode", _(enabled ? "godEnabledFor" : "godDisabledFor", matchPlayer.getDisplayName())));
|
||||
}
|
||||
|
@@ -0,0 +1,63 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
|
||||
public class Commandhat extends EssentialsCommand
|
||||
{
|
||||
public Commandhat()
|
||||
{
|
||||
super("hat");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && (args[0].contains("rem") || args[0].contains("off") || args[0].equalsIgnoreCase("0")))
|
||||
{
|
||||
final PlayerInventory inv = user.getInventory();
|
||||
final ItemStack head = inv.getHelmet();
|
||||
if (head == null || head.getType() == Material.AIR)
|
||||
{
|
||||
user.sendMessage(_("hatEmpty"));
|
||||
}
|
||||
else
|
||||
{
|
||||
final ItemStack air = new ItemStack(Material.AIR);
|
||||
inv.setHelmet(air);
|
||||
InventoryWorkaround.addItem(user.getInventory(), true, head);
|
||||
user.sendMessage(_("hatRemoved"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user.getItemInHand().getType() != Material.AIR)
|
||||
{
|
||||
final ItemStack hand = user.getItemInHand();
|
||||
if (hand.getType().getMaxDurability() == 0)
|
||||
{
|
||||
final PlayerInventory inv = user.getInventory();
|
||||
final ItemStack head = inv.getHelmet();
|
||||
inv.removeItem(hand);
|
||||
inv.setHelmet(hand);
|
||||
inv.setItemInHand(head);
|
||||
user.sendMessage(_("hatPlaced"));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(_("hatArmor"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(_("hatFail"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -4,6 +4,7 @@ import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.textreader.*;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -21,6 +22,7 @@ public class Commandhelp extends EssentialsCommand
|
||||
IText output;
|
||||
String pageStr = args.length > 0 ? args[0] : null;
|
||||
String chapterPageStr = args.length > 1 ? args[1] : null;
|
||||
String command = commandLabel;
|
||||
final IText input = new TextInput(user, "help", false, ess);
|
||||
|
||||
if (input.getLines().isEmpty())
|
||||
@@ -31,7 +33,12 @@ public class Commandhelp extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
output = new HelpInput(user, pageStr, ess);
|
||||
if (pageStr.length() > 26)
|
||||
{
|
||||
pageStr = pageStr.substring(0, 25);
|
||||
}
|
||||
output = new HelpInput(user, pageStr.toLowerCase(Locale.ENGLISH), ess);
|
||||
command = command.concat(" ").concat(pageStr);
|
||||
pageStr = chapterPageStr;
|
||||
}
|
||||
chapterPageStr = null;
|
||||
@@ -41,7 +48,7 @@ public class Commandhelp extends EssentialsCommand
|
||||
output = new KeywordReplacer(input, user, ess);
|
||||
}
|
||||
final TextPager pager = new TextPager(output);
|
||||
pager.showPage(pageStr, chapterPageStr, commandLabel, user);
|
||||
pager.showPage(pageStr, chapterPageStr, command, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -22,8 +22,8 @@ public class Commandhelpop extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
final String message = _("helpOp", user.getDisplayName(), Util.stripColor(getFinalArg(args, 0)));
|
||||
user.setDisplayNick();
|
||||
final String message = _("helpOp", user.getDisplayName(), Util.stripFormat(getFinalArg(args, 0)));
|
||||
logger.log(Level.INFO, message);
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
|
@@ -54,7 +54,7 @@ public class Commandhome extends EssentialsCommand
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
user.getTeleport().home(player, homeName.toLowerCase(Locale.ENGLISH), charge);
|
||||
goHome(user, player, homeName.toLowerCase(Locale.ENGLISH), charge);
|
||||
}
|
||||
catch (NotEnoughArgumentsException e)
|
||||
{
|
||||
@@ -80,7 +80,7 @@ public class Commandhome extends EssentialsCommand
|
||||
}
|
||||
else if (homes.size() == 1 && player.equals(user))
|
||||
{
|
||||
user.getTeleport().home(player, homes.get(0), charge);
|
||||
goHome(user, player, homes.get(0), charge);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -93,4 +93,19 @@ public class Commandhome extends EssentialsCommand
|
||||
}
|
||||
throw new NoChargeException();
|
||||
}
|
||||
|
||||
private void goHome(final User user, final User player, final String home, final Trade charge) throws Exception
|
||||
{
|
||||
final Location loc = player.getHome(home);
|
||||
if (loc == null)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
if (user.getWorld() != loc.getWorld() && ess.getSettings().isWorldHomePermissions()
|
||||
&& !user.isAuthorized("essentials.world." + loc.getWorld().getName()))
|
||||
{
|
||||
throw new Exception(_("noPerm", "essentials.world." + loc.getWorld().getName()));
|
||||
}
|
||||
user.getTeleport().home(loc, charge);
|
||||
}
|
||||
}
|
||||
|
@@ -32,15 +32,14 @@ public class Commandignore extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
final String name = player.getName();
|
||||
if (user.isIgnoredPlayer(name))
|
||||
if (user.isIgnoredPlayer(player))
|
||||
{
|
||||
user.setIgnoredPlayer(name, false);
|
||||
user.setIgnoredPlayer(player, false);
|
||||
user.sendMessage(_("unignorePlayer", player.getName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.setIgnoredPlayer(name, true);
|
||||
user.setIgnoredPlayer(player, true);
|
||||
user.sendMessage(_("ignorePlayer", player.getName()));
|
||||
}
|
||||
}
|
||||
|
@@ -17,41 +17,12 @@ public class Commandinvsee extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
|
||||
if (args.length < 1 && user.getSavedInventory() == null)
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
User invUser = user;
|
||||
if (args.length == 1)
|
||||
{
|
||||
invUser = getPlayer(server, args, 0);
|
||||
}
|
||||
if (invUser == user && user.getSavedInventory() != null)
|
||||
{
|
||||
invUser.getInventory().setContents(user.getSavedInventory());
|
||||
user.setSavedInventory(null);
|
||||
user.sendMessage(_("invRestored"));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
|
||||
if (user.getSavedInventory() == null)
|
||||
{
|
||||
user.setSavedInventory(user.getInventory().getContents());
|
||||
}
|
||||
ItemStack[] invUserStack = invUser.getInventory().getContents();
|
||||
final int userStackLength = user.getInventory().getContents().length;
|
||||
if (invUserStack.length < userStackLength)
|
||||
{
|
||||
invUserStack = Arrays.copyOf(invUserStack, userStackLength);
|
||||
}
|
||||
if (invUserStack.length > userStackLength)
|
||||
{
|
||||
throw new Exception(_("invBigger"));
|
||||
}
|
||||
user.getInventory().setContents(invUserStack);
|
||||
user.sendMessage(_("invSee", invUser.getDisplayName()));
|
||||
user.sendMessage(_("invSeeHelp"));
|
||||
throw new NoChargeException();
|
||||
final User invUser = getPlayer(server, args, 0);
|
||||
user.setInvSee(true);
|
||||
user.openInventory(invUser.getInventory());
|
||||
}
|
||||
}
|
||||
|
@@ -36,41 +36,46 @@ public class Commanditem extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(_("cantSpawnItem", itemname));
|
||||
}
|
||||
|
||||
if (args.length > 1 && Integer.parseInt(args[1]) > 0)
|
||||
try
|
||||
{
|
||||
stack.setAmount(Integer.parseInt(args[1]));
|
||||
}
|
||||
else if (ess.getSettings().getDefaultStackSize() > 0)
|
||||
{
|
||||
stack.setAmount(ess.getSettings().getDefaultStackSize());
|
||||
}
|
||||
else if (ess.getSettings().getOversizedStackSize() > 0 && user.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
stack.setAmount(ess.getSettings().getOversizedStackSize());
|
||||
}
|
||||
|
||||
if (args.length > 2)
|
||||
{
|
||||
for (int i = 2; i < args.length; i++)
|
||||
if (args.length > 1 && Integer.parseInt(args[1]) > 0)
|
||||
{
|
||||
final String[] split = args[i].split("[:+',;.]", 2);
|
||||
if (split.length < 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final Enchantment enchantment = Commandenchant.getEnchantment(split[0], user);
|
||||
int level;
|
||||
if (split.length > 1)
|
||||
{
|
||||
level = Integer.parseInt(split[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
level = enchantment.getMaxLevel();
|
||||
}
|
||||
stack.addEnchantment(enchantment, level);
|
||||
stack.setAmount(Integer.parseInt(args[1]));
|
||||
}
|
||||
else if (ess.getSettings().getDefaultStackSize() > 0)
|
||||
{
|
||||
stack.setAmount(ess.getSettings().getDefaultStackSize());
|
||||
}
|
||||
else if (ess.getSettings().getOversizedStackSize() > 0 && user.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
stack.setAmount(ess.getSettings().getOversizedStackSize());
|
||||
}
|
||||
if (args.length > 2)
|
||||
{
|
||||
for (int i = 2; i < args.length; i++)
|
||||
{
|
||||
final String[] split = args[i].split("[:+',;.]", 2);
|
||||
if (split.length < 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final Enchantment enchantment = Commandenchant.getEnchantment(split[0], user);
|
||||
int level;
|
||||
if (split.length > 1)
|
||||
{
|
||||
level = Integer.parseInt(split[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
level = enchantment.getMaxLevel();
|
||||
}
|
||||
stack.addEnchantment(enchantment, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
if (stack.getType() == Material.AIR)
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -32,6 +34,16 @@ public class Commanditemdb extends EssentialsCommand
|
||||
{
|
||||
itemStack = ess.getItemDb().get(args[0]);
|
||||
}
|
||||
sender.sendMessage(itemStack.getType().toString() + "- " + itemStack.getTypeId() + ":" + Integer.toString(itemStack.getData().getData()));
|
||||
sender.sendMessage(itemStack.getType().toString() + "- " + itemStack.getTypeId() + ":" + Integer.toString(itemStack.getDurability()));
|
||||
|
||||
if (itemStack.getType() != Material.AIR)
|
||||
{
|
||||
int maxuses = itemStack.getType().getMaxDurability();
|
||||
int durability = ((maxuses + 1) - itemStack.getDurability());
|
||||
if (maxuses != 0)
|
||||
{
|
||||
sender.sendMessage(_("durability", Integer.toString(durability)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -37,5 +37,6 @@ public class Commandjump extends EssentialsCommand
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.getTeleport().teleport(loc, charge, TeleportCause.COMMAND);
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ public class Commandkick extends EssentialsCommand
|
||||
}
|
||||
|
||||
final User user = getPlayer(server, args, 0);
|
||||
if (user.isAuthorized("essentials.kick.exempt"))
|
||||
if (sender instanceof Player && user.isAuthorized("essentials.kick.exempt"))
|
||||
{
|
||||
throw new Exception(_("kickExempt"));
|
||||
}
|
||||
|
@@ -27,5 +27,6 @@ public class Commandkickall extends EssentialsCommand
|
||||
onlinePlayer.kickPlayer(args.length > 0 ? getFinalArg(args, 0) : _("kickDefault"));
|
||||
}
|
||||
}
|
||||
sender.sendMessage(_("kickedAll"));
|
||||
}
|
||||
}
|
||||
|
@@ -24,15 +24,14 @@ public class Commandkill extends EssentialsCommand
|
||||
|
||||
for (Player matchPlayer : server.matchPlayer(args[0]))
|
||||
{
|
||||
final EntityDamageEvent ede = new EntityDamageEvent(matchPlayer, sender instanceof Player && ((Player)sender).getName().equals(matchPlayer.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, 1000);
|
||||
final EntityDamageEvent ede = new EntityDamageEvent(matchPlayer, sender instanceof Player && ((Player)sender).getName().equals(matchPlayer.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, Short.MAX_VALUE);
|
||||
server.getPluginManager().callEvent(ede);
|
||||
if (ede.isCancelled() && !sender.hasPermission("essentials.kill.force"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
matchPlayer.damage(1000);
|
||||
matchPlayer.setHealth(0);
|
||||
matchPlayer.damage(Short.MAX_VALUE);
|
||||
sender.sendMessage(_("kill", matchPlayer.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.NPC;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.entity.Snowman;
|
||||
@@ -61,7 +62,7 @@ public class Commandkillall extends EssentialsCommand
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new Exception(_("numberRequired"));
|
||||
throw new Exception(_("numberRequired"), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,11 +122,18 @@ public class Commandkillall extends EssentialsCommand
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(entity instanceof Ocelot)
|
||||
{
|
||||
if (((Ocelot)entity).isTamed())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (animals)
|
||||
{
|
||||
if (entity instanceof Animals || entity instanceof NPC || entity instanceof Snowman || entity instanceof WaterMob)
|
||||
{
|
||||
EntityDeathEvent event = new EntityDeathEvent(entity, Collections.EMPTY_LIST);
|
||||
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
|
||||
ess.getServer().getPluginManager().callEvent(event);
|
||||
entity.remove();
|
||||
numKills++;
|
||||
@@ -135,7 +143,7 @@ public class Commandkillall extends EssentialsCommand
|
||||
{
|
||||
if (entity instanceof Monster || entity instanceof ComplexLivingEntity || entity instanceof Flying || entity instanceof Slime)
|
||||
{
|
||||
EntityDeathEvent event = new EntityDeathEvent(entity, Collections.EMPTY_LIST);
|
||||
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
|
||||
ess.getServer().getPluginManager().callEvent(event);
|
||||
entity.remove();
|
||||
numKills++;
|
||||
@@ -143,14 +151,14 @@ public class Commandkillall extends EssentialsCommand
|
||||
}
|
||||
else if (all)
|
||||
{
|
||||
EntityDeathEvent event = new EntityDeathEvent(entity, Collections.EMPTY_LIST);
|
||||
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
|
||||
ess.getServer().getPluginManager().callEvent(event);
|
||||
entity.remove();
|
||||
numKills++;
|
||||
}
|
||||
else if (entityClass != null && entityClass.isAssignableFrom(entity.getClass()))
|
||||
{
|
||||
EntityDeathEvent event = new EntityDeathEvent(entity, Collections.EMPTY_LIST);
|
||||
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
|
||||
ess.getServer().getPluginManager().callEvent(event);
|
||||
entity.remove();
|
||||
numKills++;
|
||||
|
@@ -4,6 +4,7 @@ import com.earth2me.essentials.*;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.*;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandkit extends EssentialsCommand
|
||||
@@ -19,38 +20,63 @@ public class Commandkit extends EssentialsCommand
|
||||
if (args.length < 1)
|
||||
{
|
||||
final String kitList = Kit.listKits(ess, user);
|
||||
if (kitList.length() > 0)
|
||||
{
|
||||
user.sendMessage(_("kits", kitList));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(_("noKits"));
|
||||
}
|
||||
user.sendMessage(kitList.length() > 0 ? _("kits", kitList) : _("noKits"));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
else if (args.length > 1 && user.isAuthorized("essentials.kit.others"))
|
||||
{
|
||||
final User userTo = getPlayer(server, args, 1, true);
|
||||
final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH));
|
||||
giveKit(userTo, user, kitName);
|
||||
}
|
||||
else
|
||||
{
|
||||
final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH));
|
||||
giveKit(user, user, kitName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
final String kitList = Kit.listKits(ess, null);
|
||||
sender.sendMessage(kitList.length() > 0 ? _("kits", kitList) : _("noKits"));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
else
|
||||
{
|
||||
final User userTo = getPlayer(server, args, 1, true);
|
||||
final String kitName = args[0].toLowerCase(Locale.ENGLISH);
|
||||
final Object kit = ess.getSettings().getKit(kitName);
|
||||
|
||||
if (!user.isAuthorized("essentials.kit." + kitName))
|
||||
{
|
||||
throw new Exception(_("noKitPermission", "essentials.kit." + kitName));
|
||||
}
|
||||
final Map<String, Object> els = (Map<String, Object>)kit;
|
||||
final List<String> items = Kit.getItems(user, els);
|
||||
|
||||
Kit.checkTime(user, kitName, els);
|
||||
|
||||
final Trade charge = new Trade("kit-" + kitName, ess);
|
||||
charge.isAffordableFor(user);
|
||||
|
||||
Kit.expandItems(ess, user, items);
|
||||
|
||||
charge.charge(user);
|
||||
user.sendMessage(_("kitGive", kitName));
|
||||
final Map<String, Object> kit = ess.getSettings().getKit(kitName);
|
||||
final List<String> items = Kit.getItems(userTo, kit);
|
||||
Kit.expandItems(ess, userTo, items);
|
||||
|
||||
sender.sendMessage(_("kitGive", kitName));
|
||||
}
|
||||
}
|
||||
|
||||
private void giveKit(User userTo, User userFrom, String kitName) throws Exception
|
||||
{
|
||||
final Map<String, Object> kit = ess.getSettings().getKit(kitName);
|
||||
|
||||
if (!userFrom.isAuthorized("essentials.kit." + kitName))
|
||||
{
|
||||
throw new Exception(_("noKitPermission", "essentials.kit." + kitName));
|
||||
}
|
||||
|
||||
final List<String> items = Kit.getItems(userTo, kit);
|
||||
|
||||
Kit.checkTime(userFrom, kitName, kit);
|
||||
|
||||
final Trade charge = new Trade("kit-" + kitName, ess);
|
||||
charge.isAffordableFor(userFrom);
|
||||
|
||||
Kit.expandItems(ess, userTo, items);
|
||||
|
||||
charge.charge(userFrom);
|
||||
userTo.sendMessage(_("kitGive", kitName));
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,44 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Mob;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.Random;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
|
||||
|
||||
public class Commandkittycannon extends EssentialsCommand
|
||||
{
|
||||
private static Random random = new Random();
|
||||
|
||||
public Commandkittycannon()
|
||||
{
|
||||
super("kittycannon");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final Mob cat = Mob.OCELOT;
|
||||
final Ocelot ocelot = (Ocelot)cat.spawn(user, server, user.getEyeLocation());
|
||||
if (ocelot == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final int i = random.nextInt(Ocelot.Type.values().length);
|
||||
ocelot.setCatType(Ocelot.Type.values()[i]);
|
||||
ocelot.setTamed(true);
|
||||
ocelot.setVelocity(user.getEyeLocation().getDirection().multiply(2));
|
||||
ess.scheduleSyncDelayedTask(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final Location loc = ocelot.getLocation();
|
||||
ocelot.remove();
|
||||
loc.getWorld().createExplosion(loc, 0F);
|
||||
}
|
||||
}, 20);
|
||||
}
|
||||
}
|
@@ -23,11 +23,11 @@ public class Commandlightning extends EssentialsCommand
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
user = ess.getUser(((Player)sender));
|
||||
}
|
||||
if (args.length < 1 & user != null)
|
||||
{
|
||||
user.getWorld().strikeLightning(user.getTargetBlock(null, 600).getLocation());
|
||||
return;
|
||||
if ((args.length < 1 || user != null && !user.isAuthorized("essentials.lightning.others")))
|
||||
{
|
||||
user.getWorld().strikeLightning(user.getTargetBlock(null, 600).getLocation());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (server.matchPlayer(args[0]).isEmpty())
|
||||
@@ -35,7 +35,7 @@ public class Commandlightning extends EssentialsCommand
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
|
||||
int power = 1;
|
||||
int power = 5;
|
||||
if (args.length > 1)
|
||||
{
|
||||
try
|
||||
@@ -50,18 +50,12 @@ public class Commandlightning extends EssentialsCommand
|
||||
for (Player matchPlayer : server.matchPlayer(args[0]))
|
||||
{
|
||||
sender.sendMessage(_("lightningUse", matchPlayer.getDisplayName()));
|
||||
if (power <= 0)
|
||||
{
|
||||
matchPlayer.getWorld().strikeLightningEffect(matchPlayer.getLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
LightningStrike strike = matchPlayer.getWorld().strikeLightning(matchPlayer.getLocation());
|
||||
matchPlayer.damage(power - 1, strike);
|
||||
}
|
||||
|
||||
final LightningStrike strike = matchPlayer.getWorld().strikeLightningEffect(matchPlayer.getLocation());
|
||||
|
||||
if (!ess.getUser(matchPlayer).isGodModeEnabled())
|
||||
{
|
||||
matchPlayer.setHealth(matchPlayer.getHealth() < 5 ? 0 : matchPlayer.getHealth() - 5);
|
||||
matchPlayer.damage(power, strike);
|
||||
}
|
||||
if (ess.getSettings().warnOnSmite())
|
||||
{
|
||||
|
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.*;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -43,8 +44,10 @@ public class Commandlist extends EssentialsCommand
|
||||
if (showhidden && playerHidden > 0)
|
||||
{
|
||||
online = _("listAmountHidden", server.getOnlinePlayers().length - playerHidden, playerHidden, server.getMaxPlayers());
|
||||
} else {
|
||||
online = _("listAmount",server.getOnlinePlayers().length - playerHidden, server.getMaxPlayers());
|
||||
}
|
||||
else
|
||||
{
|
||||
online = _("listAmount", server.getOnlinePlayers().length - playerHidden, server.getMaxPlayers());
|
||||
}
|
||||
sender.sendMessage(online);
|
||||
|
||||
@@ -72,7 +75,7 @@ public class Commandlist extends EssentialsCommand
|
||||
for (String group : groups)
|
||||
{
|
||||
final StringBuilder groupString = new StringBuilder();
|
||||
groupString.append(group).append(": ");
|
||||
groupString.append(_("listGroupTag", Util.replaceFormat(group)));
|
||||
final List<User> users = sort.get(group);
|
||||
Collections.sort(users);
|
||||
boolean first = true;
|
||||
@@ -94,6 +97,7 @@ public class Commandlist extends EssentialsCommand
|
||||
{
|
||||
groupString.append(_("listHiddenTag"));
|
||||
}
|
||||
user.setDisplayNick();
|
||||
groupString.append(user.getDisplayName());
|
||||
groupString.append("§f");
|
||||
}
|
||||
@@ -135,6 +139,7 @@ public class Commandlist extends EssentialsCommand
|
||||
{
|
||||
onlineUsers.append(_("listHiddenTag"));
|
||||
}
|
||||
user.setDisplayNick();
|
||||
onlineUsers.append(user.getDisplayName());
|
||||
onlineUsers.append("§f");
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@ import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.List;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -57,9 +56,9 @@ public class Commandmail extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(_("playerNeverOnServer", args[1]));
|
||||
}
|
||||
if (!u.isIgnoredPlayer(user.getName()))
|
||||
if (!u.isIgnoredPlayer(user))
|
||||
{
|
||||
final String mail = Util.sanitizeString(Util.stripColor(getFinalArg(args, 2)));
|
||||
final String mail = Util.sanitizeString(Util.stripFormat(getFinalArg(args, 2)));
|
||||
u.addMail(user.getName() + ": " + mail);
|
||||
}
|
||||
user.sendMessage(_("mailSent"));
|
||||
@@ -71,7 +70,7 @@ public class Commandmail extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(_("noPerm", "essentials.mail.sendall"));
|
||||
}
|
||||
ess.scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + Util.stripColor(getFinalArg(args, 1))));
|
||||
ess.scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + Util.stripFormat(getFinalArg(args, 1))));
|
||||
user.sendMessage(_("mailSent"));
|
||||
return;
|
||||
}
|
||||
|
@@ -27,15 +27,9 @@ public class Commandme extends EssentialsCommand
|
||||
}
|
||||
|
||||
String message = getFinalArg(args, 0);
|
||||
if (user.isAuthorized("essentials.chat.color"))
|
||||
{
|
||||
message = Util.replaceColor(message);
|
||||
}
|
||||
else {
|
||||
message = Util.stripColor(message);
|
||||
}
|
||||
|
||||
message = Util.formatMessage(user, "essentials.chat", message);
|
||||
|
||||
user.setDisplayNick();
|
||||
ess.broadcastMessage(user, _("action", user.getDisplayName(), message));
|
||||
}
|
||||
}
|
||||
|
@@ -21,11 +21,11 @@ public class Commandmsg extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2 || args[0].trim().isEmpty() || args[1].trim().isEmpty())
|
||||
if (args.length < 2 || args[0].trim().length() < 3 || args[1].trim().isEmpty())
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
|
||||
String message = getFinalArg(args, 1);
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
@@ -34,18 +34,11 @@ public class Commandmsg extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(_("voiceSilenced"));
|
||||
}
|
||||
if (user.isAuthorized("essentials.msg.color"))
|
||||
{
|
||||
message = Util.replaceColor(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.stripColor(message);
|
||||
}
|
||||
message = Util.formatMessage(user, "essentials.msg", message);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.replaceColor(message);
|
||||
message = Util.replaceFormat(message);
|
||||
}
|
||||
|
||||
final String translatedMe = _("me");
|
||||
@@ -88,7 +81,7 @@ public class Commandmsg extends EssentialsCommand
|
||||
{
|
||||
sender.sendMessage(_("msgFormat", translatedMe, matchedPlayer.getDisplayName(), message));
|
||||
final User matchedUser = ess.getUser(matchedPlayer);
|
||||
if (sender instanceof Player && (matchedUser.isIgnoredPlayer(((Player)sender).getName()) || matchedUser.isHidden()))
|
||||
if (sender instanceof Player && (matchedUser.isIgnoredPlayer(ess.getUser(sender)) || matchedUser.isHidden()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@@ -28,13 +28,19 @@ public class Commandmute extends EssentialsCommand
|
||||
throw new Exception(_("muteExempt"));
|
||||
}
|
||||
long muteTimestamp = 0;
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
String time = getFinalArg(args, 1);
|
||||
final String time = getFinalArg(args, 1);
|
||||
muteTimestamp = Util.parseDateDiff(time, true);
|
||||
player.setMuted(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setMuted(!player.getMuted());
|
||||
}
|
||||
player.setMuteTimeout(muteTimestamp);
|
||||
final boolean muted = player.toggleMuted();
|
||||
final boolean muted = player.getMuted();
|
||||
sender.sendMessage(
|
||||
muted
|
||||
? (muteTimestamp > 0
|
||||
|
@@ -64,11 +64,13 @@ public class Commandnick extends EssentialsCommand
|
||||
|
||||
private String formatNickname(final User user, final String nick)
|
||||
{
|
||||
if (user == null || user.isAuthorized("essentials.nick.color"))
|
||||
if (user == null)
|
||||
{
|
||||
return nick.replace('&', '\u00a7').replaceAll("\u00a7+k", "");
|
||||
} else {
|
||||
return Util.stripColor(nick);
|
||||
return Util.replaceFormat(nick);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Util.formatString(user, "essentials.nick", nick);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -51,7 +51,7 @@ public class Commandnuke extends EssentialsCommand
|
||||
{
|
||||
for (int z = -10; z <= 10; z += 5)
|
||||
{
|
||||
final Location tntloc = new Location(world, loc.getBlockX() + x, 127, loc.getBlockZ() + z);
|
||||
final Location tntloc = new Location(world, loc.getBlockX() + x, world.getHighestBlockYAt(loc) + 64, loc.getBlockZ() + z);
|
||||
final TNTPrimed tnt = world.spawn(tntloc, TNTPrimed.class);
|
||||
}
|
||||
}
|
||||
|
@@ -22,14 +22,14 @@ public class Commandpay extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
if (args[0] == "")
|
||||
if (args[0].trim().length() < 3)
|
||||
{
|
||||
throw new NotEnoughArgumentsException("You need to specify a player to pay.");
|
||||
}
|
||||
|
||||
double amount = Double.parseDouble(args[1].replaceAll("[^0-9\\.]", ""));
|
||||
|
||||
Boolean foundUser = false;
|
||||
boolean foundUser = false;
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
{
|
||||
User u = ess.getUser(p);
|
||||
@@ -42,9 +42,9 @@ public class Commandpay extends EssentialsCommand
|
||||
foundUser = true;
|
||||
}
|
||||
|
||||
if (foundUser == false)
|
||||
if (!foundUser)
|
||||
{
|
||||
throw new NoSuchFieldException(_("playerNotFound"));
|
||||
throw new NotEnoughArgumentsException(_("playerNotFound"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,9 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandping extends EssentialsCommand
|
||||
@@ -13,8 +14,16 @@ public class Commandping extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, User player, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
player.sendMessage(_("pong"));
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
||||
sender.sendMessage(_("pong"));
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(Util.replaceFormat(getFinalArg(args, 0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -51,26 +51,18 @@ public class Commandpowertool extends EssentialsCommand
|
||||
{
|
||||
user.sendMessage(_("powerToolList", Util.joinList(powertools), itemName));
|
||||
}
|
||||
return;
|
||||
throw new NoChargeException();
|
||||
}
|
||||
if (command.startsWith("r:"))
|
||||
{
|
||||
try
|
||||
command = command.substring(2);
|
||||
if (!powertools.contains(command))
|
||||
{
|
||||
command = command.substring(2);
|
||||
if (!powertools.contains(command))
|
||||
{
|
||||
throw new Exception(_("powerToolNoSuchCommandAssigned", command, itemName));
|
||||
}
|
||||
throw new Exception(_("powerToolNoSuchCommandAssigned", command, itemName));
|
||||
}
|
||||
|
||||
powertools.remove(command);
|
||||
user.sendMessage(_("powerToolRemove", command, itemName));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
user.sendMessage(e.getMessage());
|
||||
return;
|
||||
}
|
||||
powertools.remove(command);
|
||||
user.sendMessage(_("powerToolRemove", command, itemName));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -85,7 +77,6 @@ public class Commandpowertool extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(_("powerToolAlreadySet", command, itemName));
|
||||
}
|
||||
|
||||
}
|
||||
else if (powertools != null && !powertools.isEmpty())
|
||||
{
|
||||
@@ -110,6 +101,11 @@ public class Commandpowertool extends EssentialsCommand
|
||||
user.sendMessage(_("powerToolRemoveAll", itemName));
|
||||
}
|
||||
|
||||
if (!user.arePowerToolsEnabled())
|
||||
{
|
||||
user.setPowerToolsEnabled(true);
|
||||
user.sendMessage(_("powerToolsEnabled"));
|
||||
}
|
||||
user.setPowertool(itemStack, powertools);
|
||||
}
|
||||
}
|
||||
|
@@ -55,7 +55,7 @@ public class Commandptime extends EssentialsCommand
|
||||
Long ticks;
|
||||
// Parse the target time int ticks from args[0]
|
||||
String timeParam = args[0];
|
||||
Boolean relative = true;
|
||||
boolean relative = true;
|
||||
if (timeParam.startsWith("@"))
|
||||
{
|
||||
relative = false;
|
||||
@@ -79,7 +79,7 @@ public class Commandptime extends EssentialsCommand
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
throw new NotEnoughArgumentsException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -32,20 +32,13 @@ public class Commandr extends EssentialsCommand
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
User user = ess.getUser(sender);
|
||||
if (user.isAuthorized("essentials.msg.color"))
|
||||
{
|
||||
message = Util.replaceColor(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.stripColor(message);
|
||||
}
|
||||
message = Util.formatMessage(user, "essentials.msg", message);
|
||||
replyTo = user;
|
||||
senderName = user.getDisplayName();
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.replaceColor(message);
|
||||
message = Util.replaceFormat(message);
|
||||
replyTo = Console.getConsoleReplyTo();
|
||||
senderName = Console.NAME;
|
||||
}
|
||||
@@ -62,7 +55,7 @@ public class Commandr extends EssentialsCommand
|
||||
if (target instanceof Player)
|
||||
{
|
||||
User player = ess.getUser(target);
|
||||
if (player.isIgnoredPlayer(sender instanceof Player ? ((Player)sender).getName() : Console.NAME))
|
||||
if (sender instanceof Player && player.isIgnoredPlayer(ess.getUser(sender)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@@ -31,9 +31,10 @@ public class Commandrealname extends EssentialsCommand
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final String displayName = Util.stripColor(u.getDisplayName()).toLowerCase(Locale.ENGLISH);
|
||||
u.setDisplayNick();
|
||||
final String displayName = Util.stripFormat(u.getDisplayName()).toLowerCase(Locale.ENGLISH);
|
||||
if (!whois.equals(displayName)
|
||||
&& !displayName.equals(Util.stripColor(ess.getSettings().getNicknamePrefix()) + whois)
|
||||
&& !displayName.equals(Util.stripFormat(ess.getSettings().getNicknamePrefix()) + whois)
|
||||
&& !whois.equalsIgnoreCase(u.getName()))
|
||||
{
|
||||
continue;
|
||||
|
@@ -9,7 +9,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
|
||||
//Todo: Fix this up
|
||||
public class Commandremove extends EssentialsCommand
|
||||
{
|
||||
public Commandremove()
|
||||
@@ -47,7 +47,7 @@ public class Commandremove extends EssentialsCommand
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new Exception(_("numberRequired"));
|
||||
throw new Exception(_("numberRequired"), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class Commandremove extends EssentialsCommand
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
throw new NotEnoughArgumentsException(); //TODO: translate and list types
|
||||
throw new NotEnoughArgumentsException(e); //TODO: translate and list types
|
||||
}
|
||||
|
||||
removeEntities(user, world, toRemove, radius);
|
||||
@@ -84,7 +84,7 @@ public class Commandremove extends EssentialsCommand
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
throw new NotEnoughArgumentsException(); //TODO: translate and list types
|
||||
throw new NotEnoughArgumentsException(e); //TODO: translate and list types
|
||||
}
|
||||
removeEntities(sender, world, toRemove, 0);
|
||||
}
|
||||
@@ -92,8 +92,9 @@ public class Commandremove extends EssentialsCommand
|
||||
protected void removeEntities(final CommandSender sender, final World world, final ToRemove toRemove, int radius) throws Exception
|
||||
{
|
||||
int removed = 0;
|
||||
if (radius > 0) {
|
||||
radius*=radius;
|
||||
if (radius > 0)
|
||||
{
|
||||
radius *= radius;
|
||||
}
|
||||
for (Chunk chunk : world.getLoadedChunks())
|
||||
{
|
||||
@@ -130,7 +131,7 @@ public class Commandremove extends EssentialsCommand
|
||||
removed++;
|
||||
}
|
||||
}
|
||||
else if (toRemove == ToRemove.DROPS)
|
||||
else if (toRemove == ToRemove.MINECARTS)
|
||||
{
|
||||
if (e instanceof Minecart)
|
||||
{
|
||||
|
@@ -53,6 +53,8 @@ public class Commandrepair extends EssentialsCommand
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("all"))
|
||||
{
|
||||
final Trade charge = new Trade("repair-all", ess);
|
||||
charge.isAffordableFor(user);
|
||||
final List<String> repaired = new ArrayList<String>();
|
||||
repairItems(user.getInventory().getContents(), user, repaired);
|
||||
|
||||
@@ -69,6 +71,7 @@ public class Commandrepair extends EssentialsCommand
|
||||
{
|
||||
user.sendMessage(_("repair", Util.joinList(repaired)));
|
||||
}
|
||||
charge.charge(user);
|
||||
|
||||
}
|
||||
else
|
||||
@@ -102,7 +105,7 @@ public class Commandrepair extends EssentialsCommand
|
||||
continue;
|
||||
}
|
||||
final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH);
|
||||
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess);
|
||||
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), "repair-item", ess);
|
||||
try
|
||||
{
|
||||
charge.isAffordableFor(user);
|
||||
|
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -16,6 +17,17 @@ public class Commandseen extends EssentialsCommand
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
seen(server, sender, args, true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
seen(server, user, args, user.isAuthorized("essentials.seen.banreason"), user.isAuthorized("essentials.seen.extra"));
|
||||
}
|
||||
|
||||
protected void seen(final Server server, final CommandSender sender, final String[] args, final boolean showBan, final boolean extra) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
@@ -23,20 +35,34 @@ public class Commandseen extends EssentialsCommand
|
||||
}
|
||||
try
|
||||
{
|
||||
User u = getPlayer(server, args, 0);
|
||||
sender.sendMessage(_("seenOnline", u.getDisplayName(), Util.formatDateDiff(u.getLastLogin())));
|
||||
User player = getPlayer(server, args, 0);
|
||||
player.setDisplayNick();
|
||||
sender.sendMessage(_("seenOnline", player.getDisplayName(), Util.formatDateDiff(player.getLastLogin())));
|
||||
if (extra)
|
||||
{
|
||||
sender.sendMessage(_("whoisIPAddress", player.getAddress().getAddress().toString()));
|
||||
}
|
||||
}
|
||||
catch (NoSuchFieldException e)
|
||||
{
|
||||
User u = ess.getOfflineUser(args[0]);
|
||||
if (u == null)
|
||||
User player = ess.getOfflineUser(args[0]);
|
||||
if (player == null)
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
sender.sendMessage(_("seenOffline", u.getDisplayName(), Util.formatDateDiff(u.getLastLogout())));
|
||||
if (u.isBanned())
|
||||
player.setDisplayNick();
|
||||
sender.sendMessage(_("seenOffline", player.getName(), Util.formatDateDiff(player.getLastLogout())));
|
||||
if (player.isBanned())
|
||||
{
|
||||
sender.sendMessage(_("whoisBanned", _("true")));
|
||||
sender.sendMessage(_("whoisBanned", showBan ? player.getBanReason() : _("true")));
|
||||
}
|
||||
if (extra)
|
||||
{
|
||||
sender.sendMessage(_("whoisIPAddress", player.getLastLoginAddress()));
|
||||
final Location loc = player.getLastLocation();
|
||||
if (loc != null) {
|
||||
sender.sendMessage(_("whoisLocation", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -160,8 +160,8 @@ public class Commandsell extends EssentialsCommand
|
||||
user.updateInventory();
|
||||
Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(worth * amount, ess), user.getLocation(), ess);
|
||||
user.giveMoney(worth * amount);
|
||||
user.sendMessage(_("itemSold", Util.formatCurrency(worth * amount, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), Util.formatCurrency(worth, ess)));
|
||||
logger.log(Level.INFO, _("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(Locale.ENGLISH), Util.formatCurrency(worth * amount, ess), amount, Util.formatCurrency(worth, ess)));
|
||||
user.sendMessage(_("itemSold", Util.displayCurrency(worth * amount, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth, ess)));
|
||||
logger.log(Level.INFO, _("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth * amount, ess), amount, Util.displayCurrency(worth, ess)));
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,8 @@ public class Commandsethome extends EssentialsCommand
|
||||
{
|
||||
if (user.isAuthorized("essentials.sethome.multiple"))
|
||||
{
|
||||
if ("bed".equals(args[0].toLowerCase(Locale.ENGLISH))) {
|
||||
if ("bed".equals(args[0].toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getHomeLimit(user))
|
||||
@@ -66,7 +67,8 @@ public class Commandsethome extends EssentialsCommand
|
||||
{
|
||||
name = "home";
|
||||
}
|
||||
if ("bed".equals(name.toLowerCase(Locale.ENGLISH))) {
|
||||
if ("bed".equals(name.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
usersHome.setHome(name, user.getLocation());
|
||||
@@ -77,7 +79,7 @@ public class Commandsethome extends EssentialsCommand
|
||||
{
|
||||
user.setHome();
|
||||
}
|
||||
user.sendMessage(_("homeSet"));
|
||||
user.sendMessage(_("homeSet", user.getLocation().getWorld().getName(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ()));
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
|
||||
|
||||
@@ -20,7 +21,7 @@ public class Commandsetjail extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
ess.getJails().setJail(args[0], user.getLocation());
|
||||
user.sendMessage(_("jailSet", args[0]));
|
||||
user.sendMessage(_("jailSet", Util.sanitizeString(args[0])));
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,8 @@ 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.Warps;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
|
||||
@@ -26,7 +28,25 @@ public class Commandsetwarp extends EssentialsCommand
|
||||
}
|
||||
|
||||
final Location loc = user.getLocation();
|
||||
ess.getWarps().setWarp(args[0], loc);
|
||||
final Warps warps = ess.getWarps();
|
||||
Location warpLoc = null;
|
||||
|
||||
try
|
||||
{
|
||||
warpLoc = warps.getWarp(args[0]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
|
||||
if (warpLoc == null || user.isAuthorized("essentials.warp.overwrite." + Util.sanitizeFileName(args[0])))
|
||||
{
|
||||
warps.setWarp(args[0], loc);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("warpOverwrite"));
|
||||
}
|
||||
user.sendMessage(_("warpSet", args[0]));
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ 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.inventory.ItemStack;
|
||||
|
||||
|
||||
@@ -15,6 +16,32 @@ public class Commandsetworth extends EssentialsCommand
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
ItemStack stack;
|
||||
String price;
|
||||
|
||||
if (args.length == 1)
|
||||
{
|
||||
stack = user.getInventory().getItemInHand();
|
||||
price = args[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
stack = ess.getItemDb().get(args[0]);
|
||||
price = args[1];
|
||||
}
|
||||
|
||||
ess.getWorth().setPrice(stack, Double.parseDouble(price));
|
||||
user.sendMessage(_("worthSet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
@@ -23,6 +50,6 @@ public class Commandsetworth extends EssentialsCommand
|
||||
|
||||
ItemStack stack = ess.getItemDb().get(args[0]);
|
||||
ess.getWorth().setPrice(stack, Double.parseDouble(args[1]));
|
||||
user.sendMessage(_("worthSet"));
|
||||
sender.sendMessage(_("worthSet"));
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,13 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.*;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Mob;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
|
||||
public class Commandspawner extends EssentialsCommand
|
||||
@@ -32,31 +31,34 @@ public class Commandspawner extends EssentialsCommand
|
||||
throw new Exception(_("mobSpawnTarget"));
|
||||
}
|
||||
|
||||
String name = args[0];
|
||||
|
||||
Mob mob = null;
|
||||
mob = Mob.fromName(name);
|
||||
if (mob == null)
|
||||
{
|
||||
throw new Exception(_("invalidMob"));
|
||||
}
|
||||
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new Exception(_("disabledToSpawnMob"));
|
||||
}
|
||||
if (!user.isAuthorized("essentials.spawner." + mob.name.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new Exception(_("noPermToSpawnMob"));
|
||||
}
|
||||
final Trade charge = new Trade("spawner-" + mob.name.toLowerCase(Locale.ENGLISH), ess);
|
||||
charge.isAffordableFor(user);
|
||||
try
|
||||
{
|
||||
String name = args[0];
|
||||
|
||||
Mob mob = null;
|
||||
mob = Mob.fromName(name);
|
||||
if (mob == null)
|
||||
{
|
||||
user.sendMessage(_("invalidMob"));
|
||||
return;
|
||||
}
|
||||
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new Exception(_("unableToSpawnMob"));
|
||||
}
|
||||
if (!user.isAuthorized("essentials.spawner." + mob.name.toLowerCase()))
|
||||
{
|
||||
throw new Exception(_("unableToSpawnMob"));
|
||||
}
|
||||
((CreatureSpawner)target.getBlock().getState()).setCreatureType(mob.getType());
|
||||
user.sendMessage(_("setSpawner", mob.name));
|
||||
((CreatureSpawner)target.getBlock().getState()).setSpawnedType(mob.getType());
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
throw new Exception(_("mobSpawnError"), ex);
|
||||
}
|
||||
charge.charge(user);
|
||||
user.sendMessage(_("setSpawner", mob.name));
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -5,13 +5,14 @@ import com.earth2me.essentials.Mob;
|
||||
import com.earth2me.essentials.Mob.MobException;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
import java.util.*;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Villager.Profession;
|
||||
import org.bukkit.material.Colorable;
|
||||
|
||||
|
||||
public class Commandspawnmob extends EssentialsCommand
|
||||
@@ -26,7 +27,20 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException(_("mobsAvailable", Util.joinList(Mob.getMobList())));
|
||||
final Set<String> mobList = Mob.getMobList();
|
||||
final Set<String> availableList = new HashSet<String>();
|
||||
for (String mob : mobList)
|
||||
{
|
||||
if (user.isAuthorized("essentials.spawnmob." + mob.toLowerCase()))
|
||||
{
|
||||
availableList.add(mob);
|
||||
}
|
||||
}
|
||||
if (availableList.isEmpty())
|
||||
{
|
||||
availableList.add(_("none"));
|
||||
}
|
||||
throw new NotEnoughArgumentsException(_("mobsAvailable", Util.joinList(availableList)));
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +93,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
User otherUser = null;
|
||||
if (args.length >= 3)
|
||||
{
|
||||
otherUser = getPlayer(ess.getServer(), args, 2);
|
||||
otherUser = getPlayer(ess.getServer(), args, 2);
|
||||
}
|
||||
final Location loc = (otherUser == null) ? block.getLocation() : otherUser.getLocation();
|
||||
final Location sloc = Util.getSafeDestination(loc);
|
||||
@@ -89,7 +103,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
}
|
||||
catch (MobException e)
|
||||
{
|
||||
throw new Exception(_("unableToSpawnMob"));
|
||||
throw new Exception(_("unableToSpawnMob"), e);
|
||||
}
|
||||
|
||||
if (mountType != null)
|
||||
@@ -115,7 +129,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
}
|
||||
catch (MobException e)
|
||||
{
|
||||
throw new Exception(_("unableToSpawnMob"));
|
||||
throw new Exception(_("unableToSpawnMob"), e);
|
||||
}
|
||||
spawnedMob.setPassenger(spawnedMount);
|
||||
}
|
||||
@@ -150,7 +164,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
}
|
||||
catch (MobException e)
|
||||
{
|
||||
throw new Exception(_("unableToSpawnMob"));
|
||||
throw new Exception(_("unableToSpawnMob"), e);
|
||||
}
|
||||
spawnedMob.setPassenger(spawnedMount);
|
||||
}
|
||||
@@ -163,7 +177,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
changeMobData(mobMount.getType(), spawnedMount, mountData, user);
|
||||
}
|
||||
}
|
||||
user.sendMessage(args[1] + " " + mob.name.toLowerCase(Locale.ENGLISH) + mob.suffix + " " + _("spawned"));
|
||||
user.sendMessage(mobCount + " " + mob.name.toLowerCase(Locale.ENGLISH) + mob.suffix + " " + _("spawned"));
|
||||
}
|
||||
catch (MobException e1)
|
||||
{
|
||||
@@ -184,9 +198,11 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
private void changeMobData(final CreatureType type, final Entity spawned, final String data, final User user) throws Exception
|
||||
private void changeMobData(final EntityType type, final Entity spawned, String data, final User user) throws Exception
|
||||
{
|
||||
if (type == CreatureType.SLIME || type == CreatureType.MAGMA_CUBE)
|
||||
data = data.toLowerCase(Locale.ENGLISH);
|
||||
|
||||
if (spawned instanceof Slime)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -197,35 +213,24 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
throw new Exception(_("slimeMalformedSize"), e);
|
||||
}
|
||||
}
|
||||
if ((type == CreatureType.SHEEP
|
||||
|| type == CreatureType.COW
|
||||
|| type == CreatureType.MUSHROOM_COW
|
||||
|| type == CreatureType.CHICKEN
|
||||
|| type == CreatureType.PIG
|
||||
|| type == CreatureType.WOLF)
|
||||
&& data.equalsIgnoreCase("baby"))
|
||||
if (spawned instanceof Ageable && data.contains("baby"))
|
||||
{
|
||||
((Animals)spawned).setAge(-24000);
|
||||
((Ageable)spawned).setBaby();
|
||||
return;
|
||||
}
|
||||
if (type == CreatureType.SHEEP)
|
||||
if (spawned instanceof Colorable)
|
||||
{
|
||||
if (data.toLowerCase(Locale.ENGLISH).contains("baby"))
|
||||
{
|
||||
((Sheep)spawned).setAge(-24000);
|
||||
}
|
||||
final String color = data.toUpperCase(Locale.ENGLISH).replace("BABY", "");
|
||||
try
|
||||
{
|
||||
|
||||
if (color.equalsIgnoreCase("random"))
|
||||
if (color.equals("RANDOM"))
|
||||
{
|
||||
Random rand = new Random();
|
||||
((Sheep)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
|
||||
final Random rand = new Random();
|
||||
((Colorable)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
|
||||
}
|
||||
else
|
||||
{
|
||||
((Sheep)spawned).setColor(DyeColor.valueOf(color));
|
||||
((Colorable)spawned).setColor(DyeColor.valueOf(color));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -233,30 +238,45 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
throw new Exception(_("sheepMalformedColor"), e);
|
||||
}
|
||||
}
|
||||
if (type == CreatureType.WOLF
|
||||
&& data.toLowerCase(Locale.ENGLISH).startsWith("tamed"))
|
||||
if (spawned instanceof Tameable && data.contains("tamed"))
|
||||
{
|
||||
final Wolf wolf = ((Wolf)spawned);
|
||||
wolf.setTamed(true);
|
||||
wolf.setOwner(user);
|
||||
wolf.setSitting(true);
|
||||
if (data.equalsIgnoreCase("tamedbaby"))
|
||||
{
|
||||
((Animals)spawned).setAge(-24000);
|
||||
}
|
||||
final Tameable tameable = ((Tameable)spawned);
|
||||
tameable.setTamed(true);
|
||||
tameable.setOwner(user.getBase());
|
||||
}
|
||||
if (type == CreatureType.WOLF
|
||||
&& data.toLowerCase(Locale.ENGLISH).startsWith("angry"))
|
||||
if (type == EntityType.WOLF
|
||||
&& data.contains("angry"))
|
||||
{
|
||||
((Wolf)spawned).setAngry(true);
|
||||
if (data.equalsIgnoreCase("angrybaby"))
|
||||
{
|
||||
((Animals)spawned).setAge(-24000);
|
||||
}
|
||||
}
|
||||
if (type == CreatureType.CREEPER && data.equalsIgnoreCase("powered"))
|
||||
if (type == EntityType.CREEPER && data.contains("powered"))
|
||||
{
|
||||
((Creeper)spawned).setPowered(true);
|
||||
}
|
||||
if (type == EntityType.OCELOT)
|
||||
{
|
||||
if (data.contains("siamese"))
|
||||
{
|
||||
((Ocelot)spawned).setCatType(Ocelot.Type.SIAMESE_CAT);
|
||||
}
|
||||
else if (data.contains("red"))
|
||||
{
|
||||
((Ocelot)spawned).setCatType(Ocelot.Type.RED_CAT);
|
||||
}
|
||||
else if (data.contains("black"))
|
||||
{
|
||||
((Ocelot)spawned).setCatType(Ocelot.Type.BLACK_CAT);
|
||||
}
|
||||
}
|
||||
if (type == EntityType.VILLAGER)
|
||||
{
|
||||
for (Profession prof : Villager.Profession.values())
|
||||
{
|
||||
if (data.contains(prof.toString().toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
((Villager)spawned).setProfession(prof);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
@@ -29,8 +31,12 @@ public class Commandsudo extends EssentialsCommand
|
||||
System.arraycopy(args, 2, arguments, 0, args.length - 2);
|
||||
}
|
||||
|
||||
//TODO: Translate this.
|
||||
sender.sendMessage("Running the command as " + user.getDisplayName());
|
||||
if (user.isAuthorized("essentials.sudo.exempt"))
|
||||
{
|
||||
throw new Exception(_("sudoExempt"));
|
||||
}
|
||||
|
||||
sender.sendMessage(_("sudoRun", user.getDisplayName(), command, getFinalArg(arguments, 0)));
|
||||
|
||||
final PluginCommand execCommand = ess.getServer().getPluginCommand(command);
|
||||
if (execCommand != null)
|
||||
|
@@ -16,11 +16,11 @@ public class Commandsuicide extends EssentialsCommand
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
EntityDamageEvent ede = new EntityDamageEvent(user, EntityDamageEvent.DamageCause.SUICIDE, 1000);
|
||||
EntityDamageEvent ede = new EntityDamageEvent(user.getBase(), EntityDamageEvent.DamageCause.SUICIDE, Short.MAX_VALUE);
|
||||
server.getPluginManager().callEvent(ede);
|
||||
user.damage(1000);
|
||||
user.setHealth(0);
|
||||
user.damage(Short.MAX_VALUE);
|
||||
user.sendMessage(_("suicideMessage"));
|
||||
user.setDisplayNick();
|
||||
ess.broadcastMessage(user,_("suicideSuccess", user.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Console;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.OfflinePlayer;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
@@ -25,7 +24,7 @@ public class Commandtempban extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
final User user = getPlayer(server, args, 0, true);
|
||||
if (user.getBase() instanceof OfflinePlayer)
|
||||
if (!user.isOnline())
|
||||
{
|
||||
if (sender instanceof Player
|
||||
&& !ess.getUser(sender).isAuthorized("essentials.tempban.offline"))
|
||||
@@ -45,12 +44,12 @@ public class Commandtempban extends EssentialsCommand
|
||||
final String time = getFinalArg(args, 1);
|
||||
final long banTimestamp = Util.parseDateDiff(time, true);
|
||||
|
||||
final String banReason = _("tempBanned", Util.formatDateDiff(banTimestamp));
|
||||
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
final String banReason = _("tempBanned", Util.formatDateDiff(banTimestamp), senderName);
|
||||
user.setBanReason(banReason);
|
||||
user.setBanTimeout(banTimestamp);
|
||||
user.setBanned(true);
|
||||
user.kickPlayer(banReason);
|
||||
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
|
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.DescParseTickFormat;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.*;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
@@ -19,19 +20,47 @@ public class Commandtime extends EssentialsCommand
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
boolean add = false;
|
||||
final List<String> argList = new ArrayList<String>(Arrays.asList(args));
|
||||
if (argList.remove("set") && !argList.isEmpty() && Util.isInt(argList.get(0)))
|
||||
{
|
||||
argList.set(0, argList.get(0) + "t");
|
||||
}
|
||||
if (argList.remove("add") && !argList.isEmpty() && Util.isInt(argList.get(0)))
|
||||
{
|
||||
add = true;
|
||||
argList.set(0, argList.get(0) + "t");
|
||||
}
|
||||
final String[] validArgs = argList.toArray(new String[0]);
|
||||
|
||||
// Which World(s) are we interested in?
|
||||
String worldSelector = null;
|
||||
if (args.length == 2)
|
||||
if (validArgs.length == 2)
|
||||
{
|
||||
worldSelector = args[1];
|
||||
worldSelector = validArgs[1];
|
||||
}
|
||||
final Set<World> worlds = getWorlds(server, sender, worldSelector);
|
||||
final String setTime;
|
||||
|
||||
// If no arguments we are reading the time
|
||||
if (args.length == 0)
|
||||
if (validArgs.length == 0)
|
||||
{
|
||||
getWorldsTime(sender, worlds);
|
||||
return;
|
||||
if (commandLabel.equalsIgnoreCase("day") || commandLabel.equalsIgnoreCase("eday"))
|
||||
{
|
||||
setTime = "day";
|
||||
}
|
||||
else if (commandLabel.equalsIgnoreCase("night") || commandLabel.equalsIgnoreCase("enight"))
|
||||
{
|
||||
setTime = "night";
|
||||
}
|
||||
else
|
||||
{
|
||||
getWorldsTime(sender, worlds);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
setTime = validArgs[0];
|
||||
}
|
||||
|
||||
final User user = ess.getUser(sender);
|
||||
@@ -45,14 +74,14 @@ public class Commandtime extends EssentialsCommand
|
||||
long ticks;
|
||||
try
|
||||
{
|
||||
ticks = DescParseTickFormat.parse(args[0]);
|
||||
ticks = DescParseTickFormat.parse(setTime);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
throw new NotEnoughArgumentsException(e);
|
||||
}
|
||||
|
||||
setWorldsTime(sender, worlds, ticks);
|
||||
setWorldsTime(sender, worlds, ticks, add);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,14 +105,17 @@ public class Commandtime extends EssentialsCommand
|
||||
/**
|
||||
* Used to set the time and inform of the change
|
||||
*/
|
||||
private void setWorldsTime(final CommandSender sender, final Collection<World> worlds, final long ticks)
|
||||
private void setWorldsTime(final CommandSender sender, final Collection<World> worlds, final long ticks, final boolean add)
|
||||
{
|
||||
// Update the time
|
||||
for (World world : worlds)
|
||||
{
|
||||
long time = world.getTime();
|
||||
time -= time % 24000;
|
||||
world.setTime(time + 24000 + ticks);
|
||||
if (!add)
|
||||
{
|
||||
time -= time % 24000;
|
||||
}
|
||||
world.setTime(time + (add ? 0 : 24000) + ticks);
|
||||
}
|
||||
|
||||
final StringBuilder output = new StringBuilder();
|
||||
@@ -151,4 +183,4 @@ class WorldNameComparator implements Comparator<World>
|
||||
{
|
||||
return a.getName().compareTo(b.getName());
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.OfflinePlayer;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
@@ -28,7 +27,7 @@ public class Commandtogglejail extends EssentialsCommand
|
||||
|
||||
if (args.length >= 2 && !player.isJailed())
|
||||
{
|
||||
if (player.getBase() instanceof OfflinePlayer)
|
||||
if (!player.isOnline())
|
||||
{
|
||||
if (sender instanceof Player
|
||||
&& !ess.getUser(sender).isAuthorized("essentials.togglejail.offline"))
|
||||
@@ -45,7 +44,7 @@ public class Commandtogglejail extends EssentialsCommand
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!(player.getBase() instanceof OfflinePlayer))
|
||||
if (player.isOnline())
|
||||
{
|
||||
ess.getJails().sendToJail(player, args[1]);
|
||||
}
|
||||
@@ -96,7 +95,7 @@ public class Commandtogglejail extends EssentialsCommand
|
||||
player.setJailTimeout(0);
|
||||
player.sendMessage(_("jailReleasedPlayerNotify"));
|
||||
player.setJail(null);
|
||||
if (!(player.getBase() instanceof OfflinePlayer))
|
||||
if (player.isOnline())
|
||||
{
|
||||
player.getTeleport().back();
|
||||
}
|
||||
|
@@ -20,8 +20,8 @@ public class Commandtop extends EssentialsCommand
|
||||
{
|
||||
final int topX = user.getLocation().getBlockX();
|
||||
final int topZ = user.getLocation().getBlockZ();
|
||||
final int topY = user.getWorld().getHighestBlockYAt(topX, topZ);
|
||||
user.getTeleport().teleport(new Location(user.getWorld(), user.getLocation().getX(), topY + 1, user.getLocation().getZ()), new Trade(this.getName(), ess), TeleportCause.COMMAND);
|
||||
final Location location = new Location(user.getWorld(), topX, user.getWorld().getMaxHeight(), topZ);
|
||||
user.getTeleport().teleport(location, new Trade(this.getName(), ess), TeleportCause.COMMAND);
|
||||
user.sendMessage(_("teleportTop"));
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user