mirror of
https://github.com/EssentialsX/Essentials.git
synced 2026-11-05 09:10:17 -05:00
Compare commits
1588
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
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 | ||
|
|
6ca1cdec4f | ||
|
|
86a1dda46c | ||
|
|
4326ce0d4a | ||
|
|
3ff1f4adbb | ||
|
|
492c4e8521 | ||
|
|
e3f3fe84ea | ||
|
|
6e2ac3b56e | ||
|
|
5c19e71858 | ||
|
|
a0103afde3 | ||
|
|
dbf30740fb | ||
|
|
92fa415848 | ||
|
|
2942ef40f3 | ||
|
|
3f02bcd702 | ||
|
|
fe050dd725 | ||
|
|
5b4966c888 | ||
|
|
e2abf05a27 | ||
|
|
8500542e93 | ||
|
|
d9e6f2975a | ||
|
|
2f1d9ad82c | ||
|
|
d8ac3587ac | ||
|
|
2c8aa20542 | ||
|
|
a2418a68d9 | ||
|
|
85c4fbdf4f | ||
|
|
dff8f541fe | ||
|
|
d0a5656fa4 | ||
|
|
bc76e87366 | ||
|
|
bf9a67a2e4 | ||
|
|
95885e46c9 | ||
|
|
5a7f38fa29 | ||
|
|
6a5fefb102 | ||
|
|
c47c008871 | ||
|
|
a31f5e219d | ||
|
|
9ee78bdaec | ||
|
|
735f9ce212 | ||
|
|
417148f5da | ||
|
|
8f0350570e | ||
|
|
27365d1f1b | ||
|
|
ebb3a77430 | ||
|
|
b3252168f6 | ||
|
|
e1abdbdd37 | ||
|
|
3deff2afe7 | ||
|
|
a85cbdd505 | ||
|
|
c6aa34076a | ||
|
|
92f83dfe73 | ||
|
|
00057eaca4 | ||
|
|
2f96c9763f | ||
|
|
137b60c5f2 | ||
|
|
292b7b0546 | ||
|
|
d1d31e9769 | ||
|
|
f7c6759433 | ||
|
|
5137502646 | ||
|
|
9ff8b69282 | ||
|
|
7f269187c5 | ||
|
|
6d34a2aa17 | ||
|
|
9b58b2b9c0 | ||
|
|
b4d91978c7 | ||
|
|
8aa260ee34 | ||
|
|
25976edc2b | ||
|
|
8e9094a3ef | ||
|
|
16bde87982 | ||
|
|
b8944d0b25 | ||
|
|
69209eeb2f | ||
|
|
746eb353a2 | ||
|
|
3708f2b3bb | ||
|
|
e563405a7d | ||
|
|
ae2cf3d95c | ||
|
|
270533652b | ||
|
|
324dd05c97 | ||
|
|
2a0c3eebbc | ||
|
|
e1660d47ba | ||
|
|
03d640260d | ||
|
|
da3a6af92d | ||
|
|
593cb8d56e | ||
|
|
f40f5f880b | ||
|
|
8390594682 | ||
|
|
a13740f638 | ||
|
|
5f19cbf17b | ||
|
|
145b0be2f3 | ||
|
|
1dab4f95dd | ||
|
|
f27b2290dc | ||
|
|
0ea41d9169 | ||
|
|
f93769dd1d | ||
|
|
125ea7c701 | ||
|
|
6e03ea7b7d | ||
|
|
9041596384 | ||
|
|
efda9beece | ||
|
|
4b61ac9043 | ||
|
|
72edfacfb8 | ||
|
|
aa88205d95 | ||
|
|
8d441a4cc7 | ||
|
|
766935871f | ||
|
|
f5d65371b2 | ||
|
|
662749be8b | ||
|
|
e46fe381b4 | ||
|
|
04a43eb5d0 | ||
|
|
792f70efa5 | ||
|
|
46298ae858 | ||
|
|
d08b1a5089 | ||
|
|
e015cad131 | ||
|
|
008f0d595f | ||
|
|
7ee3919175 | ||
|
|
2560bdca4a | ||
|
|
16d537bd6c | ||
|
|
5f04d1867c | ||
|
|
a10f6850e5 | ||
|
|
36bc1adf83 | ||
|
|
cd8cc63113 | ||
|
|
947bee98a0 | ||
|
|
9c052b5178 | ||
|
|
64af5b465d | ||
|
|
5c1d49fd0e | ||
|
|
79a13e97a2 | ||
|
|
89c41b0508 | ||
|
|
e7fd26ee64 | ||
|
|
8fc6684290 | ||
|
|
a66ffd8921 | ||
|
|
1f2c669eca | ||
|
|
1d5a09a03e | ||
|
|
4435121c84 | ||
|
|
813e66b4f2 | ||
|
|
26d63f3666 | ||
|
|
0fb07d4cc1 | ||
|
|
cd2f819c29 | ||
|
|
149ce7d74d | ||
|
|
c7c7e5e4ce | ||
|
|
f26cccb663 | ||
|
|
81ec87d893 | ||
|
|
91563e9dca | ||
|
|
359ea194b8 | ||
|
|
1a0b03db4d | ||
|
|
c860b1c668 | ||
|
|
c584d74852 | ||
|
|
6e82419c15 | ||
|
|
3f6b9586b4 | ||
|
|
29d4e09983 | ||
|
|
f61f80164d | ||
|
|
f0def90301 | ||
|
|
d0e5685ac0 | ||
|
|
856cef3286 | ||
|
|
d16fef9f7f | ||
|
|
43f1c0f89d | ||
|
|
256d202d50 | ||
|
|
4884bed117 | ||
|
|
3fdde2f764 | ||
|
|
390b17f0d8 | ||
|
|
fe9d5645f6 | ||
|
|
eb5c88ef08 | ||
|
|
6eea852b1d | ||
|
|
768c92e5bf | ||
|
|
2a478fe03d | ||
|
|
58057a771d | ||
|
|
4c485f3147 | ||
|
|
7726fd0081 | ||
|
|
9a568992f1 | ||
|
|
283dc9b3c1 | ||
|
|
3aba996e97 | ||
|
|
69847af08a | ||
|
|
debcf4714a | ||
|
|
4425d53664 | ||
|
|
791e8f2d14 | ||
|
|
ee5e015a63 | ||
|
|
5d4f22ad84 | ||
|
|
839ce3d526 | ||
|
|
31e80ba698 | ||
|
|
a2202439bb | ||
|
|
7c8c40c790 | ||
|
|
abd86347c7 | ||
|
|
5bb7d82fca | ||
|
|
cc06117210 | ||
|
|
5a092f0e99 | ||
|
|
98cd03ac57 | ||
|
|
8761feb93f | ||
|
|
cbd5b6c0f4 | ||
|
|
afe8ecd3df | ||
|
|
244673e1fb | ||
|
|
de40f7f556 | ||
|
|
ac77bbb0b4 | ||
|
|
fec3b61039 | ||
|
|
01530192cf | ||
|
|
64bc8d1133 | ||
|
|
815a9dcca2 | ||
|
|
58bebd851c | ||
|
|
867e66e774 | ||
|
|
9eaebadaaa | ||
|
|
8d29a2c578 | ||
|
|
2202448cee | ||
|
|
45ffeaffec | ||
|
|
79861b1f10 | ||
|
|
559400c606 | ||
|
|
5b195299ba | ||
|
|
759892078a | ||
|
|
505460349f | ||
|
|
f91b622646 | ||
|
|
70bd9bd1f3 | ||
|
|
32564fb4f7 | ||
|
|
af4dde2086 | ||
|
|
15ce04b539 | ||
|
|
907f6c6116 | ||
|
|
fc1ccda0fe | ||
|
|
d3dd8208ef | ||
|
|
a00f070400 | ||
|
|
faddbd09a4 | ||
|
|
dfa4ecbe4f | ||
|
|
40a9c28699 | ||
|
|
e37ab86c9b | ||
|
|
081491d0a1 | ||
|
|
f936cd5f27 | ||
|
|
46840a686d | ||
|
|
5f3d783e21 | ||
|
|
0e0b441168 | ||
|
|
aaf08150e6 | ||
|
|
50f215adda | ||
|
|
4b43453a74 | ||
|
|
3eff598791 | ||
|
|
a7b1c3d534 | ||
|
|
f8e1f02523 | ||
|
|
a63c116590 | ||
|
|
fad38170a8 | ||
|
|
aa5f819d7b | ||
|
|
f9905f9953 | ||
|
|
06c2453941 | ||
|
|
c0e903c1f3 | ||
|
|
f99867dd0a | ||
|
|
de12c5c6d1 | ||
|
|
95d5217f58 | ||
|
|
52b1017bda | ||
|
|
b102c5f3d8 | ||
|
|
8d0230d6a8 | ||
|
|
e379ac5d77 | ||
|
|
789a6b9540 | ||
|
|
221e1d3bb2 | ||
|
|
9410a25cce | ||
|
|
ae7d968f5c | ||
|
|
5002e7a6ad | ||
|
|
13a42d1937 | ||
|
|
46c99e5c6f | ||
|
|
02b25120e8 | ||
|
|
435219bab6 | ||
|
|
766f0a9f13 | ||
|
|
d60de76d87 | ||
|
|
324cd74826 | ||
|
|
e7ebc94a9e | ||
|
|
5c02346f85 | ||
|
|
5b539bf034 | ||
|
|
879d4913dc | ||
|
|
ef49d92c49 | ||
|
|
719539d63b | ||
|
|
fdd8fffbb3 | ||
|
|
67a3a55f5a | ||
|
|
e8eb1974b8 | ||
|
|
a82d8d1d44 | ||
|
|
9ca0e51dac | ||
|
|
10597cec2f | ||
|
|
b49a9ef165 | ||
|
|
d573671933 | ||
|
|
a0d66ce230 | ||
|
|
854fc05c5b | ||
|
|
b9077d91a5 | ||
|
|
ff13279e6c | ||
|
|
ce3a7c8719 | ||
|
|
9e1571a8e5 | ||
|
|
d2953c99ef | ||
|
|
72e187cd5c | ||
|
|
2851a4634c | ||
|
|
58237a796a | ||
|
|
5433a68502 | ||
|
|
a7097df231 | ||
|
|
51390a9698 | ||
|
|
019b49ef11 | ||
|
|
f3b278eac2 | ||
|
|
6fe8e603af | ||
|
|
6b06adfc23 | ||
|
|
2b919faa7b | ||
|
|
b2ffdc9774 | ||
|
|
e5aa7f496b | ||
|
|
cb89fe5358 | ||
|
|
ad60eb538e | ||
|
|
cbc744c85a | ||
|
|
6371a59819 | ||
|
|
20bc8840d6 | ||
|
|
f12e9f6dfb | ||
|
|
c8814bd70e | ||
|
|
8417c5e1f0 | ||
|
|
ec3586c08c | ||
|
|
d9c773270b | ||
|
|
dd84f5c331 | ||
|
|
2c2f956068 | ||
|
|
ba3ccf7a2c | ||
|
|
90f87804b1 | ||
|
|
ea21e402ec | ||
|
|
1066f7a478 | ||
|
|
1c03cdb4d0 | ||
|
|
6d3e1b862e | ||
|
|
d4c2443b5f | ||
|
|
8ce8764f6a | ||
|
|
343618642b | ||
|
|
1cb593dba3 | ||
|
|
85d743dce5 | ||
|
|
118b3638eb | ||
|
|
dc74239edc | ||
|
|
647eac32fc | ||
|
|
91be153474 | ||
|
|
b03a327f9b | ||
|
|
3b2403b686 | ||
|
|
16e3830f9e | ||
|
|
73ec9978fb | ||
|
|
055f11c89e | ||
|
|
1489203aca | ||
|
|
1f1b6aff54 | ||
|
|
8d4d8effa0 | ||
|
|
8591023ad5 | ||
|
|
42f4bba320 | ||
|
|
746c80b0d6 | ||
|
|
bbb47fe6d3 | ||
|
|
4c1c3e4852 | ||
|
|
3b0c604de0 | ||
|
|
7a80a36eab | ||
|
|
83a4431bd7 | ||
|
|
c0eec02f0a | ||
|
|
c97d069783 | ||
|
|
b0377498f7 | ||
|
|
00d44873ca | ||
|
|
2a8ccb43ae | ||
|
|
f006932639 | ||
|
|
2dc6f8c202 | ||
|
|
39851694ad | ||
|
|
737f7799fc | ||
|
|
8356624479 | ||
|
|
dde8595c51 | ||
|
|
909e5bd3f8 | ||
|
|
e6e1c7d160 | ||
|
|
a5f4ada85d | ||
|
|
4f8be31343 | ||
|
|
40220960f5 | ||
|
|
3c9f0db3d4 | ||
|
|
bd7bd86e62 | ||
|
|
5e2123c91e | ||
|
|
15d8ec6026 | ||
|
|
a8a9fc3dd6 | ||
|
|
1de4a40bf6 | ||
|
|
35f5578436 | ||
|
|
b8d60674cb | ||
|
|
a30a28265a | ||
|
|
f5344b65d3 | ||
|
|
37e5260cda | ||
|
|
e169e954ba | ||
|
|
5f0936cf44 | ||
|
|
aed160b5fc | ||
|
|
0b2a3fcf7f | ||
|
|
57a0ec9912 | ||
|
|
e5435f24db | ||
|
|
af7eae6201 | ||
|
|
60067964be | ||
|
|
cdbae1631d | ||
|
|
414d6b79e9 | ||
|
|
dd3b1e97b6 | ||
|
|
0c81a68c7b | ||
|
|
183343c388 | ||
|
|
a36b755248 | ||
|
|
1838dbc931 | ||
|
|
525fefc484 | ||
|
|
4bacdb327a | ||
|
|
19b8031933 | ||
|
|
91cdff955a | ||
|
|
8c06b13a77 | ||
|
|
7db7fd4136 | ||
|
|
99211fd407 | ||
|
|
5e24584bf7 | ||
|
|
3d839c2b21 | ||
|
|
9acc7db06f | ||
|
|
0354b8d019 | ||
|
|
eea7785b7f | ||
|
|
7268e1965d | ||
|
|
4614d6d0dd | ||
|
|
4a83d17fec | ||
|
|
e8d64aca5e | ||
|
|
e1e7a1cfdb | ||
|
|
b637e494c2 | ||
|
|
ccfc3b8d78 | ||
|
|
05c90af1ee | ||
|
|
6603d0997e | ||
|
|
0ed7f87ee0 | ||
|
|
aceda4c680 | ||
|
|
67be976d90 | ||
|
|
ec6baa3621 | ||
|
|
82f864a7f9 | ||
|
|
2a22c04688 | ||
|
|
1c6c460a09 | ||
|
|
c5251591de | ||
|
|
ccb4d3a7e8 | ||
|
|
d5db9d404a | ||
|
|
0c0c9573be | ||
|
|
76a8f794ef | ||
|
|
cbba3639b9 | ||
|
|
8791a8dbb7 | ||
|
|
098072517a | ||
|
|
b8f9a4b96f | ||
|
|
9c56b147ee | ||
|
|
41e8c4c7b8 | ||
|
|
a8a72da15e | ||
|
|
9b6c01d071 | ||
|
|
3c71ae4cd9 | ||
|
|
34edf34ba3 | ||
|
|
f250a107e4 | ||
|
|
d5c852b79d | ||
|
|
65776d6ed2 | ||
|
|
0234c55ce3 | ||
|
|
ee42030307 | ||
|
|
263a3fc80b | ||
|
|
a714e39bf4 | ||
|
|
68297b5cf8 | ||
|
|
ae4c10ced6 | ||
|
|
b5e9ad02ae | ||
|
|
c70700f7b8 | ||
|
|
b21b7b7e15 | ||
|
|
f9d14697b6 | ||
|
|
8ed4418d5f | ||
|
|
4ad19b6fad | ||
|
|
d4685d1d10 | ||
|
|
fa73394113 | ||
|
|
b25a8f059b | ||
|
|
0cb77d8a03 | ||
|
|
b41c3709ba | ||
|
|
24a6073488 | ||
|
|
3daf56c8be | ||
|
|
223028f306 | ||
|
|
7afbad3218 | ||
|
|
871c0e6b6a | ||
|
|
73d13f5748 | ||
|
|
03452bda68 | ||
|
|
613cb57fdb | ||
|
|
31b9e792bd | ||
|
|
cd8ef9361b | ||
|
|
eea381e714 | ||
|
|
5a9b573309 | ||
|
|
70c235d4f0 | ||
|
|
127681736d | ||
|
|
73a7a6a1dd | ||
|
|
dec7ea1926 | ||
|
|
94983c3ca7 | ||
|
|
32e43bf167 | ||
|
|
579bbc9f2c | ||
|
|
af456a73dd | ||
|
|
b35d5f30f9 | ||
|
|
8aaaed2ef8 | ||
|
|
e683ce5751 | ||
|
|
b0aaafd08d | ||
|
|
212442ab1c | ||
|
|
bf244fff80 | ||
|
|
2620e2ae08 | ||
|
|
d59e2834d1 | ||
|
|
63991cb38d | ||
|
|
94b70e1ee9 | ||
|
|
fd1c2824ce | ||
|
|
a5853baf4c | ||
|
|
90694b15cc | ||
|
|
5e4b7f85c8 | ||
|
|
b5bc83e714 | ||
|
|
220d68f375 | ||
|
|
e672de949c | ||
|
|
19f5a2340d | ||
|
|
1e4a54baca | ||
|
|
14cc499421 | ||
|
|
6633b39954 | ||
|
|
a886645afa | ||
|
|
8c478c76a5 | ||
|
|
293f2f7cd2 | ||
|
|
1f6b1f4a2c | ||
|
|
765ec51b32 | ||
|
|
c132a75c1a | ||
|
|
000d060ea6 | ||
|
|
317b0833ef | ||
|
|
f72762bcb2 | ||
|
|
4f8319bbb9 | ||
|
|
cd9ea163e4 | ||
|
|
fc00ff471d | ||
|
|
85ef892f0e | ||
|
|
2e0fb15952 | ||
|
|
11f02fb947 | ||
|
|
e5a8cd88f0 | ||
|
|
9987568ae8 | ||
|
|
a05f730e76 | ||
|
|
5655509c62 | ||
|
|
a9b77b3486 | ||
|
|
37bd9bc9b5 | ||
|
|
e54d73704e | ||
|
|
e5c77c1aeb | ||
|
|
edf0ab756c | ||
|
|
c96b14a34c | ||
|
|
3841648eba | ||
|
|
ffc1640308 | ||
|
|
0bbc1e540b | ||
|
|
2a98734d22 | ||
|
|
603d23659b | ||
|
|
7ecc3c25b0 | ||
|
|
41c03853ab | ||
|
|
adcffba7cf | ||
|
|
2a4c26ee69 | ||
|
|
8143154826 | ||
|
|
e271e60144 | ||
|
|
c5c29aef4e | ||
|
|
7b7d1f557f | ||
|
|
af5a86c48c | ||
|
|
022f7ab1d4 | ||
|
|
b9daf6aaa5 | ||
|
|
4be1797592 | ||
|
|
c0d046841f | ||
|
|
e4c3f7b115 | ||
|
|
f51b92c99e | ||
|
|
16be86953f | ||
|
|
eda827b244 | ||
|
|
27ee7efde5 | ||
|
|
cccebdd62e | ||
|
|
d2f3bf94ae | ||
|
|
f4e22a17db | ||
|
|
b619a54105 | ||
|
|
cd897890be | ||
|
|
437d3b41b8 | ||
|
|
1f527cdb9e | ||
|
|
90c9fe7e65 | ||
|
|
e9f942e802 | ||
|
|
f40260acef | ||
|
|
ab2e8f94f0 | ||
|
|
cf9ef46182 | ||
|
|
cc5062828a | ||
|
|
165d499ef3 | ||
|
|
1c7e0e5b9f | ||
|
|
f0c49019dd | ||
|
|
e7234e621d | ||
|
|
269947bdae | ||
|
|
4ac5551c6b | ||
|
|
05242a7e8f | ||
|
|
fd2ec22919 | ||
|
|
7618754b89 | ||
|
|
d8f7c82e2d | ||
|
|
fd4c82b0eb | ||
|
|
70d1c7d7d7 | ||
|
|
894d956ba1 | ||
|
|
52c2110a2b | ||
|
|
8890284b3e | ||
|
|
02cc1b9fe9 | ||
|
|
6d6a29a99d | ||
|
|
1d95f1c6d2 | ||
|
|
6e4bf932ec | ||
|
|
a9a8216f4d | ||
|
|
f98eb4a40d | ||
|
|
51920420ce | ||
|
|
d171cce45d | ||
|
|
5560ab4294 | ||
|
|
87ccd7bf46 | ||
|
|
d264c26310 | ||
|
|
e873ebd67d | ||
|
|
375636cd36 | ||
|
|
57f9bc06b0 | ||
|
|
97cae6c0cb | ||
|
|
1fd02b8a4a | ||
|
|
9734274ed1 | ||
|
|
3f2916967d | ||
|
|
0731de53b4 | ||
|
|
0f67d42c99 | ||
|
|
34ba8e89bc | ||
|
|
b1c6173995 | ||
|
|
dd87dcdd3d | ||
|
|
ffd7ba7d5f | ||
|
|
4ac03ef15a | ||
|
|
8daa0e7a9b | ||
|
|
982c3fef0d | ||
|
|
1757badf64 | ||
|
|
5196237c46 | ||
|
|
094a747db3 | ||
|
|
284f48f631 | ||
|
|
c2c889cab9 | ||
|
|
a2619a6e2b | ||
|
|
6e16e4724d | ||
|
|
9afcba4739 | ||
|
|
c05e8085ed | ||
|
|
6d86f40ca3 | ||
|
|
cc9e7130e8 | ||
|
|
809d18575d | ||
|
|
56b5a128f5 | ||
|
|
8915c29b31 | ||
|
|
819c8f3aa9 | ||
|
|
6c479fceed | ||
|
|
04de66bc8a | ||
|
|
32cc1b66a4 | ||
|
|
65a588ea20 | ||
|
|
e0a29ed6a0 | ||
|
|
fadfc490a7 | ||
|
|
fd7894caae | ||
|
|
8200fc2a98 | ||
|
|
4b6fc99a62 | ||
|
|
60b9d4fc80 | ||
|
|
7622c5c510 | ||
|
|
76f8cb96ca | ||
|
|
f6e56ce0f4 | ||
|
|
72596decba | ||
|
|
e8b8d26bdb | ||
|
|
d5cb9ab965 | ||
|
|
9914e187e2 | ||
|
|
36fa05f3a6 | ||
|
|
5641b1173c | ||
|
|
48f8eb9788 | ||
|
|
7f825750f0 | ||
|
|
102570958e | ||
|
|
38b6d79f49 | ||
|
|
d064c68875 | ||
|
|
2bb45022d6 | ||
|
|
dc2e23c85a | ||
|
|
5a54ef355f | ||
|
|
9af6bdb1d6 | ||
|
|
dca88382ab | ||
|
|
d4a495fb52 | ||
|
|
a4556e8cf0 | ||
|
|
c79bb03d5e | ||
|
|
9c793208ad | ||
|
|
b07b3fc373 | ||
|
|
ff92e0bf6f | ||
|
|
8854b3f565 | ||
|
|
6974abea28 | ||
|
|
9433acf689 | ||
|
|
11e8240c5c | ||
|
|
aa922c5b67 | ||
|
|
1a020698d1 | ||
|
|
022b8caa18 | ||
|
|
14c406f7fb | ||
|
|
4d877741d4 | ||
|
|
1cbd10a38e | ||
|
|
358456c8ea | ||
|
|
1c7dcfc63d | ||
|
|
82b225a261 | ||
|
|
6ab30159fa | ||
|
|
a86a1990cd | ||
|
|
625c7d0302 | ||
|
|
27a0552c2a | ||
|
|
7c5674c294 | ||
|
|
f5c442aa5c | ||
|
|
569af0bcf0 | ||
|
|
238748f360 | ||
|
|
e049364557 | ||
|
|
121966436e | ||
|
|
d3afd7a670 | ||
|
|
9d121af860 | ||
|
|
200ef0c8e2 | ||
|
|
6f77a2ba07 | ||
|
|
db97ce99ef | ||
|
|
e7b790861f | ||
|
|
d3aaf3c14a | ||
|
|
d732821e06 | ||
|
|
e628c36172 | ||
|
|
9312871250 | ||
|
|
860d446d28 | ||
|
|
03adb56d25 | ||
|
|
4aecc034c2 | ||
|
|
1543bfd550 | ||
|
|
a111a07bca | ||
|
|
9ec398b39b | ||
|
|
eb71097546 | ||
|
|
1bb3eb0d07 | ||
|
|
5395b6f73a | ||
|
|
5851c5a88b | ||
|
|
1c1726cfa4 | ||
|
|
a6bafca091 | ||
|
|
6877f95636 | ||
|
|
cb41b7ac33 | ||
|
|
d2fa4523ce | ||
|
|
9129386f12 | ||
|
|
c7fcb72d6c | ||
|
|
02ee314ab1 | ||
|
|
04af8ef329 | ||
|
|
a34c92d55a | ||
|
|
4cdf803ab7 | ||
|
|
6012086fa5 | ||
|
|
67c0f57756 | ||
|
|
164070b487 | ||
|
|
d658c75cec | ||
|
|
4c69412501 | ||
|
|
75a0164ea0 | ||
|
|
9dde04e4b8 | ||
|
|
3496df6468 | ||
|
|
ac794bb2b7 | ||
|
|
7384991efa | ||
|
|
f3dc846b1b | ||
|
|
4595c15bee | ||
|
|
81994160e8 | ||
|
|
cf59a90c52 | ||
|
|
a9a87710f3 | ||
|
|
5984cd5835 | ||
|
|
8fe0887141 | ||
|
|
8389a59d54 | ||
|
|
010245e1a5 | ||
|
|
1e3d2fbfd2 | ||
|
|
313df9988d | ||
|
|
16384159e7 | ||
|
|
06900e19f0 | ||
|
|
57c25bf151 | ||
|
|
55fc8bdd57 | ||
|
|
ae030b227a | ||
|
|
aaf25d8b9a | ||
|
|
0645d58594 | ||
|
|
11d22f95cc | ||
|
|
4f85751694 | ||
|
|
65a78a6ea9 | ||
|
|
9f52931191 | ||
|
|
93d0ab7906 | ||
|
|
6b0d0daa2e | ||
|
|
9718e654ac | ||
|
|
4d5121c21d | ||
|
|
531f40ceee | ||
|
|
b672d38db8 | ||
|
|
401498a4f7 | ||
|
|
acdad5c6ac | ||
|
|
1a0aa7970b | ||
|
|
579b30c8f7 | ||
|
|
c1fa543524 | ||
|
|
0297d22fac | ||
|
|
608ebfdb4a | ||
|
|
da337284e5 | ||
|
|
0aa9f79629 | ||
|
|
9f4d79a756 | ||
|
|
aa0935c64b | ||
|
|
16111b56ad | ||
|
|
4c0fc6e52f | ||
|
|
7668af15b0 | ||
|
|
3b9aa445e9 | ||
|
|
b2614e363b | ||
|
|
49e2c38289 | ||
|
|
3030093907 | ||
|
|
0e867df195 | ||
|
|
bfd6049913 | ||
|
|
d2c02569d0 | ||
|
|
1f6daa7424 | ||
|
|
30af6f36ce | ||
|
|
f712b56671 | ||
|
|
0462026f33 | ||
|
|
ea76161ba5 | ||
|
|
629dee3a91 | ||
|
|
f415924811 | ||
|
|
4172c563d0 | ||
|
|
ab67d0e232 | ||
|
|
5ea512817a | ||
|
|
d4c7ea1cd1 | ||
|
|
4edf1ad3f5 | ||
|
|
6224b07215 | ||
|
|
a5239ef601 | ||
|
|
458068ae87 | ||
|
|
44e920e441 | ||
|
|
f8450e39e3 | ||
|
|
c6e68f72ea | ||
|
|
4a52cd7c98 | ||
|
|
9d68261bac | ||
|
|
8bb50189bc | ||
|
|
eb665a059a | ||
|
|
f2407bcc31 | ||
|
|
a8cfbe1eab | ||
|
|
03b73072d9 | ||
|
|
48049f3870 | ||
|
|
d2c553652f | ||
|
|
3dc29be083 | ||
|
|
ee00fb77d0 | ||
|
|
d890418944 | ||
|
|
8e0560ae1a | ||
|
|
82e5447526 | ||
|
|
8b23f8608d | ||
|
|
0dd5134f5a | ||
|
|
a39a904c8a | ||
|
|
1d38b72835 | ||
|
|
efcab71969 | ||
|
|
41e11a738d | ||
|
|
62e1710607 | ||
|
|
c681befdf2 | ||
|
|
2db256678e | ||
|
|
a2ca381bbd | ||
|
|
32f5a31ea5 | ||
|
|
87dc671a0d | ||
|
|
621f9b4f48 | ||
|
|
3858e1cdd6 | ||
|
|
ff7cc5aec9 | ||
|
|
d18a47a643 | ||
|
|
497a08940e | ||
|
|
bd8fe521cd | ||
|
|
59c93901d3 | ||
|
|
3177f25eb6 | ||
|
|
b0fe189156 | ||
|
|
8103e822ed | ||
|
|
c597653ce2 | ||
|
|
d9ceb727ef | ||
|
|
2844af0039 | ||
|
|
066f3fd726 | ||
|
|
e9c0bb2133 | ||
|
|
f0acf733a5 | ||
|
|
33c6fc1f1f | ||
|
|
91b504cc66 | ||
|
|
6ea57bcd2f | ||
|
|
c92c066a3a | ||
|
|
caff3c115b | ||
|
|
517961b26a | ||
|
|
85f63d0afe | ||
|
|
ecc56351ec | ||
|
|
9b04705ec9 | ||
|
|
e786653364 | ||
|
|
e5613d43cc | ||
|
|
ce8f05cd94 | ||
|
|
e52a9c1f6b | ||
|
|
de744fe9e2 | ||
|
|
a0031d1d45 | ||
|
|
d60dd01f0f | ||
|
|
ad3bc2ad98 | ||
|
|
cf69a6d72c | ||
|
|
1a65a31a7e | ||
|
|
9c998eac2f | ||
|
|
2bdc00dc14 | ||
|
|
83e8dac6a0 | ||
|
|
3879d582d3 | ||
|
|
1fd5222d40 | ||
|
|
fe15bab05f | ||
|
|
f2dd51cf57 | ||
|
|
ac1f2badc7 | ||
|
|
d3f6e82474 | ||
|
|
676f941bb8 | ||
|
|
bd74bd1286 | ||
|
|
5831cde90e | ||
|
|
b2394048fa | ||
|
|
4811e46dd6 | ||
|
|
8d266a3440 | ||
|
|
f680fb1b76 | ||
|
|
a845f351f8 | ||
|
|
997a409b5a | ||
|
|
a6673c5157 | ||
|
|
5ef7135fc8 | ||
|
|
4c698762c3 | ||
|
|
82e389be8f | ||
|
|
1df79bc9f4 | ||
|
|
ab590af927 | ||
|
|
002e4a2772 | ||
|
|
0e9b971280 | ||
|
|
73b5fe971f | ||
|
|
6398626559 | ||
|
|
828f97c9a8 | ||
|
|
d6d4752383 | ||
|
|
d2bf35dac2 | ||
|
|
8d6e3e7c18 | ||
|
|
0b057d8e29 | ||
|
|
4c6cc5ced0 | ||
|
|
b828222176 | ||
|
|
bbab993ef1 | ||
|
|
b110ce79cc | ||
|
|
ab530f35d0 | ||
|
|
0654a76ccc | ||
|
|
e8fbdef38b | ||
|
|
96c4dd2ab9 | ||
|
|
998d097d7d | ||
|
|
df3b9a7ef9 | ||
|
|
fd6f768cca | ||
|
|
aa085de3e7 | ||
|
|
2e1c880502 | ||
|
|
e3756623a1 | ||
|
|
8f28073b29 | ||
|
|
e2024ca2b6 | ||
|
|
80491513a2 | ||
|
|
f67e13122d | ||
|
|
16e19a7775 | ||
|
|
a220b267d4 | ||
|
|
1153a0eee4 | ||
|
|
7d8b0c102c | ||
|
|
4abbbcb82b | ||
|
|
248e4e2ae2 | ||
|
|
fb211d722c | ||
|
|
1b3698283e | ||
|
|
cccddc3311 | ||
|
|
70a3a5919e | ||
|
|
fc7a3e091d | ||
|
|
f6b4daebb5 | ||
|
|
688d37ee60 | ||
|
|
382bd24046 | ||
|
|
e0d913dbaf | ||
|
|
bb1cad1bc1 | ||
|
|
d7af679243 | ||
|
|
c8f6ea7f8e | ||
|
|
d3dd4980a4 | ||
|
|
b140f606b4 | ||
|
|
057c9cb3f5 | ||
|
|
3dcf8bc8fc | ||
|
|
ecc1a0acea | ||
|
|
afb951461c | ||
|
|
e9a14b204f | ||
|
|
1cbdbc40a5 | ||
|
|
5d4aa95fc3 | ||
|
|
17e11adf9a | ||
|
|
3454db3e2b | ||
|
|
7039d613ee | ||
|
|
12e3eb1a23 | ||
|
|
a60f040f7e | ||
|
|
22c277f9ab | ||
|
|
fa423b3dd2 | ||
|
|
0c37e091c0 | ||
|
|
3dd3fa4519 | ||
|
|
b559809bfa | ||
|
|
59e45592cf | ||
|
|
1fb57cb678 | ||
|
|
fba4dd2d9a | ||
|
|
3ec0dbd404 | ||
|
|
5a5dc933ad | ||
|
|
6427a93d14 | ||
|
|
610a713997 | ||
|
|
347be03b25 | ||
|
|
322ecdb9fc | ||
|
|
033babd586 | ||
|
|
d3302dea00 | ||
|
|
8249a961f6 | ||
|
|
41344ce1b0 | ||
|
|
65be2dba99 | ||
|
|
087e600d6d | ||
|
|
f18c3c7e1d | ||
|
|
394a786044 | ||
|
|
14030deb16 | ||
|
|
0543a8f8ba | ||
|
|
34987d6e07 | ||
|
|
631583aef0 | ||
|
|
8998168ec2 | ||
|
|
00050d08d4 | ||
|
|
aa47499656 | ||
|
|
bc93bc6ae7 | ||
|
|
dfd283d998 | ||
|
|
016dd10060 | ||
|
|
8281908306 | ||
|
|
01861e5a64 | ||
|
|
3d913f9fcc | ||
|
|
6c738294d1 | ||
|
|
30f0f78efc | ||
|
|
8cc249c2d3 | ||
|
|
6946488e0d | ||
|
|
53a73998a2 | ||
|
|
f12a14d7f7 | ||
|
|
089c2210bd | ||
|
|
1a2fc307fd | ||
|
|
38aa85dd0c | ||
|
|
c374f474ed | ||
|
|
2a1b19a8a8 | ||
|
|
325889c466 | ||
|
|
216cc7f681 | ||
|
|
7df5098bf6 | ||
|
|
27adc21446 | ||
|
|
5de354af86 | ||
|
|
bb32ec9567 | ||
|
|
6ee7017603 | ||
|
|
9dc54340f8 | ||
|
|
0592c1fe11 | ||
|
|
90419cdbf5 | ||
|
|
91393e3180 | ||
|
|
dfdf49ac35 | ||
|
|
d2a3240905 | ||
|
|
1138e32292 | ||
|
|
256c963370 | ||
|
|
d818f705ad | ||
|
|
1ac033a60e | ||
|
|
af248a1d2e | ||
|
|
c0d21b6044 | ||
|
|
e10675dfdc | ||
|
|
7b8c2a4575 | ||
|
|
812a357361 | ||
|
|
ac20207ea1 | ||
|
|
43d7fb367b | ||
|
|
040e2bee86 | ||
|
|
6f88e7bb98 | ||
|
|
45f88016fc | ||
|
|
5a1ea77019 | ||
|
|
83fc7de01a | ||
|
|
d14f278ecf | ||
|
|
69b76b810c | ||
|
|
2c787e07ec | ||
|
|
3e9b27e3ef | ||
|
|
4bc3d5efad | ||
|
|
9791dcc0bc | ||
|
|
84068c18b1 | ||
|
|
a32b55e28f | ||
|
|
8d1262fc91 | ||
|
|
a2f727bebc | ||
|
|
7f1ba0d6ae | ||
|
|
2b48045a8f | ||
|
|
7e5b79aa14 | ||
|
|
a53d8ddef1 | ||
|
|
2690696712 | ||
|
|
086343ee48 | ||
|
|
c79ac59bc0 | ||
|
|
a1ad512a80 | ||
|
|
6a9865cd67 | ||
|
|
5d95d1fca6 | ||
|
|
2541efb682 | ||
|
|
8ff405f2fe | ||
|
|
376d206d2b | ||
|
|
6295127589 | ||
|
|
1c381fc203 | ||
|
|
b93d289176 | ||
|
|
a2fa666fd5 | ||
|
|
76eb00575b | ||
|
|
81d7be4f77 | ||
|
|
b776362be7 | ||
|
|
65df249510 | ||
|
|
6fa2b14d65 | ||
|
|
6ec674d0a3 | ||
|
|
93883cfc12 | ||
|
|
2e565f8881 | ||
|
|
b851cd10f2 | ||
|
|
576b48c08c | ||
|
|
5ca9927987 | ||
|
|
a753f322df | ||
|
|
300ee9c729 | ||
|
|
1fbed62c1d | ||
|
|
a21d80ecd8 | ||
|
|
1e7bf9a46c | ||
|
|
19595c5847 | ||
|
|
47c8217511 | ||
|
|
db50d455df | ||
|
|
ec5746dbe6 | ||
|
|
05ba5c00e6 | ||
|
|
bb2b504d7a | ||
|
|
5bb86309f6 | ||
|
|
abbeb0a212 | ||
|
|
d9d781a33a | ||
|
|
327c15c5be | ||
|
|
858e2a8b89 | ||
|
|
33d37a2f96 | ||
|
|
a8f6014a42 | ||
|
|
a117080b32 | ||
|
|
f75390bd3f | ||
|
|
b07ba21659 | ||
|
|
a109134b92 | ||
|
|
69d3921a6a | ||
|
|
ca3369938d | ||
|
|
fbd9ee9453 | ||
|
|
8185b05b5d | ||
|
|
b9fc6a0b2b | ||
|
|
62ebf3db41 | ||
|
|
a90b16be36 | ||
|
|
d07ecde47d | ||
|
|
5db35458e8 | ||
|
|
cf4752dad6 | ||
|
|
a085503c84 | ||
|
|
9a893f65fe | ||
|
|
cc273e919c | ||
|
|
65702ea0bf | ||
|
|
614b7b84f7 | ||
|
|
a04e0533d6 | ||
|
|
b85a5e9e0d | ||
|
|
bb6b2c9374 | ||
|
|
df47aad478 | ||
|
|
9eb73cf854 | ||
|
|
12777af61a | ||
|
|
acb50786c4 | ||
|
|
33f48eae0d | ||
|
|
7b18343e75 | ||
|
|
9bb2ef9cbe | ||
|
|
beb34a7651 | ||
|
|
0ac26265e2 | ||
|
|
d6dc6d1d39 | ||
|
|
0ab8a2760d | ||
|
|
8bb4067f06 | ||
|
|
fe1820134b | ||
|
|
7d7c686e6a | ||
|
|
0b681c3654 | ||
|
|
23eeb82ac4 | ||
|
|
edd6adc78f | ||
|
|
c9028623ac | ||
|
|
dd5bcb8762 | ||
|
|
bc1c252dca | ||
|
|
19ba6e5195 | ||
|
|
864e608582 | ||
|
|
b84785cc82 | ||
|
|
832910d480 | ||
|
|
164541794e | ||
|
|
13da2b2924 | ||
|
|
84ac520353 | ||
|
|
7aea9e71e8 | ||
|
|
5613975314 | ||
|
|
dc0ca35017 | ||
|
|
662d30ae45 | ||
|
|
4099755b9b | ||
|
|
57bee443b1 | ||
|
|
0f3c0e82f2 | ||
|
|
0e21d3287e | ||
|
|
3cedfeef2c | ||
|
|
a20f2b71da | ||
|
|
b2e3290038 | ||
|
|
979592c8ba | ||
|
|
7001798874 | ||
|
|
40a2bccf2d | ||
|
|
ee13d33b66 | ||
|
|
fdb46f60fd | ||
|
|
5027198010 | ||
|
|
90a5a4a470 | ||
|
|
85cab9533e | ||
|
|
304b13ca5e | ||
|
|
6a1c53dd01 | ||
|
|
d7b2ac97aa | ||
|
|
7b7289db4c | ||
|
|
ba2b827d7c | ||
|
|
621618e41f | ||
|
|
54559172c6 | ||
|
|
6ccb60813a | ||
|
|
2067bb8f0d | ||
|
|
b34119901e | ||
|
|
4f31d2779d | ||
|
|
ed29f29622 | ||
|
|
b8e41df0f6 | ||
|
|
602517473d | ||
|
|
cee0823db4 | ||
|
|
b317aef8c9 | ||
|
|
8b41219fcc | ||
|
|
61fa43a769 | ||
|
|
fdbc6fa94f | ||
|
|
28dd14d38c | ||
|
|
0ffe24903a | ||
|
|
f6e6e0042a | ||
|
|
e550a7cc44 | ||
|
|
9efc0840e3 | ||
|
|
82165a2af6 | ||
|
|
815b700eac | ||
|
|
fcda9f9d3b | ||
|
|
aa663c0c98 | ||
|
|
bda2f5e615 | ||
|
|
377f967dab | ||
|
|
63a4fe32c1 | ||
|
|
06dc9c25af | ||
|
|
feb1c53004 | ||
|
|
2530a5018f | ||
|
|
4bb1185bd5 | ||
|
|
d5c8d0c1bf | ||
|
|
8828fb0868 | ||
|
|
cc29ebbbc9 | ||
|
|
1c44a25a4a | ||
|
|
0483635a5c | ||
|
|
cf21ecee2e | ||
|
|
3b59dd0b02 | ||
|
|
5467e502a5 | ||
|
|
e805d1047f | ||
|
|
dc99efb0a7 | ||
|
|
6a156ede68 | ||
|
|
4a963b22f1 | ||
|
|
6af9ec266b | ||
|
|
150a0e0ddd | ||
|
|
d388290427 | ||
|
|
c8ba06f0ee | ||
|
|
a65390ed98 | ||
|
|
6b85b306ef | ||
|
|
faa7e0e7a9 | ||
|
|
fdbb6510ef | ||
|
|
aa3606007a | ||
|
|
d0bf1905a9 | ||
|
|
548666b79b | ||
|
|
6dbb5bc605 | ||
|
|
15687c20d0 | ||
|
|
81cc5b1f28 | ||
|
|
7aea8a3fce | ||
|
|
db5974970d | ||
|
|
d2bc7e01a2 | ||
|
|
3d232e13d9 | ||
|
|
83b71eef5e | ||
|
|
13e5f22c25 | ||
|
|
b88d0f88a1 | ||
|
|
d727cad2db | ||
|
|
fd1256b449 | ||
|
|
c3235b3694 | ||
|
|
c1c3005454 | ||
|
|
a3c71e4617 | ||
|
|
5aa2bc1706 | ||
|
|
277c623a77 | ||
|
|
e37db99c56 | ||
|
|
be83383fd5 | ||
|
|
033151a170 | ||
|
|
ba2539db67 | ||
|
|
e3a470e264 | ||
|
|
21d0661d79 | ||
|
|
1556801834 | ||
|
|
e0dc003464 | ||
|
|
81f0ad4d92 | ||
|
|
1ce6be5944 | ||
|
|
cc31fbed8e | ||
|
|
29a15dfe18 | ||
|
|
2f00865847 | ||
|
|
462fe18b15 | ||
|
|
31326d530f | ||
|
|
9f3eb461a9 | ||
|
|
48230f615d | ||
|
|
34b0deba29 | ||
|
|
088f50ce8a | ||
|
|
d9a93d8dff | ||
|
|
5ad12b52f8 | ||
|
|
747776344b | ||
|
|
f979a79081 | ||
|
|
e6685abe4d | ||
|
|
f867f675b9 | ||
|
|
d9bfabd652 | ||
|
|
d9b88a83d1 | ||
|
|
a8fdce257b | ||
|
|
c3a8958046 | ||
|
|
d0345e45b6 | ||
|
|
5ab3422b29 | ||
|
|
66c4a24852 | ||
|
|
db27a8c627 | ||
|
|
78c376af79 | ||
|
|
b749cd4e42 | ||
|
|
a0554f566d | ||
|
|
1696d7ae71 | ||
|
|
ad8ad8b574 | ||
|
|
3c28dabfad | ||
|
|
a38fe6acd4 | ||
|
|
f104c2e8f6 | ||
|
|
4dc92a144e | ||
|
|
1a7b198353 | ||
|
|
25c9557c59 | ||
|
|
963fd7cf01 | ||
|
|
d7080950b0 | ||
|
|
9c51f6e177 | ||
|
|
39352da929 | ||
|
|
ad65e66a7c | ||
|
|
132ddc323f | ||
|
|
411e96bb18 | ||
|
|
705f9c267c | ||
|
|
d2db6348d9 | ||
|
|
ae7275c7ad | ||
|
|
cecb9867d9 | ||
|
|
7e65038ae7 | ||
|
|
37d77f3e89 | ||
|
|
f4ef5a2094 | ||
|
|
af364b4bb4 | ||
|
|
cd4c58cfcb | ||
|
|
3898970bba | ||
|
|
fb8f89e6dc | ||
|
|
1b0b0b1b57 | ||
|
|
4c89ef5638 | ||
|
|
5478a47e25 | ||
|
|
48affa91b0 | ||
|
|
fa2f97760b | ||
|
|
557ca86ab2 | ||
|
|
b32d28be37 | ||
|
|
b9b5db8ccd | ||
|
|
7ec1ca651f | ||
|
|
8245adfd08 | ||
|
|
beea6879b1 | ||
|
|
e4ba0245be | ||
|
|
aefbf921fe | ||
|
|
8a1fb88ecd | ||
|
|
962b6848c4 | ||
|
|
2086b8c978 | ||
|
|
343291b210 | ||
|
|
7ed57bc291 | ||
|
|
367e9840cc | ||
|
|
ea590c2ed1 | ||
|
|
cb5ab32be6 | ||
|
|
244674124b | ||
|
|
39770cd46d | ||
|
|
f58fa10686 | ||
|
|
da8d5454d4 | ||
|
|
71c11d05fd | ||
|
|
dab37c7b5b | ||
|
|
ce14779d2b | ||
|
|
a447bc7e66 | ||
|
|
4d3e8332a8 | ||
|
|
367fcdd029 | ||
|
|
3b838cc23d | ||
|
|
f2d9b10e87 | ||
|
|
fc2c67ceda | ||
|
|
d02380edba | ||
|
|
3a1d0032c6 | ||
|
|
ef37306701 | ||
|
|
34568ea8fc | ||
|
|
56a2398d9b | ||
|
|
db03b3c09e | ||
|
|
b272374072 | ||
|
|
8afde1ccc0 | ||
|
|
674128b3f7 | ||
|
|
c2936186f8 | ||
|
|
5006c68af2 | ||
|
|
526df76ca9 | ||
|
|
e92aeee91b | ||
|
|
f2107047da | ||
|
|
f280985dd6 | ||
|
|
f610dd9c72 | ||
|
|
7e4cbd7b26 | ||
|
|
ffd1154ca3 | ||
|
|
7f4ba16388 | ||
|
|
66dafdca0d | ||
|
|
3a8b888e7c | ||
|
|
ed1aa2f9dc | ||
|
|
4eb94e7fac | ||
|
|
16b101b958 | ||
|
|
ff8564787a | ||
|
|
6616d9a62f | ||
|
|
ae053dea58 | ||
|
|
335c9f37ab | ||
|
|
914a44007d | ||
|
|
bbd10b90c0 | ||
|
|
d93120257b | ||
|
|
e763b362d9 | ||
|
|
5ae0ab745f | ||
|
|
e5eb1ca0cb | ||
|
|
ecaecc5e62 | ||
|
|
e596f85953 | ||
|
|
aef2ca3e5d | ||
|
|
bd7a50ad07 | ||
|
|
5346b112a4 | ||
|
|
d95d7745ad | ||
|
|
6c9a57d4b3 | ||
|
|
60235d0da4 | ||
|
|
995f18bb0f | ||
|
|
a720bf33ce | ||
|
|
ea2649db5e | ||
|
|
0f87670991 | ||
|
|
b53fc9cadc | ||
|
|
4b35e1b729 | ||
|
|
016defd043 | ||
|
|
2aa88d05cf | ||
|
|
c530030e5d | ||
|
|
48e0073b31 | ||
|
|
ce6d5596aa | ||
|
|
40e106db13 | ||
|
|
3dc0659f66 | ||
|
|
8f32d66e03 | ||
|
|
1c11ab0957 | ||
|
|
fafd9b20a9 | ||
|
|
a6d60dbc94 | ||
|
|
fa5d6fbfae | ||
|
|
88ded926f4 | ||
|
|
3b9a07e560 | ||
|
|
512a1b9183 | ||
|
|
e652ed2981 | ||
|
|
28db891aa5 | ||
|
|
b63ae9b771 | ||
|
|
fb834bf104 | ||
|
|
953ce38d63 | ||
|
|
ca29f18850 | ||
|
|
503b4fee55 | ||
|
|
27c84ceaac | ||
|
|
b7cb11cd95 | ||
|
|
cfa8b8e2f4 | ||
|
|
70621e3eff | ||
|
|
0731580cc9 | ||
|
|
8bb3a76366 | ||
|
|
d67ccd03ca | ||
|
|
5e2f4bcbb2 | ||
|
|
1331743ecf | ||
|
|
2b8d5a09a2 | ||
|
|
ed06b29dd7 | ||
|
|
209a9a2f95 | ||
|
|
d50d8bfee0 | ||
|
|
b0e606568f | ||
|
|
22ea5b0f8b | ||
|
|
6676efe029 | ||
|
|
6b360da8d8 | ||
|
|
198b205d83 | ||
|
|
b9e56d100c | ||
|
|
0a924bf226 | ||
|
|
2ea5e6c03b | ||
|
|
efaed85188 | ||
|
|
c378d98b0f | ||
|
|
9d6727daf2 | ||
|
|
ca9364d25b | ||
|
|
7fc6d73241 | ||
|
|
036bbbb462 | ||
|
|
c3a8a51ecd | ||
|
|
c6aa5f1e68 | ||
|
|
a16ced78a5 | ||
|
|
cdea68443a | ||
|
|
e24c053b95 | ||
|
|
798d4458d4 | ||
|
|
a228708138 | ||
|
|
5d8f5cecee | ||
|
|
34f650e270 | ||
|
|
49bdf5719e | ||
|
|
fd2d2456b9 | ||
|
|
adc7502115 | ||
|
|
631c7f30b6 | ||
|
|
46cba7a9a7 | ||
|
|
246383804a | ||
|
|
32bbe877aa | ||
|
|
0eee5acac7 | ||
|
|
7d112a957c | ||
|
|
76c06ce17a | ||
|
|
350a951e8b | ||
|
|
6cc742b139 | ||
|
|
ebc56c0e15 | ||
|
|
f0c503dd13 | ||
|
|
bfa8b26661 | ||
|
|
96b0f27c51 | ||
|
|
772bf4c7d0 | ||
|
|
edefb21142 | ||
|
|
01f69b3f2b | ||
|
|
26c9b34744 | ||
|
|
dfad01d558 | ||
|
|
b974410dd9 | ||
|
|
d01e2e0a3b | ||
|
|
5a544fd251 | ||
|
|
f5fac6f9f5 | ||
|
|
5d925aa338 | ||
|
|
8136179e55 | ||
|
|
dea44d7cbc | ||
|
|
e0597f2df1 | ||
|
|
99268b9d9e | ||
|
|
bcf81d9f0a | ||
|
|
775c8d34dd | ||
|
|
75973f69a5 | ||
|
|
f04b7133eb | ||
|
|
b1446154bf | ||
|
|
640f51564a | ||
|
|
5c258c03dc | ||
|
|
bc8aa0c77a | ||
|
|
cc18f95bc9 | ||
|
|
9e5c64ae9c | ||
|
|
7bbb62ce50 | ||
|
|
d8a81923b1 | ||
|
|
1321f8de5d | ||
|
|
4bfc8e1459 | ||
|
|
4f16c8b5a7 | ||
|
|
a45e620946 | ||
|
|
d877880171 | ||
|
|
a91aeb1a76 | ||
|
|
b7791caa75 | ||
|
|
6c862e72b5 | ||
|
|
710088fb13 | ||
|
|
198607d425 | ||
|
|
4bbc2aa8d5 | ||
|
|
c038751c0b | ||
|
|
f1b544a96f | ||
|
|
9a4ef7cd20 | ||
|
|
bc3d8d5ece | ||
|
|
1751baeed6 | ||
|
|
7b825cc8d5 | ||
|
|
a005436510 | ||
|
|
541fc51780 | ||
|
|
aef2dd35d6 | ||
|
|
e94a01b149 | ||
|
|
1a572bca2e | ||
|
|
5a47d18a9b | ||
|
|
991a5cb24c | ||
|
|
e8e97e86a0 | ||
|
|
f6cedda1e2 | ||
|
|
3dab3d8df8 | ||
|
|
3e359b5b48 | ||
|
|
09e17a4d6c | ||
|
|
651b89d97b | ||
|
|
0ff89abeee | ||
|
|
8ba3e3c2f9 | ||
|
|
e53ce03d36 | ||
|
|
aeb3b0f37c | ||
|
|
2d038579ba | ||
|
|
ba86a338c2 | ||
|
|
1bcc2e6e50 | ||
|
|
797dde94e1 | ||
|
|
b83bb1faa3 |
No files matched your search
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="lib/bukkit-0.0.1-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="lib/craftbukkit-0.0.1-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="lib/Permissions3.jar"/>
|
||||
</classpath>
|
||||
+18
-1
@@ -22,4 +22,21 @@
|
||||
/EssentialsXMPP/dist/
|
||||
/EssentialsXMPP/build/
|
||||
/EssentialsProtect/dist/
|
||||
/EssentialsProtect/build/
|
||||
/EssentialsProtect/build/
|
||||
/EssentialsPermissionsCommands/nbproject/private/
|
||||
/EssentialsPermissionsCommands/build/
|
||||
/EssentialsPermissionsCommands/dist/
|
||||
/Essentials/nbproject/private/
|
||||
/Essentials/dist/
|
||||
/Essentials/build/
|
||||
/YamlAnnotations/
|
||||
/EssentialsUpdate/nbproject/private/
|
||||
/EssentialsRelease/
|
||||
/EssentialsUpdate/dist/
|
||||
/EssentialsUpdate/build/
|
||||
/WebPush/apikey.php
|
||||
/WebPush/nbproject/private
|
||||
/.idea
|
||||
*.iml
|
||||
/EssentialsGroupManager/bin
|
||||
/EssentialsGroupManager/.externalToolBuilders
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Essentials</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -20,10 +20,10 @@ is divided into following sections:
|
||||
|
||||
-->
|
||||
<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="BuildAll-impl">
|
||||
<fail message="Please build using Ant 1.7.1 or higher.">
|
||||
<fail message="Please build using Ant 1.8.0 or higher.">
|
||||
<condition>
|
||||
<not>
|
||||
<antversion atleast="1.7.1"/>
|
||||
<antversion atleast="1.8.0"/>
|
||||
</not>
|
||||
</condition>
|
||||
</fail>
|
||||
@@ -223,6 +223,7 @@ is divided into following sections:
|
||||
<property name="javac.fork" value="${jdkBug6558476}"/>
|
||||
<property name="jar.index" value="false"/>
|
||||
<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"/>
|
||||
</target>
|
||||
<target name="-post-init">
|
||||
@@ -409,6 +410,7 @@ is divided into following sections:
|
||||
<property environment="env"/>
|
||||
<resolve name="profiler.current.path" value="${profiler.info.pathvar}"/>
|
||||
<java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}">
|
||||
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
|
||||
<jvmarg value="${profiler.info.jvmargs.agent}"/>
|
||||
<jvmarg line="${profiler.info.jvmargs}"/>
|
||||
<env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
|
||||
@@ -539,7 +541,7 @@ is divided into following sections:
|
||||
</chainedmapper>
|
||||
</pathconvert>
|
||||
<taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
|
||||
<copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
|
||||
<copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
<manifest>
|
||||
<attribute name="Class-Path" value="${jar.classpath}"/>
|
||||
@@ -650,6 +652,13 @@ is divided into following sections:
|
||||
<param name="call.target" value="jar"/>
|
||||
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
|
||||
</antcall>
|
||||
<antcall target="-maybe-call-dep">
|
||||
<param name="call.built.properties" value="${built-jar.properties}"/>
|
||||
<param location="${project.EssentialsXMPP}" name="call.subproject"/>
|
||||
<param location="${project.EssentialsXMPP}/build.xml" name="call.script"/>
|
||||
<param name="call.target" value="jar"/>
|
||||
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
|
||||
</antcall>
|
||||
</target>
|
||||
<target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
|
||||
<target depends="init" name="-check-automatic-build">
|
||||
@@ -913,16 +922,26 @@ is divided into following sections:
|
||||
-->
|
||||
<target depends="init" if="have.sources" name="-javadoc-build">
|
||||
<mkdir dir="${dist.javadoc.dir}"/>
|
||||
<condition else="" property="javadoc.endorsed.classpath.cmd.line.arg" value="-J${endorsed.classpath.cmd.line.arg}">
|
||||
<and>
|
||||
<isset property="endorsed.classpath.cmd.line.arg"/>
|
||||
<not>
|
||||
<equals arg1="${endorsed.classpath.cmd.line.arg}" arg2=""/>
|
||||
</not>
|
||||
</and>
|
||||
</condition>
|
||||
<javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
|
||||
<classpath>
|
||||
<path path="${javac.classpath}"/>
|
||||
</classpath>
|
||||
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
|
||||
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
|
||||
<filename name="**/*.java"/>
|
||||
</fileset>
|
||||
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
|
||||
<include name="**/*.java"/>
|
||||
<exclude name="*.java"/>
|
||||
</fileset>
|
||||
<arg line="${javadoc.endorsed.classpath.cmd.line.arg}"/>
|
||||
</javadoc>
|
||||
<copy todir="${dist.javadoc.dir}">
|
||||
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
|
||||
@@ -1135,6 +1154,13 @@ is divided into following sections:
|
||||
<param name="call.target" value="clean"/>
|
||||
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
|
||||
</antcall>
|
||||
<antcall target="-maybe-call-dep">
|
||||
<param name="call.built.properties" value="${built-clean.properties}"/>
|
||||
<param location="${project.EssentialsXMPP}" name="call.subproject"/>
|
||||
<param location="${project.EssentialsXMPP}/build.xml" name="call.script"/>
|
||||
<param name="call.target" value="clean"/>
|
||||
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
|
||||
</antcall>
|
||||
</target>
|
||||
<target depends="init" name="-do-clean">
|
||||
<delete dir="${build.dir}"/>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
build.xml.data.CRC32=c4188209
|
||||
build.xml.data.CRC32=51b33957
|
||||
build.xml.script.CRC32=7a797370
|
||||
build.xml.stylesheet.CRC32=28e38971@1.43.1.45
|
||||
build.xml.stylesheet.CRC32=28e38971@1.44.1.45
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=c4188209
|
||||
nbproject/build-impl.xml.script.CRC32=73a4865f
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45
|
||||
nbproject/build-impl.xml.data.CRC32=51b33957
|
||||
nbproject/build-impl.xml.script.CRC32=c5170bed
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46
|
||||
@@ -3,7 +3,42 @@ annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.run.all.processors=true
|
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||
application.title=BuildAll
|
||||
application.vendor=Paul
|
||||
application.vendor=
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAnnotationArgs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineArrayInit=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAssignment=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineBinaryOp=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineCallArgs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineDisjunctiveCatchTypes=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineFor=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineImplements=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineMethodParams=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineParenthesized=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTernaryOp=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineThrows=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTryResources=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesAfterClassHeader=0
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesBeforeClass=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width=4
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indentCasesFromSwitch=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeCatchOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeElseOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeFinallyOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeWhileOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceAfterTypeCast=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab=4
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size=4
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java,**/*.form
|
||||
# This directory is removed when the project is cleaned:
|
||||
@@ -27,27 +62,26 @@ dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
includes=**
|
||||
jar.compress=false
|
||||
jar.compress=true
|
||||
javac.classpath=\
|
||||
${reference.Essentials.jar}:\
|
||||
${reference.EssentialsChat.jar}:\
|
||||
${reference.EssentialsGroupBridge.jar}:\
|
||||
${reference.EssentialsGroupManager.jar}:\
|
||||
${reference.EssentialsProtect.jar}:\
|
||||
${reference.EssentialsSpawn.jar}:\
|
||||
${reference.EssentialsGeoIP.jar}
|
||||
${reference.EssentialsGeoIP.jar}:\
|
||||
${reference.EssentialsGroupBridge.jar}:\
|
||||
${reference.EssentialsXMPP.jar}:\
|
||||
${reference.EssentialsGroupManager.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.processorpath=\
|
||||
${javac.classpath}
|
||||
javac.source=1.5
|
||||
javac.target=1.5
|
||||
javac.source=1.6
|
||||
javac.target=1.6
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}:\
|
||||
${libs.junit.classpath}:\
|
||||
${libs.junit_4.classpath}
|
||||
${build.classes.dir}
|
||||
javac.test.processorpath=\
|
||||
${javac.test.classpath}
|
||||
javadoc.additionalparam=
|
||||
@@ -71,6 +105,7 @@ project.EssentialsGroupBridge=../EssentialsGroupBridge
|
||||
project.EssentialsGroupManager=../EssentialsGroupManager
|
||||
project.EssentialsProtect=../EssentialsProtect
|
||||
project.EssentialsSpawn=../EssentialsSpawn
|
||||
project.EssentialsXMPP=../EssentialsXMPP
|
||||
reference.Essentials.jar=${project.Essentials}/dist/Essentials.jar
|
||||
reference.EssentialsChat.jar=${project.EssentialsChat}/dist/EssentialsChat.jar
|
||||
reference.EssentialsGeoIP.jar=${project.EssentialsGeoIP}/dist/EssentialsGeoIP.jar
|
||||
@@ -78,6 +113,7 @@ reference.EssentialsGroupBridge.jar=${project.EssentialsGroupBridge}/dist/Essent
|
||||
reference.EssentialsGroupManager.jar=${project.EssentialsGroupManager}/dist/EssentialsGroupManager.jar
|
||||
reference.EssentialsProtect.jar=${project.EssentialsProtect}/dist/EssentialsProtect.jar
|
||||
reference.EssentialsSpawn.jar=${project.EssentialsSpawn}/dist/EssentialsSpawn.jar
|
||||
reference.EssentialsXMPP.jar=${project.EssentialsXMPP}/dist/EssentialsXMPP.jar
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
|
||||
@@ -71,6 +71,14 @@
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
<reference>
|
||||
<foreign-project>EssentialsXMPP</foreign-project>
|
||||
<artifact-type>jar</artifact-type>
|
||||
<script>build.xml</script>
|
||||
<target>jar</target>
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
</references>
|
||||
</configuration>
|
||||
</project>
|
||||
@@ -1,7 +0,0 @@
|
||||
# NetBeans cruft
|
||||
/build
|
||||
/dist
|
||||
/nbproject/private
|
||||
|
||||
# Mac cruft
|
||||
.DS_Store
|
||||
+84
-84
@@ -1,84 +1,84 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- You may freely edit this file. See commented blocks below for -->
|
||||
<!-- some examples of how to customize the build. -->
|
||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||
<!-- the Compile on Save feature is turned off for the project. -->
|
||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||
<!-- in the project's Project Properties dialog box.-->
|
||||
<project name="Essentials" default="default" basedir=".">
|
||||
|
||||
<description>Builds, tests, and runs the project Essentials.</description>
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
<!--
|
||||
|
||||
There exist several targets which are by default empty and which can be
|
||||
used for execution of your tasks. These targets are usually executed
|
||||
before and after some main targets. They are:
|
||||
|
||||
-pre-init: called before initialization of project properties
|
||||
-post-init: called after initialization of project properties
|
||||
-pre-compile: called before javac compilation
|
||||
-post-compile: called after javac compilation
|
||||
-pre-compile-single: called before javac compilation of single file
|
||||
-post-compile-single: called after javac compilation of single file
|
||||
-pre-compile-test: called before javac compilation of JUnit tests
|
||||
-post-compile-test: called after javac compilation of JUnit tests
|
||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||
-pre-jar: called before JAR building
|
||||
-post-jar: called after JAR building
|
||||
-post-clean: called after cleaning build products
|
||||
|
||||
(Targets beginning with '-' are not intended to be called on their own.)
|
||||
|
||||
Example of inserting an obfuscator after compilation could look like this:
|
||||
|
||||
<target name="-post-compile">
|
||||
<obfuscate>
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
</obfuscate>
|
||||
</target>
|
||||
|
||||
For list of available properties check the imported
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
|
||||
Another way to customize the build is by overriding existing main targets.
|
||||
The targets of interest are:
|
||||
|
||||
-init-macrodef-javac: defines macro for javac compilation
|
||||
-init-macrodef-junit: defines macro for junit execution
|
||||
-init-macrodef-debug: defines macro for class debugging
|
||||
-init-macrodef-java: defines macro for class execution
|
||||
-do-jar-with-manifest: JAR building (if you are using a manifest)
|
||||
-do-jar-without-manifest: JAR building (if you are not using a manifest)
|
||||
run: execution of project
|
||||
-javadoc-build: Javadoc generation
|
||||
test-report: JUnit report generation
|
||||
|
||||
An example of overriding the target for project execution could look like this:
|
||||
|
||||
<target name="run" depends="Essentials-impl.jar">
|
||||
<exec dir="bin" executable="launcher.exe">
|
||||
<arg file="${dist.jar}"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
Notice that the overridden target depends on the jar target and not only on
|
||||
the compile target as the regular run target does. Again, for a list of available
|
||||
properties which you can use, check the target you are overriding in the
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
-->
|
||||
<!--target name="-post-jar">
|
||||
<jar jarfile="${dist.dir}/Essentials.jar">
|
||||
<zipfileset src="${dist.jar}" excludes="META-INF/*" />
|
||||
<zipfileset src="${dist.dir}/lib/Register.jar" excludes="META-INF/*" />
|
||||
<manifest>
|
||||
<attribute name="Classpath" value="Essentials.jar"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target-->
|
||||
</project>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- You may freely edit this file. See commented blocks below for -->
|
||||
<!-- some examples of how to customize the build. -->
|
||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||
<!-- the Compile on Save feature is turned off for the project. -->
|
||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||
<!-- in the project's Project Properties dialog box.-->
|
||||
<project name="Essentials" default="default" basedir=".">
|
||||
|
||||
<description>Builds, tests, and runs the project Essentials.</description>
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
<!--
|
||||
|
||||
There exist several targets which are by default empty and which can be
|
||||
used for execution of your tasks. These targets are usually executed
|
||||
before and after some main targets. They are:
|
||||
|
||||
-pre-init: called before initialization of project properties
|
||||
-post-init: called after initialization of project properties
|
||||
-pre-compile: called before javac compilation
|
||||
-post-compile: called after javac compilation
|
||||
-pre-compile-single: called before javac compilation of single file
|
||||
-post-compile-single: called after javac compilation of single file
|
||||
-pre-compile-test: called before javac compilation of JUnit tests
|
||||
-post-compile-test: called after javac compilation of JUnit tests
|
||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||
-pre-jar: called before JAR building
|
||||
-post-jar: called after JAR building
|
||||
-post-clean: called after cleaning build products
|
||||
|
||||
(Targets beginning with '-' are not intended to be called on their own.)
|
||||
|
||||
Example of inserting an obfuscator after compilation could look like this:
|
||||
|
||||
<target name="-post-compile">
|
||||
<obfuscate>
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
</obfuscate>
|
||||
</target>
|
||||
|
||||
For list of available properties check the imported
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
|
||||
Another way to customize the build is by overriding existing main targets.
|
||||
The targets of interest are:
|
||||
|
||||
-init-macrodef-javac: defines macro for javac compilation
|
||||
-init-macrodef-junit: defines macro for junit execution
|
||||
-init-macrodef-debug: defines macro for class debugging
|
||||
-init-macrodef-java: defines macro for class execution
|
||||
-do-jar-with-manifest: JAR building (if you are using a manifest)
|
||||
-do-jar-without-manifest: JAR building (if you are not using a manifest)
|
||||
run: execution of project
|
||||
-javadoc-build: Javadoc generation
|
||||
test-report: JUnit report generation
|
||||
|
||||
An example of overriding the target for project execution could look like this:
|
||||
|
||||
<target name="run" depends="Essentials-impl.jar">
|
||||
<exec dir="bin" executable="launcher.exe">
|
||||
<arg file="${dist.jar}"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
Notice that the overridden target depends on the jar target and not only on
|
||||
the compile target as the regular run target does. Again, for a list of available
|
||||
properties which you can use, check the target you are overriding in the
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
-->
|
||||
<!--target name="-post-jar">
|
||||
<jar jarfile="${dist.dir}/Essentials.jar">
|
||||
<zipfileset src="${dist.jar}" excludes="META-INF/*" />
|
||||
<zipfileset src="${dist.dir}/lib/Register.jar" excludes="META-INF/*" />
|
||||
<manifest>
|
||||
<attribute name="Classpath" value="Essentials.jar"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target-->
|
||||
</project>
|
||||
@@ -20,10 +20,10 @@ is divided into following sections:
|
||||
|
||||
-->
|
||||
<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="Essentials-impl">
|
||||
<fail message="Please build using Ant 1.7.1 or higher.">
|
||||
<fail message="Please build using Ant 1.8.0 or higher.">
|
||||
<condition>
|
||||
<not>
|
||||
<antversion atleast="1.7.1"/>
|
||||
<antversion atleast="1.8.0"/>
|
||||
</not>
|
||||
</condition>
|
||||
</fail>
|
||||
@@ -223,6 +223,7 @@ is divided into following sections:
|
||||
<property name="javac.fork" value="${jdkBug6558476}"/>
|
||||
<property name="jar.index" value="false"/>
|
||||
<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"/>
|
||||
</target>
|
||||
<target name="-post-init">
|
||||
@@ -409,6 +410,7 @@ is divided into following sections:
|
||||
<property environment="env"/>
|
||||
<resolve name="profiler.current.path" value="${profiler.info.pathvar}"/>
|
||||
<java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}">
|
||||
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
|
||||
<jvmarg value="${profiler.info.jvmargs.agent}"/>
|
||||
<jvmarg line="${profiler.info.jvmargs}"/>
|
||||
<env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
|
||||
@@ -539,7 +541,7 @@ is divided into following sections:
|
||||
</chainedmapper>
|
||||
</pathconvert>
|
||||
<taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
|
||||
<copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
|
||||
<copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
<manifest>
|
||||
<attribute name="Class-Path" value="${jar.classpath}"/>
|
||||
@@ -601,6 +603,13 @@ is divided into following sections:
|
||||
<propertyfile file="${built-jar.properties}">
|
||||
<entry key="${basedir}" value=""/>
|
||||
</propertyfile>
|
||||
<antcall target="-maybe-call-dep">
|
||||
<param name="call.built.properties" value="${built-jar.properties}"/>
|
||||
<param location="${project.EssentialsGroupManager}" name="call.subproject"/>
|
||||
<param location="${project.EssentialsGroupManager}/build.xml" name="call.script"/>
|
||||
<param name="call.target" value="jar"/>
|
||||
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
|
||||
</antcall>
|
||||
</target>
|
||||
<target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
|
||||
<target depends="init" name="-check-automatic-build">
|
||||
@@ -864,16 +873,26 @@ is divided into following sections:
|
||||
-->
|
||||
<target depends="init" if="have.sources" name="-javadoc-build">
|
||||
<mkdir dir="${dist.javadoc.dir}"/>
|
||||
<condition else="" property="javadoc.endorsed.classpath.cmd.line.arg" value="-J${endorsed.classpath.cmd.line.arg}">
|
||||
<and>
|
||||
<isset property="endorsed.classpath.cmd.line.arg"/>
|
||||
<not>
|
||||
<equals arg1="${endorsed.classpath.cmd.line.arg}" arg2=""/>
|
||||
</not>
|
||||
</and>
|
||||
</condition>
|
||||
<javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
|
||||
<classpath>
|
||||
<path path="${javac.classpath}"/>
|
||||
</classpath>
|
||||
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
|
||||
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
|
||||
<filename name="**/*.java"/>
|
||||
</fileset>
|
||||
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
|
||||
<include name="**/*.java"/>
|
||||
<exclude name="*.java"/>
|
||||
</fileset>
|
||||
<arg line="${javadoc.endorsed.classpath.cmd.line.arg}"/>
|
||||
</javadoc>
|
||||
<copy todir="${dist.javadoc.dir}">
|
||||
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
|
||||
@@ -1037,6 +1056,13 @@ is divided into following sections:
|
||||
<propertyfile file="${built-clean.properties}">
|
||||
<entry key="${basedir}" value=""/>
|
||||
</propertyfile>
|
||||
<antcall target="-maybe-call-dep">
|
||||
<param name="call.built.properties" value="${built-clean.properties}"/>
|
||||
<param location="${project.EssentialsGroupManager}" name="call.subproject"/>
|
||||
<param location="${project.EssentialsGroupManager}/build.xml" name="call.script"/>
|
||||
<param name="call.target" value="clean"/>
|
||||
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
|
||||
</antcall>
|
||||
</target>
|
||||
<target depends="init" name="-do-clean">
|
||||
<delete dir="${build.dir}"/>
|
||||
|
||||
@@ -3,9 +3,9 @@ build.xml.script.CRC32=3233ee78
|
||||
build.xml.stylesheet.CRC32=28e38971@1.38.2.45
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=4b596d89
|
||||
nbproject/build-impl.xml.script.CRC32=4926001b
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45
|
||||
nbproject/build-impl.xml.data.CRC32=a830bc14
|
||||
nbproject/build-impl.xml.script.CRC32=a9f8842a
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46
|
||||
nbproject/profiler-build-impl.xml.data.CRC32=ab78ce15
|
||||
nbproject/profiler-build-impl.xml.script.CRC32=abda56ed
|
||||
nbproject/profiler-build-impl.xml.stylesheet.CRC32=f10cf54c@1.11.1
|
||||
@@ -1 +1,3 @@
|
||||
DoNotUseThreads
|
||||
LongVariable
|
||||
SignatureDeclareThrowsException
|
||||
@@ -1,9 +1,47 @@
|
||||
annotation.processing.enabled=true
|
||||
annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.run.all.processors=true
|
||||
annotation.processing.processors.list=lombok.core.AnnotationProcessor
|
||||
annotation.processing.run.all.processors=false
|
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||
application.title=Essentials
|
||||
application.vendor=Paul
|
||||
application.vendor=
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAnnotationArgs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineArrayInit=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAssignment=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineBinaryOp=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineCallArgs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineDisjunctiveCatchTypes=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineFor=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineImplements=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineMethodParams=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineParenthesized=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTernaryOp=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineThrows=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTryResources=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesAfterClassHeader=0
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesBeforeClass=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.importGroupsOrder=*
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width=4
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indentCasesFromSwitch=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeCatchOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeElseOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeFinallyOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeWhileOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.separateImportGroups=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceAfterTypeCast=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab=4
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size=4
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java,**/*.form
|
||||
# This directory is removed when the project is cleaned:
|
||||
@@ -26,31 +64,53 @@ dist.jar=${dist.dir}/Essentials.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.BOSEconomy.jar=../lib/BOSEconomy.jar
|
||||
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar
|
||||
file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar
|
||||
file.reference.bPermissions.jar=../lib/bPermissions.jar
|
||||
file.reference.bpermissions2.jar=../lib/bpermissions2.jar
|
||||
file.reference.bukkit.jar=../lib/bukkit.jar
|
||||
file.reference.craftbukkit.jar=../lib/craftbukkit.jar
|
||||
file.reference.iCo4.jar=../lib/iCo4.jar
|
||||
file.reference.iCo5.jar=../lib/iCo5.jar
|
||||
file.reference.junit-4.5.jar=..\\lib\\junit_4\\junit-4.5.jar
|
||||
file.reference.Permissions.jar=..\\lib\\Permissions.jar
|
||||
file.reference.iCo6.jar=../lib/iCo6.jar
|
||||
file.reference.lombok.jar=../lib/lombok-0.10.8.jar
|
||||
file.reference.MultiCurrency.jar=../lib/MultiCurrency.jar
|
||||
file.reference.Permissions3.jar=../lib/Permissions3.jar
|
||||
file.reference.PermissionsBukkit-1.2.jar=../lib/PermissionsBukkit-1.2.jar
|
||||
file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar
|
||||
file.reference.Privileges.jar=..\\lib\\Privileges.jar
|
||||
file.reference.Vault.jar=../lib/Vault.jar
|
||||
includes=**
|
||||
jar.compress=false
|
||||
jar.archive.disabled=${jnlp.enabled}
|
||||
jar.compress=true
|
||||
jar.index=${jnlp.enabled}
|
||||
javac.classpath=\
|
||||
${file.reference.Permissions.jar}:\
|
||||
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
|
||||
${file.reference.BOSEconomy.jar}:\
|
||||
${file.reference.Permissions3.jar}:\
|
||||
${file.reference.iCo4.jar}:\
|
||||
${file.reference.iCo5.jar}
|
||||
${file.reference.iCo5.jar}:\
|
||||
${file.reference.iCo6.jar}:\
|
||||
${file.reference.MultiCurrency.jar}:\
|
||||
${file.reference.BOSEconomy7.jar}:\
|
||||
${file.reference.PermissionsEx.jar}:\
|
||||
${file.reference.bPermissions.jar}:\
|
||||
${file.reference.PermissionsBukkit-1.2.jar}:\
|
||||
${file.reference.lombok.jar}:\
|
||||
${reference.EssentialsGroupManager.jar}:\
|
||||
${file.reference.bukkit.jar}:\
|
||||
${file.reference.craftbukkit.jar}:\
|
||||
${file.reference.Vault.jar}:\
|
||||
${file.reference.Privileges.jar}:\
|
||||
${file.reference.bpermissions2.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.processorpath=\
|
||||
${javac.classpath}
|
||||
javac.source=1.5
|
||||
javac.target=1.5
|
||||
javac.source=1.6
|
||||
javac.target=1.6
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}:\
|
||||
${file.reference.junit-4.5.jar}
|
||||
${libs.junit_4.10.classpath}
|
||||
javac.test.processorpath=\
|
||||
${javac.test.classpath}
|
||||
javadoc.additionalparam=
|
||||
@@ -60,13 +120,25 @@ javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
javadoc.private=false
|
||||
javadoc.reference.PermissionsEx.jar=../lib/PermissionsEx-javadoc.jar
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
jnlp.codebase.type=no.codebase
|
||||
jnlp.descriptor=application
|
||||
jnlp.enabled=false
|
||||
jnlp.mixed.code=default
|
||||
jnlp.offline-allowed=false
|
||||
jnlp.signed=false
|
||||
jnlp.signing=
|
||||
jnlp.signing.alias=
|
||||
jnlp.signing.keystore=
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
mkdist.disabled=false
|
||||
mkdist.disabled=true
|
||||
platform.active=default_platform
|
||||
project.EssentialsGroupManager=../EssentialsGroupManager
|
||||
reference.EssentialsGroupManager.jar=../EssentialsGroupManager/dist/EssentialsGroupManager.jar
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
|
||||
@@ -14,6 +14,15 @@
|
||||
<libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
|
||||
<definitions>../lib/nblibraries.properties</definitions>
|
||||
</libraries>
|
||||
<references xmlns="http://www.netbeans.org/ns/ant-project-references/1"/>
|
||||
<references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
|
||||
<reference>
|
||||
<foreign-project>EssentialsGroupManager</foreign-project>
|
||||
<artifact-type>jar</artifact-type>
|
||||
<script>build.xml</script>
|
||||
<target>jar</target>
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
</references>
|
||||
</configuration>
|
||||
</project>
|
||||
@@ -0,0 +1,137 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.PluginCommandYamlParser;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public class AlternativeCommandsHandler
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final transient Map<String, List<PluginCommand>> altcommands = new HashMap<String, List<PluginCommand>>();
|
||||
private final transient Map<String, String> disabledList = new HashMap<String, String>();
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public AlternativeCommandsHandler(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
for (Plugin plugin : ess.getServer().getPluginManager().getPlugins())
|
||||
{
|
||||
if (plugin.isEnabled())
|
||||
{
|
||||
addPlugin(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void addPlugin(final Plugin plugin)
|
||||
{
|
||||
if (plugin.getDescription().getMain().contains("com.earth2me.essentials"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final List<Command> commands = PluginCommandYamlParser.parse(plugin);
|
||||
final String pluginName = plugin.getDescription().getName().toLowerCase(Locale.ENGLISH);
|
||||
|
||||
for (Command command : commands)
|
||||
{
|
||||
final PluginCommand pc = (PluginCommand)command;
|
||||
final List<String> labels = new ArrayList<String>(pc.getAliases());
|
||||
labels.add(pc.getName());
|
||||
|
||||
PluginCommand reg = ess.getServer().getPluginCommand(pluginName + ":" + pc.getName().toLowerCase(Locale.ENGLISH));
|
||||
if (reg == null)
|
||||
{
|
||||
reg = ess.getServer().getPluginCommand(pc.getName().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
if (reg == null || !reg.getPlugin().equals(plugin))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (String label : labels)
|
||||
{
|
||||
List<PluginCommand> plugincommands = altcommands.get(label.toLowerCase(Locale.ENGLISH));
|
||||
if (plugincommands == null)
|
||||
{
|
||||
plugincommands = new ArrayList<PluginCommand>();
|
||||
altcommands.put(label.toLowerCase(Locale.ENGLISH), plugincommands);
|
||||
}
|
||||
boolean found = false;
|
||||
for (PluginCommand pc2 : plugincommands)
|
||||
{
|
||||
if (pc2.getPlugin().equals(plugin))
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
plugincommands.add(reg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removePlugin(final Plugin plugin)
|
||||
{
|
||||
final Iterator<Map.Entry<String, List<PluginCommand>>> iterator = altcommands.entrySet().iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
final Map.Entry<String, List<PluginCommand>> entry = iterator.next();
|
||||
final Iterator<PluginCommand> pcIterator = entry.getValue().iterator();
|
||||
while (pcIterator.hasNext())
|
||||
{
|
||||
final PluginCommand pc = pcIterator.next();
|
||||
if (pc.getPlugin() == null || pc.getPlugin().equals(plugin))
|
||||
{
|
||||
pcIterator.remove();
|
||||
}
|
||||
}
|
||||
if (entry.getValue().isEmpty())
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PluginCommand getAlternative(final String label)
|
||||
{
|
||||
final List<PluginCommand> commands = altcommands.get(label);
|
||||
if (commands == null || commands.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (commands.size() == 1)
|
||||
{
|
||||
return commands.get(0);
|
||||
}
|
||||
// return the first command that is not an alias
|
||||
for (PluginCommand command : commands)
|
||||
{
|
||||
if (command.getName().equalsIgnoreCase(label))
|
||||
{
|
||||
return command;
|
||||
}
|
||||
}
|
||||
// return the first alias
|
||||
return commands.get(0);
|
||||
}
|
||||
|
||||
public void executed(final String label, final String otherLabel)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials: Alternative command " + label + " found, using " + otherLabel);
|
||||
}
|
||||
disabledList.put(label, otherLabel);
|
||||
}
|
||||
|
||||
public Map<String, String> disabledCommands()
|
||||
{
|
||||
return disabledList;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,46 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
|
||||
public class Backup implements Runnable {
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private final CraftServer server;
|
||||
private final IEssentials ess;
|
||||
private boolean running = false;
|
||||
private int taskId = -1;
|
||||
private boolean active = false;
|
||||
|
||||
public Backup(IEssentials ess) {
|
||||
public class Backup implements Runnable
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient final Server server;
|
||||
private transient final IEssentials ess;
|
||||
private transient boolean running = false;
|
||||
private transient int taskId = -1;
|
||||
private transient boolean active = false;
|
||||
|
||||
public Backup(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
server = (CraftServer)ess.getServer();
|
||||
if (server.getOnlinePlayers().length > 0) {
|
||||
server = ess.getServer();
|
||||
if (server.getOnlinePlayers().length > 0)
|
||||
{
|
||||
startTask();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void onPlayerJoin() {
|
||||
void onPlayerJoin()
|
||||
{
|
||||
startTask();
|
||||
}
|
||||
|
||||
private void startTask() {
|
||||
if (!running) {
|
||||
long interval = ess.getSettings().getBackupInterval()*1200; // minutes -> ticks
|
||||
if (interval < 1200) {
|
||||
|
||||
private void startTask()
|
||||
{
|
||||
if (!running)
|
||||
{
|
||||
final long interval = ess.getSettings().getBackupInterval() * 1200; // minutes -> ticks
|
||||
if (interval < 1200)
|
||||
{
|
||||
return;
|
||||
}
|
||||
taskId = ess.scheduleSyncRepeatingTask(this, interval, interval);
|
||||
@@ -37,48 +48,87 @@ public class Backup implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if (active) return;
|
||||
active = true;
|
||||
final String command = ess.getSettings().getBackupCommand();
|
||||
if (command == null || "".equals(command)) {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
logger.log(Level.INFO, Util.i18n("backupStarted"));
|
||||
final CommandSender cs = server.getServer().console;
|
||||
active = true;
|
||||
final String command = ess.getSettings().getBackupCommand();
|
||||
if (command == null || "".equals(command))
|
||||
{
|
||||
return;
|
||||
}
|
||||
LOGGER.log(Level.INFO, _("backupStarted"));
|
||||
final CommandSender cs = server.getConsoleSender();
|
||||
server.dispatchCommand(cs, "save-all");
|
||||
server.dispatchCommand(cs, "save-off");
|
||||
|
||||
|
||||
ess.scheduleAsyncDelayedTask(
|
||||
new Runnable() {
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
Process child = Runtime.getRuntime().exec(command);
|
||||
child.waitFor();
|
||||
} catch (InterruptedException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
} catch (IOException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
} finally {
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable() {
|
||||
|
||||
public void run() {
|
||||
server.dispatchCommand(cs, "save-on");
|
||||
if (server.getOnlinePlayers().length == 0) {
|
||||
running = false;
|
||||
if (taskId != -1) {
|
||||
server.getScheduler().cancelTask(taskId);
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
final ProcessBuilder childBuilder = new ProcessBuilder(command);
|
||||
childBuilder.redirectErrorStream(true);
|
||||
childBuilder.directory(ess.getDataFolder().getParentFile().getParentFile());
|
||||
final Process child = childBuilder.start();
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(child.getInputStream()));
|
||||
try
|
||||
{
|
||||
child.waitFor();
|
||||
String line;
|
||||
do
|
||||
{
|
||||
line = reader.readLine();
|
||||
if (line != null)
|
||||
{
|
||||
LOGGER.log(Level.INFO, line);
|
||||
}
|
||||
}
|
||||
while (line != null);
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
active = false;
|
||||
logger.log(Level.INFO, Util.i18n("backupFinished"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
catch (InterruptedException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
server.dispatchCommand(cs, "save-on");
|
||||
if (server.getOnlinePlayers().length == 0)
|
||||
{
|
||||
running = false;
|
||||
if (taskId != -1)
|
||||
{
|
||||
server.getScheduler().cancelTask(taskId);
|
||||
}
|
||||
}
|
||||
active = false;
|
||||
LOGGER.log(Level.INFO, _("backupFinished"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Charge
|
||||
{
|
||||
private final String command;
|
||||
private final Double costs;
|
||||
private final ItemStack items;
|
||||
private final IEssentials ess;
|
||||
|
||||
public Charge(String command, IEssentials ess)
|
||||
{
|
||||
this(command, null, null, ess);
|
||||
}
|
||||
|
||||
public Charge(double money, IEssentials ess)
|
||||
{
|
||||
this(null, money, null, ess);
|
||||
}
|
||||
|
||||
public Charge(ItemStack items, IEssentials ess)
|
||||
{
|
||||
this(null, null, items, ess);
|
||||
}
|
||||
|
||||
private Charge(String command, Double money, ItemStack item, IEssentials ess)
|
||||
{
|
||||
this.command = command;
|
||||
this.costs = money;
|
||||
this.items = item;
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public void isAffordableFor(IUser user) throws Exception
|
||||
{
|
||||
double mon = user.getMoney();
|
||||
if (costs != null)
|
||||
{
|
||||
if (mon < costs && !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
}
|
||||
if (items != null)
|
||||
{
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, items))
|
||||
{
|
||||
throw new Exception(Util.format("missingItems", items.getAmount(), items.getType().toString().toLowerCase().replace("_", " ")));
|
||||
}
|
||||
}
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
if (user.isAuthorized("essentials.nocommandcost.all")
|
||||
|| user.isAuthorized("essentials.nocommandcost." + command))
|
||||
{
|
||||
return;
|
||||
}
|
||||
double cost = ess.getSettings().getCommandCost(command.startsWith("/") ? command.substring(1) : command);
|
||||
if (mon < cost && !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void charge(IUser user) throws Exception
|
||||
{
|
||||
double mon = user.getMoney();
|
||||
if (costs != null)
|
||||
{
|
||||
if (mon < costs && !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(costs);
|
||||
}
|
||||
if (items != null)
|
||||
{
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, items))
|
||||
{
|
||||
throw new Exception(Util.format("missingItems", items.getAmount(), items.getType().toString().toLowerCase().replace("_", " ")));
|
||||
}
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, items);
|
||||
user.updateInventory();
|
||||
}
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
if (user.isAuthorized("essentials.nocommandcost.all")
|
||||
|| user.isAuthorized("essentials.nocommandcost." + command))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
double cost = ess.getSettings().getCommandCost(command.startsWith("/") ? command.substring(1) : command);
|
||||
if (mon < cost && !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(cost);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
|
||||
public class ChargeException extends Exception
|
||||
{
|
||||
public ChargeException(final String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ChargeException(final String message, final Throwable throwable)
|
||||
{
|
||||
super(message, throwable);
|
||||
}
|
||||
}
|
||||
@@ -2,33 +2,37 @@ package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
|
||||
public final class Console implements IReplyTo {
|
||||
|
||||
public final class Console implements IReplyTo
|
||||
{
|
||||
private static Console instance = new Console();
|
||||
private CommandSender replyTo;
|
||||
public final static String NAME = "Console";
|
||||
|
||||
private Console() {
|
||||
|
||||
}
|
||||
|
||||
public static CommandSender getCommandSender(Server server) throws Exception {
|
||||
if (! (server instanceof CraftServer)) {
|
||||
throw new Exception(Util.i18n("invalidServer"));
|
||||
}
|
||||
return ((CraftServer)server).getServer().console;
|
||||
|
||||
private Console()
|
||||
{
|
||||
}
|
||||
|
||||
public void setReplyTo(CommandSender user) {
|
||||
public static CommandSender getCommandSender(Server server) throws Exception
|
||||
{
|
||||
return server.getConsoleSender();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReplyTo(CommandSender user)
|
||||
{
|
||||
replyTo = user;
|
||||
}
|
||||
|
||||
public CommandSender getReplyTo() {
|
||||
@Override
|
||||
public CommandSender getReplyTo()
|
||||
{
|
||||
return replyTo;
|
||||
}
|
||||
|
||||
public static Console getConsoleReplyTo() {
|
||||
|
||||
public static Console getConsoleReplyTo()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* This utility class is used for converting between the ingame
|
||||
* time in ticks to ingame time as a friendly string.
|
||||
* Note that the time is INGAME.
|
||||
*
|
||||
* http://www.minecraftwiki.net/wiki/Day/night_cycle
|
||||
*
|
||||
* @author Olof Larsson
|
||||
*/
|
||||
public final class DescParseTickFormat
|
||||
{
|
||||
// ============================================
|
||||
// First some information vars. TODO: Should this be in a config file?
|
||||
// --------------------------------------------
|
||||
public static final Map<String, Integer> nameToTicks = new LinkedHashMap<String, Integer>();
|
||||
public static final Set<String> resetAliases = new HashSet<String>();
|
||||
public static final int ticksAtMidnight = 18000;
|
||||
public static final int ticksPerDay = 24000;
|
||||
public static final int ticksPerHour = 1000;
|
||||
public static final double ticksPerMinute = 1000d / 60d;
|
||||
public static final double ticksPerSecond = 1000d / 60d / 60d;
|
||||
private static final SimpleDateFormat SDFTwentyFour = new SimpleDateFormat("HH:mm", Locale.ENGLISH);
|
||||
private static final SimpleDateFormat SDFTwelve = new SimpleDateFormat("h:mmaa", Locale.ENGLISH);
|
||||
|
||||
static
|
||||
{
|
||||
SDFTwentyFour.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
SDFTwelve.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
|
||||
nameToTicks.put("sunrise", 23000);
|
||||
nameToTicks.put("dawn", 23000);
|
||||
|
||||
nameToTicks.put("daystart", 0);
|
||||
nameToTicks.put("day", 0);
|
||||
|
||||
nameToTicks.put("morning", 1000);
|
||||
|
||||
nameToTicks.put("midday", 6000);
|
||||
nameToTicks.put("noon", 6000);
|
||||
|
||||
nameToTicks.put("afternoon", 9000);
|
||||
|
||||
nameToTicks.put("sunset", 12000);
|
||||
nameToTicks.put("dusk", 12000);
|
||||
nameToTicks.put("sundown", 12000);
|
||||
nameToTicks.put("nightfall", 12000);
|
||||
|
||||
nameToTicks.put("nightstart", 14000);
|
||||
nameToTicks.put("night", 14000);
|
||||
|
||||
nameToTicks.put("midnight", 18000);
|
||||
|
||||
resetAliases.add("reset");
|
||||
resetAliases.add("normal");
|
||||
resetAliases.add("default");
|
||||
}
|
||||
|
||||
private DescParseTickFormat()
|
||||
{
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// PARSE. From describing String to int
|
||||
// --------------------------------------------
|
||||
public static long parse(String desc) throws NumberFormatException
|
||||
{
|
||||
// Only look at alphanumeric and lowercase and : for 24:00
|
||||
desc = desc.toLowerCase(Locale.ENGLISH).replaceAll("[^A-Za-z0-9:]", "");
|
||||
|
||||
// Detect ticks format
|
||||
try
|
||||
{
|
||||
return parseTicks(desc);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
// Detect 24-hour format
|
||||
try
|
||||
{
|
||||
return parse24(desc);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
// Detect 12-hour format
|
||||
try
|
||||
{
|
||||
return parse12(desc);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
// Detect aliases
|
||||
try
|
||||
{
|
||||
return parseAlias(desc);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
// Well we failed to understand...
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
public static long parseTicks(String desc) throws NumberFormatException
|
||||
{
|
||||
if (!desc.matches("^[0-9]+ti?c?k?s?$"))
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
desc = desc.replaceAll("[^0-9]", "");
|
||||
|
||||
return Long.parseLong(desc) % 24000;
|
||||
}
|
||||
|
||||
public static long parse24(String desc) throws NumberFormatException
|
||||
{
|
||||
if (!desc.matches("^[0-9]{2}[^0-9]?[0-9]{2}$"))
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
desc = desc.toLowerCase(Locale.ENGLISH).replaceAll("[^0-9]", "");
|
||||
|
||||
if (desc.length() != 4)
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
final int hours = Integer.parseInt(desc.substring(0, 2));
|
||||
final int minutes = Integer.parseInt(desc.substring(2, 4));
|
||||
|
||||
return hoursMinutesToTicks(hours, minutes);
|
||||
}
|
||||
|
||||
public static long parse12(String desc) throws NumberFormatException
|
||||
{
|
||||
if (!desc.matches("^[0-9]{1,2}([^0-9]?[0-9]{2})?(pm|am)$"))
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
int hours = 0;
|
||||
int minutes = 0;
|
||||
|
||||
desc = desc.toLowerCase(Locale.ENGLISH).replaceAll("[^0-9]", "");
|
||||
|
||||
if (desc.length() > 4)
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
if (desc.length() == 4)
|
||||
{
|
||||
hours += Integer.parseInt(desc.substring(0, 2));
|
||||
minutes += Integer.parseInt(desc.substring(2, 4));
|
||||
}
|
||||
else if (desc.length() == 3)
|
||||
{
|
||||
hours += Integer.parseInt(desc.substring(0, 1));
|
||||
minutes += Integer.parseInt(desc.substring(1, 3));
|
||||
}
|
||||
else if (desc.length() == 2)
|
||||
{
|
||||
hours += Integer.parseInt(desc.substring(0, 2));
|
||||
}
|
||||
else if (desc.length() == 1)
|
||||
{
|
||||
hours += Integer.parseInt(desc.substring(0, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
if (desc.endsWith("pm") && hours != 12)
|
||||
{
|
||||
hours += 12;
|
||||
}
|
||||
|
||||
if (desc.endsWith("am") && hours == 12)
|
||||
{
|
||||
hours -= 12;
|
||||
}
|
||||
|
||||
return hoursMinutesToTicks(hours, minutes);
|
||||
}
|
||||
|
||||
public static long hoursMinutesToTicks(final int hours, final int minutes)
|
||||
{
|
||||
long ret = ticksAtMidnight;
|
||||
ret += (hours) * ticksPerHour;
|
||||
|
||||
ret += (minutes / 60.0) * ticksPerHour;
|
||||
|
||||
ret %= ticksPerDay;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static long parseAlias(final String desc) throws NumberFormatException
|
||||
{
|
||||
final Integer ret = nameToTicks.get(desc);
|
||||
if (ret == null)
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static boolean meansReset(final String desc)
|
||||
{
|
||||
return resetAliases.contains(desc);
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// FORMAT. From int to describing String
|
||||
// --------------------------------------------
|
||||
public static String format(final long ticks)
|
||||
{
|
||||
return _("timeFormat", format24(ticks), format12(ticks), formatTicks(ticks));
|
||||
}
|
||||
|
||||
public static String formatTicks(final long ticks)
|
||||
{
|
||||
return (ticks % ticksPerDay) + "ticks";
|
||||
}
|
||||
|
||||
public static String format24(final long ticks)
|
||||
{
|
||||
synchronized (SDFTwentyFour)
|
||||
{
|
||||
return formatDateFormat(ticks, SDFTwentyFour);
|
||||
}
|
||||
}
|
||||
|
||||
public static String format12(final long ticks)
|
||||
{
|
||||
synchronized (SDFTwelve)
|
||||
{
|
||||
return formatDateFormat(ticks, SDFTwelve);
|
||||
}
|
||||
}
|
||||
|
||||
public static String formatDateFormat(final long ticks, final SimpleDateFormat format)
|
||||
{
|
||||
final Date date = ticksToDate(ticks);
|
||||
return format.format(date);
|
||||
}
|
||||
|
||||
public static Date ticksToDate(long ticks)
|
||||
{
|
||||
// Assume the server time starts at 0. It would start on a day.
|
||||
// But we will simulate that the server started with 0 at midnight.
|
||||
ticks = ticks - ticksAtMidnight + ticksPerDay;
|
||||
|
||||
// How many ingame days have passed since the server start?
|
||||
final long days = ticks / ticksPerDay;
|
||||
ticks = ticks - days * ticksPerDay;
|
||||
|
||||
// How many hours on the last day?
|
||||
final long hours = ticks / ticksPerHour;
|
||||
ticks = ticks - hours * ticksPerHour;
|
||||
|
||||
// How many minutes on the last day?
|
||||
final long minutes = (long)Math.floor(ticks / ticksPerMinute);
|
||||
final double dticks = ticks - minutes * ticksPerMinute;
|
||||
|
||||
// How many seconds on the last day?
|
||||
final long seconds = (long)Math.floor(dticks / ticksPerSecond);
|
||||
|
||||
// Now we create an english GMT calendar (We wan't no daylight savings)
|
||||
final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.ENGLISH);
|
||||
cal.setLenient(true);
|
||||
|
||||
// And we set the time to 0! And append the time that passed!
|
||||
cal.set(0, Calendar.JANUARY, 1, 0, 0, 0);
|
||||
cal.add(Calendar.DAY_OF_YEAR, (int)days);
|
||||
cal.add(Calendar.HOUR_OF_DAY, (int)hours);
|
||||
cal.add(Calendar.MINUTE, (int)minutes);
|
||||
cal.add(Calendar.SECOND, (int)seconds + 1); // To solve rounding errors.
|
||||
|
||||
return cal.getTime();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
|
||||
public class Enchantments
|
||||
{
|
||||
private static final transient Pattern NUMPATTERN = Pattern.compile("\\d+");
|
||||
private static final Map<String, Enchantment> ENCHANTMENTS = new HashMap<String, Enchantment>();
|
||||
|
||||
static
|
||||
{
|
||||
ENCHANTMENTS.put("alldamage", Enchantment.DAMAGE_ALL);
|
||||
ENCHANTMENTS.put("alldmg", Enchantment.DAMAGE_ALL);
|
||||
ENCHANTMENTS.put("sharpness", Enchantment.DAMAGE_ALL);
|
||||
ENCHANTMENTS.put("arthropodsdamage", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ENCHANTMENTS.put("ardmg", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ENCHANTMENTS.put("baneofarthropods", 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("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("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("protection", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
ENCHANTMENTS.put("prot", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
ENCHANTMENTS.put("explosionsprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ENCHANTMENTS.put("expprot", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ENCHANTMENTS.put("blastprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ENCHANTMENTS.put("fallprotection", Enchantment.PROTECTION_FALL);
|
||||
ENCHANTMENTS.put("fallprot", Enchantment.PROTECTION_FALL);
|
||||
ENCHANTMENTS.put("featherfalling", Enchantment.PROTECTION_FALL);
|
||||
ENCHANTMENTS.put("fireprotection", Enchantment.PROTECTION_FIRE);
|
||||
ENCHANTMENTS.put("fireprot", Enchantment.PROTECTION_FIRE);
|
||||
ENCHANTMENTS.put("projectileprotection", Enchantment.PROTECTION_PROJECTILE);
|
||||
ENCHANTMENTS.put("projprot", Enchantment.PROTECTION_PROJECTILE);
|
||||
ENCHANTMENTS.put("silktouch", Enchantment.SILK_TOUCH);
|
||||
ENCHANTMENTS.put("waterworker", Enchantment.WATER_WORKER);
|
||||
ENCHANTMENTS.put("aquaaffinity", Enchantment.WATER_WORKER);
|
||||
ENCHANTMENTS.put("firearrow", Enchantment.ARROW_FIRE);
|
||||
ENCHANTMENTS.put("arrowdamage", Enchantment.ARROW_DAMAGE);
|
||||
ENCHANTMENTS.put("arrowknockback", Enchantment.ARROW_KNOCKBACK);
|
||||
ENCHANTMENTS.put("arrowkb", Enchantment.ARROW_KNOCKBACK);
|
||||
ENCHANTMENTS.put("infinitearrows", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("infarrows", Enchantment.ARROW_INFINITE);
|
||||
}
|
||||
|
||||
public static Enchantment getByName(String name) {
|
||||
Enchantment enchantment;
|
||||
if (NUMPATTERN.matcher(name).matches()) {
|
||||
enchantment = Enchantment.getById(Integer.parseInt(name));
|
||||
} else {
|
||||
enchantment = Enchantment.getByName(name.toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
if (enchantment == null)
|
||||
{
|
||||
enchantment = ENCHANTMENTS.get(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
return enchantment;
|
||||
}
|
||||
|
||||
public static Set<Entry<String, Enchantment>> entrySet()
|
||||
{
|
||||
return ENCHANTMENTS.entrySet();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,388 +1,50 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.craftbukkit.block.CraftSign;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class EssentialsBlockListener extends BlockListener
|
||||
public class EssentialsBlockListener implements Listener
|
||||
{
|
||||
private final IEssentials ess;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
public final static List<Material> protectedBlocks = new ArrayList<Material>(4);
|
||||
private final transient IEssentials ess;
|
||||
|
||||
static
|
||||
{
|
||||
protectedBlocks.add(Material.CHEST);
|
||||
protectedBlocks.add(Material.BURNING_FURNACE);
|
||||
protectedBlocks.add(Material.FURNACE);
|
||||
protectedBlocks.add(Material.DISPENSER);
|
||||
}
|
||||
|
||||
public EssentialsBlockListener(IEssentials ess)
|
||||
public EssentialsBlockListener(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onBlockPlace(final BlockPlaceEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
if (ess.getSettings().areSignsDisabled()) return;
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
if (protectedBlocks.contains(event.getBlock().getType()) && !user.isAuthorized("essentials.signs.protection.override"))
|
||||
if (event.isCancelled())
|
||||
{
|
||||
if (isBlockProtected(event.getBlock(), user))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
user.sendMessage(Util.format("noDestroyPermission", event.getBlock().getType().toString().toLowerCase()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkProtectionSign(event.getBlock(), user) != NOSIGN &&
|
||||
checkProtectionSign(event.getBlock(), user) != OWNER)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
user.sendMessage(Util.format("noDestroyPermission", event.getBlock().getType().toString().toLowerCase()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSignChange(SignChangeEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
if (ess.getSettings().areSignsDisabled()) return;
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
String username = user.getName().substring(0, user.getName().length() > 14 ? 14 : user.getName().length());
|
||||
|
||||
try
|
||||
{
|
||||
if (event.getLine(0).equalsIgnoreCase("[Protection]"))
|
||||
{
|
||||
Block block = event.getBlock();
|
||||
if (user.isAuthorized("essentials.signs.protection.create") && hasAdjacentChest(block) && !isBlockProtected(block, user))
|
||||
event.setLine(0, "§1[Protection]");
|
||||
else
|
||||
event.setLine(0, "§4[Protection]");
|
||||
event.setLine(3, username);
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Disposal]"))
|
||||
{
|
||||
if (user.isAuthorized("essentials.signs.disposal.create"))
|
||||
event.setLine(0, "§1[Disposal]");
|
||||
else
|
||||
event.setLine(0, "§4[Disposal]");
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Heal]"))
|
||||
{
|
||||
event.setLine(0, "§4[Heal]");
|
||||
if (user.isAuthorized("essentials.signs.heal.create"))
|
||||
{
|
||||
if (!event.getLine(1).isEmpty())
|
||||
{
|
||||
String[] l1 = event.getLine(1).split("[ :-]+", 2);
|
||||
boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
if (q1 < 1 || (!m1 && (int)q1 < 1)) throw new Exception(Util.i18n("moreThanZero"));
|
||||
if (!m1) ItemDb.get(l1[1]);
|
||||
event.setLine(1, (m1 ? Util.formatCurrency(q1) : (int)q1 + " " + l1[1]));
|
||||
}
|
||||
event.setLine(0, "§1[Heal]");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Free]"))
|
||||
{
|
||||
event.setLine(0, "§4[Free]");
|
||||
ItemDb.get(event.getLine(1));
|
||||
if (user.isAuthorized("essentials.signs.free.create"))
|
||||
event.setLine(0, "§1[Free]");
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Mail]"))
|
||||
{
|
||||
if (user.isAuthorized("essentials.signs.mail.create"))
|
||||
event.setLine(0, "§1[Mail]");
|
||||
else
|
||||
event.setLine(0, "§4[Mail]");
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Balance]"))
|
||||
{
|
||||
if (user.isAuthorized("essentials.signs.balance.create"))
|
||||
event.setLine(0, "§1[Balance]");
|
||||
else
|
||||
event.setLine(0, "§4[Balance]");
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Warp]"))
|
||||
{
|
||||
event.setLine(0, "§4[Warp]");
|
||||
if (user.isAuthorized("essentials.signs.warp.create")) {
|
||||
if (!event.getLine(3).isEmpty())
|
||||
{
|
||||
String[] l1 = event.getLine(3).split("[ :-]+", 2);
|
||||
boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
|
||||
if (!m1 && l1.length != 2)
|
||||
{
|
||||
throw new Exception(Util.format("invalidSignLine", 4));
|
||||
}
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
if ((int)q1 < 1) throw new Exception(Util.i18n("moreThanZero"));
|
||||
if (!m1) ItemDb.get(l1[1]);
|
||||
event.setLine(3, (m1 ? Util.formatCurrency(q1) : (int)q1 + " " + l1[1]));
|
||||
}
|
||||
if (event.getLine(1).isEmpty()) {
|
||||
event.setLine(1, "§dWarp name!");
|
||||
return;
|
||||
} else {
|
||||
ess.getWarps().getWarp(event.getLine(1));
|
||||
if (event.getLine(2).equalsIgnoreCase("Everyone")) {
|
||||
event.setLine(2, "§2Everyone");
|
||||
}
|
||||
event.setLine(0, "§1[Warp]");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
Block signBlock = event.getBlockAgainst();
|
||||
if (signBlock.getType() == Material.WALL_SIGN || signBlock.getType() == Material.SIGN_POST)
|
||||
{
|
||||
Sign sign = new CraftSign(signBlock);
|
||||
if (sign.getLine(0).matches("§1\\[[a-zA-Z]+\\]"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
// Do not rely on getItemInHand();
|
||||
// http://leaky.bukkit.org/issues/663
|
||||
final ItemStack is = new ItemStack(event.getBlockPlaced().getType(), 1, (short)0, event.getBlockPlaced().getData());
|
||||
switch(is.getType()) {
|
||||
case WOODEN_DOOR:
|
||||
is.setType(Material.WOOD_DOOR);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case IRON_DOOR_BLOCK:
|
||||
is.setType(Material.IRON_DOOR);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case SIGN_POST:
|
||||
case WALL_SIGN:
|
||||
is.setType(Material.SIGN);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case CROPS:
|
||||
is.setType(Material.SEEDS);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case CAKE_BLOCK:
|
||||
is.setType(Material.CAKE);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case BED_BLOCK:
|
||||
is.setType(Material.BED);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case REDSTONE_WIRE:
|
||||
is.setType(Material.REDSTONE);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case REDSTONE_TORCH_OFF:
|
||||
case REDSTONE_TORCH_ON:
|
||||
is.setType(Material.REDSTONE_TORCH_ON);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case DIODE_BLOCK_OFF:
|
||||
case DIODE_BLOCK_ON:
|
||||
is.setType(Material.DIODE);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case DOUBLE_STEP:
|
||||
is.setType(Material.STEP);
|
||||
break;
|
||||
case TORCH:
|
||||
case RAILS:
|
||||
case LADDER:
|
||||
case WOOD_STAIRS:
|
||||
case COBBLESTONE_STAIRS:
|
||||
case LEVER:
|
||||
case STONE_BUTTON:
|
||||
case FURNACE:
|
||||
case DISPENSER:
|
||||
case PUMPKIN:
|
||||
case JACK_O_LANTERN:
|
||||
case WOOD_PLATE:
|
||||
case STONE_PLATE:
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
final ItemStack is = Util.convertBlockToItem(event.getBlockPlaced());
|
||||
if (is == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
boolean unlimitedForUser = user.hasUnlimited(is);
|
||||
if (unlimitedForUser) {
|
||||
final boolean unlimitedForUser = user.hasUnlimited(is);
|
||||
if (unlimitedForUser && user.getGameMode() == GameMode.SURVIVAL)
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable() {
|
||||
|
||||
public void run() {
|
||||
user.getInventory().addItem(is);
|
||||
user.updateInventory();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasAdjacentChest(Block block)
|
||||
{
|
||||
Block[] faces = getAdjacentBlocks(block);
|
||||
for (Block b : faces)
|
||||
{
|
||||
if (protectedBlocks.contains(b.getType()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private static final int NOT_ALLOWED = 0;
|
||||
private static final int ALLOWED = 1;
|
||||
private static final int NOSIGN = 2;
|
||||
private static final int OWNER = 3;
|
||||
|
||||
private int checkProtectionSign(Block block, User user)
|
||||
{
|
||||
String username = user.getName().substring(0, user.getName().length() > 14 ? 14 : user.getName().length());
|
||||
if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)
|
||||
{
|
||||
Sign sign = new CraftSign(block);
|
||||
if (sign.getLine(0).equalsIgnoreCase("§1[Protection]") && !user.isAuthorized("essentials.signs.protection.override"))
|
||||
{
|
||||
for (int i = 1; i <= 2; i++) {
|
||||
String line = sign.getLine(i);
|
||||
if (line.startsWith("(") && line.endsWith(")")) {
|
||||
line = line.substring(1, line.length() - 1);
|
||||
if (user.inGroup(line)) {
|
||||
return ALLOWED;
|
||||
}
|
||||
} else if (line.equalsIgnoreCase(username)) {
|
||||
return ALLOWED;
|
||||
}
|
||||
}
|
||||
if (sign.getLine(3).equalsIgnoreCase(username))
|
||||
{
|
||||
return OWNER;
|
||||
}
|
||||
return NOT_ALLOWED;
|
||||
}
|
||||
}
|
||||
return NOSIGN;
|
||||
}
|
||||
|
||||
private static Block[] getAdjacentBlocks(Block block)
|
||||
{
|
||||
return new Block[]
|
||||
{
|
||||
block.getFace(BlockFace.NORTH),
|
||||
block.getFace(BlockFace.SOUTH),
|
||||
block.getFace(BlockFace.EAST),
|
||||
block.getFace(BlockFace.WEST),
|
||||
block.getFace(BlockFace.DOWN),
|
||||
block.getFace(BlockFace.UP)
|
||||
};
|
||||
}
|
||||
|
||||
public boolean isBlockProtected(Block block, User user)
|
||||
{
|
||||
Block[] faces = getAdjacentBlocks(block);
|
||||
boolean protect = false;
|
||||
for (Block b : faces)
|
||||
{
|
||||
int check = checkProtectionSign(b, user);
|
||||
if (check == NOT_ALLOWED)
|
||||
{
|
||||
protect = true;
|
||||
}
|
||||
if (check == ALLOWED || check == OWNER)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (protectedBlocks.contains(b.getType()))
|
||||
{
|
||||
Block[] faceChest = getAdjacentBlocks(b);
|
||||
|
||||
for (Block a : faceChest)
|
||||
{
|
||||
check = checkProtectionSign(a, user);
|
||||
if (check == NOT_ALLOWED)
|
||||
new Runnable()
|
||||
{
|
||||
protect = true;
|
||||
}
|
||||
if (check == ALLOWED || check == OWNER)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return protect;
|
||||
}
|
||||
|
||||
public static boolean isBlockProtected(Block block)
|
||||
{
|
||||
Block[] faces = getAdjacentBlocks(block);
|
||||
for (Block b : faces)
|
||||
{
|
||||
if (b.getType() == Material.SIGN_POST || b.getType() == Material.WALL_SIGN)
|
||||
{
|
||||
Sign sign = new CraftSign(b);
|
||||
if (sign.getLine(0).equalsIgnoreCase("§1[Protection]"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (protectedBlocks.contains(b.getType()))
|
||||
{
|
||||
Block[] faceChest = getAdjacentBlocks(b);
|
||||
|
||||
for (Block a : faceChest)
|
||||
{
|
||||
if (a.getType() == Material.SIGN_POST || a.getType() == Material.WALL_SIGN)
|
||||
{
|
||||
Sign sign = new CraftSign(a);
|
||||
if (sign.getLine(0).equalsIgnoreCase("§1[Protection]"))
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
return true;
|
||||
user.getInventory().addItem(is);
|
||||
user.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -13,28 +11,26 @@ 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 File configFile;
|
||||
private String templateName = null;
|
||||
private Class<?> resourceClass = EssentialsConf.class;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient File configFile;
|
||||
private transient String templateName = null;
|
||||
private transient Class<?> resourceClass = EssentialsConf.class;
|
||||
|
||||
public EssentialsConf(File configFile)
|
||||
public EssentialsConf(final File configFile)
|
||||
{
|
||||
super(configFile);
|
||||
super();
|
||||
this.configFile = configFile;
|
||||
if (this.root == null)
|
||||
{
|
||||
this.root = new HashMap<String, Object>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
{
|
||||
configFile = configFile.getAbsoluteFile();
|
||||
@@ -42,36 +38,87 @@ public class EssentialsConf extends Configuration
|
||||
{
|
||||
if (!configFile.getParentFile().mkdirs())
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
|
||||
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()));
|
||||
}
|
||||
}
|
||||
// This will delete files where the first character is 0. In most cases they are broken.
|
||||
if (configFile.exists() && configFile.length() != 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
final InputStream input = new FileInputStream(configFile);
|
||||
try
|
||||
{
|
||||
if (input.read() == 0)
|
||||
{
|
||||
input.close();
|
||||
configFile.delete();
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
input.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (!configFile.exists())
|
||||
{
|
||||
if (templateName != null)
|
||||
{
|
||||
logger.log(Level.INFO, Util.format("creatingConfigFromTemplate", configFile.toString()));
|
||||
LOGGER.log(Level.INFO, _("creatingConfigFromTemplate", configFile.toString()));
|
||||
createFromTemplate();
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.log(Level.INFO, Util.format("creatingEmptyConfig", configFile.toString()));
|
||||
LOGGER.log(Level.INFO, _("creatingEmptyConfig", configFile.toString()));
|
||||
if (!configFile.createNewFile())
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
|
||||
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()));
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()), ex);
|
||||
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.load();
|
||||
if (this.root == null)
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
this.root = new HashMap<String, Object>();
|
||||
super.load(configFile);
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
catch (InvalidConfigurationException ex)
|
||||
{
|
||||
File broken = new File(configFile.getAbsolutePath() + ".broken." + System.currentTimeMillis());
|
||||
configFile.renameTo(broken);
|
||||
LOGGER.log(Level.SEVERE, "The file " + configFile.toString() + " is broken, it has been renamed to " + broken.toString(), ex.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +131,7 @@ public class EssentialsConf extends Configuration
|
||||
istr = resourceClass.getResourceAsStream(templateName);
|
||||
if (istr == null)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("couldNotFindTemplate", templateName));
|
||||
LOGGER.log(Level.SEVERE, _("couldNotFindTemplate", templateName));
|
||||
return;
|
||||
}
|
||||
ostr = new FileOutputStream(configFile);
|
||||
@@ -99,8 +146,7 @@ public class EssentialsConf extends Configuration
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("failedToWriteConfig", configFile.toString()), ex);
|
||||
return;
|
||||
LOGGER.log(Level.SEVERE, _("failedToWriteConfig", configFile.toString()), ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -124,12 +170,12 @@ public class EssentialsConf extends Configuration
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("failedToCloseConfig", configFile.toString()), ex);
|
||||
LOGGER.log(Level.SEVERE, _("failedToCloseConfig", configFile.toString()), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTemplateName(String templateName)
|
||||
public void setTemplateName(final String templateName)
|
||||
{
|
||||
this.templateName = templateName;
|
||||
}
|
||||
@@ -139,101 +185,143 @@ public class EssentialsConf extends Configuration
|
||||
return configFile;
|
||||
}
|
||||
|
||||
public void setTemplateName(String templateName, Class<?> resClass)
|
||||
public void setTemplateName(final String templateName, final Class<?> resClass)
|
||||
{
|
||||
this.templateName = templateName;
|
||||
this.resourceClass = resClass;
|
||||
}
|
||||
|
||||
public boolean hasProperty(String path)
|
||||
public boolean hasProperty(final String path)
|
||||
{
|
||||
return getProperty(path) != null;
|
||||
return isSet(path);
|
||||
}
|
||||
|
||||
public Location getLocation(String path, Server server)
|
||||
public Location getLocation(final String path, final Server server) throws Exception
|
||||
{
|
||||
String worldName = getString((path != null ? path + "." : "") + "world");
|
||||
final String worldName = getString((path == null ? "" : path + ".") + "world");
|
||||
if (worldName == null || worldName.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
World world = server.getWorld(worldName);
|
||||
final World world = server.getWorld(worldName);
|
||||
if (world == null)
|
||||
{
|
||||
return null;
|
||||
throw new Exception(_("invalidWorld"));
|
||||
}
|
||||
return new Location(world,
|
||||
getDouble((path != null ? path + "." : "") + "x", 0),
|
||||
getDouble((path != null ? path + "." : "") + "y", 0),
|
||||
getDouble((path != null ? path + "." : "") + "z", 0),
|
||||
(float)getDouble((path != null ? path + "." : "") + "yaw", 0),
|
||||
(float)getDouble((path != null ? path + "." : "") + "pitch", 0));
|
||||
getDouble((path == null ? "" : path + ".") + "x", 0),
|
||||
getDouble((path == null ? "" : path + ".") + "y", 0),
|
||||
getDouble((path == null ? "" : path + ".") + "z", 0),
|
||||
(float)getDouble((path == null ? "" : path + ".") + "yaw", 0),
|
||||
(float)getDouble((path == null ? "" : path + ".") + "pitch", 0));
|
||||
}
|
||||
|
||||
public void setProperty(String path, Location loc)
|
||||
public void setProperty(final String path, final Location loc)
|
||||
{
|
||||
setProperty((path != null ? path + "." : "") + "world", loc.getWorld().getName());
|
||||
setProperty((path != null ? path + "." : "") + "x", loc.getX());
|
||||
setProperty((path != null ? path + "." : "") + "y", loc.getY());
|
||||
setProperty((path != null ? path + "." : "") + "z", loc.getZ());
|
||||
setProperty((path != null ? path + "." : "") + "yaw", loc.getYaw());
|
||||
setProperty((path != null ? path + "." : "") + "pitch", loc.getPitch());
|
||||
}
|
||||
|
||||
public ItemStack getItemStack(String path)
|
||||
{
|
||||
return new ItemStack(
|
||||
Material.valueOf(getString(path + ".type", "AIR")),
|
||||
getInt(path + ".amount", 1),
|
||||
(short)getInt(path + ".damage", 0)/*,
|
||||
(byte)getInt(path + ".data", 0)*/);
|
||||
}
|
||||
|
||||
public void setProperty(String path, ItemStack stack)
|
||||
{
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("type", stack.getType().toString());
|
||||
map.put("amount", stack.getAmount());
|
||||
map.put("damage", stack.getDurability());
|
||||
// getData().getData() is broken
|
||||
//map.put("data", stack.getDurability());
|
||||
setProperty(path, map);
|
||||
}
|
||||
|
||||
public long getLong(String path, long def)
|
||||
{
|
||||
Number num;
|
||||
try
|
||||
{
|
||||
num = (Number)getProperty(path);
|
||||
}
|
||||
catch(ClassCastException ex)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
if (num == null)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
return num.longValue();
|
||||
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 double getDouble(String path, double def)
|
||||
public ItemStack getItemStack(final String path)
|
||||
{
|
||||
final ItemStack stack = new ItemStack(
|
||||
Material.valueOf(getString(path + ".type", "AIR")),
|
||||
getInt(path + ".amount", 1),
|
||||
(short)getInt(path + ".damage", 0));
|
||||
final ConfigurationSection enchants = getConfigurationSection(path + ".enchant");
|
||||
if (enchants != null)
|
||||
{
|
||||
for (String enchant : enchants.getKeys(false))
|
||||
{
|
||||
final Enchantment enchantment = Enchantment.getByName(enchant.toUpperCase(Locale.ENGLISH));
|
||||
if (enchantment == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final int level = getInt(path + ".enchant." + enchant, enchantment.getStartLevel());
|
||||
stack.addUnsafeEnchantment(enchantment, level);
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
/*
|
||||
* ,
|
||||
* (byte)getInt(path + ".data", 0)
|
||||
*/
|
||||
}
|
||||
|
||||
public void setProperty(final String path, final ItemStack stack)
|
||||
{
|
||||
final Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("type", stack.getType().toString());
|
||||
map.put("amount", stack.getAmount());
|
||||
map.put("damage", stack.getDurability());
|
||||
Map<Enchantment, Integer> enchantments = stack.getEnchantments();
|
||||
if (!enchantments.isEmpty())
|
||||
{
|
||||
Map<String, Integer> enchant = new HashMap<String, Integer>();
|
||||
for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet())
|
||||
{
|
||||
enchant.put(entry.getKey().getName().toLowerCase(Locale.ENGLISH), entry.getValue());
|
||||
}
|
||||
map.put("enchant", enchant);
|
||||
}
|
||||
// getData().getData() is broken
|
||||
//map.put("data", stack.getDurability());
|
||||
set(path, map);
|
||||
}
|
||||
|
||||
public long getLong(final String path, final long def)
|
||||
{
|
||||
Number num;
|
||||
try
|
||||
{
|
||||
num = (Number)getProperty(path);
|
||||
final Number num = (Number)get(path);
|
||||
return num == null ? def : num.longValue();
|
||||
}
|
||||
catch(ClassCastException ex)
|
||||
catch (ClassCastException ex)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
if (num == null)
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(final String path, final double def)
|
||||
{
|
||||
try
|
||||
{
|
||||
Number num = (Number)get(path);
|
||||
return num == null ? def : num.doubleValue();
|
||||
}
|
||||
catch (ClassCastException ex)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
return num.doubleValue();
|
||||
}
|
||||
|
||||
public void save() {
|
||||
try
|
||||
{
|
||||
save(configFile);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1,250 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.craftbukkit.block.CraftSign;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class EssentialsEcoBlockListener extends BlockListener
|
||||
{
|
||||
private final IEssentials ess;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
public EssentialsEcoBlockListener(Essentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ess.getSettings().areSignsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
String username = user.getName().substring(0, user.getName().length() > 13 ? 13 : user.getName().length());
|
||||
if (event.getBlock().getType() != Material.WALL_SIGN && event.getBlock().getType() != Material.SIGN_POST)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Sign sign = new CraftSign(event.getBlock());
|
||||
|
||||
if (sign.getLine(0).equals("§1[Trade]"))
|
||||
{
|
||||
if (!sign.getLine(3).substring(2).equals(username))
|
||||
{
|
||||
if (!user.isOp())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
String[] l1 = sign.getLines()[1].split("[ :-]+");
|
||||
String[] l2 = sign.getLines()[2].split("[ :-]+");
|
||||
boolean m1 = l1[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
|
||||
boolean m2 = l2[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
double q2 = Double.parseDouble(m2 ? l2[0].substring(1) : l2[0]);
|
||||
double r1 = Double.parseDouble(l1[m1 ? 1 : 2]);
|
||||
double r2 = Double.parseDouble(l2[m2 ? 1 : 2]);
|
||||
if ((!m1 & q1 < 1) || (!m2 & q2 < 1))
|
||||
{
|
||||
throw new Exception(Util.i18n("moreThanZero"));
|
||||
}
|
||||
|
||||
ItemStack i1 = m1 || r1 <= 0 ? null : ItemDb.get(l1[1], (int)r1);
|
||||
ItemStack i2 = m2 || r2 <= 0 ? null : ItemDb.get(l2[1], (int)r2);
|
||||
|
||||
if (m1)
|
||||
{
|
||||
user.giveMoney(r1);
|
||||
}
|
||||
else if (i1 != null)
|
||||
{
|
||||
Map<Integer, ItemStack> leftOver = user.getInventory().addItem(i1);
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
if (m2)
|
||||
{
|
||||
user.giveMoney(r2);
|
||||
}
|
||||
else if (i2 != null)
|
||||
{
|
||||
Map<Integer, ItemStack> leftOver = user.getInventory().addItem(i2);
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
}
|
||||
}
|
||||
user.updateInventory();
|
||||
|
||||
sign.setType(Material.AIR);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSignChange(SignChangeEvent event)
|
||||
{
|
||||
if (ess.getSettings().areSignsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
String username = user.getName().substring(0, user.getName().length() > 13 ? 13 : user.getName().length());
|
||||
|
||||
if ((event.getLine(0).equalsIgnoreCase("[Buy]") || event.getLine(0).equalsIgnoreCase("#1[Buy]")) && user.isAuthorized("essentials.signs.buy.create"))
|
||||
{
|
||||
try
|
||||
{
|
||||
event.setLine(0, "§1[Buy]");
|
||||
event.setLine(1, "" + Math.abs(Integer.parseInt(event.getLine(1))));
|
||||
ItemStack is = ItemDb.get(event.getLine(2));
|
||||
if (is.getTypeId() == 0 || Math.abs(Integer.parseInt(event.getLine(1))) == 0)
|
||||
{
|
||||
throw new Exception("Don't sell air.");
|
||||
}
|
||||
double price = Double.parseDouble(event.getLine(3).replaceAll("[^0-9\\.]", ""));
|
||||
event.setLine(3, Util.formatCurrency(price));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
event.setLine(0, "§4[Buy]");
|
||||
event.setLine(1, "#");
|
||||
event.setLine(2, "Item");
|
||||
event.setLine(3, "$Price");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ((event.getLine(0).equalsIgnoreCase("[Sell]") || event.getLine(0).equalsIgnoreCase("#1[Sell]")) && user.isAuthorized("essentials.signs.sell.create"))
|
||||
{
|
||||
try
|
||||
{
|
||||
event.setLine(0, "§1[Sell]");
|
||||
event.setLine(1, "" + Math.abs(Integer.parseInt(event.getLine(1))));
|
||||
ItemStack is = ItemDb.get(event.getLine(2));
|
||||
if (is.getTypeId() == 0 || Math.abs(Integer.parseInt(event.getLine(1))) == 0)
|
||||
{
|
||||
throw new Exception("Can't buy air.");
|
||||
}
|
||||
double price = Double.parseDouble(event.getLine(3).replaceAll("[^0-9\\.]", ""));
|
||||
event.setLine(3, Util.formatCurrency(price));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
event.setLine(0, "§4[Sell]");
|
||||
event.setLine(1, "#");
|
||||
event.setLine(2, "Item");
|
||||
event.setLine(3, "$Price");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ((event.getLine(0).equalsIgnoreCase("[Trade]") || event.getLine(0).equalsIgnoreCase("#1[Trade]")) && user.isAuthorized("essentials.signs.trade.create"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String[] l1 = event.getLine(1).split("[ :-]+");
|
||||
String[] l2 = event.getLine(2).split("[ :-]+");
|
||||
boolean m1 = l1[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
|
||||
boolean m2 = l2[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
double q2 = Double.parseDouble(m2 ? l2[0].substring(1) : l2[0]);
|
||||
if (m1 ? l1.length != 1 : l1.length != 2)
|
||||
{
|
||||
throw new Exception(Util.format("invalidSignLine", 2));
|
||||
}
|
||||
if (m2 ? l2.length != 2 : l2.length != 3)
|
||||
{
|
||||
throw new Exception(Util.format("invalidSignLine", 3));
|
||||
}
|
||||
double r2 = Double.parseDouble(l2[m2 ? 1 : 2]);
|
||||
r2 = m2 ? r2 : r2 - r2 % q2;
|
||||
if ((!m1 & q1 < 1) || (!m2 & q2 < 1) || r2 < 1)
|
||||
{
|
||||
throw new Exception(Util.i18n("moreThanZero"));
|
||||
}
|
||||
if (!m1)
|
||||
{
|
||||
ItemDb.get(l1[1]);
|
||||
}
|
||||
|
||||
if (m2)
|
||||
{
|
||||
if (user.getMoney() < r2)
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(r2);
|
||||
//user.sendMessage("r2: " + r2 + " q2: " + q2);
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack i2 = ItemDb.get(l2[1], (int)r2);
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, i2))
|
||||
{
|
||||
throw new Exception(Util.format("missingItems", (int)r2, l2[1]));
|
||||
}
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, i2);
|
||||
user.updateInventory();
|
||||
}
|
||||
|
||||
event.setLine(0, "§1[Trade]");
|
||||
event.setLine(1, (m1 ? Util.formatCurrency(q1) : (int)q1 + " " + l1[1]) + ":0");
|
||||
event.setLine(2, (m2 ? Util.formatCurrency(q2) : (int)q2 + " " + l2[1]) + ":" + (m2 ? Util.roundDouble(r2) : "" + (int)r2));
|
||||
event.setLine(3, "§8" + username);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
event.setLine(0, "§4[Trade]");
|
||||
event.setLine(1, "# ItemOr" + ess.getSettings().getCurrencySymbol());
|
||||
event.setLine(2, "# ItemOr" + ess.getSettings().getCurrencySymbol() + ":#");
|
||||
event.setLine(3, "§8" + username);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,211 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.craftbukkit.block.CraftSign;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class EssentialsEcoPlayerListener extends PlayerListener
|
||||
{
|
||||
private final IEssentials ess;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
EssentialsEcoPlayerListener(IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if (ess.getSettings().areSignsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
String username = user.getName().substring(0, user.getName().length() > 13 ? 13 : user.getName().length());
|
||||
if (event.getClickedBlock().getType() != Material.WALL_SIGN && event.getClickedBlock().getType() != Material.SIGN_POST)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Sign sign = new CraftSign(event.getClickedBlock());
|
||||
|
||||
if (sign.getLine(0).equals("§1[Buy]") && user.isAuthorized("essentials.signs.buy.use"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int amount = Integer.parseInt(sign.getLine(1));
|
||||
ItemStack item = ItemDb.get(sign.getLine(2), amount);
|
||||
double cost = Double.parseDouble(sign.getLine(3).substring(1));
|
||||
if (user.getMoney() < cost)
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(cost);
|
||||
Map<Integer, ItemStack> leftOver = user.getInventory().addItem(item);
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
}
|
||||
user.updateInventory();
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (sign.getLine(0).equals("§1[Sell]") && user.isAuthorized("essentials.signs.sell.use"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int amount = Integer.parseInt(sign.getLine(1));
|
||||
ItemStack item = ItemDb.get(sign.getLine(2), amount);
|
||||
double cost = Double.parseDouble(sign.getLine(3).substring(1));
|
||||
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, item))
|
||||
{
|
||||
throw new Exception(Util.format("missingItems", amount, sign.getLine(2)));
|
||||
}
|
||||
user.giveMoney(cost);
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, item);
|
||||
user.updateInventory();
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (sign.getLine(0).equals("§1[Trade]") && user.isAuthorized("essentials.signs.trade.use"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String[] l1 = sign.getLine(1).split("[ :-]+");
|
||||
String[] l2 = sign.getLine(2).split("[ :-]+");
|
||||
boolean m1 = l1[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
|
||||
boolean m2 = l2[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
double q2 = Double.parseDouble(m2 ? l2[0].substring(1) : l2[0]);
|
||||
double r1 = Double.parseDouble(l1[m1 ? 1 : 2]);
|
||||
double r2 = Double.parseDouble(l2[m2 ? 1 : 2]);
|
||||
r1 = m1 ? r1 : r1 - r1 % q1;
|
||||
r2 = m2 ? r2 : r2 - r2 % q2;
|
||||
if ((!m1 & q1 < 1) || (!m2 & q2 < 1))
|
||||
{
|
||||
throw new Exception(Util.i18n("moreThanZero"));
|
||||
}
|
||||
|
||||
ItemStack i1 = m1 || r1 <= 0 ? null : ItemDb.get(l1[1], (int)r1);
|
||||
ItemStack qi1 = m1 ? null : ItemDb.get(l1[1], (int)q1);
|
||||
ItemStack qi2 = m2 ? null : ItemDb.get(l2[1], (int)q2);
|
||||
|
||||
if (username.equals(sign.getLine(3).substring(2)))
|
||||
{
|
||||
if (m1)
|
||||
{
|
||||
user.giveMoney(r1);
|
||||
}
|
||||
else if (i1 != null)
|
||||
{
|
||||
Map<Integer, ItemStack> leftOver = user.getInventory().addItem(i1);
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
}
|
||||
user.updateInventory();
|
||||
}
|
||||
r1 = 0;
|
||||
sign.setLine(1, (m1 ? Util.formatCurrency(q1) : ((int)q1) + " " + l1[1]) + ":0");
|
||||
sign.update();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m1)
|
||||
{
|
||||
if (user.getMoney() < q1)
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, qi1))
|
||||
{
|
||||
throw new Exception(Util.format("missingItems", (int)q1, l1[1]));
|
||||
}
|
||||
}
|
||||
|
||||
if (r2 < q2)
|
||||
{
|
||||
throw new Exception(Util.i18n("tradeSignEmpty"));
|
||||
}
|
||||
|
||||
if (m1)
|
||||
{
|
||||
user.takeMoney(q1);
|
||||
}
|
||||
else
|
||||
{
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, qi1);
|
||||
}
|
||||
|
||||
if (m2)
|
||||
{
|
||||
user.giveMoney(q2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Map<Integer, ItemStack> leftOver = user.getInventory().addItem(qi2);
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
user.updateInventory();
|
||||
|
||||
r1 += q1;
|
||||
r2 -= q2;
|
||||
|
||||
|
||||
sign.setLine(0, "§1[Trade]");
|
||||
sign.setLine(1, (m1 ? Util.formatCurrency(q1) : ((int)q1) + " " + l1[1]) + ":" + (m1 ? Util.roundDouble(r1) : "" + (int)r1));
|
||||
sign.setLine(2, (m2 ? Util.formatCurrency(q2) : ((int)q2) + " " + l2[1]) + ":" + (m2 ? Util.roundDouble(r2) : "" + (int)r2));
|
||||
sign.update();
|
||||
user.sendMessage(Util.i18n("tradeCompleted"));
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,20 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.List;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class EssentialsEntityListener extends EntityListener
|
||||
public class EssentialsEntityListener implements Listener
|
||||
{
|
||||
private final IEssentials ess;
|
||||
|
||||
@@ -22,43 +23,59 @@ public class EssentialsEntityListener extends EntityListener
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageEvent event)
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
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)
|
||||
final User defender = ess.getUser(eDefend);
|
||||
final User attacker = ess.getUser(eAttack);
|
||||
attacker.updateActivity(true);
|
||||
final List<String> commandList = attacker.getPowertool(attacker.getItemInHand());
|
||||
if (commandList != null && !commandList.isEmpty())
|
||||
{
|
||||
User defender = ess.getUser(eDefend);
|
||||
User attacker = ess.getUser(eAttack);
|
||||
ItemStack is = attacker.getItemInHand();
|
||||
String command = attacker.getPowertool(is);
|
||||
if (command != null && !command.isEmpty())
|
||||
for (String command : commandList)
|
||||
{
|
||||
attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", defender.getName()));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", defender.getName()));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (event instanceof EntityDamageEvent || event instanceof EntityDamageByBlockEvent || event instanceof EntityDamageByProjectileEvent)
|
||||
else if (eDefend instanceof Animals && eAttack instanceof Player)
|
||||
{
|
||||
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
final User player = ess.getUser(eAttack);
|
||||
final ItemStack hand = player.getItemInHand();
|
||||
if (hand != null && hand.getType() == Material.MILK_BUCKET)
|
||||
{
|
||||
CraftPlayer player = (CraftPlayer)event.getEntity();
|
||||
player.getHandle().fireTicks = 0;
|
||||
player.setRemainingAir(player.getMaximumAir());
|
||||
((Animals)eDefend).setAge(-24000);
|
||||
hand.setType(Material.BUCKET);
|
||||
player.setItemInHand(hand);
|
||||
player.updateInventory();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCombust(EntityCombustEvent event)
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityDamage(final EntityDamageEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
final Player player = (Player)event.getEntity();
|
||||
player.setFireTicks(0);
|
||||
player.setRemainingAir(player.getMaximumAir());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityCombust(final EntityCombustEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
@@ -66,17 +83,37 @@ public class EssentialsEntityListener extends EntityListener
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDeath(EntityDeathEvent event)
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerDeathEvent(final PlayerDeathEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player)
|
||||
final User user = ess.getUser(event.getEntity());
|
||||
if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back"))
|
||||
{
|
||||
User user = ess.getUser(event.getEntity());
|
||||
if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back"))
|
||||
{
|
||||
user.setLastLocation();
|
||||
user.sendMessage(Util.i18n("backAfterDeath"));
|
||||
}
|
||||
user.setLastLocation();
|
||||
user.sendMessage(_("backAfterDeath"));
|
||||
}
|
||||
if (!ess.getSettings().areDeathMessagesEnabled())
|
||||
{
|
||||
event.setDeathMessage("");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onFoodLevelChange(final FoodLevelChangeEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityRegainHealth(final EntityRegainHealthEvent event)
|
||||
{
|
||||
if (event.getRegainReason() == RegainReason.SATIATED && event.getEntity() instanceof Player
|
||||
&& ess.getUser(event.getEntity()).isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
|
||||
class EssentialsErrorHandler extends Handler
|
||||
{
|
||||
private final Map<BigInteger, String> errors = new HashMap<BigInteger, String>();
|
||||
private final List<LogRecord> records = new LinkedList<LogRecord>();
|
||||
|
||||
public EssentialsErrorHandler()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publish(LogRecord lr)
|
||||
{
|
||||
if (lr.getThrown() == null || lr.getLevel().intValue() < Level.WARNING.intValue())
|
||||
{
|
||||
return;
|
||||
}
|
||||
synchronized (records)
|
||||
{
|
||||
records.add(lr);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush()
|
||||
{
|
||||
synchronized (records)
|
||||
{
|
||||
sortRecords();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws SecurityException
|
||||
{
|
||||
synchronized (records)
|
||||
{
|
||||
sortRecords();
|
||||
}
|
||||
}
|
||||
|
||||
private void sortRecords()
|
||||
{
|
||||
for (LogRecord lr : records)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (lr.getThrown() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Throwable tr = lr.getThrown();
|
||||
StackTraceElement[] elements = tr.getStackTrace();
|
||||
if (elements == null || elements.length <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
boolean essentialsFound = false;
|
||||
for (StackTraceElement stackTraceElement : elements)
|
||||
{
|
||||
if (stackTraceElement.getClassName().contains("com.earth2me.essentials"))
|
||||
{
|
||||
essentialsFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!essentialsFound && tr.getCause() != null)
|
||||
{
|
||||
Throwable cause = tr.getCause();
|
||||
StackTraceElement[] elements2 = cause.getStackTrace();
|
||||
if (elements2 != null)
|
||||
{
|
||||
for (StackTraceElement stackTraceElement : elements2)
|
||||
{
|
||||
if (stackTraceElement.getClassName().contains("com.earth2me.essentials"))
|
||||
{
|
||||
essentialsFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("[").append(lr.getLevel().getName()).append("] ").append(lr.getMessage()).append("\n");
|
||||
sb.append(tr.getMessage()).append("\n");
|
||||
for (StackTraceElement stackTraceElement : tr.getStackTrace())
|
||||
{
|
||||
sb.append(stackTraceElement.toString()).append("\n");
|
||||
}
|
||||
if (tr.getCause() != null && tr.getCause().getStackTrace() != null)
|
||||
{
|
||||
sb.append(tr.getCause().getMessage()).append("\n");
|
||||
for (StackTraceElement stackTraceElement : tr.getCause().getStackTrace())
|
||||
{
|
||||
sb.append(stackTraceElement.toString()).append("\n");
|
||||
}
|
||||
}
|
||||
String errorReport = sb.toString();
|
||||
byte[] bytesOfMessage = errorReport.getBytes("UTF-8");
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
BigInteger bi = new BigInteger(md.digest(bytesOfMessage));
|
||||
errors.put(bi, errorReport);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
//Ignore all exceptions inside the exception handler
|
||||
}
|
||||
}
|
||||
records.clear();
|
||||
}
|
||||
|
||||
Map<BigInteger, String> getErrors()
|
||||
{
|
||||
return errors;
|
||||
}
|
||||
}
|
||||
@@ -1,90 +1,82 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.textreader.IText;
|
||||
import com.earth2me.essentials.textreader.KeywordReplacer;
|
||||
import com.earth2me.essentials.textreader.TextInput;
|
||||
import com.earth2me.essentials.textreader.TextPager;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.InventoryPlayer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.craftbukkit.block.CraftSign;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
import org.bukkit.event.player.PlayerAnimationType;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerEggThrowEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class EssentialsPlayerListener extends PlayerListener
|
||||
public class EssentialsPlayerListener implements Listener
|
||||
{
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private final Server server;
|
||||
private final IEssentials ess;
|
||||
private final EssentialsBlockListener essBlockListener;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final transient Server server;
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public EssentialsPlayerListener(IEssentials parent)
|
||||
public EssentialsPlayerListener(final IEssentials parent)
|
||||
{
|
||||
this.ess = parent;
|
||||
this.server = parent.getServer();
|
||||
essBlockListener = new EssentialsBlockListener(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event)
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerRespawn(final PlayerRespawnEvent event)
|
||||
{
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
user.setDisplayName(user.getNick());
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
updateCompass(user);
|
||||
if (user.isJailed() && user.getJail() != null && !user.getJail().isEmpty()) {
|
||||
try
|
||||
{
|
||||
event.setRespawnLocation(ess.getJail().getJail(user.getJail()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayNick();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerChat(PlayerChatEvent event)
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerChat(final PlayerChatEvent event)
|
||||
{
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isMuted())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
logger.info(Util.format("mutedUserSpeaks", user.getName()));
|
||||
user.sendMessage(_("playerMuted"));
|
||||
LOGGER.info(_("mutedUserSpeaks", user.getName()));
|
||||
}
|
||||
Iterator<Player> it = event.getRecipients().iterator();
|
||||
final Iterator<Player> it = event.getRecipients().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
User u = ess.getUser(it.next());
|
||||
final User u = ess.getUser(it.next());
|
||||
if (u.isIgnoredPlayer(user.getName()))
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
user.updateActivity(true);
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayNick();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event)
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerMove(final PlayerMoveEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
@@ -92,452 +84,184 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
|
||||
if (!ess.getSettings().getNetherPortalsEnabled())
|
||||
if (user.isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Block block = event.getPlayer().getWorld().getBlockAt(event.getTo().getBlockX(), event.getTo().getBlockY(), event.getTo().getBlockZ());
|
||||
List<World> worlds = server.getWorlds();
|
||||
|
||||
if (block.getType() == Material.PORTAL && worlds.size() > 1 && user.isAuthorized("essentials.portal"))
|
||||
{
|
||||
if (user.getJustPortaled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Location loc = event.getTo();
|
||||
World nether = server.getWorld(ess.getSettings().getNetherName());
|
||||
if (nether == null) {
|
||||
for (World world : worlds)
|
||||
{
|
||||
if (world.getEnvironment() == World.Environment.NETHER) {
|
||||
nether = world;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nether == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
final World world = user.getWorld() == nether ? worlds.get(0) : nether;
|
||||
|
||||
double factor;
|
||||
if (user.getWorld().getEnvironment() == World.Environment.NETHER && world.getEnvironment() == World.Environment.NORMAL)
|
||||
{
|
||||
factor = ess.getSettings().getNetherRatio();
|
||||
}
|
||||
else if (user.getWorld().getEnvironment() != world.getEnvironment())
|
||||
{
|
||||
factor = 1.0 / ess.getSettings().getNetherRatio();
|
||||
}
|
||||
else
|
||||
{
|
||||
factor = 1.0;
|
||||
}
|
||||
|
||||
int x = loc.getBlockX();
|
||||
int y = loc.getBlockY();
|
||||
int z = loc.getBlockZ();
|
||||
|
||||
if (user.getWorld().getBlockAt(x, y, z - 1).getType() == Material.PORTAL)
|
||||
{
|
||||
z--;
|
||||
}
|
||||
if (user.getWorld().getBlockAt(x - 1, y, z).getType() == Material.PORTAL)
|
||||
{
|
||||
x--;
|
||||
}
|
||||
|
||||
x = (int)(x * factor);
|
||||
z = (int)(z * factor);
|
||||
loc = new Location(world, x + .5, y, z + .5);
|
||||
|
||||
Block dest = world.getBlockAt(x, y, z);
|
||||
NetherPortal portal = NetherPortal.findPortal(dest);
|
||||
if (portal == null)
|
||||
{
|
||||
if (world.getEnvironment() == World.Environment.NETHER || ess.getSettings().getGenerateExitPortals())
|
||||
{
|
||||
portal = NetherPortal.createPortal(dest);
|
||||
logger.info(Util.format("userCreatedPortal", event.getPlayer().getName()));
|
||||
user.sendMessage(Util.i18n("generatingPortal"));
|
||||
loc = portal.getSpawn();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.info(Util.format("userUsedPortal", event.getPlayer().getName()));
|
||||
user.sendMessage(Util.i18n("usingPortal"));
|
||||
loc = portal.getSpawn();
|
||||
}
|
||||
|
||||
event.setFrom(loc);
|
||||
event.setTo(loc);
|
||||
final Location from = event.getFrom();
|
||||
final Location to = event.getTo().clone();
|
||||
to.setX(from.getX());
|
||||
to.setY(from.getY());
|
||||
to.setZ(from.getZ());
|
||||
try
|
||||
{
|
||||
user.getTeleport().now(loc, new Charge("portal", ess));
|
||||
event.setTo(Util.getSafeDestination(to));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
user.sendMessage(ex.getMessage());
|
||||
event.setTo(to);
|
||||
}
|
||||
user.setJustPortaled(true);
|
||||
user.sendMessage(Util.i18n("teleportingPortal"));
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
user.setJustPortaled(false);
|
||||
final Location afk = user.getAfkPosition();
|
||||
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9)
|
||||
{
|
||||
user.updateActivity(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerQuit(final PlayerQuitEvent event)
|
||||
{
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (ess.getSettings().removeGodOnDisconnect() && user.isGodModeEnabled())
|
||||
{
|
||||
user.toggleGodModeEnabled();
|
||||
}
|
||||
if (user.getSavedInventory() != null)
|
||||
{
|
||||
user.getInventory().setContents(user.getSavedInventory());
|
||||
user.setSavedInventory(null);
|
||||
}
|
||||
if (!ess.getSettings().getReclaimSetting())
|
||||
{
|
||||
return;
|
||||
}
|
||||
user.updateActivity(false);
|
||||
user.dispose();
|
||||
Thread thread = new Thread(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.sleep(1000);
|
||||
Runtime rt = Runtime.getRuntime();
|
||||
double mem = rt.freeMemory();
|
||||
rt.runFinalization();
|
||||
rt.gc();
|
||||
mem = rt.freeMemory() - mem;
|
||||
mem /= 1024 * 1024;
|
||||
logger.log(Level.INFO, Util.format("freedMemory", mem));
|
||||
}
|
||||
catch (InterruptedException ex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
thread.setPriority(Thread.MIN_PRIORITY);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
ess.getBackup().onPlayerJoin();
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
|
||||
//we do not know the ip address on playerlogin so we need to do this here.
|
||||
if (user.isIpBanned())
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
String banReason = user.getBanReason();
|
||||
user.kickPlayer(banReason != null && !banReason.isEmpty() ? banReason : Util.i18n("defaultBanReason"));
|
||||
return;
|
||||
user.setDisplayNick();
|
||||
}
|
||||
user.setLastLoginAddress(user.getAddress().getAddress().getHostAddress());
|
||||
user.updateActivity(false);
|
||||
if (user.isAuthorized("essentials.sleepingignored"))
|
||||
{
|
||||
user.setSleepingIgnored(true);
|
||||
}
|
||||
|
||||
user.setDisplayName(user.getNick());
|
||||
|
||||
if (!ess.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd"))
|
||||
{
|
||||
for (String m : ess.getMotd(user, null))
|
||||
try
|
||||
{
|
||||
if (m == null)
|
||||
final IText input = new TextInput(user, "motd", true, ess);
|
||||
final IText output = new KeywordReplacer(input, user, ess);
|
||||
final TextPager pager = new TextPager(output, true);
|
||||
pager.showPage("1", null, "motd", user);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
continue;
|
||||
LOGGER.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.log(Level.WARNING, ex.getMessage());
|
||||
}
|
||||
user.sendMessage(m);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ess.getSettings().isCommandDisabled("mail") && user.isAuthorized("essentials.mail"))
|
||||
{
|
||||
List<String> mail = user.getMails();
|
||||
final List<String> mail = user.getMails();
|
||||
if (mail.isEmpty())
|
||||
{
|
||||
user.sendMessage(Util.i18n("noNewMail"));
|
||||
user.sendMessage(_("noNewMail"));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.format("youHaveNewMail", mail.size()));
|
||||
user.sendMessage(_("youHaveNewMail", mail.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerLogin(PlayerLoginEvent event)
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerLogin(final PlayerLoginEvent event)
|
||||
{
|
||||
if (event.getResult() != Result.ALLOWED)
|
||||
switch (event.getResult())
|
||||
{
|
||||
case ALLOWED:
|
||||
case KICK_FULL:
|
||||
case KICK_BANNED:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
user.setNPC(false);
|
||||
|
||||
if (user.isBanned())
|
||||
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))
|
||||
{
|
||||
String banReason = user.getBanReason();
|
||||
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() ? banReason : Util.i18n("defaultBanReason"));
|
||||
final String banReason = user.getBanReason();
|
||||
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : _("defaultBanReason"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (server.getOnlinePlayers().length >= server.getMaxPlayers() && !user.isAuthorized("essentials.joinfullserver"))
|
||||
{
|
||||
event.disallow(Result.KICK_FULL, Util.i18n("serverFull"));
|
||||
event.disallow(Result.KICK_FULL, _("serverFull"));
|
||||
return;
|
||||
}
|
||||
event.allow();
|
||||
|
||||
user.setLastLogin(System.currentTimeMillis());
|
||||
updateCompass(user);
|
||||
}
|
||||
|
||||
private void updateCompass(User user)
|
||||
private void updateCompass(final User user)
|
||||
{
|
||||
try
|
||||
Location loc = user.getHome(user.getLocation());
|
||||
if (loc == null)
|
||||
{
|
||||
user.setCompassTarget(user.getHome(user.getLocation()));
|
||||
loc = user.getBedSpawnLocation();
|
||||
}
|
||||
catch (Exception ex)
|
||||
if (loc != null)
|
||||
{
|
||||
user.setCompassTarget(loc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerTeleport(final PlayerTeleportEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
|
||||
|
||||
//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())
|
||||
{
|
||||
return;
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.setLastLocation();
|
||||
}
|
||||
try
|
||||
{
|
||||
event.setTo(ess.getJail().getJail(user.getJail()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.WARNING, Util.i18n("returnPlayerToJailError"), ex);
|
||||
}
|
||||
user.sendMessage(Util.i18n("jailMessage"));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerEggThrow(final PlayerEggThrowEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final ItemStack stack = new ItemStack(Material.EGG, 1);
|
||||
if (user.hasUnlimited(stack))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!ess.getSettings().areSignsDisabled() && EssentialsBlockListener.protectedBlocks.contains(event.getClickedBlock().getType()))
|
||||
{
|
||||
if (!user.isAuthorized("essentials.signs.protection.override"))
|
||||
{
|
||||
if (essBlockListener.isBlockProtected(event.getClickedBlock(), user))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
user.sendMessage(Util.format("noAccessPermission", event.getClickedBlock().getType().toString().toLowerCase()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ess.getSettings().getBedSetsHome() && event.getClickedBlock().getType() == Material.BED_BLOCK)
|
||||
{
|
||||
try
|
||||
{
|
||||
user.setHome();
|
||||
user.sendMessage(Util.i18n("homeSetToBed"));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ess.getSettings().areSignsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (event.getClickedBlock().getType() != Material.WALL_SIGN && event.getClickedBlock().getType() != Material.SIGN_POST)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Sign sign = new CraftSign(event.getClickedBlock());
|
||||
|
||||
try
|
||||
{
|
||||
if (sign.getLine(0).equals("§1[Free]") && user.isAuthorized("essentials.signs.free.use"))
|
||||
{
|
||||
ItemStack item = ItemDb.get(sign.getLine(1));
|
||||
CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(user.getHandle()));
|
||||
inv.clear();
|
||||
item.setAmount(9 * 4 * 64);
|
||||
inv.addItem(item);
|
||||
user.showInventory(inv);
|
||||
return;
|
||||
}
|
||||
if (sign.getLine(0).equals("§1[Disposal]") && user.isAuthorized("essentials.signs.disposal.use"))
|
||||
{
|
||||
CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(user.getHandle()));
|
||||
inv.clear();
|
||||
user.showInventory(inv);
|
||||
return;
|
||||
}
|
||||
if (sign.getLine(0).equals("§1[Heal]") && user.isAuthorized("essentials.signs.heal.use"))
|
||||
{
|
||||
if (!sign.getLine(1).isEmpty())
|
||||
{
|
||||
String[] l1 = sign.getLine(1).split("[ :-]+");
|
||||
boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
if (!m1 && (int)q1 < 1)
|
||||
{
|
||||
throw new Exception(Util.i18n("moreThanZero"));
|
||||
}
|
||||
if (m1)
|
||||
{
|
||||
if (user.getMoney() < q1)
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(q1);
|
||||
user.sendMessage(Util.format("moneyTaken", Util.formatCurrency(q1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack i = ItemDb.get(l1[1], (int)q1);
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, i))
|
||||
{
|
||||
throw new Exception(Util.format("missingItems", (int)q1, l1[1]));
|
||||
}
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, i);
|
||||
user.updateInventory();
|
||||
}
|
||||
}
|
||||
user.setHealth(20);
|
||||
user.sendMessage(Util.i18n("youAreHealed"));
|
||||
return;
|
||||
}
|
||||
if (sign.getLine(0).equals("§1[Mail]") && user.isAuthorized("essentials.signs.mail.use") && user.isAuthorized("essentials.mail"))
|
||||
{
|
||||
List<String> mail = user.getMails();
|
||||
if (mail.isEmpty())
|
||||
{
|
||||
user.sendMessage(Util.i18n("noNewMail"));
|
||||
return;
|
||||
}
|
||||
for (String s : mail)
|
||||
{
|
||||
user.sendMessage(s);
|
||||
}
|
||||
user.sendMessage(Util.i18n("markMailAsRead"));
|
||||
return;
|
||||
}
|
||||
if (sign.getLine(0).equals("§1[Balance]") && user.isAuthorized("essentials.signs.balance.use"))
|
||||
{
|
||||
user.sendMessage(Util.format("balance", user.getMoney()));
|
||||
return;
|
||||
}
|
||||
if (sign.getLine(0).equals("§1[Warp]"))
|
||||
{
|
||||
|
||||
if (!sign.getLine(2).isEmpty())
|
||||
{
|
||||
if (sign.getLine(2).equals("§2Everyone"))
|
||||
{
|
||||
Charge charge = chargeUserForWarp(sign, user);
|
||||
user.getTeleport().warp(sign.getLine(1), charge);
|
||||
return;
|
||||
}
|
||||
if (user.inGroup(sign.getLine(2)))
|
||||
{
|
||||
Charge charge = chargeUserForWarp(sign, user);
|
||||
user.getTeleport().warp(sign.getLine(1), charge);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (user.isAuthorized("essentials.signs.warp.use")
|
||||
&& (!ess.getSettings().getPerWarpPermission() || user.isAuthorized("essentials.warp." + sign.getLine(1))))
|
||||
{
|
||||
Charge charge = chargeUserForWarp(sign, user);
|
||||
user.getTeleport().warp(sign.getLine(1), charge);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Charge chargeUserForWarp(Sign sign, User user) throws Exception
|
||||
{
|
||||
if (!sign.getLine(3).isEmpty())
|
||||
{
|
||||
String[] l1 = sign.getLine(3).split("[ :-]+");
|
||||
boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
if (!m1 && (int)q1 < 1)
|
||||
{
|
||||
throw new Exception(Util.i18n("moreThanZero"));
|
||||
}
|
||||
if (m1)
|
||||
{
|
||||
return new Charge(q1, ess);
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack i = ItemDb.get(l1[1], (int)q1);
|
||||
return new Charge(i, ess);
|
||||
}
|
||||
}
|
||||
return new Charge("warpsign", ess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerEggThrow(PlayerEggThrowEvent event)
|
||||
{
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
ItemStack is = new ItemStack(Material.EGG, 1);
|
||||
if (user.hasUnlimited(is))
|
||||
{
|
||||
user.getInventory().addItem(is);
|
||||
user.getInventory().addItem(stack);
|
||||
user.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event)
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.hasUnlimited(new ItemStack(event.getBucket())))
|
||||
@@ -545,6 +269,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
event.getItemStack().setType(event.getBucket());
|
||||
ess.scheduleSyncDelayedTask(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
user.updateInventory();
|
||||
@@ -553,44 +278,139 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerAnimation(PlayerAnimationEvent event)
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
usePowertools(event);
|
||||
}
|
||||
|
||||
private void usePowertools(PlayerAnimationEvent event)
|
||||
{
|
||||
if (event.getAnimationType() != PlayerAnimationType.ARM_SWING)
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
ItemStack is = user.getItemInHand();
|
||||
if (is == null || is.getType() == Material.AIR)
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final 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))
|
||||
{
|
||||
return;
|
||||
}
|
||||
String command = user.getPowertool(is);
|
||||
if (command == null || command.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (command.matches(".*\\{player\\}.*"))
|
||||
{
|
||||
//user.sendMessage("Click a player to use this command");
|
||||
return;
|
||||
}
|
||||
if (command.startsWith("c:"))
|
||||
{
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
p.sendMessage(user.getDisplayName() + ":" + command.substring(2));
|
||||
final User spyer = ess.getUser(player);
|
||||
if (spyer.isSocialSpyEnabled() && !user.equals(spyer))
|
||||
{
|
||||
player.sendMessage(user.getDisplayName() + " : " + event.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!cmd.equalsIgnoreCase("afk"))
|
||||
{
|
||||
user.getServer().dispatchCommand(user, command);
|
||||
user.updateActivity(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerChangedWorld(final PlayerChangedWorldEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayNick();
|
||||
}
|
||||
updateCompass(user);
|
||||
|
||||
if (ess.getSettings().getNoGodWorlds().contains(event.getPlayer().getLocation().getWorld().getName()))
|
||||
{
|
||||
if (user.isGodModeEnabledRaw())
|
||||
{
|
||||
user.sendMessage(_("noGodWorldWarning"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.updateActivity(true);
|
||||
switch (event.getAction())
|
||||
{
|
||||
case RIGHT_CLICK_BLOCK:
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ess.getSettings().getUpdateBedAtDaytime() && event.getClickedBlock().getType() == Material.BED_BLOCK)
|
||||
{
|
||||
event.getPlayer().setBedSpawnLocation(event.getClickedBlock().getLocation());
|
||||
}
|
||||
break;
|
||||
case LEFT_CLICK_AIR:
|
||||
case LEFT_CLICK_BLOCK:
|
||||
if (user.hasPowerTools() && user.arePowerToolsEnabled())
|
||||
{
|
||||
if (usePowertools(user))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean usePowertools(final User user)
|
||||
{
|
||||
final ItemStack is = user.getItemInHand();
|
||||
int id;
|
||||
if (is == null || (id = is.getTypeId()) == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
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.matches(".*\\{player\\}.*"))
|
||||
{
|
||||
//user.sendMessage("Click a player to use this command");
|
||||
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)
|
||||
public void onPlayerPickupItem(final PlayerPickupItemEvent event)
|
||||
{
|
||||
if (event.isCancelled() || !ess.getSettings().getDisableItemPickupWhileAfk())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isAfk())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +1,50 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
|
||||
|
||||
public class EssentialsPluginListener extends ServerListener
|
||||
public class EssentialsPluginListener implements Listener, IConf
|
||||
{
|
||||
private final Methods methods;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
public EssentialsPluginListener(Methods methods)
|
||||
{
|
||||
this.methods = methods;
|
||||
}
|
||||
private final transient IEssentials ess;
|
||||
|
||||
@Override
|
||||
public void onPluginEnable(PluginEnableEvent event)
|
||||
public EssentialsPluginListener(final IEssentials ess)
|
||||
{
|
||||
if (!methods.hasMethod())
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(final PluginEnableEvent event)
|
||||
{
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
ess.getAlternativeCommandsHandler().addPlugin(event.getPlugin());
|
||||
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(ess.getServer().getPluginManager()))
|
||||
{
|
||||
if (methods.setMethod(event.getPlugin()))
|
||||
{
|
||||
logger.log(Level.INFO, "[Essentials] Payment method found (" + methods.getMethod().getName() + " version: " + methods.getMethod().getVersion() + ")");
|
||||
}
|
||||
ess.getLogger().log(Level.INFO, "Payment method found (" + ess.getPaymentMethod().getMethod().getName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(final PluginDisableEvent event)
|
||||
{
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
ess.getAlternativeCommandsHandler().removePlugin(event.getPlugin());
|
||||
// Check to see if the plugin thats being disabled is the one we are using
|
||||
if (ess.getPaymentMethod() != null && ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().checkDisabled(event.getPlugin()))
|
||||
{
|
||||
ess.getPaymentMethod().reset();
|
||||
ess.getLogger().log(Level.INFO, "Payment method was disabled. No longer accepting payments.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginDisable(PluginDisableEvent event)
|
||||
public void reloadConfig()
|
||||
{
|
||||
// Check to see if the plugin thats being disabled is the one we are using
|
||||
if (methods != null && methods.hasMethod())
|
||||
{
|
||||
if (methods.checkDisabled(event.getPlugin()))
|
||||
{
|
||||
logger.log(Level.INFO, "[Essentials] Payment method was disabled. No longer accepting payments.");
|
||||
}
|
||||
}
|
||||
ess.getPermissionsHandler().setUseSuperperms(ess.getSettings().useBukkitPermissions());
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
}
|
||||
}
|
||||
@@ -1,81 +1,53 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class EssentialsTimer implements Runnable, IConf
|
||||
public class EssentialsTimer implements Runnable
|
||||
{
|
||||
private final IEssentials ess;
|
||||
private final Set<User> allUsers = new HashSet<User>();
|
||||
|
||||
EssentialsTimer(IEssentials ess)
|
||||
private final transient IEssentials ess;
|
||||
private final transient Set<User> onlineUsers = new HashSet<User>();
|
||||
|
||||
EssentialsTimer(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
File userdir = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdir.exists()) {
|
||||
return;
|
||||
}
|
||||
for (String string : userdir.list())
|
||||
{
|
||||
if (!string.endsWith(".yml")) {
|
||||
continue;
|
||||
}
|
||||
String name = string.substring(0, string.length()-4);
|
||||
User u = ess.getUser(new OfflinePlayer(name));
|
||||
allUsers.add(u);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
long currentTime = System.currentTimeMillis();
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
User u = ess.getUser(player);
|
||||
allUsers.add(u);
|
||||
u.setLastActivity(currentTime);
|
||||
}
|
||||
|
||||
for (User user: allUsers) {
|
||||
if (user.getBanTimeout() > 0 && user.getBanTimeout() < currentTime) {
|
||||
user.setBanTimeout(0);
|
||||
((CraftServer)ess.getServer()).getHandle().b(user.getName());
|
||||
ess.loadBanList();
|
||||
try
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
onlineUsers.add(user);
|
||||
user.setLastOnlineActivity(currentTime);
|
||||
user.checkActivity();
|
||||
}
|
||||
if (user.getMuteTimeout() > 0 && user.getMuteTimeout() < currentTime && user.isMuted()) {
|
||||
user.setMuteTimeout(0);
|
||||
user.sendMessage(Util.i18n("canTalkAgain"));
|
||||
user.setMuted(false);
|
||||
}
|
||||
if (user.getJailTimeout() > 0 && user.getJailTimeout() < currentTime && user.isJailed()) {
|
||||
user.setJailTimeout(0);
|
||||
user.setJailed(false);
|
||||
user.sendMessage(Util.i18n("haveBeenReleased"));
|
||||
user.setJail(null);
|
||||
try
|
||||
{
|
||||
user.getTeleport().back();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (user.getLastActivity() < currentTime && user.getLastActivity() > user.getLastLogout()) {
|
||||
user.setLastLogout(user.getLastActivity());
|
||||
catch (Exception e)
|
||||
{
|
||||
ess.getLogger().log(Level.WARNING, "EssentialsTimer Error:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadConfig()
|
||||
{
|
||||
for (User user : allUsers)
|
||||
final Iterator<User> iterator = onlineUsers.iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
user.reloadConfig();
|
||||
final User user = iterator.next();
|
||||
if (user.getLastOnlineActivity() < currentTime && user.getLastOnlineActivity() > user.getLastLogout())
|
||||
{
|
||||
user.setLastLogout(user.getLastOnlineActivity());
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
user.checkMuteTimeout(currentTime);
|
||||
user.checkJailTimeout(currentTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.math.BigInteger;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
class EssentialsUpdateTimer implements Runnable
|
||||
{
|
||||
private URL url;
|
||||
private final Essentials ess;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
public EssentialsUpdateTimer(Essentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
try
|
||||
{
|
||||
url = new URL("http://127.0.0.1:8080/check");
|
||||
}
|
||||
catch (MalformedURLException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, "Invalid url!", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("v=").append(URLEncoder.encode(ess.getDescription().getVersion(),"UTF-8"));
|
||||
sb.append("&b=").append(URLEncoder.encode(ess.getServer().getVersion(),"UTF-8"));
|
||||
sb.append("&jv=").append(URLEncoder.encode(System.getProperty("java.version"),"UTF-8"));
|
||||
sb.append("&l=").append(URLEncoder.encode(Util.getCurrentLocale().toString(),"UTF-8"));
|
||||
sb.append("&on=").append(URLEncoder.encode(System.getProperty("os.name"),"UTF-8"));
|
||||
sb.append("&ov=").append(URLEncoder.encode(System.getProperty("os.version"),"UTF-8"));
|
||||
for (BigInteger bigInteger : ess.getErrors().keySet())
|
||||
{
|
||||
sb.append("&e[]=").append(bigInteger.toString(36));
|
||||
}
|
||||
URLConnection conn = url.openConnection();
|
||||
conn.setConnectTimeout(10000);
|
||||
conn.setDoOutput(true);
|
||||
conn.connect();
|
||||
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
|
||||
wr.write(sb.toString());
|
||||
wr.flush();
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String ret = br.readLine();
|
||||
wr.close();
|
||||
br.close();
|
||||
logger.log(Level.INFO, ret);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, "Failed to open connection", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,17 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.util.List;
|
||||
import com.earth2me.essentials.craftbukkit.FakeWorld;
|
||||
import com.earth2me.essentials.settings.Spawns;
|
||||
import com.earth2me.essentials.storage.YamlStorageWriter;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.security.DigestInputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@@ -16,63 +20,114 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class EssentialsUpgrade
|
||||
{
|
||||
private static boolean alreadyRun = false;
|
||||
private final static Logger logger = Logger.getLogger("Minecraft");
|
||||
private final IEssentials ess;
|
||||
private final static Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final transient IEssentials ess;
|
||||
private final transient EssentialsConf doneFile;
|
||||
|
||||
EssentialsUpgrade(String version, IEssentials essentials)
|
||||
EssentialsUpgrade(final IEssentials essentials)
|
||||
{
|
||||
ess = essentials;
|
||||
if (alreadyRun)
|
||||
if (!ess.getDataFolder().exists())
|
||||
{
|
||||
return;
|
||||
ess.getDataFolder().mkdirs();
|
||||
}
|
||||
alreadyRun = true;
|
||||
doneFile = new EssentialsConf(new File(ess.getDataFolder(), "upgrades-done.yml"));
|
||||
doneFile.load();
|
||||
}
|
||||
|
||||
private void moveWorthValuesToWorthYml()
|
||||
{
|
||||
if (doneFile.getBoolean("moveWorthValuesToWorthYml", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
File configFile = new File(ess.getDataFolder(), "config.yml");
|
||||
final File configFile = new File(ess.getDataFolder(), "config.yml");
|
||||
if (!configFile.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
EssentialsConf conf = new EssentialsConf(configFile);
|
||||
final EssentialsConf conf = new EssentialsConf(configFile);
|
||||
conf.load();
|
||||
Worth w = new Worth(ess.getDataFolder());
|
||||
final Worth worth = new Worth(ess.getDataFolder());
|
||||
boolean found = false;
|
||||
for (Material mat : Material.values())
|
||||
{
|
||||
int id = mat.getId();
|
||||
double value = conf.getDouble("worth-" + id, Double.NaN);
|
||||
final int id = mat.getId();
|
||||
final double value = conf.getDouble("worth-" + id, Double.NaN);
|
||||
if (!Double.isNaN(value))
|
||||
{
|
||||
found = true;
|
||||
w.setPrice(new ItemStack(mat, 1, (short)0, (byte)0), value);
|
||||
worth.setPrice(new ItemStack(mat, 1, (short)0, (byte)0), value);
|
||||
}
|
||||
}
|
||||
if (found)
|
||||
{
|
||||
removeLinesFromConfig(configFile, "\\s*#?\\s*worth-[0-9]+.*", "# Worth values have been moved to worth.yml");
|
||||
}
|
||||
doneFile.setProperty("moveWorthValuesToWorthYml", true);
|
||||
doneFile.save();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.i18n("upgradingFilesError"), e);
|
||||
LOGGER.log(Level.SEVERE, _("upgradingFilesError"), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void moveMotdRulesToFile(String name)
|
||||
{
|
||||
if (doneFile.getBoolean("move" + name + "ToFile", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
final File file = new File(ess.getDataFolder(), name + ".txt");
|
||||
if (file.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File configFile = new File(ess.getDataFolder(), "config.yml");
|
||||
if (!configFile.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final EssentialsConf conf = new EssentialsConf(configFile);
|
||||
conf.load();
|
||||
List<String> lines = conf.getStringList(name);
|
||||
if (lines != null && !lines.isEmpty())
|
||||
{
|
||||
if (!file.createNewFile())
|
||||
{
|
||||
throw new IOException("Failed to create file " + file);
|
||||
}
|
||||
PrintWriter writer = new PrintWriter(file);
|
||||
|
||||
for (String line : lines)
|
||||
{
|
||||
writer.println(line);
|
||||
}
|
||||
writer.close();
|
||||
}
|
||||
doneFile.setProperty("move" + name + "ToFile", true);
|
||||
doneFile.save();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, _("upgradingFilesError"), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeLinesFromConfig(File file, String regex, String info) throws Exception
|
||||
{
|
||||
boolean needUpdate = false;
|
||||
BufferedReader br = new BufferedReader(new FileReader(file));
|
||||
File tempFile = File.createTempFile("essentialsupgrade", ".tmp.yml", ess.getDataFolder());
|
||||
BufferedWriter bw = new BufferedWriter(new FileWriter(tempFile));
|
||||
final BufferedReader bReader = new BufferedReader(new FileReader(file));
|
||||
final File tempFile = File.createTempFile("essentialsupgrade", ".tmp.yml", ess.getDataFolder());
|
||||
final BufferedWriter bWriter = new BufferedWriter(new FileWriter(tempFile));
|
||||
do
|
||||
{
|
||||
String line = br.readLine();
|
||||
final String line = bReader.readLine();
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
@@ -81,8 +136,8 @@ public class EssentialsUpgrade
|
||||
{
|
||||
if (!needUpdate && info != null)
|
||||
{
|
||||
bw.write(info, 0, info.length());
|
||||
bw.newLine();
|
||||
bWriter.write(info, 0, info.length());
|
||||
bWriter.newLine();
|
||||
}
|
||||
needUpdate = true;
|
||||
}
|
||||
@@ -90,45 +145,51 @@ public class EssentialsUpgrade
|
||||
{
|
||||
if (line.endsWith("\r\n"))
|
||||
{
|
||||
bw.write(line, 0, line.length() - 2);
|
||||
bWriter.write(line, 0, line.length() - 2);
|
||||
}
|
||||
else if (line.endsWith("\r") || line.endsWith("\n"))
|
||||
{
|
||||
bw.write(line, 0, line.length() - 1);
|
||||
bWriter.write(line, 0, line.length() - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
bw.write(line, 0, line.length());
|
||||
bWriter.write(line, 0, line.length());
|
||||
}
|
||||
bw.newLine();
|
||||
bWriter.newLine();
|
||||
}
|
||||
}
|
||||
while (true);
|
||||
br.close();
|
||||
bw.close();
|
||||
bReader.close();
|
||||
bWriter.close();
|
||||
if (needUpdate)
|
||||
{
|
||||
if (!file.renameTo(new File(file.getParentFile(), file.getName().concat("." + System.currentTimeMillis() + ".upgradebackup"))))
|
||||
{
|
||||
throw new Exception(Util.i18n("configFileMoveError"));
|
||||
throw new Exception(_("configFileMoveError"));
|
||||
}
|
||||
if (!tempFile.renameTo(file))
|
||||
{
|
||||
throw new Exception(Util.i18n("configFileRenameError"));
|
||||
throw new Exception(_("configFileRenameError"));
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
tempFile.delete();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateUsersToNewDefaultHome()
|
||||
{
|
||||
File userdataFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (doneFile.getBoolean("updateUsersToNewDefaultHome", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File userdataFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdataFolder.exists() || !userdataFolder.isDirectory())
|
||||
{
|
||||
return;
|
||||
}
|
||||
File[] userFiles = userdataFolder.listFiles();
|
||||
final File[] userFiles = userdataFolder.listFiles();
|
||||
|
||||
for (File file : userFiles)
|
||||
{
|
||||
@@ -136,15 +197,16 @@ public class EssentialsUpgrade
|
||||
{
|
||||
continue;
|
||||
}
|
||||
EssentialsConf config = new EssentialsConf(file);
|
||||
final EssentialsConf config = new EssentialsConf(file);
|
||||
try
|
||||
{
|
||||
config.load();
|
||||
if (config.hasProperty("home") && !config.hasProperty("home.default"))
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object> vals = (List<Object>)config.getProperty("home");
|
||||
if (vals == null) {
|
||||
final List<Object> vals = (List<Object>)config.getProperty("home");
|
||||
if (vals == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
World world = ess.getServer().getWorlds().get(0);
|
||||
@@ -154,7 +216,7 @@ public class EssentialsUpgrade
|
||||
}
|
||||
if (world != null)
|
||||
{
|
||||
Location loc = new Location(
|
||||
final Location loc = new Location(
|
||||
world,
|
||||
((Number)vals.get(0)).doubleValue(),
|
||||
((Number)vals.get(1)).doubleValue(),
|
||||
@@ -162,7 +224,7 @@ public class EssentialsUpgrade
|
||||
((Number)vals.get(3)).floatValue(),
|
||||
((Number)vals.get(4)).floatValue());
|
||||
|
||||
String worldName = world.getName().toLowerCase();
|
||||
final String worldName = world.getName().toLowerCase(Locale.ENGLISH);
|
||||
if (worldName != null && !worldName.isEmpty())
|
||||
{
|
||||
config.removeProperty("home");
|
||||
@@ -175,30 +237,159 @@ public class EssentialsUpgrade
|
||||
}
|
||||
catch (RuntimeException ex)
|
||||
{
|
||||
logger.log(Level.INFO, "File: "+file.toString());
|
||||
LOGGER.log(Level.INFO, "File: " + file.toString());
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
doneFile.setProperty("updateUsersToNewDefaultHome", true);
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
private void updateUsersPowerToolsFormat()
|
||||
{
|
||||
if (doneFile.getBoolean("updateUsersPowerToolsFormat", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File userdataFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdataFolder.exists() || !userdataFolder.isDirectory())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File[] userFiles = userdataFolder.listFiles();
|
||||
|
||||
for (File file : userFiles)
|
||||
{
|
||||
if (!file.isFile() || !file.getName().endsWith(".yml"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final EssentialsConf config = new EssentialsConf(file);
|
||||
try
|
||||
{
|
||||
config.load();
|
||||
if (config.hasProperty("powertools"))
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
final Map<String, Object> powertools = config.getConfigurationSection("powertools").getValues(false);
|
||||
if (powertools == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
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<String, Object>)powertools).put(entry.getKey(), temp);
|
||||
}
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
catch (RuntimeException ex)
|
||||
{
|
||||
LOGGER.log(Level.INFO, "File: " + file.toString());
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
doneFile.setProperty("updateUsersPowerToolsFormat", true);
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
private void updateUsersHomesFormat()
|
||||
{
|
||||
if (doneFile.getBoolean("updateUsersHomesFormat", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File userdataFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdataFolder.exists() || !userdataFolder.isDirectory())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File[] userFiles = userdataFolder.listFiles();
|
||||
|
||||
for (File file : userFiles)
|
||||
{
|
||||
if (!file.isFile() || !file.getName().endsWith(".yml"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final EssentialsConf config = new EssentialsConf(file);
|
||||
try
|
||||
{
|
||||
|
||||
config.load();
|
||||
if (config.hasProperty("home") && config.hasProperty("home.default"))
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
final String defworld = (String)config.getProperty("home.default");
|
||||
final Location defloc = getFakeLocation(config, "home.worlds." + defworld);
|
||||
if (defloc != null)
|
||||
{
|
||||
config.setProperty("homes.home", defloc);
|
||||
}
|
||||
|
||||
Set<String> worlds = config.getConfigurationSection("home.worlds").getKeys(false);
|
||||
Location loc;
|
||||
String worldName;
|
||||
|
||||
if (worlds == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (String world : worlds)
|
||||
{
|
||||
if (defworld.equalsIgnoreCase(world))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
loc = getFakeLocation(config, "home.worlds." + world);
|
||||
if (loc == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
worldName = loc.getWorld().getName().toLowerCase(Locale.ENGLISH);
|
||||
if (worldName != null && !worldName.isEmpty())
|
||||
{
|
||||
config.setProperty("homes." + worldName, loc);
|
||||
}
|
||||
}
|
||||
config.removeProperty("home");
|
||||
config.save();
|
||||
}
|
||||
|
||||
}
|
||||
catch (RuntimeException ex)
|
||||
{
|
||||
LOGGER.log(Level.INFO, "File: " + file.toString());
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
doneFile.setProperty("updateUsersHomesFormat", true);
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
private void moveUsersDataToUserdataFolder()
|
||||
{
|
||||
File usersFile = new File(ess.getDataFolder(), "users.yml");
|
||||
final File usersFile = new File(ess.getDataFolder(), "users.yml");
|
||||
if (!usersFile.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
EssentialsConf usersConfig = new EssentialsConf(usersFile);
|
||||
final EssentialsConf usersConfig = new EssentialsConf(usersFile);
|
||||
usersConfig.load();
|
||||
for (String username : usersConfig.getKeys(null))
|
||||
for (String username : usersConfig.getKeys(false))
|
||||
{
|
||||
User user = new User(new OfflinePlayer(username), ess);
|
||||
String nickname = usersConfig.getString(username + ".nickname");
|
||||
final User user = new User(new OfflinePlayer(username, ess), ess);
|
||||
final String nickname = usersConfig.getString(username + ".nickname");
|
||||
if (nickname != null && !nickname.isEmpty() && !nickname.equals(username))
|
||||
{
|
||||
user.setNickname(nickname);
|
||||
}
|
||||
List<String> mails = usersConfig.getStringList(username + ".mail", null);
|
||||
final List<String> mails = usersConfig.getStringList(username + ".mail");
|
||||
if (mails != null && !mails.isEmpty())
|
||||
{
|
||||
user.setMails(mails);
|
||||
@@ -206,8 +397,9 @@ public class EssentialsUpgrade
|
||||
if (!user.hasHome())
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object> vals = (List<Object>)usersConfig.getProperty(username + ".home");
|
||||
if (vals != null) {
|
||||
final List<Object> vals = (List<Object>)usersConfig.getProperty(username + ".home");
|
||||
if (vals != null)
|
||||
{
|
||||
World world = ess.getServer().getWorlds().get(0);
|
||||
if (vals.size() > 5)
|
||||
{
|
||||
@@ -215,12 +407,12 @@ public class EssentialsUpgrade
|
||||
}
|
||||
if (world != null)
|
||||
{
|
||||
user.setHome(new Location(world,
|
||||
((Number)vals.get(0)).doubleValue(),
|
||||
((Number)vals.get(1)).doubleValue(),
|
||||
((Number)vals.get(2)).doubleValue(),
|
||||
((Number)vals.get(3)).floatValue(),
|
||||
((Number)vals.get(4)).floatValue()), true);
|
||||
user.setHome("home", new Location(world,
|
||||
((Number)vals.get(0)).doubleValue(),
|
||||
((Number)vals.get(1)).doubleValue(),
|
||||
((Number)vals.get(2)).doubleValue(),
|
||||
((Number)vals.get(3)).floatValue(),
|
||||
((Number)vals.get(4)).floatValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -230,40 +422,56 @@ public class EssentialsUpgrade
|
||||
|
||||
private void convertWarps()
|
||||
{
|
||||
File warpsFolder = new File(ess.getDataFolder(), "warps");
|
||||
final File warpsFolder = new File(ess.getDataFolder(), "warps");
|
||||
if (!warpsFolder.exists())
|
||||
{
|
||||
warpsFolder.mkdirs();
|
||||
}
|
||||
File[] listOfFiles = warpsFolder.listFiles();
|
||||
final File[] listOfFiles = warpsFolder.listFiles();
|
||||
if (listOfFiles.length >= 1)
|
||||
{
|
||||
for (int i = 0; i < listOfFiles.length; i++)
|
||||
{
|
||||
String filename = listOfFiles[i].getName();
|
||||
final String filename = listOfFiles[i].getName();
|
||||
if (listOfFiles[i].isFile() && filename.endsWith(".dat"))
|
||||
{
|
||||
try
|
||||
{
|
||||
BufferedReader rx = new BufferedReader(new FileReader(listOfFiles[i]));
|
||||
final BufferedReader rx = new BufferedReader(new FileReader(listOfFiles[i]));
|
||||
double x, y, z;
|
||||
float yaw, pitch;
|
||||
String worldName;
|
||||
try
|
||||
{
|
||||
if (!rx.ready()) continue;
|
||||
if (!rx.ready())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
x = Double.parseDouble(rx.readLine().trim());
|
||||
if (!rx.ready()) continue;
|
||||
if (!rx.ready())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
y = Double.parseDouble(rx.readLine().trim());
|
||||
if (!rx.ready()) continue;
|
||||
if (!rx.ready())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
z = Double.parseDouble(rx.readLine().trim());
|
||||
if (!rx.ready()) continue;
|
||||
if (!rx.ready())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
yaw = Float.parseFloat(rx.readLine().trim());
|
||||
if (!rx.ready()) continue;
|
||||
if (!rx.ready())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
pitch = Float.parseFloat(rx.readLine().trim());
|
||||
worldName = rx.readLine();
|
||||
}
|
||||
finally {
|
||||
finally
|
||||
{
|
||||
rx.close();
|
||||
}
|
||||
World w = null;
|
||||
@@ -285,61 +493,61 @@ public class EssentialsUpgrade
|
||||
w = w1;
|
||||
}
|
||||
}
|
||||
Location loc = new Location(w, x, y, z, yaw, pitch);
|
||||
final Location loc = new Location(w, x, y, z, yaw, pitch);
|
||||
ess.getWarps().setWarp(filename.substring(0, filename.length() - 4), loc);
|
||||
if (!listOfFiles[i].renameTo(new File(warpsFolder, filename + ".old")))
|
||||
{
|
||||
throw new Exception(Util.format("fileRenameError", filename));
|
||||
throw new Exception(_("fileRenameError", filename));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
File warpFile = new File(ess.getDataFolder(), "warps.txt");
|
||||
final File warpFile = new File(ess.getDataFolder(), "warps.txt");
|
||||
if (warpFile.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
BufferedReader rx = new BufferedReader(new FileReader(warpFile));
|
||||
try
|
||||
final BufferedReader rx = new BufferedReader(new FileReader(warpFile));
|
||||
try
|
||||
{
|
||||
for (String[] parts = new String[0]; rx.ready(); parts = rx.readLine().split(":"))
|
||||
{
|
||||
if (parts.length < 6)
|
||||
for (String[] parts = new String[0]; rx.ready(); parts = rx.readLine().split(":"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String name = parts[0];
|
||||
double x = Double.parseDouble(parts[1].trim());
|
||||
double y = Double.parseDouble(parts[2].trim());
|
||||
double z = Double.parseDouble(parts[3].trim());
|
||||
float yaw = Float.parseFloat(parts[4].trim());
|
||||
float pitch = Float.parseFloat(parts[5].trim());
|
||||
if (name.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
World w = null;
|
||||
for (World world : ess.getServer().getWorlds())
|
||||
{
|
||||
if (world.getEnvironment() != World.Environment.NETHER)
|
||||
if (parts.length < 6)
|
||||
{
|
||||
w = world;
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
final String name = parts[0];
|
||||
final double x = Double.parseDouble(parts[1].trim());
|
||||
final double y = Double.parseDouble(parts[2].trim());
|
||||
final double z = Double.parseDouble(parts[3].trim());
|
||||
final float yaw = Float.parseFloat(parts[4].trim());
|
||||
final float pitch = Float.parseFloat(parts[5].trim());
|
||||
if (name.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
World w = null;
|
||||
for (World world : ess.getServer().getWorlds())
|
||||
{
|
||||
if (world.getEnvironment() != World.Environment.NETHER)
|
||||
{
|
||||
w = world;
|
||||
break;
|
||||
}
|
||||
}
|
||||
final Location loc = new Location(w, x, y, z, yaw, pitch);
|
||||
ess.getWarps().setWarp(name, loc);
|
||||
if (!warpFile.renameTo(new File(ess.getDataFolder(), "warps.txt.old")))
|
||||
{
|
||||
throw new Exception(_("fileRenameError", "warps.txt"));
|
||||
}
|
||||
}
|
||||
Location loc = new Location(w, x, y, z, yaw, pitch);
|
||||
ess.getWarps().setWarp(name, loc);
|
||||
if (!warpFile.renameTo(new File(ess.getDataFolder(), "warps.txt.old")))
|
||||
{
|
||||
throw new Exception(Util.format("fileRenameError", "warps.txt"));
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -348,52 +556,60 @@ public class EssentialsUpgrade
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sanitizeAllUserFilenames()
|
||||
{
|
||||
File usersFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (doneFile.getBoolean("sanitizeAllUserFilenames", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File usersFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!usersFolder.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
File[] listOfFiles = usersFolder.listFiles();
|
||||
final File[] listOfFiles = usersFolder.listFiles();
|
||||
for (int i = 0; i < listOfFiles.length; i++)
|
||||
{
|
||||
String filename = listOfFiles[i].getName();
|
||||
final String filename = listOfFiles[i].getName();
|
||||
if (!listOfFiles[i].isFile() || !filename.endsWith(".yml"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String sanitizedFilename = Util.sanitizeFileName(filename.substring(0, filename.length() - 4)) + ".yml";
|
||||
final String sanitizedFilename = Util.sanitizeFileName(filename.substring(0, filename.length() - 4)) + ".yml";
|
||||
if (sanitizedFilename.equals(filename))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
File tmpFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename + ".tmp");
|
||||
File newFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename);
|
||||
if (!listOfFiles[i].renameTo(tmpFile)) {
|
||||
logger.log(Level.WARNING, Util.format("userdataMoveError", filename, sanitizedFilename));
|
||||
final File tmpFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename + ".tmp");
|
||||
final File newFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename);
|
||||
if (!listOfFiles[i].renameTo(tmpFile))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("userdataMoveError", filename, sanitizedFilename));
|
||||
continue;
|
||||
}
|
||||
if (newFile.exists())
|
||||
{
|
||||
logger.log(Level.WARNING, Util.format("duplicatedUserdata", filename, sanitizedFilename));
|
||||
LOGGER.log(Level.WARNING, _("duplicatedUserdata", filename, sanitizedFilename));
|
||||
continue;
|
||||
}
|
||||
if (!tmpFile.renameTo(newFile)) {
|
||||
logger.log(Level.WARNING, Util.format("userdataMoveBackError", sanitizedFilename, sanitizedFilename));
|
||||
if (!tmpFile.renameTo(newFile))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("userdataMoveBackError", sanitizedFilename, sanitizedFilename));
|
||||
}
|
||||
}
|
||||
doneFile.setProperty("sanitizeAllUserFilenames", true);
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
private World getFakeWorld(String name)
|
||||
|
||||
private World getFakeWorld(final String name)
|
||||
{
|
||||
File bukkitDirectory = ess.getDataFolder().getParentFile().getParentFile();
|
||||
File worldDirectory = new File(bukkitDirectory, name);
|
||||
final File bukkitDirectory = ess.getDataFolder().getParentFile().getParentFile();
|
||||
final File worldDirectory = new File(bukkitDirectory, name);
|
||||
if (worldDirectory.exists() && worldDirectory.isDirectory())
|
||||
{
|
||||
return new FakeWorld(worldDirectory.getName(), World.Environment.NORMAL);
|
||||
@@ -401,6 +617,167 @@ public class EssentialsUpgrade
|
||||
return null;
|
||||
}
|
||||
|
||||
public Location getFakeLocation(EssentialsConf config, String path)
|
||||
{
|
||||
String worldName = config.getString((path != null ? path + "." : "") + "world");
|
||||
if (worldName == null || worldName.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
World world = getFakeWorld(worldName);
|
||||
if (world == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Location(world,
|
||||
config.getDouble((path != null ? path + "." : "") + "x", 0),
|
||||
config.getDouble((path != null ? path + "." : "") + "y", 0),
|
||||
config.getDouble((path != null ? path + "." : "") + "z", 0),
|
||||
(float)config.getDouble((path != null ? path + "." : "") + "yaw", 0),
|
||||
(float)config.getDouble((path != null ? path + "." : "") + "pitch", 0));
|
||||
}
|
||||
|
||||
private void deleteOldItemsCsv()
|
||||
{
|
||||
if (doneFile.getBoolean("deleteOldItemsCsv", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File file = new File(ess.getDataFolder(), "items.csv");
|
||||
if (file.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
final Set<BigInteger> oldconfigs = new HashSet<BigInteger>();
|
||||
oldconfigs.add(new BigInteger("66ec40b09ac167079f558d1099e39f10", 16)); // sep 1
|
||||
oldconfigs.add(new BigInteger("34284de1ead43b0bee2aae85e75c041d", 16)); // crlf
|
||||
oldconfigs.add(new BigInteger("c33bc9b8ee003861611bbc2f48eb6f4f", 16)); // jul 24
|
||||
oldconfigs.add(new BigInteger("6ff17925430735129fc2a02f830c1daa", 16)); // crlf
|
||||
|
||||
MessageDigest digest = ManagedFile.getDigest();
|
||||
final BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
|
||||
final DigestInputStream dis = new DigestInputStream(bis, digest);
|
||||
final byte[] buffer = new byte[1024];
|
||||
try
|
||||
{
|
||||
while (dis.read(buffer) != -1)
|
||||
{
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
dis.close();
|
||||
}
|
||||
|
||||
BigInteger hash = new BigInteger(1, digest.digest());
|
||||
if (oldconfigs.contains(hash) && !file.delete())
|
||||
{
|
||||
throw new IOException("Could not delete file " + file.toString());
|
||||
}
|
||||
doneFile.setProperty("deleteOldItemsCsv", true);
|
||||
doneFile.save();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSpawnsToNewSpawnsConfig()
|
||||
{
|
||||
if (doneFile.getBoolean("updateSpawnsToNewSpawnsConfig", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File configFile = new File(ess.getDataFolder(), "spawn.yml");
|
||||
if (configFile.exists())
|
||||
{
|
||||
|
||||
final EssentialsConf config = new EssentialsConf(configFile);
|
||||
try
|
||||
{
|
||||
config.load();
|
||||
if (!config.hasProperty("spawns"))
|
||||
{
|
||||
final Spawns spawns = new Spawns();
|
||||
Set<String> keys = config.getKeys(false);
|
||||
for (String group : keys)
|
||||
{
|
||||
Location loc = getFakeLocation(config, group);
|
||||
spawns.getSpawns().put(group.toLowerCase(Locale.ENGLISH), loc);
|
||||
}
|
||||
if (!configFile.renameTo(new File(ess.getDataFolder(), "spawn.yml.old")))
|
||||
{
|
||||
throw new Exception(_("fileRenameError", "spawn.yml"));
|
||||
}
|
||||
PrintWriter writer = new PrintWriter(configFile);
|
||||
try
|
||||
{
|
||||
new YamlStorageWriter(writer).save(spawns);
|
||||
}
|
||||
finally
|
||||
{
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
doneFile.setProperty("updateSpawnsToNewSpawnsConfig", true);
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
private void updateJailsToNewJailsConfig()
|
||||
{
|
||||
if (doneFile.getBoolean("updateJailsToNewJailsConfig", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File configFile = new File(ess.getDataFolder(), "jail.yml");
|
||||
if (configFile.exists())
|
||||
{
|
||||
|
||||
final EssentialsConf config = new EssentialsConf(configFile);
|
||||
try
|
||||
{
|
||||
config.load();
|
||||
if (!config.hasProperty("jails"))
|
||||
{
|
||||
final com.earth2me.essentials.settings.Jails jails = new com.earth2me.essentials.settings.Jails();
|
||||
Set<String> keys = config.getKeys(false);
|
||||
for (String jailName : keys)
|
||||
{
|
||||
Location loc = getFakeLocation(config, jailName);
|
||||
jails.getJails().put(jailName.toLowerCase(Locale.ENGLISH), loc);
|
||||
}
|
||||
if (!configFile.renameTo(new File(ess.getDataFolder(), "jail.yml.old")))
|
||||
{
|
||||
throw new Exception(_("fileRenameError", "jail.yml"));
|
||||
}
|
||||
PrintWriter writer = new PrintWriter(configFile);
|
||||
try
|
||||
{
|
||||
new YamlStorageWriter(writer).save(jails);
|
||||
}
|
||||
finally
|
||||
{
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
doneFile.setProperty("updateJailsToNewJailsConfig", true);
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
public void beforeSettings()
|
||||
{
|
||||
if (!ess.getDataFolder().exists())
|
||||
@@ -408,6 +785,8 @@ public class EssentialsUpgrade
|
||||
ess.getDataFolder().mkdirs();
|
||||
}
|
||||
moveWorthValuesToWorthYml();
|
||||
moveMotdRulesToFile("motd");
|
||||
moveMotdRulesToFile("rules");
|
||||
}
|
||||
|
||||
public void afterSettings()
|
||||
@@ -416,5 +795,10 @@ public class EssentialsUpgrade
|
||||
updateUsersToNewDefaultHome();
|
||||
moveUsersDataToUserdataFolder();
|
||||
convertWarps();
|
||||
updateUsersPowerToolsFormat();
|
||||
updateUsersHomesFormat();
|
||||
deleteOldItemsCsv();
|
||||
updateSpawnsToNewSpawnsConfig();
|
||||
updateJailsToNewJailsConfig();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
public class ExecuteTimer
|
||||
{
|
||||
private final transient List<ExecuteRecord> times;
|
||||
private final transient DecimalFormat decimalFormat = new DecimalFormat("#0.000", DecimalFormatSymbols.getInstance(Locale.US));
|
||||
|
||||
|
||||
public ExecuteTimer()
|
||||
{
|
||||
times = new ArrayList<ExecuteRecord>();
|
||||
}
|
||||
|
||||
public void start()
|
||||
{
|
||||
times.clear();
|
||||
mark("start");
|
||||
|
||||
}
|
||||
|
||||
public void mark(final String label)
|
||||
{
|
||||
if (!times.isEmpty() || "start".equals(label))
|
||||
{
|
||||
times.add(new ExecuteRecord(label, System.nanoTime()));
|
||||
}
|
||||
}
|
||||
|
||||
public String end()
|
||||
{
|
||||
final StringBuilder output = new StringBuilder();
|
||||
output.append("execution time: ");
|
||||
String mark;
|
||||
long time0 = 0;
|
||||
long time1 = 0;
|
||||
long time2 = 0;
|
||||
double duration;
|
||||
|
||||
for (ExecuteRecord pair : times)
|
||||
{
|
||||
mark = (String)pair.getMark();
|
||||
time2 = (Long)pair.getTime();
|
||||
if (time1 > 0)
|
||||
{
|
||||
duration = (time2 - time1)/1000000.0;
|
||||
output.append(mark).append(": ").append(decimalFormat.format(duration)).append("ms - ");
|
||||
}
|
||||
else
|
||||
{
|
||||
time0 = time2;
|
||||
}
|
||||
time1 = time2;
|
||||
}
|
||||
duration = (time1 - time0)/1000000.0;
|
||||
output.append("Total: ").append(decimalFormat.format(duration)).append("ms");
|
||||
times.clear();
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
|
||||
static private class ExecuteRecord
|
||||
{
|
||||
private final String mark;
|
||||
private final long time;
|
||||
|
||||
public ExecuteRecord(final String mark, final long time)
|
||||
{
|
||||
this.mark = mark;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getMark()
|
||||
{
|
||||
return mark;
|
||||
}
|
||||
|
||||
public long getTime()
|
||||
{
|
||||
return time;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.II18n;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
public class I18n implements II18n
|
||||
{
|
||||
private static I18n instance;
|
||||
private static final String MESSAGES = "messages";
|
||||
private final transient Locale defaultLocale = Locale.getDefault();
|
||||
private transient Locale currentLocale = defaultLocale;
|
||||
private transient ResourceBundle customBundle;
|
||||
private transient ResourceBundle localeBundle;
|
||||
private final transient ResourceBundle defaultBundle;
|
||||
private final transient Map<String, MessageFormat> messageFormatCache = new HashMap<String, MessageFormat>();
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public I18n(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
customBundle = ResourceBundle.getBundle(MESSAGES, defaultLocale, new FileResClassLoader(I18n.class.getClassLoader(), ess));
|
||||
localeBundle = ResourceBundle.getBundle(MESSAGES, defaultLocale);
|
||||
defaultBundle = ResourceBundle.getBundle(MESSAGES, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public void onEnable()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public void onDisable()
|
||||
{
|
||||
instance = null;
|
||||
}
|
||||
|
||||
public Locale getCurrentLocale()
|
||||
{
|
||||
return currentLocale;
|
||||
}
|
||||
|
||||
public String translate(final String string)
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
return customBundle.getString(string);
|
||||
}
|
||||
catch (MissingResourceException ex)
|
||||
{
|
||||
return localeBundle.getString(string);
|
||||
}
|
||||
}
|
||||
catch (MissingResourceException ex)
|
||||
{
|
||||
Logger.getLogger("Minecraft").log(Level.WARNING, String.format("Missing translation key \"%s\" in translation file %s", ex.getKey(), localeBundle.getLocale().toString()), ex);
|
||||
return defaultBundle.getString(string);
|
||||
}
|
||||
}
|
||||
|
||||
public static String _(final String string, final Object... objects)
|
||||
{
|
||||
if (instance == null) {
|
||||
return "";
|
||||
}
|
||||
if (objects.length == 0)
|
||||
{
|
||||
return instance.translate(string);
|
||||
}
|
||||
else
|
||||
{
|
||||
return instance.format(string, objects);
|
||||
}
|
||||
}
|
||||
|
||||
public String format(final String string, final Object... objects)
|
||||
{
|
||||
final String format = translate(string);
|
||||
MessageFormat messageFormat = messageFormatCache.get(format);
|
||||
if (messageFormat == null)
|
||||
{
|
||||
messageFormat = new MessageFormat(format);
|
||||
messageFormatCache.put(format, messageFormat);
|
||||
}
|
||||
return messageFormat.format(objects);
|
||||
}
|
||||
|
||||
public void updateLocale(final String loc)
|
||||
{
|
||||
if (loc == null || loc.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final String[] parts = loc.split("[_\\.]");
|
||||
if (parts.length == 1)
|
||||
{
|
||||
currentLocale = new Locale(parts[0]);
|
||||
}
|
||||
if (parts.length == 2)
|
||||
{
|
||||
currentLocale = new Locale(parts[0], parts[1]);
|
||||
}
|
||||
if (parts.length == 3)
|
||||
{
|
||||
currentLocale = new Locale(parts[0], parts[1], parts[2]);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
public static String capitalCase(final String input)
|
||||
{
|
||||
return input == null || input.length() == 0
|
||||
? input
|
||||
: input.toUpperCase(Locale.ENGLISH).charAt(0)
|
||||
+ input.toLowerCase(Locale.ENGLISH).substring(1);
|
||||
}
|
||||
|
||||
|
||||
private static class FileResClassLoader extends ClassLoader
|
||||
{
|
||||
private final transient File dataFolder;
|
||||
|
||||
public FileResClassLoader(final ClassLoader classLoader, final IEssentials ess)
|
||||
{
|
||||
super(classLoader);
|
||||
this.dataFolder = ess.getDataFolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getResource(final String string)
|
||||
{
|
||||
final File file = new File(dataFolder, string);
|
||||
if (file.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
return file.toURI().toURL();
|
||||
}
|
||||
catch (MalformedURLException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
return super.getResource(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getResourceAsStream(final String string)
|
||||
{
|
||||
final File file = new File(dataFolder, string);
|
||||
if (file.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
return new FileInputStream(file);
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
return super.getResourceAsStream(string);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
/**
|
||||
* @deprecated New interface will be IReload in api package
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IConf {
|
||||
public void reloadConfig();
|
||||
}
|
||||
@@ -1,68 +1,68 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.IJails;
|
||||
import com.earth2me.essentials.perm.PermissionsHandler;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
public interface IEssentials
|
||||
|
||||
/**
|
||||
* @deprecated This will be moved to the api package soon
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IEssentials extends Plugin
|
||||
{
|
||||
void addReloadListener(IConf listener);
|
||||
|
||||
void reload();
|
||||
|
||||
boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath);
|
||||
|
||||
User getUser(Object base);
|
||||
|
||||
User getOfflineUser(String name);
|
||||
|
||||
World getWorld(String name);
|
||||
|
||||
int broadcastMessage(String name, String message);
|
||||
|
||||
Settings getSettings();
|
||||
|
||||
CraftScheduler getScheduler();
|
||||
|
||||
String[] getMotd(CommandSender sender, String def);
|
||||
|
||||
String[] getLines(CommandSender sender, String node, String def);
|
||||
|
||||
Jail getJail();
|
||||
|
||||
void reload();
|
||||
|
||||
boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix, IEssentialsModule module);
|
||||
|
||||
User getUser(Object base);
|
||||
|
||||
I18n getI18n();
|
||||
|
||||
User getOfflineUser(String name);
|
||||
|
||||
World getWorld(String name);
|
||||
|
||||
int broadcastMessage(IUser sender, String message);
|
||||
|
||||
ISettings getSettings();
|
||||
|
||||
BukkitScheduler getScheduler();
|
||||
|
||||
IJails getJails();
|
||||
|
||||
Warps getWarps();
|
||||
|
||||
|
||||
Worth getWorth();
|
||||
|
||||
|
||||
Backup getBackup();
|
||||
|
||||
Spawn getSpawn();
|
||||
|
||||
void loadBanList();
|
||||
|
||||
public boolean isRegisterFallbackEnabled();
|
||||
|
||||
public Methods getPaymentMethod();
|
||||
|
||||
Server getServer();
|
||||
|
||||
File getDataFolder();
|
||||
|
||||
PluginDescriptionFile getDescription();
|
||||
|
||||
|
||||
Methods getPaymentMethod();
|
||||
|
||||
int scheduleAsyncDelayedTask(Runnable run);
|
||||
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run);
|
||||
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run, long delay);
|
||||
|
||||
int scheduleSyncRepeatingTask(final Runnable run, long delay, long period);
|
||||
|
||||
List<String> getBans();
|
||||
TNTExplodeListener getTNTListener();
|
||||
|
||||
List<String> getBannedIps();
|
||||
PermissionsHandler getPermissionsHandler();
|
||||
|
||||
AlternativeCommandsHandler getAlternativeCommandsHandler();
|
||||
|
||||
void showError(final CommandSender sender, final Throwable exception, final String commandLabel);
|
||||
|
||||
ItemDb getItemDb();
|
||||
|
||||
UserMap getUserMap();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
|
||||
public interface IEssentialsModule
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.signs.EssentialsSign;
|
||||
import com.earth2me.essentials.textreader.IText;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
|
||||
public interface ISettings extends IConf
|
||||
{
|
||||
boolean areSignsDisabled();
|
||||
|
||||
IText getAnnounceNewPlayerFormat();
|
||||
|
||||
boolean getAnnounceNewPlayers();
|
||||
|
||||
String getNewPlayerKit();
|
||||
|
||||
String getBackupCommand();
|
||||
|
||||
long getBackupInterval();
|
||||
|
||||
MessageFormat getChatFormat(String group);
|
||||
|
||||
int getChatRadius();
|
||||
|
||||
double getCommandCost(IEssentialsCommand cmd);
|
||||
|
||||
double getCommandCost(String label);
|
||||
|
||||
String getCurrencySymbol();
|
||||
|
||||
int getOversizedStackSize();
|
||||
|
||||
int getDefaultStackSize();
|
||||
|
||||
double getHealCooldown();
|
||||
|
||||
Map<String, Object> getKit(String name);
|
||||
|
||||
ConfigurationSection getKits();
|
||||
|
||||
String getLocale();
|
||||
|
||||
String getNewbieSpawn();
|
||||
|
||||
String getNicknamePrefix();
|
||||
|
||||
ChatColor getOperatorColor() throws Exception;
|
||||
|
||||
boolean getPerWarpPermission();
|
||||
|
||||
boolean getProtectBoolean(final String configName, boolean def);
|
||||
|
||||
int getProtectCreeperMaxHeight();
|
||||
|
||||
List<Integer> getProtectList(final String configName);
|
||||
|
||||
boolean getProtectPreventSpawn(final String creatureName);
|
||||
|
||||
String getProtectString(final String configName);
|
||||
|
||||
boolean getRespawnAtHome();
|
||||
|
||||
Set getMultipleHomes();
|
||||
|
||||
int getHomeLimit(String set);
|
||||
|
||||
int getHomeLimit(User user);
|
||||
|
||||
boolean getSortListByGroups();
|
||||
|
||||
int getSpawnMobLimit();
|
||||
|
||||
int getStartingBalance();
|
||||
|
||||
double getTeleportCooldown();
|
||||
|
||||
double getTeleportDelay();
|
||||
|
||||
boolean hidePermissionlessHelp();
|
||||
|
||||
boolean isCommandDisabled(final IEssentialsCommand cmd);
|
||||
|
||||
boolean isCommandDisabled(String label);
|
||||
|
||||
boolean isCommandOverridden(String name);
|
||||
|
||||
boolean isCommandRestricted(IEssentialsCommand cmd);
|
||||
|
||||
boolean isCommandRestricted(String label);
|
||||
|
||||
boolean isDebug();
|
||||
|
||||
boolean isEcoDisabled();
|
||||
|
||||
boolean isTradeInStacks(int id);
|
||||
|
||||
List<Integer> itemSpawnBlacklist();
|
||||
|
||||
List<EssentialsSign> enabledSigns();
|
||||
|
||||
boolean permissionBasedItemSpawn();
|
||||
|
||||
boolean showNonEssCommandsInHelp();
|
||||
|
||||
boolean spawnIfNoHome();
|
||||
|
||||
boolean warnOnBuildDisallow();
|
||||
|
||||
boolean warnOnSmite();
|
||||
|
||||
double getMaxMoney();
|
||||
|
||||
double getMinMoney();
|
||||
|
||||
boolean isEcoLogEnabled();
|
||||
|
||||
boolean isEcoLogUpdateEnabled();
|
||||
|
||||
boolean removeGodOnDisconnect();
|
||||
|
||||
boolean changeDisplayName();
|
||||
|
||||
boolean isPlayerCommand(String string);
|
||||
|
||||
boolean useBukkitPermissions();
|
||||
|
||||
boolean addPrefixSuffix();
|
||||
|
||||
boolean disablePrefix();
|
||||
|
||||
boolean disableSuffix();
|
||||
|
||||
long getAutoAfk();
|
||||
|
||||
long getAutoAfkKick();
|
||||
|
||||
boolean getFreezeAfkPlayers();
|
||||
|
||||
boolean areDeathMessagesEnabled();
|
||||
|
||||
public void setDebug(boolean debug);
|
||||
|
||||
Set<String> getNoGodWorlds();
|
||||
|
||||
boolean getUpdateBedAtDaytime();
|
||||
|
||||
boolean getRepairEnchanted();
|
||||
|
||||
boolean getIsWorldTeleportPermissions();
|
||||
|
||||
boolean registerBackInListener();
|
||||
|
||||
boolean getDisableItemPickupWhileAfk();
|
||||
|
||||
EventPriority getRespawnPriority();
|
||||
|
||||
long getTpaAcceptCancellation();
|
||||
}
|
||||
@@ -7,22 +7,20 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
|
||||
public interface IUser
|
||||
/**
|
||||
* @deprecated This will be moved to the api package soon
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IUser extends Player
|
||||
{
|
||||
int getHealth();
|
||||
|
||||
Location getLocation();
|
||||
|
||||
boolean isOnline();
|
||||
|
||||
void sendMessage(String string);
|
||||
|
||||
long getLastTeleportTimestamp();
|
||||
|
||||
boolean isAuthorized(String node);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
|
||||
|
||||
void setLastTeleportTimestamp(long time);
|
||||
|
||||
Location getLastLocation();
|
||||
@@ -33,19 +31,21 @@ public interface IUser
|
||||
|
||||
void takeMoney(double value);
|
||||
|
||||
PlayerInventory getInventory();
|
||||
|
||||
void updateInventory();
|
||||
void giveMoney(double value);
|
||||
|
||||
boolean canAfford(double value);
|
||||
|
||||
String getGroup();
|
||||
|
||||
void setLastLocation();
|
||||
|
||||
Location getHome(Location location);
|
||||
Location getHome(String name) throws Exception;
|
||||
|
||||
String getName();
|
||||
Location getHome(Location loc) throws Exception;
|
||||
|
||||
InetSocketAddress getAddress();
|
||||
boolean isHidden();
|
||||
|
||||
String getDisplayName();
|
||||
Teleport getTeleport();
|
||||
|
||||
void setJail(String jail);
|
||||
}
|
||||
@@ -1,192 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.HashMap;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/*
|
||||
* This class can be removed when
|
||||
* https://github.com/Bukkit/CraftBukkit/pull/193
|
||||
* is accepted to CraftBukkit
|
||||
*/
|
||||
|
||||
public final class InventoryWorkaround
|
||||
{
|
||||
private InventoryWorkaround()
|
||||
{
|
||||
}
|
||||
|
||||
public static int first(Inventory ci, ItemStack item, boolean forceDurability, boolean forceAmount)
|
||||
{
|
||||
return next(ci, item, 0, forceDurability, forceAmount);
|
||||
}
|
||||
|
||||
public static int next(Inventory ci, ItemStack item, int start, boolean forceDurability, boolean forceAmount)
|
||||
{
|
||||
ItemStack[] inventory = ci.getContents();
|
||||
for (int i = start; i < inventory.length; i++)
|
||||
{
|
||||
ItemStack cItem = inventory[i];
|
||||
if (cItem == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (item.getTypeId() == cItem.getTypeId() && (!forceAmount || item.getAmount() == cItem.getAmount()) && (!forceDurability || cItem.getDurability() == item.getDurability()))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static HashMap<Integer, ItemStack> removeItem(Inventory ci, boolean forceDurability, ItemStack... items)
|
||||
{
|
||||
HashMap<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
||||
|
||||
// TODO: optimization
|
||||
|
||||
for (int i = 0; i < items.length; i++)
|
||||
{
|
||||
ItemStack item = items[i];
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int toDelete = item.getAmount();
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
||||
// Bail when done
|
||||
if (toDelete <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// get first Item, ignore the amount
|
||||
int first = first(ci, item, forceDurability, false);
|
||||
|
||||
// Drat! we don't have this type in the inventory
|
||||
if (first == -1)
|
||||
{
|
||||
item.setAmount(toDelete);
|
||||
leftover.put(i, item);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack itemStack = ci.getItem(first);
|
||||
int amount = itemStack.getAmount();
|
||||
|
||||
if (amount <= toDelete)
|
||||
{
|
||||
toDelete -= amount;
|
||||
// clear the slot, all used up
|
||||
ci.clear(first);
|
||||
}
|
||||
else
|
||||
{
|
||||
// split the stack and store
|
||||
itemStack.setAmount(amount - toDelete);
|
||||
ci.setItem(first, itemStack);
|
||||
toDelete = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return leftover;
|
||||
}
|
||||
|
||||
public static boolean containsItem(Inventory ci, boolean forceDurability, ItemStack... items)
|
||||
{
|
||||
HashMap<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
||||
|
||||
// TODO: optimization
|
||||
|
||||
// combine items
|
||||
|
||||
ItemStack[] combined = new ItemStack[items.length];
|
||||
for (int i = 0; i < items.length; i++)
|
||||
{
|
||||
if (items[i] == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (int j = 0; j < combined.length; j++)
|
||||
{
|
||||
if (combined[j] == null)
|
||||
{
|
||||
combined[j] = new ItemStack(items[i].getType(), items[i].getAmount(), items[i].getDurability());
|
||||
break;
|
||||
}
|
||||
if (combined[j].getTypeId() == items[i].getTypeId() && (!forceDurability || combined[j].getDurability() == items[i].getDurability()))
|
||||
{
|
||||
combined[j].setAmount(combined[j].getAmount() + items[i].getAmount());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < combined.length; i++)
|
||||
{
|
||||
ItemStack item = combined[i];
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int mustHave = item.getAmount();
|
||||
int position = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
// Bail when done
|
||||
if (mustHave <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
int slot = next(ci, item, position, forceDurability, false);
|
||||
|
||||
// Drat! we don't have this type in the inventory
|
||||
if (slot == -1)
|
||||
{
|
||||
leftover.put(i, item);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack itemStack = ci.getItem(slot);
|
||||
int amount = itemStack.getAmount();
|
||||
|
||||
if (amount <= mustHave)
|
||||
{
|
||||
mustHave -= amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
mustHave = 0;
|
||||
}
|
||||
position = slot + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return leftover.isEmpty();
|
||||
}
|
||||
|
||||
public static Item[] dropItem(Location loc, ItemStack itm)
|
||||
{
|
||||
int maxStackSize = itm.getType().getMaxStackSize();
|
||||
int stacks = itm.getAmount() / maxStackSize;
|
||||
int leftover = itm.getAmount() % maxStackSize;
|
||||
Item[] itemStacks = new Item[stacks + (leftover > 0 ? 1 : 0)];
|
||||
for (int i = 0; i < stacks; i++) {
|
||||
itemStacks[i] = loc.getWorld().dropItem(loc, new ItemStack(itm.getType(), maxStackSize, itm.getDurability()));
|
||||
}
|
||||
if (leftover > 0) {
|
||||
itemStacks[stacks] = loc.getWorld().dropItem(loc, new ItemStack(itm.getType(), leftover, itm.getDurability()));
|
||||
}
|
||||
return itemStacks;
|
||||
}
|
||||
}
|
||||
@@ -1,114 +1,70 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
import com.earth2me.essentials.api.IItemDb;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public final class ItemDb
|
||||
public class ItemDb implements IConf, IItemDb
|
||||
{
|
||||
private ItemDb()
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public ItemDb(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
file = new ManagedFile("items.csv", ess);
|
||||
}
|
||||
|
||||
private final static Logger logger = Logger.getLogger("Minecraft");
|
||||
private static Map<String, Integer> items = new HashMap<String, Integer>();
|
||||
private static Map<String, Short> durabilities = new HashMap<String, Short>();
|
||||
private final transient Map<String, Integer> items = new HashMap<String, Integer>();
|
||||
private final transient Map<String, Short> durabilities = new HashMap<String, Short>();
|
||||
private final transient ManagedFile file;
|
||||
|
||||
public static void load(File folder, String fname) throws IOException
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
folder.mkdirs();
|
||||
File file = new File(folder, fname);
|
||||
final List<String> lines = file.getLines();
|
||||
|
||||
if (!file.exists())
|
||||
if (lines.isEmpty())
|
||||
{
|
||||
file.createNewFile();
|
||||
InputStream res = ItemDb.class.getResourceAsStream("/items.csv");
|
||||
FileWriter tx = null;
|
||||
try
|
||||
{
|
||||
tx = new FileWriter(file);
|
||||
for (int i = 0; (i = res.read()) > 0;)
|
||||
{
|
||||
tx.write(i);
|
||||
}
|
||||
tx.flush();
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
res.close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
try
|
||||
{
|
||||
if (tx != null)
|
||||
{
|
||||
tx.close();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
BufferedReader rx = new BufferedReader(new FileReader(file));
|
||||
try
|
||||
{
|
||||
items.clear();
|
||||
durabilities.clear();
|
||||
items.clear();
|
||||
|
||||
for (int i = 0; rx.ready(); i++)
|
||||
for (String line : lines)
|
||||
{
|
||||
line = line.trim().toLowerCase(Locale.ENGLISH);
|
||||
if (line.length() > 0 && line.charAt(0) == '#')
|
||||
{
|
||||
try
|
||||
{
|
||||
String line = rx.readLine().trim().toLowerCase();
|
||||
if (line.startsWith("#"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String[] parts = line.split("[^a-z0-9]");
|
||||
if (parts.length < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int numeric = Integer.parseInt(parts[1]);
|
||||
|
||||
durabilities.put(parts[0].toLowerCase(), parts.length > 2 && !parts[2].equals("0") ? Short.parseShort(parts[2]) : 0);
|
||||
items.put(parts[0].toLowerCase(), numeric);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.warning(Util.format("parseError", fname, i));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
rx.close();
|
||||
|
||||
final String[] parts = line.split("[^a-z0-9]");
|
||||
if (parts.length < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final int numeric = Integer.parseInt(parts[1]);
|
||||
|
||||
durabilities.put(parts[0].toLowerCase(Locale.ENGLISH), parts.length > 2 && !parts[2].equals("0") ? Short.parseShort(parts[2]) : 0);
|
||||
items.put(parts[0].toLowerCase(Locale.ENGLISH), numeric);
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack get(String id, int quantity) throws Exception
|
||||
public ItemStack get(final String id, final int quantity) throws Exception
|
||||
{
|
||||
ItemStack retval = get(id.toLowerCase());
|
||||
final ItemStack retval = get(id.toLowerCase(Locale.ENGLISH));
|
||||
retval.setAmount(quantity);
|
||||
return retval;
|
||||
}
|
||||
|
||||
public static ItemStack get(String id) throws Exception
|
||||
public ItemStack get(final String id) throws Exception
|
||||
{
|
||||
int itemid = 0;
|
||||
String itemname = null;
|
||||
@@ -124,14 +80,14 @@ public final class ItemDb
|
||||
}
|
||||
else if (id.matches("^[^:+',;.]+[:+',;.]\\d+$"))
|
||||
{
|
||||
itemname = id.split("[:+',;.]")[0].toLowerCase();
|
||||
itemname = id.split("[:+',;.]")[0].toLowerCase(Locale.ENGLISH);
|
||||
metaData = Short.parseShort(id.split("[:+',;.]")[1]);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
itemname = id.toLowerCase();
|
||||
itemname = id.toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
|
||||
if (itemname != null)
|
||||
{
|
||||
if (items.containsKey(itemname))
|
||||
@@ -142,19 +98,24 @@ public final class ItemDb
|
||||
metaData = durabilities.get(itemname);
|
||||
}
|
||||
}
|
||||
else if (Material.getMaterial(itemname) != null)
|
||||
{
|
||||
itemid = Material.getMaterial(itemname).getId();
|
||||
metaData = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(Util.format("unknownItemName", id));
|
||||
throw new Exception(_("unknownItemName", id));
|
||||
}
|
||||
}
|
||||
|
||||
Material mat = Material.getMaterial(itemid);
|
||||
final Material mat = Material.getMaterial(itemid);
|
||||
if (mat == null)
|
||||
{
|
||||
throw new Exception(Util.format("unknownItemId", itemid));
|
||||
throw new Exception(_("unknownItemId", itemid));
|
||||
}
|
||||
ItemStack retval = new ItemStack(mat);
|
||||
retval.setAmount(Essentials.getStatic().getSettings().getDefaultStackSize());
|
||||
final ItemStack retval = new ItemStack(mat);
|
||||
retval.setAmount(mat.getMaxStackSize());
|
||||
retval.setDurability(metaData);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
|
||||
public class Jail extends BlockListener implements IConf
|
||||
{
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private final EssentialsConf config;
|
||||
private final IEssentials ess;
|
||||
|
||||
public Jail(IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
config = new EssentialsConf(new File(ess.getDataFolder(), "jail.yml"));
|
||||
config.load();
|
||||
}
|
||||
|
||||
public void setJail(Location loc, String jailName) throws Exception
|
||||
{
|
||||
config.setProperty(jailName.toLowerCase(), loc);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public Location getJail(String jailName) throws Exception
|
||||
{
|
||||
if (config.getProperty(jailName.toLowerCase()) == null)
|
||||
{
|
||||
throw new Exception(Util.i18n("jailNotExist"));
|
||||
}
|
||||
|
||||
Location loc = config.getLocation(jailName.toLowerCase(), ess.getServer());
|
||||
return loc;
|
||||
}
|
||||
|
||||
public void sendToJail(User user, String jail) throws Exception
|
||||
{
|
||||
user.getTeleport().now(getJail(jail));
|
||||
user.setJail(jail);
|
||||
}
|
||||
|
||||
public void delJail(String jail) throws Exception
|
||||
{
|
||||
config.removeProperty(jail.toLowerCase());
|
||||
config.save();
|
||||
}
|
||||
|
||||
public List<String> getJails() throws Exception
|
||||
{
|
||||
return config.getKeys(null);
|
||||
}
|
||||
|
||||
public void reloadConfig()
|
||||
{
|
||||
config.load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockDamage(BlockDamageEvent event)
|
||||
{
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
|
||||
|
||||
public class JailPlayerListener extends PlayerListener
|
||||
{
|
||||
private final IEssentials ess;
|
||||
|
||||
public JailPlayerListener(IEssentials parent)
|
||||
{
|
||||
this.ess = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IJails;
|
||||
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.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.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
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();
|
||||
|
||||
public Jails(final IEssentials ess)
|
||||
{
|
||||
super(ess, com.earth2me.essentials.settings.Jails.class);
|
||||
reloadConfig();
|
||||
registerListeners();
|
||||
}
|
||||
|
||||
private void registerListeners()
|
||||
{
|
||||
final PluginManager pluginManager = ess.getServer().getPluginManager();
|
||||
final JailBlockListener blockListener = new JailBlockListener();
|
||||
final JailPlayerListener playerListener = new JailPlayerListener();
|
||||
pluginManager.registerEvents(blockListener, ess);
|
||||
pluginManager.registerEvents(playerListener, ess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getStorageFile()
|
||||
{
|
||||
return new File(ess.getDataFolder(), "jail.yml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getJail(final String jailName) throws Exception
|
||||
{
|
||||
acquireReadLock();
|
||||
try
|
||||
{
|
||||
if (getData().getJails() == null || jailName == null
|
||||
|| !getData().getJails().containsKey(jailName.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new Exception(_("jailNotExist"));
|
||||
}
|
||||
Location loc = getData().getJails().get(jailName.toLowerCase(Locale.ENGLISH));
|
||||
if (loc == null || loc.getWorld() == null)
|
||||
{
|
||||
throw new Exception(_("jailNotExist"));
|
||||
}
|
||||
return loc;
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getList() throws Exception
|
||||
{
|
||||
acquireReadLock();
|
||||
try
|
||||
{
|
||||
if (getData().getJails() == null)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return new ArrayList<String>(getData().getJails().keySet());
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeJail(final String jail) throws Exception
|
||||
{
|
||||
acquireWriteLock();
|
||||
try
|
||||
{
|
||||
if (getData().getJails() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
getData().getJails().remove(jail.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendToJail(final IUser user, final String jail) throws Exception
|
||||
{
|
||||
acquireReadLock();
|
||||
try
|
||||
{
|
||||
if (!(user.getBase() instanceof OfflinePlayer))
|
||||
{
|
||||
Location loc = getJail(jail);
|
||||
user.getTeleport().now(loc, false, TeleportCause.COMMAND);
|
||||
}
|
||||
user.setJail(jail);
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setJail(final String jailName, final Location loc) throws Exception
|
||||
{
|
||||
acquireWriteLock();
|
||||
try
|
||||
{
|
||||
if (getData().getJails() == null)
|
||||
{
|
||||
getData().setJails(new HashMap<String, Location>());
|
||||
}
|
||||
getData().getJails().put(jailName.toLowerCase(Locale.ENGLISH), loc);
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class JailBlockListener implements Listener
|
||||
{
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onBlockBreak(final BlockBreakEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onBlockPlace(final BlockPlaceEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onBlockDamage(final BlockDamageEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class JailPlayerListener implements Listener
|
||||
{
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerRespawn(final PlayerRespawnEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
event.setRespawnLocation(getJail(user.getJail()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerTeleport(final PlayerTeleportEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
event.setTo(getJail(user.getJail()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
|
||||
}
|
||||
}
|
||||
user.sendMessage(_("jailMessage"));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
sendToJail(user, user.getJail());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
|
||||
}
|
||||
}
|
||||
user.sendMessage(_("jailMessage"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
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 org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Kit
|
||||
{
|
||||
//TODO: Convert this to use one of the new text classes?
|
||||
public static String listKits(final IEssentials ess, final User user) throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
final ConfigurationSection kits = ess.getSettings().getKits();
|
||||
final StringBuilder list = new StringBuilder();
|
||||
for (String kiteItem : kits.getKeys(false))
|
||||
{
|
||||
if (user.isAuthorized("essentials.kit." + kiteItem.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
list.append(" ").append(capitalCase(kiteItem));
|
||||
}
|
||||
}
|
||||
return list.toString().trim();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(_("kitError"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void checkTime(final User user, final String kitName, final Map<String, Object> els) throws NoChargeException
|
||||
{
|
||||
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 Long lastTime = user.getKitTimestamp(kitName);
|
||||
if (lastTime == null || lastTime < mintime)
|
||||
{
|
||||
final Calendar now = new GregorianCalendar();
|
||||
user.setKitTimestamp(kitName, now.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())));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getItems(final User user, final Map<String, Object> kit) throws Exception
|
||||
{
|
||||
if (kit == null)
|
||||
{
|
||||
throw new Exception(_("kitError2"));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return (List<String>)kit.get("items");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
user.sendMessage(_("kitError2"));
|
||||
throw new Exception(_("kitErrorHelp"));
|
||||
}
|
||||
}
|
||||
|
||||
public static void expandItems(final IEssentials ess, final User user, final List<String> items) throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
boolean spew = false;
|
||||
for (String d : items)
|
||||
{
|
||||
final String[] parts = d.split("[^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 Map<Integer, ItemStack> overfilled;
|
||||
if (user.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), new ItemStack(id, amount, data));
|
||||
}
|
||||
else
|
||||
{
|
||||
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, new ItemStack(id, amount, data));
|
||||
}
|
||||
for (ItemStack itemStack : overfilled.values())
|
||||
{
|
||||
user.getWorld().dropItemNaturally(user.getLocation(), itemStack);
|
||||
spew = true;
|
||||
}
|
||||
}
|
||||
user.updateInventory();
|
||||
if (spew)
|
||||
{
|
||||
user.sendMessage(_("kitInvFull"));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
user.updateInventory();
|
||||
throw new Exception(_("kitError2"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.security.DigestInputStream;
|
||||
import java.security.DigestOutputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
|
||||
public class ManagedFile
|
||||
{
|
||||
private final static int BUFFERSIZE = 1024 * 8;
|
||||
private final transient File file;
|
||||
|
||||
public ManagedFile(final String filename, final IEssentials ess)
|
||||
{
|
||||
file = new File(ess.getDataFolder(), filename);
|
||||
|
||||
if (file.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (checkForVersion(file, ess.getDescription().getVersion()) && !file.delete())
|
||||
{
|
||||
throw new IOException("Could not delete file " + file.toString());
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (!file.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
copyResourceAscii("/" + filename, file);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Bukkit.getLogger().log(Level.SEVERE, _("itemsCsvNotLoaded"), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyResourceAscii(final String resourceName, final File file) throws IOException
|
||||
{
|
||||
final InputStreamReader reader = new InputStreamReader(ManagedFile.class.getResourceAsStream(resourceName));
|
||||
try
|
||||
{
|
||||
final MessageDigest digest = getDigest();
|
||||
final DigestOutputStream digestStream = new DigestOutputStream(new FileOutputStream(file), digest);
|
||||
try
|
||||
{
|
||||
final OutputStreamWriter writer = new OutputStreamWriter(digestStream);
|
||||
try
|
||||
{
|
||||
final char[] buffer = new char[BUFFERSIZE];
|
||||
do
|
||||
{
|
||||
final int length = reader.read(buffer);
|
||||
if (length >= 0)
|
||||
{
|
||||
writer.write(buffer, 0, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (true);
|
||||
writer.write("\n");
|
||||
writer.flush();
|
||||
final BigInteger hashInt = new BigInteger(1, digest.digest());
|
||||
digestStream.on(false);
|
||||
digestStream.write('#');
|
||||
digestStream.write(hashInt.toString(16).getBytes());
|
||||
}
|
||||
finally
|
||||
{
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
digestStream.close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean checkForVersion(final File file, final String version) throws IOException
|
||||
{
|
||||
if (file.length() < 33)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
|
||||
try
|
||||
{
|
||||
final byte[] buffer = new byte[(int)file.length()];
|
||||
int position = 0;
|
||||
do
|
||||
{
|
||||
final int length = bis.read(buffer, position, Math.min((int)file.length() - position, BUFFERSIZE));
|
||||
if (length < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
position += length;
|
||||
}
|
||||
while (position < file.length());
|
||||
final ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
|
||||
if (bais.skip(file.length() - 33) != file.length() - 33)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(bais));
|
||||
try
|
||||
{
|
||||
String hash = reader.readLine();
|
||||
if (hash != null && hash.matches("#[a-f0-9]{32}"))
|
||||
{
|
||||
hash = hash.substring(1);
|
||||
bais.reset();
|
||||
final String versionline = reader.readLine();
|
||||
if (versionline != null && versionline.matches("#version: .+"))
|
||||
{
|
||||
final String versioncheck = versionline.substring(10);
|
||||
if (!versioncheck.equalsIgnoreCase(version))
|
||||
{
|
||||
bais.reset();
|
||||
final MessageDigest digest = getDigest();
|
||||
final DigestInputStream digestStream = new DigestInputStream(bais, digest);
|
||||
try
|
||||
{
|
||||
final byte[] bytes = new byte[(int)file.length() - 33];
|
||||
digestStream.read(bytes);
|
||||
final BigInteger correct = new BigInteger(hash, 16);
|
||||
final BigInteger test = new BigInteger(1, digest.digest());
|
||||
if (correct.equals(test))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Bukkit.getLogger().warning("File " + file.toString() + " has been modified by user and file version differs, please update the file manually.");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
digestStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
bis.close();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static MessageDigest getDigest() throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
return MessageDigest.getInstance("MD5");
|
||||
}
|
||||
catch (NoSuchAlgorithmException ex)
|
||||
{
|
||||
throw new IOException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getLines()
|
||||
{
|
||||
try
|
||||
{
|
||||
final BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
try
|
||||
{
|
||||
final List<String> lines = new ArrayList<String>();
|
||||
do
|
||||
{
|
||||
final String line = reader.readLine();
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
lines.add(line);
|
||||
}
|
||||
}
|
||||
while (true);
|
||||
return lines;
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,103 +1,89 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.Entity;
|
||||
import net.minecraft.server.WorldServer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public enum Mob
|
||||
{
|
||||
CHICKEN("Chicken", Enemies.FRIENDLY),
|
||||
COW("Cow", Enemies.FRIENDLY),
|
||||
CREEPER("Creeper", Enemies.ENEMY),
|
||||
GHAST("Ghast", Enemies.ENEMY),
|
||||
GIANT("Giant", "GiantZombie", Enemies.ENEMY),
|
||||
PIG("Pig", Enemies.FRIENDLY),
|
||||
PIGZOMB("PigZombie", Enemies.NEUTRAL),
|
||||
SHEEP("Sheep", Enemies.FRIENDLY, ""),
|
||||
SKELETON("Skeleton", Enemies.ENEMY),
|
||||
SLIME("Slime", Enemies.ENEMY),
|
||||
SPIDER("Spider", Enemies.ENEMY),
|
||||
SQUID("Squid", Enemies.FRIENDLY),
|
||||
ZOMBIE("Zombie", Enemies.ENEMY),
|
||||
MONSTER("Monster", Enemies.ENEMY),
|
||||
WOLF("Wolf", Enemies.NEUTRAL);
|
||||
|
||||
CHICKEN("Chicken", Enemies.FRIENDLY, 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);
|
||||
|
||||
public static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
private Mob(String n, Enemies en, String s)
|
||||
private Mob(String n, Enemies en, String s, EntityType type)
|
||||
{
|
||||
this.s = s;
|
||||
this.suffix = s;
|
||||
this.name = n;
|
||||
this.craftClass = n;
|
||||
this.entityClass = n;
|
||||
this.type = en;
|
||||
this.bukkitType = type;
|
||||
}
|
||||
|
||||
private Mob(String n, Enemies en)
|
||||
private Mob(String n, Enemies en, EntityType type)
|
||||
{
|
||||
this.name = n;
|
||||
this.craftClass = n;
|
||||
this.entityClass = n;
|
||||
this.type = en;
|
||||
this.bukkitType = type;
|
||||
}
|
||||
|
||||
private Mob(String n, String ec, Enemies en)
|
||||
{
|
||||
this.name = n;
|
||||
this.craftClass = n;
|
||||
this.entityClass = ec;
|
||||
this.type = en;
|
||||
}
|
||||
|
||||
private Mob(String n, String ec, String cc, Enemies en)
|
||||
{
|
||||
this.name = n;
|
||||
this.entityClass = ec;
|
||||
this.craftClass = cc;
|
||||
this.type = en;
|
||||
}
|
||||
public String s = "s";
|
||||
public String name;
|
||||
public Enemies type;
|
||||
private String entityClass;
|
||||
private String craftClass;
|
||||
public String suffix = "s";
|
||||
final public String name;
|
||||
final public Enemies type;
|
||||
final private EntityType bukkitType;
|
||||
private static final Map<String, Mob> hashMap = new HashMap<String, Mob>();
|
||||
|
||||
static
|
||||
{
|
||||
for (Mob mob : Mob.values())
|
||||
{
|
||||
hashMap.put(mob.name, mob);
|
||||
hashMap.put(mob.name.toLowerCase(Locale.ENGLISH), mob);
|
||||
}
|
||||
}
|
||||
|
||||
public static Set<String> getMobList() {
|
||||
return Collections.unmodifiableSet(hashMap.keySet());
|
||||
}
|
||||
|
||||
@SuppressWarnings(
|
||||
public LivingEntity spawn(final Player player, final Server server, final Location loc) throws MobException
|
||||
{
|
||||
"unchecked", "CallToThreadDumpStack"
|
||||
})
|
||||
public CraftEntity spawn(Player player, Server server) throws MobException
|
||||
{
|
||||
try
|
||||
final LivingEntity entity = player.getWorld().spawn(loc, (Class<? extends LivingEntity>)this.bukkitType.getEntityClass());
|
||||
if (entity == null)
|
||||
{
|
||||
WorldServer world = ((org.bukkit.craftbukkit.CraftWorld)player.getWorld()).getHandle();
|
||||
Constructor<CraftEntity> craft = (Constructor<CraftEntity>)ClassLoader.getSystemClassLoader().loadClass("org.bukkit.craftbukkit.entity.Craft" + craftClass).getConstructors()[0];
|
||||
Constructor<Entity> entity = (Constructor<Entity>)ClassLoader.getSystemClassLoader().loadClass("net.minecraft.server.Entity" + entityClass).getConstructors()[0];
|
||||
return craft.newInstance((CraftServer)server, entity.newInstance(world));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.WARNING, Util.i18n("unableToSpawnMob"), ex);
|
||||
throw new MobException(ex);
|
||||
logger.log(Level.WARNING, _("unableToSpawnMob"));
|
||||
throw new MobException();
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,26 +93,26 @@ public enum Mob
|
||||
NEUTRAL("neutral"),
|
||||
ENEMY("enemy");
|
||||
|
||||
private Enemies(String t)
|
||||
private Enemies(final String type)
|
||||
{
|
||||
this.type = t;
|
||||
this.type = type;
|
||||
}
|
||||
protected String type;
|
||||
final protected String type;
|
||||
}
|
||||
|
||||
public EntityType getType()
|
||||
{
|
||||
return bukkitType;
|
||||
}
|
||||
|
||||
public static Mob fromName(final String name)
|
||||
{
|
||||
return hashMap.get(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
|
||||
public static class MobException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private MobException(Exception ex)
|
||||
{
|
||||
super(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static Mob fromName(String n)
|
||||
{
|
||||
return hashMap.get(n);
|
||||
}
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
/**
|
||||
* @author SpaceManiac
|
||||
* @licent MIT
|
||||
* @origin https://github.com/SpaceManiac/Nether/blob/master/org/innectis/Nether/NetherPortal.java
|
||||
*/
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
public class NetherPortal
|
||||
{
|
||||
private Block block;
|
||||
|
||||
public NetherPortal(Block b)
|
||||
{
|
||||
block = b;
|
||||
}
|
||||
|
||||
public Block getBlock()
|
||||
{
|
||||
return block;
|
||||
}
|
||||
|
||||
public void setBlock(Block b)
|
||||
{
|
||||
block = b;
|
||||
}
|
||||
|
||||
// Return a random spawnable location
|
||||
public Location getSpawn()
|
||||
{
|
||||
if (block.getWorld().getBlockAt(block.getX() + 1, block.getY(), block.getZ()).getType().equals(Material.PORTAL)
|
||||
|| block.getWorld().getBlockAt(block.getX() - 1, block.getY(), block.getZ()).getType().equals(Material.PORTAL))
|
||||
{
|
||||
// portal is in X direction
|
||||
return new Location(block.getWorld(), block.getX() + 1,
|
||||
block.getY(), block.getZ() + 1 - 2 * Math.round(Math.random()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// portal is in Z direction
|
||||
return new Location(block.getWorld(), block.getX() + 1 - 2 * Math.round(Math.random()),
|
||||
block.getY(), block.getZ() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// ==============================
|
||||
// Find a nearby portal within 16 blocks of the given block
|
||||
// Not guaranteed to be the nearest
|
||||
public static NetherPortal findPortal(Block dest)
|
||||
{
|
||||
World world = dest.getWorld();
|
||||
|
||||
// Get list of columns in a circle around the block
|
||||
ArrayList<Block> columns = new ArrayList<Block>();
|
||||
for (int x = dest.getX() - 16; x <= dest.getX() + 16; ++x)
|
||||
{
|
||||
for (int z = dest.getZ() - 16; z <= dest.getZ() + 16; ++z)
|
||||
{
|
||||
int dx = dest.getX() - x, dz = dest.getZ() - z;
|
||||
if (dx * dx + dz * dz <= 256)
|
||||
{
|
||||
columns.add(world.getBlockAt(x, 0, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For each column try to find a portal block
|
||||
for (Block col : columns)
|
||||
{
|
||||
for (int y = 127; y >= 0; --y)
|
||||
{
|
||||
Block b = world.getBlockAt(col.getX(), y, col.getZ());
|
||||
if (b.getType().equals(Material.PORTAL) && Math.abs(dest.getY() - y) <= 16)
|
||||
{
|
||||
// Huzzah!
|
||||
return new NetherPortal(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Nope!
|
||||
return null;
|
||||
}
|
||||
|
||||
// Create a new portal at the specified block, fudging position if needed
|
||||
// Will occasionally end up making portals in bad places, but let's hope not
|
||||
public static NetherPortal createPortal(Block dest)
|
||||
{
|
||||
World world = dest.getWorld();
|
||||
|
||||
// Try not to spawn within water or lava
|
||||
Material m = dest.getType();
|
||||
while (((m.equals(Material.LAVA) || m.equals(Material.WATER) || m.equals(Material.STATIONARY_LAVA)
|
||||
|| m.equals(Material.STATIONARY_WATER) || m.equals(Material.SAND) || m.equals(Material.GRAVEL))) &&
|
||||
dest.getY() < 120)
|
||||
{
|
||||
dest = world.getBlockAt(dest.getX(), dest.getY() + 4, dest.getZ());
|
||||
m = dest.getType();
|
||||
}
|
||||
|
||||
// Not too high or too low overall
|
||||
if (dest.getY() > 120)
|
||||
{
|
||||
dest = world.getBlockAt(dest.getX(), 120, dest.getZ());
|
||||
}
|
||||
else if (dest.getY() < 8)
|
||||
{
|
||||
dest = world.getBlockAt(dest.getX(), 8, dest.getZ());
|
||||
}
|
||||
|
||||
// Create the physical portal
|
||||
// For now, don't worry about direction
|
||||
|
||||
int x = dest.getX(), y = dest.getY(), z = dest.getZ();
|
||||
Logger.getLogger("Minecraft").log(Level.INFO, Util.format("creatingPortal", x, y, z));
|
||||
|
||||
// Clear area around portal
|
||||
ArrayList<Block> columns = new ArrayList<Block>();
|
||||
for (int x2 = x - 4; x2 <= x + 4; ++x2)
|
||||
{
|
||||
for (int z2 = z - 4; z2 <= z + 4; ++z2)
|
||||
{
|
||||
double dx = x + 0.5f - x2, dz = z - z2;
|
||||
if (dx * dx + dz * dz <= 13)
|
||||
{
|
||||
columns.add(world.getBlockAt(x2, 0, z2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clear area around portal
|
||||
for (Block col : columns)
|
||||
{
|
||||
// Stone platform
|
||||
world.getBlockAt(col.getX(), y - 1, col.getZ()).setType(Material.STONE);
|
||||
for (int yd = 0; yd < 4; ++yd)
|
||||
{
|
||||
world.getBlockAt(col.getX(), y + yd, col.getZ()).setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
// Build obsidian frame
|
||||
for (int xd = -1; xd < 3; ++xd)
|
||||
{
|
||||
for (int yd = -1; yd < 4; ++yd)
|
||||
{
|
||||
if (xd == -1 || yd == -1 || xd == 2 || yd == 3)
|
||||
{
|
||||
world.getBlockAt(x + xd, y + yd, z).setType(Material.OBSIDIAN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set it alight!
|
||||
dest.setType(Material.FIRE);
|
||||
|
||||
return new NetherPortal(dest);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,99 +1,38 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.IInventory;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
|
||||
import lombok.Delegate;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.permissions.ServerOperator;
|
||||
|
||||
|
||||
public class PlayerExtension extends PlayerWrapper
|
||||
public class PlayerExtension implements Player
|
||||
{
|
||||
protected final IEssentials ess;
|
||||
|
||||
public PlayerExtension(Player base, IEssentials ess)
|
||||
@Delegate(types =
|
||||
{
|
||||
super(base);
|
||||
this.ess = ess;
|
||||
Player.class, Entity.class, CommandSender.class, ServerOperator.class,
|
||||
HumanEntity.class, ConfigurationSerializable.class, LivingEntity.class,
|
||||
Permissible.class
|
||||
})
|
||||
protected Player base;
|
||||
|
||||
public PlayerExtension(final Player base)
|
||||
{
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
public boolean isBanned()
|
||||
public final Player getBase()
|
||||
{
|
||||
return ess.getBans().contains(getName());
|
||||
return base;
|
||||
}
|
||||
|
||||
public boolean isIpBanned()
|
||||
public final Player setBase(final Player base)
|
||||
{
|
||||
return ess.getBannedIps().contains(getAddress().getAddress().toString().replace("/", ""));
|
||||
}
|
||||
|
||||
public float getCorrectedYaw()
|
||||
{
|
||||
float angle = (getLocation().getYaw() - 90.0f) % 360.0f;
|
||||
if (angle < 0) {
|
||||
angle += 360.0f;
|
||||
}
|
||||
return angle;
|
||||
}
|
||||
|
||||
public void showInventory(IInventory inventory)
|
||||
{
|
||||
getHandle().a(inventory);
|
||||
}
|
||||
|
||||
public void showInventory(CraftInventoryPlayer inventory)
|
||||
{
|
||||
showInventory((IInventory)inventory.getInventory());
|
||||
}
|
||||
|
||||
public TargetBlock getTarget()
|
||||
{
|
||||
return new TargetBlock(getBase());
|
||||
}
|
||||
|
||||
public String getGroup()
|
||||
{
|
||||
try
|
||||
{
|
||||
return com.nijikokun.bukkit.Permissions.Permissions.Security.getGroup(getWorld().getName(), getName());
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
return "default";
|
||||
}
|
||||
}
|
||||
|
||||
public boolean inGroup(String group)
|
||||
{
|
||||
try
|
||||
{
|
||||
return com.nijikokun.bukkit.Permissions.Permissions.Security.inGroup(getWorld().getName(), getName(), group);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canBuild()
|
||||
{
|
||||
try
|
||||
{
|
||||
return isOp() || com.nijikokun.bukkit.Permissions.Permissions.Security.canGroupBuild(getWorld().getName(), getGroup());
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public EntityPlayer getHandle()
|
||||
{
|
||||
return getCraftPlayer().getHandle();
|
||||
}
|
||||
|
||||
public CraftPlayer getCraftPlayer()
|
||||
{
|
||||
return (CraftPlayer)base;
|
||||
return this.base = base;
|
||||
}
|
||||
}
|
||||
@@ -1,533 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.inventory.*;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class PlayerWrapper implements Player
|
||||
{
|
||||
protected Player base;
|
||||
|
||||
public PlayerWrapper(Player base)
|
||||
{
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
public final Player getBase()
|
||||
{
|
||||
return base;
|
||||
}
|
||||
|
||||
public final Player setBase(Player base)
|
||||
{
|
||||
return this.base = base;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayName(String string)
|
||||
{
|
||||
base.setDisplayName(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompassTarget(Location lctn)
|
||||
{
|
||||
base.setCompassTarget(lctn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getAddress()
|
||||
{
|
||||
return base.getAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kickPlayer(String string)
|
||||
{
|
||||
base.kickPlayer(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return base.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerInventory getInventory()
|
||||
{
|
||||
return base.getInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemInHand()
|
||||
{
|
||||
return base.getItemInHand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemInHand(ItemStack is)
|
||||
{
|
||||
base.setItemInHand(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHealth()
|
||||
{
|
||||
return base.getHealth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHealth(int i)
|
||||
{
|
||||
base.setHealth(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Egg throwEgg()
|
||||
{
|
||||
return base.throwEgg();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Snowball throwSnowball()
|
||||
{
|
||||
return base.throwSnowball();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Arrow shootArrow()
|
||||
{
|
||||
return base.shootArrow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInsideVehicle()
|
||||
{
|
||||
return base.isInsideVehicle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean leaveVehicle()
|
||||
{
|
||||
return base.leaveVehicle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vehicle getVehicle()
|
||||
{
|
||||
return base.getVehicle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation()
|
||||
{
|
||||
return base.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld()
|
||||
{
|
||||
return base.getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Server getServer()
|
||||
{
|
||||
return base.getServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnline()
|
||||
{
|
||||
return base.isOnline();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOp()
|
||||
{
|
||||
return base.isOp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean teleport(Location lctn)
|
||||
{
|
||||
return base.teleport(lctn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean teleport(Entity entity)
|
||||
{
|
||||
return base.teleport(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String string)
|
||||
{
|
||||
base.sendMessage(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVelocity(Vector vector)
|
||||
{
|
||||
base.setVelocity(vector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getVelocity()
|
||||
{
|
||||
return base.getVelocity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEyeHeight()
|
||||
{
|
||||
return base.getEyeHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEyeHeight(boolean bln)
|
||||
{
|
||||
return base.getEyeHeight(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Block> getLineOfSight(HashSet<Byte> hs, int i)
|
||||
{
|
||||
return base.getLineOfSight(hs, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getTargetBlock(HashSet<Byte> hs, int i)
|
||||
{
|
||||
return base.getTargetBlock(hs, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Block> getLastTwoTargetBlocks(HashSet<Byte> hs, int i)
|
||||
{
|
||||
return base.getLastTwoTargetBlocks(hs, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireTicks()
|
||||
{
|
||||
return base.getFireTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFireTicks()
|
||||
{
|
||||
return base.getMaxFireTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFireTicks(int i)
|
||||
{
|
||||
base.setFireTicks(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
base.remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* This is not deprecated because the underlying method isn't really deprecated; rather, it's just "imperfect". By
|
||||
* We will continue to use this method even after the underlying CraftBukkit method is changed, so do not deprecate
|
||||
* it. Chances are Bukkit will also choose to un-deprecate this method at some point.
|
||||
*/
|
||||
@Override
|
||||
public void updateInventory()
|
||||
{
|
||||
base.updateInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chat(String string)
|
||||
{
|
||||
base.chat(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSneaking()
|
||||
{
|
||||
return base.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSneaking(boolean bln)
|
||||
{
|
||||
base.setSneaking(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEntityId()
|
||||
{
|
||||
return base.getEntityId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performCommand(String string)
|
||||
{
|
||||
return base.performCommand(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRemainingAir()
|
||||
{
|
||||
return base.getRemainingAir();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRemainingAir(int i)
|
||||
{
|
||||
base.setRemainingAir(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumAir()
|
||||
{
|
||||
return base.getMaximumAir();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaximumAir(int i)
|
||||
{
|
||||
base.setMaximumAir(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
if (base.getDisplayName() != null)
|
||||
return base.getDisplayName();
|
||||
else
|
||||
return base.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void damage(int i)
|
||||
{
|
||||
base.damage(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void damage(int i, Entity entity)
|
||||
{
|
||||
base.damage(i, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getEyeLocation()
|
||||
{
|
||||
return base.getEyeLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRawMessage(String string) {
|
||||
base.sendRawMessage(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getCompassTarget()
|
||||
{
|
||||
return base.getCompassTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumNoDamageTicks()
|
||||
{
|
||||
return base.getMaximumNoDamageTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaximumNoDamageTicks(int i)
|
||||
{
|
||||
base.setMaximumNoDamageTicks(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLastDamage()
|
||||
{
|
||||
return base.getLastDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastDamage(int i)
|
||||
{
|
||||
base.setLastDamage(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNoDamageTicks()
|
||||
{
|
||||
return base.getNoDamageTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoDamageTicks(int i)
|
||||
{
|
||||
base.setNoDamageTicks(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getPassenger()
|
||||
{
|
||||
return base.getPassenger();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setPassenger(Entity entity)
|
||||
{
|
||||
return base.setPassenger(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return base.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eject()
|
||||
{
|
||||
return base.eject();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void teleportTo(Location lctn)
|
||||
{
|
||||
base.teleportTo(lctn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void teleportTo(Entity entity)
|
||||
{
|
||||
base.teleportTo(entity);
|
||||
}
|
||||
|
||||
public void saveData()
|
||||
{
|
||||
base.saveData();
|
||||
}
|
||||
|
||||
public void loadData()
|
||||
{
|
||||
base.loadData();
|
||||
}
|
||||
|
||||
public boolean isSleeping()
|
||||
{
|
||||
return base.isSleeping();
|
||||
}
|
||||
|
||||
public int getSleepTicks()
|
||||
{
|
||||
return base.getSleepTicks();
|
||||
}
|
||||
|
||||
public List<Entity> getNearbyEntities(double d, double d1, double d2)
|
||||
{
|
||||
return base.getNearbyEntities(d, d1, d2);
|
||||
}
|
||||
|
||||
public boolean isDead()
|
||||
{
|
||||
return base.isDead();
|
||||
}
|
||||
|
||||
public float getFallDistance()
|
||||
{
|
||||
return base.getFallDistance();
|
||||
}
|
||||
|
||||
public void setFallDistance(float f)
|
||||
{
|
||||
base.setFallDistance(f);
|
||||
}
|
||||
|
||||
public void setSleepingIgnored(boolean bln)
|
||||
{
|
||||
base.setSleepingIgnored(bln);
|
||||
}
|
||||
|
||||
public boolean isSleepingIgnored()
|
||||
{
|
||||
return base.isSleepingIgnored();
|
||||
}
|
||||
|
||||
public void awardAchievement(Achievement a)
|
||||
{
|
||||
base.awardAchievement(a);
|
||||
}
|
||||
|
||||
public void incrementStatistic(Statistic ststc)
|
||||
{
|
||||
base.incrementStatistic(ststc);
|
||||
}
|
||||
|
||||
public void incrementStatistic(Statistic ststc, int i)
|
||||
{
|
||||
base.incrementStatistic(ststc, i);
|
||||
}
|
||||
|
||||
public void incrementStatistic(Statistic ststc, Material mtrl)
|
||||
{
|
||||
base.incrementStatistic(ststc, mtrl);
|
||||
}
|
||||
|
||||
public void incrementStatistic(Statistic ststc, Material mtrl, int i)
|
||||
{
|
||||
base.incrementStatistic(ststc, mtrl, i);
|
||||
}
|
||||
|
||||
public void playNote(Location lctn, byte b, byte b1)
|
||||
{
|
||||
base.playNote(lctn, b, b1);
|
||||
}
|
||||
|
||||
public void sendBlockChange(Location lctn, Material mtrl, byte b)
|
||||
{
|
||||
base.sendBlockChange(lctn, mtrl, b);
|
||||
}
|
||||
|
||||
public void sendBlockChange(Location lctn, int i, byte b)
|
||||
{
|
||||
base.sendBlockChange(lctn, i, b);
|
||||
}
|
||||
|
||||
public void setLastDamageCause(EntityDamageEvent ede)
|
||||
{
|
||||
base.setLastDamageCause(ede);
|
||||
|
||||
}
|
||||
|
||||
public EntityDamageEvent getLastDamageCause()
|
||||
{
|
||||
return base.getLastDamageCause();
|
||||
}
|
||||
|
||||
public void playEffect(Location lctn, Effect effect, int i)
|
||||
{
|
||||
base.playEffect(lctn, effect, i);
|
||||
}
|
||||
|
||||
public boolean sendChunkChange(Location lctn, int i, int i1, int i2, byte[] bytes)
|
||||
{
|
||||
return base.sendChunkChange(lctn, i, i1, i2, bytes);
|
||||
}
|
||||
|
||||
public UUID getUniqueId()
|
||||
{
|
||||
return base.getUniqueId();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,87 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
|
||||
public class Spawn implements IConf {
|
||||
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private final EssentialsConf config;
|
||||
private final Server server;
|
||||
|
||||
public Spawn(Server server, File dataFolder) {
|
||||
File configFile = new File(dataFolder, "spawn.yml");
|
||||
this.server = server;
|
||||
config = new EssentialsConf(configFile);
|
||||
config.load();
|
||||
}
|
||||
|
||||
public void setSpawn(Location loc, String group) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("world", loc.getWorld().getName());
|
||||
map.put("x", loc.getX());
|
||||
map.put("y", loc.getY());
|
||||
map.put("z", loc.getZ());
|
||||
map.put("yaw", loc.getYaw());
|
||||
map.put("pitch", loc.getPitch());
|
||||
config.setProperty(group, map);
|
||||
config.save();
|
||||
|
||||
if ("default".equals(group)) {
|
||||
loc.getWorld().setSpawnLocation(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
}
|
||||
}
|
||||
|
||||
public Location getSpawn(String group) {
|
||||
if (config.getProperty(group) == null) {
|
||||
group = "default";
|
||||
}
|
||||
if (config.getProperty(group) == null) {
|
||||
for (World w : server.getWorlds()) {
|
||||
if (w.getEnvironment() != Environment.NORMAL) {
|
||||
continue;
|
||||
}
|
||||
return w.getSpawnLocation();
|
||||
}
|
||||
}
|
||||
String worldId = config.getString(group + ".world", "");
|
||||
World world = server.getWorlds().get(server.getWorlds().size() > 1 ? 1 : 0);
|
||||
for (World w : server.getWorlds()) {
|
||||
if (w.getEnvironment() != Environment.NORMAL) {
|
||||
continue;
|
||||
}
|
||||
world = w;
|
||||
break;
|
||||
}
|
||||
for (World w : server.getWorlds()) {
|
||||
if (!w.getName().equals(worldId)) {
|
||||
continue;
|
||||
}
|
||||
world = w;
|
||||
break;
|
||||
}
|
||||
|
||||
double x = config.getDouble(group + ".x", config.getDouble("default.x", 0));
|
||||
double y = config.getDouble(group + ".y", config.getDouble("default.y", 0));
|
||||
double z = config.getDouble(group + ".z", config.getDouble("default.z", 0));
|
||||
float yaw = (float) config.getDouble(group + ".yaw", config.getDouble("default.yaw", 0));
|
||||
float pitch = (float) config.getDouble(group + ".pitch", config.getDouble("default.pitch", 0));
|
||||
Location retval = new Location(world, x, y, z, yaw, pitch);
|
||||
|
||||
if (y < 1) {
|
||||
retval.setY(world.getHighestBlockYAt(retval));
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public void reloadConfig() {
|
||||
config.load();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
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;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
|
||||
public class TNTExplodeListener implements Listener, Runnable
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
private transient boolean enabled = false;
|
||||
private transient int timer = -1;
|
||||
|
||||
public TNTExplodeListener(final IEssentials ess)
|
||||
{
|
||||
super();
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public void enable()
|
||||
{
|
||||
if (!enabled)
|
||||
{
|
||||
enabled = true;
|
||||
timer = ess.scheduleSyncDelayedTask(this, 1000);
|
||||
return;
|
||||
}
|
||||
if (timer != -1)
|
||||
{
|
||||
ess.getScheduler().cancelTask(timer);
|
||||
timer = ess.scheduleSyncDelayedTask(this, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onEntityExplode(final EntityExplodeEvent event)
|
||||
{
|
||||
if (!enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (event.getEntity() instanceof LivingEntity)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FakeExplosion.createExplosion(event, ess.getServer(), ess.getServer().getOnlinePlayers());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
@@ -1,599 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
/**
|
||||
* @author toi
|
||||
* Thanks to Raphfrk for optimization of this class.
|
||||
*/
|
||||
public class TargetBlock {
|
||||
|
||||
private Location loc;
|
||||
private double viewHeight;
|
||||
private int maxDistance;
|
||||
private int[] blockToIgnore;
|
||||
private double checkDistance, curDistance;
|
||||
private double xRotation, yRotation;
|
||||
private Vector targetPos = new Vector();
|
||||
private Vector targetPosDouble = new Vector();
|
||||
private Vector prevPos = new Vector();
|
||||
private final Vector offset = new Vector();
|
||||
|
||||
/**
|
||||
* Constructor requiring a player, uses default values
|
||||
*
|
||||
* @param player Player to work with
|
||||
*/
|
||||
public TargetBlock(Player player)
|
||||
{
|
||||
this.setValues(player.getLocation(), 300, 1.65, 0.2, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor requiring a location, uses default values
|
||||
*
|
||||
* @param loc Location to work with
|
||||
*/
|
||||
public TargetBlock(Location loc)
|
||||
{
|
||||
this.setValues(loc, 300, 0, 0.2, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor requiring a player, max distance and a checking distance
|
||||
*
|
||||
* @param player Player to work with
|
||||
* @param maxDistance How far it checks for blocks
|
||||
* @param checkDistance How often to check for blocks, the smaller the more precise
|
||||
*/
|
||||
public TargetBlock(Player player, int maxDistance, double checkDistance)
|
||||
{
|
||||
this.setValues(player.getLocation(), maxDistance, 1.65, checkDistance, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor requiring a location, max distance and a checking distance
|
||||
*
|
||||
* @param loc What location to work with
|
||||
* @param maxDistance How far it checks for blocks
|
||||
* @param checkDistance How often to check for blocks, the smaller the more precise
|
||||
*/
|
||||
public TargetBlock(Location loc, int maxDistance, double checkDistance) {
|
||||
this.setValues(loc, maxDistance, 0, checkDistance, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor requiring a player, max distance, checking distance and an array of blocks to ignore
|
||||
*
|
||||
* @param player What player to work with
|
||||
* @param maxDistance How far it checks for blocks
|
||||
* @param checkDistance How often to check for blocks, the smaller the more precise
|
||||
* @param blocksToIgnore Integer array of what block ids to ignore while checking for viable targets
|
||||
*/
|
||||
public TargetBlock (Player player, int maxDistance, double checkDistance, int[] blocksToIgnore)
|
||||
{
|
||||
this.setValues(player.getLocation(), maxDistance, 1.65, checkDistance, blocksToIgnore);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor requiring a location, max distance, checking distance and an array of blocks to ignore
|
||||
*
|
||||
* @param loc What location to work with
|
||||
* @param maxDistance How far it checks for blocks
|
||||
* @param checkDistance How often to check for blocks, the smaller the more precise
|
||||
* @param blocksToIgnore Array of what block ids to ignore while checking for viable targets
|
||||
*/
|
||||
public TargetBlock (Location loc, int maxDistance, double checkDistance, int[] blocksToIgnore)
|
||||
{
|
||||
this.setValues(loc, maxDistance, 0, checkDistance, blocksToIgnore);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor requiring a player, max distance, checking distance and an array of blocks to ignore
|
||||
*
|
||||
* @param player What player to work with
|
||||
* @param maxDistance How far it checks for blocks
|
||||
* @param checkDistance How often to check for blocks, the smaller the more precise
|
||||
* @param blocksToIgnore String ArrayList of what block ids to ignore while checking for viable targets
|
||||
*/
|
||||
public TargetBlock (Player player, int maxDistance, double checkDistance, ArrayList<String> blocksToIgnore)
|
||||
{
|
||||
int[] bti = this.convertStringArraytoIntArray(blocksToIgnore);
|
||||
this.setValues(player.getLocation(), maxDistance, 1.65, checkDistance, bti);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor requiring a location, max distance, checking distance and an array of blocks to ignore
|
||||
*
|
||||
* @param loc What location to work with
|
||||
* @param maxDistance How far it checks for blocks
|
||||
* @param checkDistance How often to check for blocks, the smaller the more precise
|
||||
* @param blocksToIgnore String ArrayList of what block ids to ignore while checking for viable targets
|
||||
*/
|
||||
public TargetBlock (Location loc, int maxDistance, double checkDistance, ArrayList<String> blocksToIgnore)
|
||||
{
|
||||
int[] bti = this.convertStringArraytoIntArray(blocksToIgnore);
|
||||
this.setValues(loc, maxDistance, 0, checkDistance, bti);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the values, all constructors uses this function
|
||||
*
|
||||
* @param loc Location of the view
|
||||
* @param maxDistance How far it checks for blocks
|
||||
* @param viewPos Where the view is positioned in y-axis
|
||||
* @param checkDistance How often to check for blocks, the smaller the more precise
|
||||
* @param blocksToIgnore Ids of blocks to ignore while checking for viable targets
|
||||
*/
|
||||
private void setValues(Location loc, int maxDistance, double viewHeight, double checkDistance, int[] blocksToIgnore)
|
||||
{
|
||||
this.loc = loc;
|
||||
this.maxDistance = maxDistance;
|
||||
this.viewHeight = viewHeight;
|
||||
this.checkDistance = checkDistance;
|
||||
this.blockToIgnore = blocksToIgnore;
|
||||
this.curDistance = 0;
|
||||
xRotation = (loc.getYaw() + 90) % 360;
|
||||
yRotation = loc.getPitch() * -1;
|
||||
|
||||
double h = (checkDistance * Math.cos(Math.toRadians(yRotation)));
|
||||
offset.setY((checkDistance * Math.sin(Math.toRadians(yRotation))));
|
||||
offset.setX((h * Math.cos(Math.toRadians(xRotation))));
|
||||
offset.setZ((h * Math.sin(Math.toRadians(xRotation))));
|
||||
|
||||
targetPosDouble = new Vector(loc.getX(), loc.getY() + viewHeight, loc.getZ());
|
||||
targetPos = new Vector( targetPosDouble.getBlockX(), targetPosDouble.getBlockY(), targetPosDouble.getBlockZ());
|
||||
prevPos = targetPos.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this to reset checking position to allow you to check for a new target with the same TargetBlock instance.
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
targetPosDouble = new Vector(loc.getX(), loc.getY() + viewHeight, loc.getZ());
|
||||
targetPos = new Vector( targetPosDouble.getBlockX(), targetPosDouble.getBlockY(), targetPosDouble.getBlockZ());
|
||||
prevPos = targetPos.clone();
|
||||
this.curDistance = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the distance to a block. Measures from the block underneath the player to the targetblock
|
||||
* Should only be used when passing player as an constructor parameter
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public double getDistanceToBlock()
|
||||
{
|
||||
Vector blockUnderPlayer = new Vector(
|
||||
(int) Math.floor(loc.getX() + 0.5),
|
||||
(int) Math.floor(loc.getY() - 0.5),
|
||||
(int) Math.floor(loc.getZ() + 0.5));
|
||||
|
||||
Block blk = getTargetBlock();
|
||||
double x = blk.getX() - blockUnderPlayer.getBlockX();
|
||||
double y = blk.getY() - blockUnderPlayer.getBlockY();
|
||||
double z = blk.getZ() - blockUnderPlayer.getBlockZ();
|
||||
|
||||
return Math.sqrt((Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rounded distance to a block. Measures from the block underneath the player to the targetblock
|
||||
* Should only be used when passing player as an constructor parameter
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int getDistanceToBlockRounded()
|
||||
{
|
||||
Vector blockUnderPlayer = new Vector(
|
||||
(int) Math.floor(loc.getX() + 0.5),
|
||||
(int) Math.floor(loc.getY() - 0.5),
|
||||
(int) Math.floor(loc.getZ() + 0.5));
|
||||
|
||||
Block blk = getTargetBlock();
|
||||
double x = blk.getX() - blockUnderPlayer.getBlockX();
|
||||
double y = blk.getY() - blockUnderPlayer.getBlockY();
|
||||
double z = blk.getZ() - blockUnderPlayer.getBlockZ();
|
||||
|
||||
return (int) Math.round((Math.sqrt((Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2)))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the floored x distance to a block.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int getXDistanceToBlock()
|
||||
{
|
||||
this.reset();
|
||||
return (int) Math.floor(getTargetBlock().getX() - loc.getBlockX() + 0.5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the floored y distance to a block
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int getYDistanceToBlock()
|
||||
{
|
||||
this.reset();
|
||||
return (int) Math.floor(getTargetBlock().getY() - loc.getBlockY() + viewHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the floored z distance to a block
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int getZDistanceToBlock()
|
||||
{
|
||||
this.reset();
|
||||
return (int) Math.floor(getTargetBlock().getZ() - loc.getBlockZ() + 0.5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the block at the sight. Returns null if out of range or if no viable target was found
|
||||
*
|
||||
* @return Block
|
||||
*/
|
||||
@SuppressWarnings("empty-statement")
|
||||
public Block getTargetBlock()
|
||||
{
|
||||
this.reset();
|
||||
while ((getNextBlock() != null) && ((getCurrentBlock().getTypeId() == 0) || this.blockToIgnoreHasValue(getCurrentBlock().getTypeId())));
|
||||
return getCurrentBlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of the block at the sight. Returns false if the block wasn't set.
|
||||
*
|
||||
* @param typeID ID of type to set the block to
|
||||
* @return boolean
|
||||
*/
|
||||
@SuppressWarnings("empty-statement")
|
||||
public boolean setTargetBlock(int typeID)
|
||||
{
|
||||
if (Material.getMaterial(typeID) != null)
|
||||
{
|
||||
this.reset();
|
||||
while (getNextBlock() != null && getCurrentBlock().getTypeId() == 0);
|
||||
if (getCurrentBlock() != null)
|
||||
{
|
||||
Block blk = loc.getWorld().getBlockAt(targetPos.getBlockX(), targetPos.getBlockY(), targetPos.getBlockZ());
|
||||
blk.setTypeId(typeID);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of the block at the sight. Returns false if the block wasn't set.
|
||||
*
|
||||
* @param type Material to set the block to
|
||||
* @return boolean
|
||||
*/
|
||||
@SuppressWarnings("empty-statement")
|
||||
public boolean setTargetBlock(Material type)
|
||||
{
|
||||
this.reset();
|
||||
while ((getNextBlock() != null) && ((getCurrentBlock().getTypeId() == 0) || this.blockToIgnoreHasValue(getCurrentBlock().getTypeId())));
|
||||
if (getCurrentBlock() != null)
|
||||
{
|
||||
Block blk = loc.getWorld().getBlockAt(targetPos.getBlockX(), targetPos.getBlockY(), targetPos.getBlockZ());
|
||||
blk.setType(type);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of the block at the sight. Returns false if the block wasn't set.
|
||||
* Observe! At the moment this function is using the built-in enumerator function .valueOf(String) but would preferably be changed to smarter function, when implemented
|
||||
*
|
||||
* @param type Name of type to set the block to
|
||||
* @return boolean
|
||||
*/
|
||||
@SuppressWarnings("empty-statement")
|
||||
public boolean setTargetBlock(String type)
|
||||
{
|
||||
Material mat = Material.valueOf(type);
|
||||
if (mat != null)
|
||||
{
|
||||
this.reset();
|
||||
while ((getNextBlock() != null) && ((getCurrentBlock().getTypeId() == 0) || this.blockToIgnoreHasValue(getCurrentBlock().getTypeId())));
|
||||
if (getCurrentBlock() != null)
|
||||
{
|
||||
Block blk = loc.getWorld().getBlockAt(targetPos.getBlockX(), targetPos.getBlockY(), targetPos.getBlockZ());
|
||||
blk.setType(mat);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the block attached to the face at the sight. Returns null if out of range or if no viable target was found
|
||||
*
|
||||
* @return Block
|
||||
*/
|
||||
@SuppressWarnings("empty-statement")
|
||||
public Block getFaceBlock()
|
||||
{
|
||||
while ((getNextBlock() != null) && ((getCurrentBlock().getTypeId() == 0) || this.blockToIgnoreHasValue(getCurrentBlock().getTypeId())));
|
||||
if (getCurrentBlock() != null)
|
||||
{
|
||||
return getPreviousBlock();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of the block attached to the face at the sight. Returns false if the block wasn't set.
|
||||
*
|
||||
* @param typeID
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean setFaceBlock(int typeID)
|
||||
{
|
||||
if (Material.getMaterial(typeID) != null)
|
||||
{
|
||||
if (getCurrentBlock() != null)
|
||||
{
|
||||
Block blk = loc.getWorld().getBlockAt(prevPos.getBlockX(), prevPos.getBlockY(), prevPos.getBlockZ());
|
||||
blk.setTypeId(typeID);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of the block attached to the face at the sight. Returns false if the block wasn't set.
|
||||
*
|
||||
* @param type
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean setFaceBlock(Material type)
|
||||
{
|
||||
if (getCurrentBlock() != null)
|
||||
{
|
||||
Block blk = loc.getWorld().getBlockAt(prevPos.getBlockX(), prevPos.getBlockY(), prevPos.getBlockZ());
|
||||
blk.setType(type);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of the block attached to the face at the sight. Returns false if the block wasn't set.
|
||||
* Observe! At the moment this function is using the built-in enumerator function .valueOf(String) but would preferably be changed to smarter function, when implemented
|
||||
*
|
||||
* @param type
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean setFaceBlock(String type)
|
||||
{
|
||||
Material mat = Material.valueOf(type);
|
||||
if (mat != null)
|
||||
{
|
||||
if (getCurrentBlock() != null)
|
||||
{
|
||||
Block blk = loc.getWorld().getBlockAt(prevPos.getBlockX(), prevPos.getBlockY(), prevPos.getBlockZ());
|
||||
blk.setType(mat);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get next block
|
||||
*
|
||||
* @return Block
|
||||
*/
|
||||
public Block getNextBlock()
|
||||
{
|
||||
prevPos = targetPos.clone();
|
||||
do
|
||||
{
|
||||
curDistance += checkDistance;
|
||||
|
||||
targetPosDouble.setX(offset.getX() + targetPosDouble.getX());
|
||||
targetPosDouble.setY(offset.getY() + targetPosDouble.getY());
|
||||
targetPosDouble.setZ(offset.getZ() + targetPosDouble.getZ());
|
||||
targetPos = new Vector( targetPosDouble.getBlockX(), targetPosDouble.getBlockY(), targetPosDouble.getBlockZ());
|
||||
}
|
||||
while (curDistance <= maxDistance && targetPos.getBlockX() == prevPos.getBlockX() && targetPos.getBlockY() == prevPos.getBlockY() && targetPos.getBlockZ() == prevPos.getBlockZ());
|
||||
if (curDistance > maxDistance)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.loc.getWorld().getBlockAt(this.targetPos.getBlockX(), this.targetPos.getBlockY(), this.targetPos.getBlockZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current block along the line of vision
|
||||
*
|
||||
* @return Block
|
||||
*/
|
||||
public Block getCurrentBlock()
|
||||
{
|
||||
if (curDistance > maxDistance)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.loc.getWorld().getBlockAt(this.targetPos.getBlockX(), this.targetPos.getBlockY(), this.targetPos.getBlockZ());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets current block type. Returns false if the block wasn't set.
|
||||
*
|
||||
* @param typeID
|
||||
*/
|
||||
public boolean setCurrentBlock(int typeID)
|
||||
{
|
||||
if (Material.getMaterial(typeID) != null)
|
||||
{
|
||||
Block blk = getCurrentBlock();
|
||||
if (blk != null)
|
||||
{
|
||||
blk.setTypeId(typeID);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets current block type. Returns false if the block wasn't set.
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
public boolean setCurrentBlock(Material type)
|
||||
{
|
||||
Block blk = getCurrentBlock();
|
||||
if (blk != null)
|
||||
{
|
||||
blk.setType(type);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets current block type. Returns false if the block wasn't set.
|
||||
* Observe! At the moment this function is using the built-in enumerator function .valueOf(String) but would preferably be changed to smarter function, when implemented
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
public boolean setCurrentBlock(String type)
|
||||
{
|
||||
Material mat = Material.valueOf(type);
|
||||
if (mat != null)
|
||||
{
|
||||
Block blk = getCurrentBlock();
|
||||
if (blk != null)
|
||||
{
|
||||
blk.setType(mat);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the previous block in the aimed path
|
||||
*
|
||||
* @return Block
|
||||
*/
|
||||
public Block getPreviousBlock()
|
||||
{
|
||||
return this.loc.getWorld().getBlockAt(prevPos.getBlockX(), prevPos.getBlockY(), prevPos.getBlockZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets previous block type id. Returns false if the block wasn't set.
|
||||
*
|
||||
* @param typeID
|
||||
*/
|
||||
public boolean setPreviousBlock(int typeID)
|
||||
{
|
||||
if (Material.getMaterial(typeID) != null)
|
||||
{
|
||||
Block blk = getPreviousBlock();
|
||||
if (blk != null)
|
||||
{
|
||||
blk.setTypeId(typeID);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets previous block type id. Returns false if the block wasn't set.
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
public boolean setPreviousBlock(Material type)
|
||||
{
|
||||
Block blk = getPreviousBlock();
|
||||
if (blk != null)
|
||||
{
|
||||
blk.setType(type);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets previous block type id. Returns false if the block wasn't set.
|
||||
* Observe! At the moment this function is using the built-in enumerator function .valueOf(String) but would preferably be changed to smarter function, when implemented
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
public boolean setPreviousBlock(String type)
|
||||
{
|
||||
Material mat = Material.valueOf(type);
|
||||
if (mat != null)
|
||||
{
|
||||
Block blk = getPreviousBlock();
|
||||
if (blk != null)
|
||||
{
|
||||
blk.setType(mat);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private int[] convertStringArraytoIntArray(ArrayList<String> array)
|
||||
{
|
||||
if (array != null)
|
||||
{
|
||||
int intarray[] = new int[array.size()];
|
||||
for (int i = 0; i < array.size(); i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
intarray[i] = Integer.parseInt(array.get(i));
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
intarray[i] = 0;
|
||||
}
|
||||
}
|
||||
return intarray;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean blockToIgnoreHasValue(int value)
|
||||
{
|
||||
if (this.blockToIgnore != null)
|
||||
{
|
||||
if (this.blockToIgnore.length > 0)
|
||||
{
|
||||
for (int i : this.blockToIgnore)
|
||||
{
|
||||
if (i == value)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,23 @@
|
||||
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.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
|
||||
public class Teleport implements Runnable
|
||||
public class Teleport implements Runnable, ITeleport
|
||||
{
|
||||
private static final double MOVE_CONSTANT = 0.3;
|
||||
|
||||
|
||||
private static class Target
|
||||
{
|
||||
private final Location location;
|
||||
@@ -48,22 +56,25 @@ public class Teleport implements Runnable
|
||||
private long initY;
|
||||
private long initZ;
|
||||
private Target teleportTarget;
|
||||
private Charge chargeFor;
|
||||
private Trade chargeFor;
|
||||
private final IEssentials ess;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private TeleportCause cause;
|
||||
|
||||
private void initTimer(long delay, Target target, Charge chargeFor)
|
||||
private void initTimer(long delay, Target target, Trade chargeFor, TeleportCause cause)
|
||||
{
|
||||
this.started = System.currentTimeMillis();
|
||||
this.delay = delay;
|
||||
this.health = user.getHealth();
|
||||
this.initX = Math.round(user.getLocation().getX() * 10000);
|
||||
this.initY = Math.round(user.getLocation().getY() * 10000);
|
||||
this.initZ = Math.round(user.getLocation().getZ() * 10000);
|
||||
this.initX = Math.round(user.getLocation().getX() * MOVE_CONSTANT);
|
||||
this.initY = Math.round(user.getLocation().getY() * MOVE_CONSTANT);
|
||||
this.initZ = Math.round(user.getLocation().getZ() * MOVE_CONSTANT);
|
||||
this.teleportTarget = target;
|
||||
this.chargeFor = chargeFor;
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
|
||||
@@ -72,9 +83,9 @@ public class Teleport implements Runnable
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
if (Math.round(user.getLocation().getX() * 10000) != initX
|
||||
|| Math.round(user.getLocation().getY() * 10000) != initY
|
||||
|| Math.round(user.getLocation().getZ() * 10000) != initZ
|
||||
if (Math.round(user.getLocation().getX() * MOVE_CONSTANT) != initX
|
||||
|| Math.round(user.getLocation().getY() * MOVE_CONSTANT) != initY
|
||||
|| Math.round(user.getLocation().getZ() * MOVE_CONSTANT) != initZ
|
||||
|| user.getHealth() < health)
|
||||
{ // user moved, cancel teleport
|
||||
cancel(true);
|
||||
@@ -89,11 +100,11 @@ public class Teleport implements Runnable
|
||||
try
|
||||
{
|
||||
cooldown(false);
|
||||
user.sendMessage(Util.i18n("teleportationCommencing"));
|
||||
user.sendMessage(_("teleportationCommencing"));
|
||||
try
|
||||
{
|
||||
|
||||
now(teleportTarget);
|
||||
|
||||
now(teleportTarget, cause);
|
||||
if (chargeFor != null)
|
||||
{
|
||||
chargeFor.charge(user);
|
||||
@@ -101,17 +112,12 @@ public class Teleport implements Runnable
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
ess.showError(user.getBase(), ex, "teleport");
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
user.sendMessage(Util.format("cooldownWithMessage", ex.getMessage()));
|
||||
user.sendMessage(_("cooldownWithMessage", ex.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,16 +128,20 @@ public class Teleport implements Runnable
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public void respawn(Spawn spawn, Charge chargeFor) throws Exception
|
||||
public void respawn(final Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
teleport(new Target(spawn.getSpawn(user.getGroup())), chargeFor);
|
||||
final Player player = user.getBase();
|
||||
final Location bed = player.getBedSpawnLocation();
|
||||
final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, bed == null ? player.getWorld().getSpawnLocation() : bed, bed != null);
|
||||
ess.getServer().getPluginManager().callEvent(pre);
|
||||
teleport(new Target(pre.getRespawnLocation()), chargeFor, cause);
|
||||
}
|
||||
|
||||
public void warp(String warp, Charge chargeFor) throws Exception
|
||||
public void warp(String warp, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
Location loc = ess.getWarps().getWarp(warp);
|
||||
teleport(new Target(loc), chargeFor);
|
||||
user.sendMessage(Util.format("warpingTo", warp));
|
||||
teleport(new Target(loc), chargeFor, cause);
|
||||
user.sendMessage(_("warpingTo", warp));
|
||||
}
|
||||
|
||||
public void cooldown(boolean check) throws Exception
|
||||
@@ -146,7 +156,7 @@ public class Teleport implements Runnable
|
||||
cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
|
||||
if (cooldownTime.after(now) && !user.isAuthorized("essentials.teleport.cooldown.bypass"))
|
||||
{
|
||||
throw new Exception(Util.format("timeBeforeTeleport", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
|
||||
throw new Exception(_("timeBeforeTeleport", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
|
||||
}
|
||||
}
|
||||
// if justCheck is set, don't update lastTeleport; we're just checking
|
||||
@@ -167,7 +177,7 @@ public class Teleport implements Runnable
|
||||
ess.getServer().getScheduler().cancelTask(teleTimer);
|
||||
if (notifyUser)
|
||||
{
|
||||
user.sendMessage(Util.i18n("pendingTeleportCancelled"));
|
||||
user.sendMessage(_("pendingTeleportCancelled"));
|
||||
}
|
||||
}
|
||||
finally
|
||||
@@ -180,18 +190,23 @@ public class Teleport implements Runnable
|
||||
{
|
||||
cancel(false);
|
||||
}
|
||||
|
||||
public void teleport(Location loc, Charge chargeFor) throws Exception
|
||||
|
||||
public void teleport(Location loc, Trade chargeFor) throws Exception
|
||||
{
|
||||
teleport(new Target(loc), chargeFor);
|
||||
teleport(new Target(loc), chargeFor, TeleportCause.PLUGIN);
|
||||
}
|
||||
|
||||
public void teleport(Entity entity, Charge chargeFor) throws Exception
|
||||
public void teleport(Location loc, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
teleport(new Target(entity), chargeFor);
|
||||
teleport(new Target(loc), chargeFor, cause);
|
||||
}
|
||||
|
||||
private void teleport(Target target, Charge chargeFor) throws Exception
|
||||
public void teleport(Entity entity, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
teleport(new Target(entity), chargeFor, cause);
|
||||
}
|
||||
|
||||
private void teleport(Target target, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
|
||||
@@ -203,7 +218,7 @@ public class Teleport implements Runnable
|
||||
if (delay <= 0 || user.isAuthorized("essentials.teleport.timer.bypass"))
|
||||
{
|
||||
cooldown(false);
|
||||
now(target);
|
||||
now(target, cause);
|
||||
if (chargeFor != null)
|
||||
{
|
||||
chargeFor.charge(user);
|
||||
@@ -215,67 +230,61 @@ public class Teleport implements Runnable
|
||||
Calendar c = new GregorianCalendar();
|
||||
c.add(Calendar.SECOND, (int)delay);
|
||||
c.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
|
||||
user.sendMessage(Util.format("dontMoveMessage", Util.formatDateDiff(c.getTimeInMillis())));
|
||||
initTimer((long)(delay * 1000.0), target, chargeFor);
|
||||
user.sendMessage(_("dontMoveMessage", Util.formatDateDiff(c.getTimeInMillis())));
|
||||
initTimer((long)(delay * 1000.0), target, chargeFor, cause);
|
||||
|
||||
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
|
||||
}
|
||||
|
||||
private void now(Target target) throws Exception
|
||||
private void now(Target target, TeleportCause cause) throws Exception
|
||||
{
|
||||
cancel();
|
||||
user.setLastLocation();
|
||||
user.getBase().teleport(Util.getSafeDestination(target.getLocation()));
|
||||
user.getBase().teleport(Util.getSafeDestination(target.getLocation()), cause);
|
||||
}
|
||||
|
||||
public void now(Location loc) throws Exception
|
||||
public void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception
|
||||
{
|
||||
cooldown(false);
|
||||
now(new Target(loc));
|
||||
if (cooldown)
|
||||
{
|
||||
cooldown(false);
|
||||
}
|
||||
now(new Target(loc), cause);
|
||||
}
|
||||
|
||||
public void now(Location loc, Charge chargeFor) throws Exception
|
||||
|
||||
public void now(Location loc, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
cooldown(false);
|
||||
chargeFor.charge(user);
|
||||
now(new Target(loc));
|
||||
now(new Target(loc), cause);
|
||||
}
|
||||
|
||||
public void now(Entity entity) throws Exception
|
||||
public void now(Entity entity, boolean cooldown, TeleportCause cause) throws Exception
|
||||
{
|
||||
cooldown(false);
|
||||
now(new Target(entity));
|
||||
if (cooldown)
|
||||
{
|
||||
cooldown(false);
|
||||
}
|
||||
now(new Target(entity), cause);
|
||||
}
|
||||
|
||||
public void back(Charge chargeFor) throws Exception
|
||||
public void back(Trade chargeFor) throws Exception
|
||||
{
|
||||
teleport(new Target(user.getLastLocation()), chargeFor);
|
||||
teleport(new Target(user.getLastLocation()), chargeFor, TeleportCause.COMMAND);
|
||||
}
|
||||
|
||||
public void back() throws Exception
|
||||
{
|
||||
back(null);
|
||||
now(new Target(user.getLastLocation()), TeleportCause.COMMAND);
|
||||
}
|
||||
|
||||
public void home(Charge chargeFor) throws Exception
|
||||
public void home(IUser user, String home, Trade chargeFor) throws Exception
|
||||
{
|
||||
home(user, chargeFor);
|
||||
}
|
||||
|
||||
public void home(IUser user, Charge chargeFor) throws Exception
|
||||
{
|
||||
Location loc = user.getHome(this.user.getLocation());
|
||||
final Location loc = user.getHome(home);
|
||||
if (loc == null)
|
||||
{
|
||||
if (ess.getSettings().spawnIfNoHome())
|
||||
{
|
||||
respawn(ess.getSpawn(), chargeFor);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(user == this.user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer"));
|
||||
}
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
teleport(new Target(loc), chargeFor);
|
||||
teleport(new Target(loc), chargeFor, TeleportCause.COMMAND);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,321 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import com.earth2me.essentials.craftbukkit.SetExpFix;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
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 Double money;
|
||||
private final transient ItemStack itemStack;
|
||||
private final transient Integer exp;
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public Trade(final String command, final IEssentials ess)
|
||||
{
|
||||
this(command, null, null, null, ess);
|
||||
}
|
||||
|
||||
public Trade(final double money, final IEssentials ess)
|
||||
{
|
||||
this(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);
|
||||
}
|
||||
|
||||
private Trade(final String command, final Double money, final ItemStack item, final Integer exp, final IEssentials ess)
|
||||
{
|
||||
this.command = command;
|
||||
this.money = money;
|
||||
this.itemStack = item;
|
||||
this.exp = exp;
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public void isAffordableFor(final IUser user) throws ChargeException
|
||||
{
|
||||
final double mon = user.getMoney();
|
||||
if (getMoney() != null
|
||||
&& mon < getMoney()
|
||||
&& getMoney() > 0
|
||||
&& !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
|
||||
if (getItemStack() != null
|
||||
&& !InventoryWorkaround.containsItem(user.getInventory(), true, true, itemStack))
|
||||
{
|
||||
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
|
||||
}
|
||||
|
||||
if (command != null && !command.isEmpty()
|
||||
&& !user.isAuthorized("essentials.nocommandcost.all")
|
||||
&& !user.isAuthorized("essentials.nocommandcost." + command)
|
||||
&& mon < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
|
||||
&& 0 < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
|
||||
&& !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
|
||||
if (exp != null && exp > 0
|
||||
&& SetExpFix.getTotalExperience(user) < exp)
|
||||
{
|
||||
throw new ChargeException(_("notEnoughExperience"));
|
||||
}
|
||||
}
|
||||
|
||||
public void pay(final IUser user)
|
||||
{
|
||||
pay(user, true);
|
||||
}
|
||||
|
||||
public boolean pay(final IUser user, final boolean dropItems)
|
||||
{
|
||||
boolean success = true;
|
||||
if (getMoney() != null && getMoney() > 0)
|
||||
{
|
||||
user.giveMoney(getMoney());
|
||||
}
|
||||
if (getItemStack() != null)
|
||||
{
|
||||
if (dropItems)
|
||||
{
|
||||
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItem(user.getInventory(), true, getItemStack());
|
||||
final Location loc = user.getLocation();
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
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
|
||||
{
|
||||
success = InventoryWorkaround.addAllItems(user.getInventory(), true, getItemStack());
|
||||
}
|
||||
user.updateInventory();
|
||||
}
|
||||
if (getExperience() != null)
|
||||
{
|
||||
SetExpFix.setTotalExperience(user, SetExpFix.getTotalExperience(user) + getExperience());
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
public void charge(final IUser user) throws ChargeException
|
||||
{
|
||||
if (getMoney() != null)
|
||||
{
|
||||
if (!user.canAfford(getMoney()) && getMoney() > 0)
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(getMoney());
|
||||
}
|
||||
if (getItemStack() != null)
|
||||
{
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, true, itemStack))
|
||||
{
|
||||
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
|
||||
}
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, true, getItemStack());
|
||||
user.updateInventory();
|
||||
}
|
||||
if (command != null && !command.isEmpty()
|
||||
&& !user.isAuthorized("essentials.nocommandcost.all")
|
||||
&& !user.isAuthorized("essentials.nocommandcost." + command))
|
||||
{
|
||||
final double cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
|
||||
if (!user.canAfford(cost) && cost > 0)
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(cost);
|
||||
}
|
||||
if (getExperience() != null)
|
||||
{
|
||||
final int experience = SetExpFix.getTotalExperience(user);
|
||||
if (experience < getExperience() && getExperience() > 0)
|
||||
{
|
||||
throw new ChargeException(_("notEnoughExperience"));
|
||||
}
|
||||
SetExpFix.setTotalExperience(user, experience - getExperience());
|
||||
}
|
||||
}
|
||||
|
||||
public Double getMoney()
|
||||
{
|
||||
return money;
|
||||
}
|
||||
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public Integer getExperience()
|
||||
{
|
||||
return exp;
|
||||
}
|
||||
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 ((loc == null && !ess.getSettings().isEcoLogUpdateEnabled())
|
||||
|| (loc != null && !ess.getSettings().isEcoLogEnabled()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (fw == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
fw = new FileWriter(new File(ess.getDataFolder(), "trade.log"), true);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(type).append(",").append(subtype).append(",").append(event).append(",\"");
|
||||
sb.append(DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(new Date()));
|
||||
sb.append("\",\"");
|
||||
if (sender != null)
|
||||
{
|
||||
sb.append(sender);
|
||||
}
|
||||
sb.append("\",");
|
||||
if (charge == null)
|
||||
{
|
||||
sb.append("\"\",\"\",\"\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (charge.getItemStack() != null)
|
||||
{
|
||||
sb.append(charge.getItemStack().getAmount()).append(",");
|
||||
sb.append(charge.getItemStack().getType().toString()).append(",");
|
||||
sb.append(charge.getItemStack().getDurability());
|
||||
}
|
||||
if (charge.getMoney() != null)
|
||||
{
|
||||
sb.append(charge.getMoney()).append(",");
|
||||
sb.append("money").append(",");
|
||||
sb.append(ess.getSettings().getCurrencySymbol());
|
||||
}
|
||||
if (charge.getExperience() != null)
|
||||
{
|
||||
sb.append(charge.getExperience()).append(",");
|
||||
sb.append("exp").append(",");
|
||||
sb.append("\"\"");
|
||||
}
|
||||
}
|
||||
sb.append(",\"");
|
||||
if (receiver != null)
|
||||
{
|
||||
sb.append(receiver);
|
||||
}
|
||||
sb.append("\",");
|
||||
if (pay == null)
|
||||
{
|
||||
sb.append("\"\",\"\",\"\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pay.getItemStack() != null)
|
||||
{
|
||||
sb.append(pay.getItemStack().getAmount()).append(",");
|
||||
sb.append(pay.getItemStack().getType().toString()).append(",");
|
||||
sb.append(pay.getItemStack().getDurability());
|
||||
}
|
||||
if (pay.getMoney() != null)
|
||||
{
|
||||
sb.append(pay.getMoney()).append(",");
|
||||
sb.append("money").append(",");
|
||||
sb.append(ess.getSettings().getCurrencySymbol());
|
||||
}
|
||||
if (pay.getExperience() != null)
|
||||
{
|
||||
sb.append(pay.getExperience()).append(",");
|
||||
sb.append("exp").append(",");
|
||||
sb.append("\"\"");
|
||||
}
|
||||
}
|
||||
if (loc == null)
|
||||
{
|
||||
sb.append(",\"\",\"\",\"\",\"\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append(",\"");
|
||||
sb.append(loc.getWorld().getName()).append("\",");
|
||||
sb.append(loc.getBlockX()).append(",");
|
||||
sb.append(loc.getBlockY()).append(",");
|
||||
sb.append(loc.getBlockZ()).append(",");
|
||||
}
|
||||
sb.append("\n");
|
||||
try
|
||||
{
|
||||
fw.write(sb.toString());
|
||||
fw.flush();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void closeLog()
|
||||
{
|
||||
if (fw != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
fw.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
fw = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +1,66 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
{
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private boolean justPortaled = false;
|
||||
private CommandSender replyTo = null;
|
||||
private User teleportRequester;
|
||||
private boolean teleportRequestHere;
|
||||
private final Teleport teleport;
|
||||
private long lastActivity;
|
||||
private transient User teleportRequester;
|
||||
private transient boolean teleportRequestHere;
|
||||
private transient final Teleport teleport;
|
||||
private transient long teleportRequestTime;
|
||||
private transient long lastOnlineActivity;
|
||||
private transient long lastActivity = System.currentTimeMillis();
|
||||
private boolean hidden = false;
|
||||
private transient Location afkPosition = null;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
User(Player base, IEssentials ess)
|
||||
User(final Player base, final IEssentials ess)
|
||||
{
|
||||
super(base, ess);
|
||||
teleport = new Teleport(this, ess);
|
||||
if (isAfk())
|
||||
{
|
||||
afkPosition = getLocation();
|
||||
}
|
||||
}
|
||||
|
||||
User update(Player base)
|
||||
User update(final Player base)
|
||||
{
|
||||
setBase(base);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isAuthorized(IEssentialsCommand cmd)
|
||||
@Override
|
||||
public boolean isAuthorized(final IEssentialsCommand cmd)
|
||||
{
|
||||
return isAuthorized("essentials." + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
|
||||
return isAuthorized(cmd, "essentials.");
|
||||
}
|
||||
|
||||
public boolean isAuthorized(String node)
|
||||
@Override
|
||||
public boolean isAuthorized(final IEssentialsCommand cmd, final String permissionPrefix)
|
||||
{
|
||||
return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(final String node)
|
||||
{
|
||||
if (base instanceof OfflinePlayer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isOp())
|
||||
{
|
||||
return true;
|
||||
@@ -49,149 +71,170 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return com.nijikokun.bukkit.Permissions.Permissions.Security.permission(base, node);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
String[] cmds = node.split("\\.", 2);
|
||||
return !ess.getSettings().isCommandRestricted(cmds[cmds.length - 1]);
|
||||
}
|
||||
return ess.getPermissionsHandler().hasPermission(base, node);
|
||||
}
|
||||
|
||||
public void healCooldown() throws Exception
|
||||
{
|
||||
Calendar now = new GregorianCalendar();
|
||||
final Calendar now = new GregorianCalendar();
|
||||
if (getLastHealTimestamp() > 0)
|
||||
{
|
||||
double cooldown = ess.getSettings().getHealCooldown();
|
||||
Calendar cooldownTime = new GregorianCalendar();
|
||||
final double cooldown = ess.getSettings().getHealCooldown();
|
||||
final Calendar cooldownTime = new GregorianCalendar();
|
||||
cooldownTime.setTimeInMillis(getLastHealTimestamp());
|
||||
cooldownTime.add(Calendar.SECOND, (int)cooldown);
|
||||
cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
|
||||
if (cooldownTime.after(now) && !isAuthorized("essentials.heal.cooldown.bypass"))
|
||||
{
|
||||
throw new Exception(Util.format("timeBeforeHeal", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
|
||||
throw new Exception(_("timeBeforeHeal", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
|
||||
}
|
||||
}
|
||||
setLastHealTimestamp(now.getTimeInMillis());
|
||||
}
|
||||
|
||||
public void giveMoney(double value)
|
||||
@Override
|
||||
public void giveMoney(final double value)
|
||||
{
|
||||
giveMoney(value, null);
|
||||
}
|
||||
|
||||
public void giveMoney(final double value, final CommandSender initiator)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
setMoney(getMoney() + value);
|
||||
sendMessage(Util.format("addedToAccount", Util.formatCurrency(value)));
|
||||
sendMessage(_("addedToAccount", Util.displayCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage(_("addedToOthersAccount", Util.displayCurrency(value, ess), this.getDisplayName(), Util.displayCurrency(getMoney(), ess)));
|
||||
}
|
||||
}
|
||||
|
||||
public void payUser(User reciever, double value) throws Exception
|
||||
public void payUser(final User reciever, final double value) throws Exception
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!canAfford(value))
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
else
|
||||
if (canAfford(value))
|
||||
{
|
||||
setMoney(getMoney() - value);
|
||||
reciever.setMoney(reciever.getMoney() + value);
|
||||
sendMessage(Util.format("moneySentTo", Util.formatCurrency(value), reciever.getDisplayName()));
|
||||
reciever.sendMessage(Util.format("moneyRecievedFrom", Util.formatCurrency(value), getDisplayName()));
|
||||
sendMessage(_("moneySentTo", Util.displayCurrency(value, ess), reciever.getDisplayName()));
|
||||
reciever.sendMessage(_("moneyRecievedFrom", Util.displayCurrency(value, ess), getDisplayName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("notEnoughMoney"));
|
||||
}
|
||||
}
|
||||
|
||||
public void takeMoney(double value)
|
||||
@Override
|
||||
public void takeMoney(final double value)
|
||||
{
|
||||
takeMoney(value, null);
|
||||
}
|
||||
|
||||
public void takeMoney(final double value, final CommandSender initiator)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
setMoney(getMoney() - value);
|
||||
sendMessage(Util.format("takenFromAccount", Util.formatCurrency(value)));
|
||||
sendMessage(_("takenFromAccount", Util.displayCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage(_("takenFromOthersAccount", Util.displayCurrency(value, ess), this.getDisplayName(), Util.displayCurrency(getMoney(), ess)));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canAfford(double cost)
|
||||
public boolean canAfford(final double cost)
|
||||
{
|
||||
double mon = getMoney();
|
||||
return mon >= cost || isAuthorized("essentials.eco.loan");
|
||||
return canAfford(cost, true);
|
||||
}
|
||||
|
||||
public boolean canAfford(final double cost, final boolean permcheck)
|
||||
{
|
||||
final double mon = getMoney();
|
||||
if (!permcheck || isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
return (mon - cost) >= ess.getSettings().getMinMoney();
|
||||
}
|
||||
return cost <= mon;
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
this.base = new OfflinePlayer(getName());
|
||||
this.base = new OfflinePlayer(getName(), ess);
|
||||
}
|
||||
|
||||
public boolean getJustPortaled()
|
||||
{
|
||||
return justPortaled;
|
||||
}
|
||||
|
||||
public void setJustPortaled(boolean value)
|
||||
{
|
||||
justPortaled = value;
|
||||
}
|
||||
|
||||
public void setReplyTo(CommandSender user)
|
||||
@Override
|
||||
public void setReplyTo(final CommandSender user)
|
||||
{
|
||||
replyTo = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSender getReplyTo()
|
||||
{
|
||||
return replyTo;
|
||||
}
|
||||
|
||||
public int compareTo(User t)
|
||||
@Override
|
||||
public int compareTo(final User other)
|
||||
{
|
||||
return ChatColor.stripColor(this.getDisplayName()).compareToIgnoreCase(ChatColor.stripColor(t.getDisplayName()));
|
||||
return Util.stripColor(this.getDisplayName()).compareToIgnoreCase(Util.stripColor(other.getDisplayName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
public boolean equals(final Object object)
|
||||
{
|
||||
if (!(o instanceof User))
|
||||
if (!(object instanceof User))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User) o).getDisplayName()));
|
||||
|
||||
return this.getName().equalsIgnoreCase(((User)object).getName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ChatColor.stripColor(this.getDisplayName()).hashCode();
|
||||
return this.getName().hashCode();
|
||||
}
|
||||
|
||||
public Boolean canSpawnItem(int itemId)
|
||||
public Boolean canSpawnItem(final int itemId)
|
||||
{
|
||||
return !ess.getSettings().itemSpawnBlacklist().contains(itemId);
|
||||
}
|
||||
|
||||
public Location getHome() throws Exception
|
||||
{
|
||||
return getHome(getHomes().get(0));
|
||||
}
|
||||
|
||||
public void setHome()
|
||||
{
|
||||
setHome(getLocation(), true);
|
||||
setHome("home", getLocation());
|
||||
}
|
||||
|
||||
public void setHome(boolean defaultHome)
|
||||
public void setHome(final String name)
|
||||
{
|
||||
setHome(getLocation(), defaultHome);
|
||||
setHome(name, getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastLocation()
|
||||
{
|
||||
setLastLocation(getLocation());
|
||||
}
|
||||
|
||||
public void requestTeleport(User player, boolean here)
|
||||
public void requestTeleport(final User player, final boolean here)
|
||||
{
|
||||
teleportRequestTime = System.currentTimeMillis();
|
||||
teleportRequester = player;
|
||||
teleportRequestHere = here;
|
||||
}
|
||||
@@ -206,78 +249,141 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return teleportRequestHere;
|
||||
}
|
||||
|
||||
public String getNick()
|
||||
public String getNick(final boolean addprefixsuffix)
|
||||
{
|
||||
String nickname = getNickname();
|
||||
if (ess.getSettings().isCommandDisabled("nick") || nickname == null || nickname.isEmpty() || nickname.equals(getName()))
|
||||
final StringBuilder nickname = new StringBuilder();
|
||||
final String nick = getNickname();
|
||||
if (ess.getSettings().isCommandDisabled("nick") || nick == null || nick.isEmpty() || nick.equals(getName()))
|
||||
{
|
||||
nickname = getName();
|
||||
nickname.append(getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
nickname = ess.getSettings().getNicknamePrefix() + nickname;
|
||||
nickname.append(ess.getSettings().getNicknamePrefix()).append(nick);
|
||||
}
|
||||
if (isOp())
|
||||
|
||||
if (addprefixsuffix && isOp())
|
||||
{
|
||||
try
|
||||
{
|
||||
nickname = ess.getSettings().getOperatorColor().toString() + nickname + "§f";
|
||||
final String opPrefix = ess.getSettings().getOperatorColor().toString();
|
||||
if (opPrefix.length() > 0) {
|
||||
nickname.insert(0, opPrefix);
|
||||
nickname.append("§f");
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
return nickname;
|
||||
if (addprefixsuffix && ess.getSettings().addPrefixSuffix())
|
||||
{
|
||||
if (!ess.getSettings().disablePrefix())
|
||||
{
|
||||
final String prefix = ess.getPermissionsHandler().getPrefix(base).replace('&', '§');
|
||||
nickname.insert(0, prefix);
|
||||
}
|
||||
if (!ess.getSettings().disableSuffix())
|
||||
{
|
||||
final String suffix = ess.getPermissionsHandler().getSuffix(base).replace('&', '§');
|
||||
nickname.append(suffix);
|
||||
if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§"))
|
||||
{
|
||||
nickname.append("§f");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nickname.append("§f");
|
||||
}
|
||||
}
|
||||
|
||||
return nickname.toString();
|
||||
}
|
||||
|
||||
public void setDisplayNick()
|
||||
{
|
||||
String name = getNick(true);
|
||||
setDisplayName(name);
|
||||
if (name.length() > 16)
|
||||
{
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
public long getLastActivity()
|
||||
public long getLastOnlineActivity()
|
||||
{
|
||||
return lastActivity;
|
||||
return lastOnlineActivity;
|
||||
}
|
||||
|
||||
public void setLastActivity(long timestamp)
|
||||
public void setLastOnlineActivity(final long timestamp)
|
||||
{
|
||||
lastActivity = timestamp;
|
||||
lastOnlineActivity = timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMoney()
|
||||
{
|
||||
if (ess.isRegisterFallbackEnabled() && ess.getPaymentMethod().hasMethod())
|
||||
if (ess.getPaymentMethod().hasMethod())
|
||||
{
|
||||
try
|
||||
{
|
||||
Method method = ess.getPaymentMethod().getMethod();
|
||||
if (!method.hasAccount(this.getName())) {
|
||||
final Method method = ess.getPaymentMethod().getMethod();
|
||||
if (!method.hasAccount(this.getName()))
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
return account.balance();
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
{
|
||||
}
|
||||
}
|
||||
return super.getMoney();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMoney(double value)
|
||||
public void setMoney(final double value)
|
||||
{
|
||||
if (ess.isRegisterFallbackEnabled() && ess.getPaymentMethod().hasMethod())
|
||||
if (ess.getPaymentMethod().hasMethod())
|
||||
{
|
||||
try
|
||||
{
|
||||
Method method = ess.getPaymentMethod().getMethod();
|
||||
if (!method.hasAccount(this.getName())) {
|
||||
final Method method = ess.getPaymentMethod().getMethod();
|
||||
if (!method.hasAccount(this.getName()))
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
account.set(value);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
@@ -285,5 +391,189 @@ 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
|
||||
public void setAfk(final boolean set)
|
||||
{
|
||||
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
|
||||
if (set && !isAfk())
|
||||
{
|
||||
afkPosition = getLocation();
|
||||
}
|
||||
else if (!set && isAfk())
|
||||
{
|
||||
afkPosition = null;
|
||||
}
|
||||
super.setAfk(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggleAfk()
|
||||
{
|
||||
final boolean now = super.toggleAfk();
|
||||
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : now);
|
||||
return now;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden()
|
||||
{
|
||||
return hidden;
|
||||
}
|
||||
|
||||
public void setHidden(final boolean hidden)
|
||||
{
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
//Returns true if status expired during this check
|
||||
public boolean checkJailTimeout(final long currentTime)
|
||||
{
|
||||
if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed())
|
||||
{
|
||||
setJailTimeout(0);
|
||||
setJailed(false);
|
||||
sendMessage(_("haveBeenReleased"));
|
||||
setJail(null);
|
||||
try
|
||||
{
|
||||
getTeleport().back();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//Returns true if status expired during this check
|
||||
public boolean checkMuteTimeout(final long currentTime)
|
||||
{
|
||||
if (getMuteTimeout() > 0 && getMuteTimeout() < currentTime && isMuted())
|
||||
{
|
||||
setMuteTimeout(0);
|
||||
sendMessage(_("canTalkAgain"));
|
||||
setMuted(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//Returns true if status expired during this check
|
||||
public boolean checkBanTimeout(final long currentTime)
|
||||
{
|
||||
if (getBanTimeout() > 0 && getBanTimeout() < currentTime && isBanned())
|
||||
{
|
||||
setBanTimeout(0);
|
||||
setBanned(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void updateActivity(final boolean broadcast)
|
||||
{
|
||||
if (isAfk())
|
||||
{
|
||||
setAfk(false);
|
||||
if (broadcast && !isHidden())
|
||||
{
|
||||
ess.broadcastMessage(this, _("userIsNotAway", getDisplayName()));
|
||||
}
|
||||
}
|
||||
lastActivity = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void checkActivity()
|
||||
{
|
||||
final long autoafkkick = ess.getSettings().getAutoAfkKick();
|
||||
if (autoafkkick > 0 && lastActivity > 0 && (lastActivity + (autoafkkick * 1000)) < System.currentTimeMillis()
|
||||
&& !isHidden() && !isAuthorized("essentials.kick.exempt") && !isAuthorized("essentials.afk.kickexempt"))
|
||||
{
|
||||
final String kickReason = _("autoAfkKickReason", autoafkkick / 60.0);
|
||||
lastActivity = 0;
|
||||
kickPlayer(kickReason);
|
||||
|
||||
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
if (user.isAuthorized("essentials.kick.notify"))
|
||||
{
|
||||
player.sendMessage(_("playerKicked", Console.NAME, getName(), kickReason));
|
||||
}
|
||||
}
|
||||
}
|
||||
final long autoafk = ess.getSettings().getAutoAfk();
|
||||
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis() && isAuthorized("essentials.afk"))
|
||||
{
|
||||
setAfk(true);
|
||||
if (!isHidden())
|
||||
{
|
||||
ess.broadcastMessage(this, _("userIsAway", getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Location getAfkPosition()
|
||||
{
|
||||
return afkPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggleGodModeEnabled()
|
||||
{
|
||||
if (!isGodModeEnabled())
|
||||
{
|
||||
setFoodLevel(20);
|
||||
}
|
||||
return super.toggleGodModeEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGodModeEnabled()
|
||||
{
|
||||
return (super.isGodModeEnabled() && !ess.getSettings().getNoGodWorlds().contains(getLocation().getWorld().getName()))
|
||||
|| (isAfk() && ess.getSettings().getFreezeAfkPlayers());
|
||||
}
|
||||
|
||||
public boolean isGodModeEnabledRaw()
|
||||
{
|
||||
return super.isGodModeEnabled();
|
||||
}
|
||||
|
||||
public String getGroup()
|
||||
{
|
||||
return ess.getPermissionsHandler().getGroup(base);
|
||||
}
|
||||
|
||||
public boolean inGroup(final String group)
|
||||
{
|
||||
return ess.getPermissionsHandler().inGroup(base, group);
|
||||
}
|
||||
|
||||
public boolean canBuild()
|
||||
{
|
||||
if (isOp())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return ess.getPermissionsHandler().canBuild(base, getGroup());
|
||||
}
|
||||
|
||||
public long getTeleportRequestTime()
|
||||
{
|
||||
return teleportRequestTime;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,24 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
super(base, ess);
|
||||
super(base);
|
||||
this.ess = ess;
|
||||
File folder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!folder.exists())
|
||||
{
|
||||
@@ -31,12 +28,14 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void reloadConfig()
|
||||
{
|
||||
config.load();
|
||||
money = _getMoney();
|
||||
unlimited = _getUnlimited();
|
||||
powertools = getPowertools();
|
||||
powertools = _getPowertools();
|
||||
homes = _getHomes();
|
||||
lastLocation = _getLastLocation();
|
||||
lastTeleportTimestamp = _getLastTeleportTimestamp();
|
||||
lastHealTimestamp = _getLastHealTimestamp();
|
||||
@@ -45,31 +44,36 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
savedInventory = _getSavedInventory();
|
||||
teleportEnabled = getTeleportEnabled();
|
||||
ignoredPlayers = getIgnoredPlayers();
|
||||
godmode = getGodModeEnabled();
|
||||
godmode = _getGodModeEnabled();
|
||||
muted = getMuted();
|
||||
muteTimeout = _getMuteTimeout();
|
||||
jailed = getJailed();
|
||||
jailTimeout = _getJailTimeout();
|
||||
lastLogin = _getLastLogin();
|
||||
lastLogout = _getLastLogout();
|
||||
lastLoginAddress = _getLastLoginAddress();
|
||||
afk = getAfk();
|
||||
newplayer = getNew();
|
||||
geolocation = _getGeoLocation();
|
||||
isSocialSpyEnabled = _isSocialSpyEnabled();
|
||||
isNPC = _isNPC();
|
||||
arePowerToolsEnabled = _arePowerToolsEnabled();
|
||||
kitTimestamps = _getKitTimestamps();
|
||||
nickname = _getNickname();
|
||||
}
|
||||
|
||||
private double money;
|
||||
|
||||
private double _getMoney() {
|
||||
|
||||
private double _getMoney()
|
||||
{
|
||||
double money = ess.getSettings().getStartingBalance();
|
||||
if (config.hasProperty("money"))
|
||||
{
|
||||
return config.getDouble("money", ess.getSettings().getStartingBalance());
|
||||
money = config.getDouble("money", money);
|
||||
}
|
||||
else
|
||||
if (Math.abs(money) > ess.getSettings().getMaxMoney())
|
||||
{
|
||||
return ess.getSettings().getStartingBalance();
|
||||
money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney();
|
||||
}
|
||||
return money;
|
||||
}
|
||||
|
||||
public double getMoney()
|
||||
@@ -80,9 +84,102 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
public void setMoney(double value)
|
||||
{
|
||||
money = value;
|
||||
if (Math.abs(money) > ess.getSettings().getMaxMoney())
|
||||
{
|
||||
money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney();
|
||||
}
|
||||
config.setProperty("money", value);
|
||||
config.save();
|
||||
}
|
||||
private Map<String, Object> homes;
|
||||
|
||||
private Map<String, Object> _getHomes()
|
||||
{
|
||||
if (config.isConfigurationSection("homes"))
|
||||
{
|
||||
return config.getConfigurationSection("homes").getValues(false);
|
||||
}
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
public Location getHome(String name) throws Exception
|
||||
{
|
||||
Location loc = config.getLocation("homes." + name, getServer());
|
||||
if (loc == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
loc = config.getLocation("homes." + getHomes().get(Integer.parseInt(name) - 1), getServer());
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return loc;
|
||||
}
|
||||
|
||||
public Location getHome(final Location world)
|
||||
{
|
||||
try
|
||||
{
|
||||
Location loc;
|
||||
for (String home : getHomes())
|
||||
{
|
||||
loc = config.getLocation("homes." + home, getServer());
|
||||
if (world.getWorld() == loc.getWorld())
|
||||
{
|
||||
return loc;
|
||||
}
|
||||
|
||||
}
|
||||
loc = config.getLocation("homes." + getHomes().get(0), getServer());
|
||||
return loc;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getHomes()
|
||||
{
|
||||
return new ArrayList(homes.keySet());
|
||||
}
|
||||
|
||||
public void setHome(String name, Location loc)
|
||||
{
|
||||
//Invalid names will corrupt the yaml
|
||||
name = Util.sanitizeFileName(name);
|
||||
homes.put(name, loc);
|
||||
config.setProperty("homes." + name, loc);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public void delHome(String name) throws Exception
|
||||
{
|
||||
String search = name;
|
||||
if (!homes.containsKey(search))
|
||||
{
|
||||
search = Util.sanitizeFileName(name);
|
||||
}
|
||||
if (homes.containsKey(search))
|
||||
{
|
||||
homes.remove(name);
|
||||
config.removeProperty("homes." + name);
|
||||
config.save();
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO: move this message to messages file
|
||||
throw new Exception("Home " + name + " doesn't exist");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasHome()
|
||||
{
|
||||
@@ -92,48 +189,22 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String nickname;
|
||||
|
||||
public Location getHome(Location location)
|
||||
{
|
||||
if (!hasHome())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
World world = location.getWorld();
|
||||
String worldHome = "home.worlds." + world.getName().toLowerCase();
|
||||
if (!config.hasProperty(worldHome))
|
||||
{
|
||||
String defaultWorld = config.getString("home.default");
|
||||
worldHome = "home.worlds." + defaultWorld;
|
||||
}
|
||||
Location loc = config.getLocation(worldHome, getServer());
|
||||
return loc;
|
||||
}
|
||||
|
||||
public void setHome(Location loc, boolean b)
|
||||
{
|
||||
String worldName = loc.getWorld().getName().toLowerCase();
|
||||
if (worldName == null || worldName.isEmpty())
|
||||
{
|
||||
logger.log(Level.WARNING, Util.i18n("emptyWorldName"));
|
||||
return;
|
||||
}
|
||||
if (b || !config.hasProperty("home.default"))
|
||||
{
|
||||
config.setProperty("home.default", worldName);
|
||||
}
|
||||
|
||||
config.setProperty("home.worlds." + worldName, loc);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public String getNickname()
|
||||
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();
|
||||
}
|
||||
@@ -141,7 +212,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()
|
||||
@@ -167,46 +238,64 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("unlimited", unlimited);
|
||||
config.save();
|
||||
}
|
||||
private Map<Integer, String> powertools;
|
||||
private Map<String, Object> powertools;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<Integer, String> getPowertools()
|
||||
private Map<String, Object> _getPowertools()
|
||||
{
|
||||
Object o = config.getProperty("powertools");
|
||||
if (o instanceof Map)
|
||||
if (config.isConfigurationSection("powertools"))
|
||||
{
|
||||
return (Map<Integer, String>)o;
|
||||
return config.getConfigurationSection("powertools").getValues(false);
|
||||
}
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
public void clearAllPowertools()
|
||||
{
|
||||
powertools.clear();
|
||||
config.setProperty("powertools", powertools);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public List<String> getPowertool(ItemStack stack)
|
||||
{
|
||||
return (List<String>)powertools.get("" + stack.getTypeId());
|
||||
}
|
||||
|
||||
public List<String> getPowertool(int id)
|
||||
{
|
||||
return (List<String>)powertools.get("" + id);
|
||||
}
|
||||
|
||||
public void setPowertool(ItemStack stack, List<String> commandList)
|
||||
{
|
||||
if (commandList == null || commandList.isEmpty())
|
||||
{
|
||||
powertools.remove("" + stack.getTypeId());
|
||||
}
|
||||
else
|
||||
{
|
||||
return new HashMap<Integer, String>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getPowertool(ItemStack stack)
|
||||
{
|
||||
return powertools.get(stack.getTypeId());
|
||||
}
|
||||
|
||||
public void setPowertool(ItemStack stack, String command)
|
||||
{
|
||||
if (command == null || command.isEmpty())
|
||||
{
|
||||
powertools.remove(stack.getTypeId());
|
||||
}
|
||||
else
|
||||
{
|
||||
powertools.put(stack.getTypeId(), command);
|
||||
powertools.put("" + stack.getTypeId(), commandList);
|
||||
}
|
||||
config.setProperty("powertools", powertools);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean hasPowerTools()
|
||||
{
|
||||
return !powertools.isEmpty();
|
||||
}
|
||||
private Location lastLocation;
|
||||
|
||||
private Location _getLastLocation()
|
||||
{
|
||||
return config.getLocation("lastlocation", getServer());
|
||||
try
|
||||
{
|
||||
return config.getLocation("lastlocation", getServer());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Location getLastLocation()
|
||||
@@ -216,6 +305,10 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
public void setLastLocation(Location loc)
|
||||
{
|
||||
if (loc == null || loc.getWorld() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lastLocation = loc;
|
||||
config.setProperty("lastlocation", loc);
|
||||
config.save();
|
||||
@@ -286,7 +379,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()
|
||||
@@ -324,7 +417,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
private ItemStack[] _getSavedInventory()
|
||||
{
|
||||
int size = config.getInt("inventory.size", 0);
|
||||
if (size < 1 || size > getInventory().getSize())
|
||||
if (size < 1 || (getInventory() != null && size > getInventory().getSize()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -383,6 +476,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
setTeleportEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean toggleSocialSpy()
|
||||
{
|
||||
boolean ret = !isSocialSpyEnabled();
|
||||
@@ -393,7 +487,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
public List<String> getIgnoredPlayers()
|
||||
{
|
||||
return config.getStringList("ignore", new ArrayList<String>());
|
||||
return config.getStringList("ignore");
|
||||
}
|
||||
|
||||
public void setIgnoredPlayers(List<String> players)
|
||||
@@ -413,24 +507,24 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
public boolean isIgnoredPlayer(String name)
|
||||
{
|
||||
return ignoredPlayers.contains(name.toLowerCase());
|
||||
return ignoredPlayers.contains(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public void setIgnoredPlayer(String name, boolean set)
|
||||
{
|
||||
if (set)
|
||||
{
|
||||
ignoredPlayers.add(name.toLowerCase());
|
||||
ignoredPlayers.add(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
else
|
||||
{
|
||||
ignoredPlayers.remove(name.toLowerCase());
|
||||
ignoredPlayers.remove(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
setIgnoredPlayers(ignoredPlayers);
|
||||
}
|
||||
private boolean godmode;
|
||||
|
||||
private boolean getGodModeEnabled()
|
||||
private boolean _getGodModeEnabled()
|
||||
{
|
||||
return config.getBoolean("godmode", false);
|
||||
}
|
||||
@@ -597,6 +691,24 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("timestamps.logout", time);
|
||||
config.save();
|
||||
}
|
||||
private String lastLoginAddress;
|
||||
|
||||
private String _getLastLoginAddress()
|
||||
{
|
||||
return config.getString("ipAddress", "");
|
||||
}
|
||||
|
||||
public String getLastLoginAddress()
|
||||
{
|
||||
return lastLoginAddress;
|
||||
}
|
||||
|
||||
public void setLastLoginAddress(String address)
|
||||
{
|
||||
lastLoginAddress = address;
|
||||
config.setProperty("ipAddress", address);
|
||||
config.save();
|
||||
}
|
||||
private boolean afk;
|
||||
|
||||
private boolean getAfk()
|
||||
@@ -622,26 +734,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
setAfk(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private boolean newplayer;
|
||||
|
||||
private boolean getNew()
|
||||
{
|
||||
return config.getBoolean("newplayer", true);
|
||||
}
|
||||
|
||||
public boolean isNew()
|
||||
{
|
||||
return newplayer;
|
||||
}
|
||||
|
||||
public void setNew(boolean set)
|
||||
{
|
||||
newplayer = set;
|
||||
config.setProperty("newplayer", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
private String geolocation;
|
||||
|
||||
private String _getGeoLocation()
|
||||
@@ -668,42 +761,94 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
|
||||
private boolean isSocialSpyEnabled;
|
||||
|
||||
|
||||
private boolean _isSocialSpyEnabled()
|
||||
{
|
||||
return config.getBoolean("socialspy", false);
|
||||
}
|
||||
|
||||
|
||||
public boolean isSocialSpyEnabled()
|
||||
{
|
||||
return isSocialSpyEnabled;
|
||||
}
|
||||
|
||||
|
||||
public void setSocialSpyEnabled(boolean status)
|
||||
{
|
||||
isSocialSpyEnabled = status;
|
||||
config.setProperty("socialspy", status);
|
||||
config.save();
|
||||
}
|
||||
|
||||
private boolean isNPC;
|
||||
|
||||
|
||||
private boolean _isNPC()
|
||||
{
|
||||
return config.getBoolean("npc", false);
|
||||
}
|
||||
|
||||
|
||||
public boolean isNPC()
|
||||
{
|
||||
return isNPC;
|
||||
}
|
||||
|
||||
|
||||
public void setNPC(boolean set)
|
||||
{
|
||||
isNPC = set;
|
||||
config.setProperty("npc", set);
|
||||
config.save();
|
||||
}
|
||||
private boolean arePowerToolsEnabled;
|
||||
|
||||
public boolean arePowerToolsEnabled()
|
||||
{
|
||||
return arePowerToolsEnabled;
|
||||
}
|
||||
|
||||
public void setPowerToolsEnabled(boolean set)
|
||||
{
|
||||
arePowerToolsEnabled = set;
|
||||
config.setProperty("powertoolsenabled", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean togglePowerToolsEnabled()
|
||||
{
|
||||
boolean ret = !arePowerToolsEnabled();
|
||||
setPowerToolsEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private boolean _arePowerToolsEnabled()
|
||||
{
|
||||
return config.getBoolean("powertoolsenabled", true);
|
||||
}
|
||||
private Map<String, Object> kitTimestamps;
|
||||
|
||||
private Map<String, Object> _getKitTimestamps()
|
||||
{
|
||||
|
||||
if (config.isConfigurationSection("timestamps.kits"))
|
||||
{
|
||||
return config.getConfigurationSection("timestamps.kits").getValues(false);
|
||||
}
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
public Long getKitTimestamp(final String name)
|
||||
{
|
||||
final Number num = (Number)kitTimestamps.get(name.toLowerCase(Locale.ENGLISH));
|
||||
return num == null ? null : num.longValue();
|
||||
}
|
||||
|
||||
public void setKitTimestamp(final String name, final long time)
|
||||
{
|
||||
kitTimestamps.put(name.toLowerCase(Locale.ENGLISH), time);
|
||||
config.setProperty("timestamps.kits", kitTimestamps);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class UserMap extends CacheLoader<String, User> implements IConf
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
private final transient Cache<String, User> users = CacheBuilder.newBuilder().softValues().build(this);
|
||||
private final transient ConcurrentSkipListSet<String> keys = new ConcurrentSkipListSet<String>();
|
||||
|
||||
public UserMap(final IEssentials ess)
|
||||
{
|
||||
super();
|
||||
this.ess = ess;
|
||||
loadAllUsersAsync(ess);
|
||||
}
|
||||
|
||||
private void loadAllUsersAsync(final IEssentials ess)
|
||||
{
|
||||
ess.scheduleAsyncDelayedTask(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final File userdir = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdir.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
keys.clear();
|
||||
users.invalidateAll();
|
||||
for (String string : userdir.list())
|
||||
{
|
||||
if (!string.endsWith(".yml"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final String name = string.substring(0, string.length() - 4);
|
||||
keys.add(Util.sanitizeFileName(name));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean userExists(final String name)
|
||||
{
|
||||
return keys.contains(Util.sanitizeFileName(name));
|
||||
}
|
||||
|
||||
public User getUser(final String name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return users.get(name);
|
||||
}
|
||||
catch (ExecutionException ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch (UncheckedExecutionException ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public User load(final String name) throws Exception
|
||||
{
|
||||
String sanitizedName = Util.sanitizeFileName(name);
|
||||
if (!sanitizedName.equals(name))
|
||||
{
|
||||
User user = getUser(sanitizedName);
|
||||
if (user == null)
|
||||
{
|
||||
throw new Exception("User not found!");
|
||||
}
|
||||
else
|
||||
{
|
||||
return user;
|
||||
}
|
||||
}
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
if (player.getName().equalsIgnoreCase(name))
|
||||
{
|
||||
keys.add(sanitizedName);
|
||||
return new User(player, ess);
|
||||
}
|
||||
}
|
||||
final File userFile = getUserFile2(sanitizedName);
|
||||
if (userFile.exists())
|
||||
{
|
||||
keys.add(sanitizedName);
|
||||
return new User(new OfflinePlayer(name, ess), ess);
|
||||
}
|
||||
throw new Exception("User not found!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
loadAllUsersAsync(ess);
|
||||
}
|
||||
|
||||
public void removeUser(final String name)
|
||||
{
|
||||
keys.remove(Util.sanitizeFileName(name));
|
||||
users.invalidate(Util.sanitizeFileName(name));
|
||||
users.invalidate(name);
|
||||
}
|
||||
|
||||
public Set<String> getAllUniqueUsers()
|
||||
{
|
||||
return Collections.unmodifiableSet(keys);
|
||||
}
|
||||
|
||||
public int getUniqueUsers()
|
||||
{
|
||||
return keys.size();
|
||||
}
|
||||
|
||||
public File getUserFile(final String name)
|
||||
{
|
||||
return getUserFile2(Util.sanitizeFileName(name));
|
||||
}
|
||||
|
||||
private File getUserFile2(final String name)
|
||||
{
|
||||
final File userFolder = new File(ess.getDataFolder(), "userdata");
|
||||
return new File(userFolder, name + ".yml");
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,9 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Enumeration;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Level;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -25,6 +11,8 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Util
|
||||
@@ -33,10 +21,18 @@ 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]");
|
||||
|
||||
public static String sanitizeFileName(String name)
|
||||
public static String sanitizeFileName(final String name)
|
||||
{
|
||||
return name.toLowerCase().replaceAll("[^a-z0-9]", "_");
|
||||
final String newName = INVALIDFILECHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_");
|
||||
return newName;
|
||||
}
|
||||
|
||||
public static String sanitizeString(final String string)
|
||||
{
|
||||
return INVALIDCHARS.matcher(string).replaceAll("");
|
||||
}
|
||||
|
||||
public static String formatDateDiff(long date)
|
||||
@@ -52,7 +48,7 @@ public class Util
|
||||
boolean future = false;
|
||||
if (toDate.equals(fromDate))
|
||||
{
|
||||
return Util.i18n("now");
|
||||
return _("now");
|
||||
}
|
||||
if (toDate.after(fromDate))
|
||||
{
|
||||
@@ -71,18 +67,18 @@ public class Util
|
||||
};
|
||||
String[] names = new String[]
|
||||
{
|
||||
Util.i18n("year"),
|
||||
Util.i18n("years"),
|
||||
Util.i18n("month"),
|
||||
Util.i18n("months"),
|
||||
Util.i18n("day"),
|
||||
Util.i18n("days"),
|
||||
Util.i18n("hour"),
|
||||
Util.i18n("hours"),
|
||||
Util.i18n("minute"),
|
||||
Util.i18n("minutes"),
|
||||
Util.i18n("second"),
|
||||
Util.i18n("seconds")
|
||||
_("year"),
|
||||
_("years"),
|
||||
_("month"),
|
||||
_("months"),
|
||||
_("day"),
|
||||
_("days"),
|
||||
_("hour"),
|
||||
_("hours"),
|
||||
_("minute"),
|
||||
_("minutes"),
|
||||
_("second"),
|
||||
_("seconds")
|
||||
};
|
||||
for (int i = 0; i < types.length; i++)
|
||||
{
|
||||
@@ -182,7 +178,7 @@ public class Util
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
throw new Exception(Util.i18n("illegalDate"));
|
||||
throw new Exception(_("illegalDate"));
|
||||
}
|
||||
Calendar c = new GregorianCalendar();
|
||||
if (years > 0)
|
||||
@@ -215,56 +211,118 @@ public class Util
|
||||
}
|
||||
return c.getTimeInMillis();
|
||||
}
|
||||
// The player can stand inside these materials
|
||||
private static final Set<Integer> AIR_MATERIALS = new HashSet<Integer>();
|
||||
private static final HashSet<Byte> AIR_MATERIALS_TARGET = new HashSet<Byte>();
|
||||
|
||||
public static Location getSafeDestination(Location loc) throws Exception
|
||||
static
|
||||
{
|
||||
if (loc == null)
|
||||
AIR_MATERIALS.add(Material.AIR.getId());
|
||||
AIR_MATERIALS.add(Material.SAPLING.getId());
|
||||
AIR_MATERIALS.add(Material.POWERED_RAIL.getId());
|
||||
AIR_MATERIALS.add(Material.DETECTOR_RAIL.getId());
|
||||
AIR_MATERIALS.add(Material.LONG_GRASS.getId());
|
||||
AIR_MATERIALS.add(Material.DEAD_BUSH.getId());
|
||||
AIR_MATERIALS.add(Material.YELLOW_FLOWER.getId());
|
||||
AIR_MATERIALS.add(Material.RED_ROSE.getId());
|
||||
AIR_MATERIALS.add(Material.BROWN_MUSHROOM.getId());
|
||||
AIR_MATERIALS.add(Material.RED_MUSHROOM.getId());
|
||||
AIR_MATERIALS.add(Material.TORCH.getId());
|
||||
AIR_MATERIALS.add(Material.REDSTONE_WIRE.getId());
|
||||
AIR_MATERIALS.add(Material.SEEDS.getId());
|
||||
AIR_MATERIALS.add(Material.SIGN_POST.getId());
|
||||
AIR_MATERIALS.add(Material.WOODEN_DOOR.getId());
|
||||
AIR_MATERIALS.add(Material.LADDER.getId());
|
||||
AIR_MATERIALS.add(Material.RAILS.getId());
|
||||
AIR_MATERIALS.add(Material.WALL_SIGN.getId());
|
||||
AIR_MATERIALS.add(Material.LEVER.getId());
|
||||
AIR_MATERIALS.add(Material.STONE_PLATE.getId());
|
||||
AIR_MATERIALS.add(Material.IRON_DOOR_BLOCK.getId());
|
||||
AIR_MATERIALS.add(Material.WOOD_PLATE.getId());
|
||||
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.SUGAR_CANE_BLOCK.getId());
|
||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId());
|
||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_ON.getId());
|
||||
AIR_MATERIALS.add(Material.TRAP_DOOR.getId());
|
||||
AIR_MATERIALS.add(Material.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.WATER_LILY.getId());
|
||||
|
||||
for (Integer integer : AIR_MATERIALS)
|
||||
{
|
||||
throw new Exception(Util.i18n("destinationNotSet"));
|
||||
AIR_MATERIALS_TARGET.add(integer.byteValue());
|
||||
}
|
||||
World world = loc.getWorld();
|
||||
double x = Math.floor(loc.getX()) + 0.5;
|
||||
double y = Math.floor(loc.getY());
|
||||
double z = Math.floor(loc.getZ()) + 0.5;
|
||||
AIR_MATERIALS_TARGET.add((byte)Material.WATER.getId());
|
||||
AIR_MATERIALS_TARGET.add((byte)Material.STATIONARY_WATER.getId());
|
||||
}
|
||||
|
||||
public static Location getTarget(final LivingEntity entity) throws Exception
|
||||
{
|
||||
final Block block = entity.getTargetBlock(AIR_MATERIALS_TARGET, 300);
|
||||
if (block == null)
|
||||
{
|
||||
throw new Exception("Not targeting a block");
|
||||
}
|
||||
return block.getLocation();
|
||||
}
|
||||
|
||||
public static Location getSafeDestination(final Location loc) throws Exception
|
||||
{
|
||||
if (loc == null || loc.getWorld() == null)
|
||||
{
|
||||
throw new Exception(_("destinationNotSet"));
|
||||
}
|
||||
final World world = loc.getWorld();
|
||||
int x = loc.getBlockX();
|
||||
int y = (int)Math.round(loc.getY());
|
||||
int z = loc.getBlockZ();
|
||||
|
||||
while (isBlockAboveAir(world, x, y, z))
|
||||
{
|
||||
y -= 1.0D;
|
||||
if (y < 0.0D)
|
||||
y -= 1;
|
||||
if (y < 0)
|
||||
{
|
||||
throw new Exception(Util.i18n("holeInFloor"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (isBlockUnsafe(world, x, y, z))
|
||||
{
|
||||
y += 1.0D;
|
||||
if (y >= 110.0D)
|
||||
y += 1;
|
||||
if (y >= 127)
|
||||
{
|
||||
x += 1.0D;
|
||||
x += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (isBlockUnsafe(world, x, y, z))
|
||||
{
|
||||
y -= 1.0D;
|
||||
if (y <= 1.0D)
|
||||
y -= 1;
|
||||
if (y <= 1)
|
||||
{
|
||||
y = 110.0D;
|
||||
x += 1.0D;
|
||||
y = 127;
|
||||
x += 1;
|
||||
if (x - 32 > loc.getBlockX())
|
||||
{
|
||||
throw new Exception(_("holeInFloor"));
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Location(world, x, y, z, loc.getYaw(), loc.getPitch());
|
||||
return new Location(world, x + 0.5D, y, z + 0.5D, loc.getYaw(), loc.getPitch());
|
||||
}
|
||||
|
||||
private static boolean isBlockAboveAir(World world, double x, double y, double z)
|
||||
private static boolean isBlockAboveAir(final World world, final int x, final int y, final int z)
|
||||
{
|
||||
return world.getBlockAt((int)Math.floor(x), (int)Math.floor(y - 1.0D), (int)Math.floor(z)).getType() == Material.AIR;
|
||||
return AIR_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType().getId());
|
||||
}
|
||||
|
||||
public static boolean isBlockUnsafe(World world, double x, double y, double z)
|
||||
public static boolean isBlockUnsafe(final World world, final int x, final int y, final int z)
|
||||
{
|
||||
Block below = world.getBlockAt((int)Math.floor(x), (int)Math.floor(y - 1.0D), (int)Math.floor(z));
|
||||
final Block below = world.getBlockAt(x, y - 1, z);
|
||||
if (below.getType() == Material.LAVA || below.getType() == Material.STATIONARY_LAVA)
|
||||
{
|
||||
return true;
|
||||
@@ -275,18 +333,100 @@ public class Util
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((world.getBlockAt((int)Math.floor(x), (int)Math.floor(y), (int)Math.floor(z)).getType() != Material.AIR)
|
||||
|| (world.getBlockAt((int)Math.floor(x), (int)Math.floor(y + 1.0D), (int)Math.floor(z)).getType() != Material.AIR))
|
||||
if ((!AIR_MATERIALS.contains(world.getBlockAt(x, y, z).getType().getId()))
|
||||
|| (!AIR_MATERIALS.contains(world.getBlockAt(x, y + 1, z).getType().getId())))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return isBlockAboveAir(world, x, y, z);
|
||||
}
|
||||
private static DecimalFormat df = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
|
||||
|
||||
public static String formatCurrency(double value)
|
||||
public static ItemStack convertBlockToItem(final Block block)
|
||||
{
|
||||
String str = Essentials.getStatic().getSettings().getCurrencySymbol() + df.format(value);
|
||||
final ItemStack is = new ItemStack(block.getType(), 1, (short)0, block.getData());
|
||||
switch (is.getType())
|
||||
{
|
||||
case WOODEN_DOOR:
|
||||
is.setType(Material.WOOD_DOOR);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case IRON_DOOR_BLOCK:
|
||||
is.setType(Material.IRON_DOOR);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case SIGN_POST:
|
||||
case WALL_SIGN:
|
||||
is.setType(Material.SIGN);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case CROPS:
|
||||
is.setType(Material.SEEDS);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case CAKE_BLOCK:
|
||||
is.setType(Material.CAKE);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case BED_BLOCK:
|
||||
is.setType(Material.BED);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case REDSTONE_WIRE:
|
||||
is.setType(Material.REDSTONE);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case REDSTONE_TORCH_OFF:
|
||||
case REDSTONE_TORCH_ON:
|
||||
is.setType(Material.REDSTONE_TORCH_ON);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case DIODE_BLOCK_OFF:
|
||||
case DIODE_BLOCK_ON:
|
||||
is.setType(Material.DIODE);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case DOUBLE_STEP:
|
||||
is.setType(Material.STEP);
|
||||
break;
|
||||
case TORCH:
|
||||
case RAILS:
|
||||
case LADDER:
|
||||
case WOOD_STAIRS:
|
||||
case COBBLESTONE_STAIRS:
|
||||
case LEVER:
|
||||
case STONE_BUTTON:
|
||||
case FURNACE:
|
||||
case DISPENSER:
|
||||
case PUMPKIN:
|
||||
case JACK_O_LANTERN:
|
||||
case WOOD_PLATE:
|
||||
case STONE_PLATE:
|
||||
case PISTON_STICKY_BASE:
|
||||
case PISTON_BASE:
|
||||
case IRON_FENCE:
|
||||
case THIN_GLASS:
|
||||
case TRAP_DOOR:
|
||||
case FENCE:
|
||||
case FENCE_GATE:
|
||||
case NETHER_FENCE:
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case FIRE:
|
||||
return null;
|
||||
case PUMPKIN_STEM:
|
||||
is.setType(Material.PUMPKIN_SEEDS);
|
||||
break;
|
||||
case MELON_STEM:
|
||||
is.setType(Material.MELON_SEEDS);
|
||||
break;
|
||||
}
|
||||
return is;
|
||||
}
|
||||
private static DecimalFormat dFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
|
||||
|
||||
public static String formatAsCurrency(final double value)
|
||||
{
|
||||
String str = dFormat.format(value);
|
||||
if (str.endsWith(".00"))
|
||||
{
|
||||
str = str.substring(0, str.length() - 3);
|
||||
@@ -294,156 +434,87 @@ public class Util
|
||||
return str;
|
||||
}
|
||||
|
||||
public static double roundDouble(double d)
|
||||
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;
|
||||
}
|
||||
|
||||
public static Locale getCurrentLocale()
|
||||
{
|
||||
return currentLocale;
|
||||
}
|
||||
|
||||
|
||||
private static class ConfigClassLoader extends ClassLoader
|
||||
{
|
||||
private final File dataFolder;
|
||||
private final ClassLoader cl;
|
||||
|
||||
public ConfigClassLoader(File dataFolder, ClassLoader cl)
|
||||
{
|
||||
this.dataFolder = dataFolder;
|
||||
this.cl = cl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getResource(String string)
|
||||
{
|
||||
File file = new File(dataFolder, string);
|
||||
if (file.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
return file.toURI().toURL();
|
||||
}
|
||||
catch (MalformedURLException ex)
|
||||
{
|
||||
return cl.getResource(string);
|
||||
}
|
||||
}
|
||||
return cl.getResource(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void clearAssertionStatus()
|
||||
{
|
||||
cl.clearAssertionStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getResourceAsStream(String string)
|
||||
{
|
||||
File file = new File(dataFolder, string);
|
||||
if (file.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
BufferedReader br = new BufferedReader(new FileReader(file));
|
||||
String version = br.readLine();
|
||||
br.close();
|
||||
if (version == null || !version.equals("#version: " + Essentials.getStatic().getDescription().getVersion()))
|
||||
{
|
||||
logger.log(Level.WARNING, String.format("Translation file %s is not updated for Essentials version. Will use default.", file));
|
||||
return cl.getResourceAsStream(string);
|
||||
}
|
||||
return new FileInputStream(file);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
return cl.getResourceAsStream(string);
|
||||
}
|
||||
}
|
||||
return cl.getResourceAsStream(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<URL> getResources(String string) throws IOException
|
||||
{
|
||||
return cl.getResources(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> loadClass(String string) throws ClassNotFoundException
|
||||
{
|
||||
return cl.loadClass(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setClassAssertionStatus(String string, boolean bln)
|
||||
{
|
||||
cl.setClassAssertionStatus(string, bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setDefaultAssertionStatus(boolean bln)
|
||||
{
|
||||
cl.setDefaultAssertionStatus(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setPackageAssertionStatus(String string, boolean bln)
|
||||
{
|
||||
cl.setPackageAssertionStatus(string, bln);
|
||||
}
|
||||
}
|
||||
private static final Locale defaultLocale = Locale.getDefault();
|
||||
private static Locale currentLocale = defaultLocale;
|
||||
private static ResourceBundle bundle = ResourceBundle.getBundle("messages", defaultLocale);
|
||||
private static ResourceBundle defaultBundle = ResourceBundle.getBundle("messages", Locale.US);
|
||||
|
||||
public static String i18n(String string)
|
||||
public static boolean isInt(final String sInt)
|
||||
{
|
||||
try
|
||||
{
|
||||
return bundle.getString(string);
|
||||
Integer.parseInt(sInt);
|
||||
}
|
||||
catch (MissingResourceException ex)
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
logger.log(Level.WARNING, String.format("Missing translation key \"%s\" in translation file %s", ex.getKey(), bundle.getLocale().toString()), ex);
|
||||
return defaultBundle.getString(string);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String format(String string, Object... objects)
|
||||
public static String joinList(Object... list)
|
||||
{
|
||||
MessageFormat mf = new MessageFormat(i18n(string));
|
||||
return mf.format(objects);
|
||||
return joinList(", ", list);
|
||||
}
|
||||
|
||||
public static void updateLocale(String loc, File dataFolder)
|
||||
public static String joinList(String seperator, Object... list)
|
||||
{
|
||||
if (loc == null || loc.isEmpty())
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (Object each : list)
|
||||
{
|
||||
return;
|
||||
if (buf.length() > 0)
|
||||
{
|
||||
buf.append(seperator);
|
||||
}
|
||||
|
||||
if (each instanceof Collection)
|
||||
{
|
||||
buf.append(joinList(seperator, ((Collection)each).toArray()));
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
buf.append(each.toString());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
buf.append(each.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
String[] parts = loc.split("[_\\.]");
|
||||
if (parts.length == 1)
|
||||
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)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
currentLocale = new Locale(parts[0]);
|
||||
return null;
|
||||
}
|
||||
if (parts.length == 2)
|
||||
|
||||
return VANILLA_COLOR_PATTERN.matcher(input).replaceAll("");
|
||||
}
|
||||
|
||||
public static String replaceColor(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
currentLocale = new Locale(parts[0], parts[1]);
|
||||
}
|
||||
if (parts.length == 3)
|
||||
{
|
||||
currentLocale = new Locale(parts[0], parts[1], parts[2]);
|
||||
}
|
||||
logger.log(Level.INFO, String.format("Using locale %s", currentLocale.toString()));
|
||||
bundle = ResourceBundle.getBundle("messages", currentLocale, new ConfigClassLoader(dataFolder, Util.class.getClassLoader()));
|
||||
if (!bundle.keySet().containsAll(defaultBundle.keySet()))
|
||||
{
|
||||
logger.log(Level.WARNING, String.format("Translation file %s does not contain all translation keys.", currentLocale.toString()));
|
||||
return null;
|
||||
}
|
||||
|
||||
return EASY_COLOR_PATTERN.matcher(input).replaceAll("\u00a7$1");
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,8 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
@@ -35,9 +32,9 @@ public class Warps implements IConf
|
||||
return warpPoints.isEmpty();
|
||||
}
|
||||
|
||||
public Iterable<String> getWarpNames()
|
||||
public Collection<String> getWarpNames()
|
||||
{
|
||||
List<String> keys = new ArrayList<String>();
|
||||
final List<String> keys = new ArrayList<String>();
|
||||
for (StringIgnoreCase stringIgnoreCase : warpPoints.keySet())
|
||||
{
|
||||
keys.add(stringIgnoreCase.getString());
|
||||
@@ -51,7 +48,7 @@ public class Warps implements IConf
|
||||
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(warp));
|
||||
if (conf == null)
|
||||
{
|
||||
throw new Exception(Util.i18n("warpNotExist"));
|
||||
throw new Exception(_("warpNotExist"));
|
||||
}
|
||||
return conf.getLocation(null, server);
|
||||
}
|
||||
@@ -65,7 +62,7 @@ public class Warps implements IConf
|
||||
File confFile = new File(warpsFolder, filename + ".yml");
|
||||
if (confFile.exists())
|
||||
{
|
||||
throw new Exception(Util.i18n("similarWarpExist"));
|
||||
throw new Exception(_("similarWarpExist"));
|
||||
}
|
||||
conf = new EssentialsConf(confFile);
|
||||
warpPoints.put(new StringIgnoreCase(name), conf);
|
||||
@@ -80,15 +77,16 @@ public class Warps implements IConf
|
||||
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(name));
|
||||
if (conf == null)
|
||||
{
|
||||
throw new Exception(Util.i18n("warpNotExist"));
|
||||
throw new Exception(_("warpNotExist"));
|
||||
}
|
||||
if (!conf.getFile().delete())
|
||||
{
|
||||
throw new Exception(Util.i18n("warpDeleteError"));
|
||||
throw new Exception(_("warpDeleteError"));
|
||||
}
|
||||
warpPoints.remove(new StringIgnoreCase(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void reloadConfig()
|
||||
{
|
||||
warpPoints.clear();
|
||||
@@ -112,7 +110,7 @@ public class Warps implements IConf
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.WARNING, Util.format("loadWarpError", filename), ex);
|
||||
logger.log(Level.WARNING, _("loadWarpError", filename), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -132,7 +130,7 @@ public class Warps implements IConf
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return getString().toLowerCase().hashCode();
|
||||
return getString().toLowerCase(Locale.ENGLISH).hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -19,36 +20,42 @@ public class Worth implements IConf
|
||||
|
||||
public double getPrice(ItemStack itemStack)
|
||||
{
|
||||
String itemname = itemStack.getType().toString().toLowerCase().replace("_", "");
|
||||
String itemname = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
double result;
|
||||
result = config.getDouble("worth."+itemname+"."+itemStack.getDurability(), Double.NaN);
|
||||
if (Double.isNaN(result)) {
|
||||
result = config.getDouble("worth."+itemname+".0", Double.NaN);
|
||||
result = config.getDouble("worth." + itemname + "." + itemStack.getDurability(), Double.NaN);
|
||||
if (Double.isNaN(result))
|
||||
{
|
||||
result = config.getDouble("worth." + itemname + ".0", Double.NaN);
|
||||
}
|
||||
if (Double.isNaN(result)) {
|
||||
result = config.getDouble("worth."+itemname, Double.NaN);
|
||||
if (Double.isNaN(result))
|
||||
{
|
||||
result = config.getDouble("worth." + itemname, Double.NaN);
|
||||
}
|
||||
if (Double.isNaN(result)) {
|
||||
result = config.getDouble("worth-"+itemStack.getTypeId(), Double.NaN);
|
||||
if (Double.isNaN(result))
|
||||
{
|
||||
result = config.getDouble("worth-" + itemStack.getTypeId(), Double.NaN);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setPrice(ItemStack itemStack, double price)
|
||||
{
|
||||
if (itemStack.getType().getData() == null) {
|
||||
config.setProperty("worth." + itemStack.getType().toString().toLowerCase().replace("_", ""), price);
|
||||
} else {
|
||||
// Bukkit-bug: getDurability still contains the correct value, while getData().getData() is 0.
|
||||
config.setProperty("worth." + itemStack.getType().toString().toLowerCase().replace("_", "")+"."+itemStack.getDurability(), price);
|
||||
if (itemStack.getType().getData() == null)
|
||||
{
|
||||
config.setProperty("worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""), price);
|
||||
}
|
||||
config.removeProperty("worth-"+itemStack.getTypeId());
|
||||
else
|
||||
{
|
||||
// Bukkit-bug: getDurability still contains the correct value, while getData().getData() is 0.
|
||||
config.setProperty("worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "") + "." + itemStack.getDurability(), price);
|
||||
}
|
||||
config.removeProperty("worth-" + itemStack.getTypeId());
|
||||
config.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
config.load();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +1,16 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.EssentialsConf;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.UserData;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
/**
|
||||
* Instead of using this api directly, we recommend to use the register plugin:
|
||||
* http://bit.ly/RegisterMethod
|
||||
@@ -20,10 +21,20 @@ public final class Economy
|
||||
{
|
||||
}
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private static IEssentials ess;
|
||||
private static final String noCallBeforeLoad = "Essentials API is called before Essentials is loaded.";
|
||||
|
||||
/**
|
||||
* @param aEss the ess to set
|
||||
*/
|
||||
public static void setEss(IEssentials aEss)
|
||||
{
|
||||
ess = aEss;
|
||||
}
|
||||
|
||||
private static void createNPCFile(String name)
|
||||
{
|
||||
File folder = new File(Essentials.getStatic().getDataFolder(), "userdata");
|
||||
File folder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!folder.exists())
|
||||
{
|
||||
folder.mkdirs();
|
||||
@@ -31,13 +42,13 @@ public final class Economy
|
||||
EssentialsConf npcConfig = new EssentialsConf(new File(folder, Util.sanitizeFileName(name) + ".yml"));
|
||||
npcConfig.load();
|
||||
npcConfig.setProperty("npc", true);
|
||||
npcConfig.setProperty("money", Essentials.getStatic().getSettings().getStartingBalance());
|
||||
npcConfig.setProperty("money", ess.getSettings().getStartingBalance());
|
||||
npcConfig.save();
|
||||
}
|
||||
|
||||
|
||||
private static void deleteNPC(String name)
|
||||
{
|
||||
File folder = new File(Essentials.getStatic().getDataFolder(), "userdata");
|
||||
File folder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!folder.exists())
|
||||
{
|
||||
folder.mkdirs();
|
||||
@@ -45,24 +56,31 @@ public final class Economy
|
||||
File config = new File(folder, Util.sanitizeFileName(name) + ".yml");
|
||||
EssentialsConf npcConfig = new EssentialsConf(config);
|
||||
npcConfig.load();
|
||||
if (npcConfig.hasProperty("npc") && npcConfig.getBoolean("npc", false)) {
|
||||
if (!config.delete()) {
|
||||
logger.log(Level.WARNING, Util.format("deleteFileError", config));
|
||||
if (npcConfig.hasProperty("npc") && npcConfig.getBoolean("npc", false))
|
||||
{
|
||||
if (!config.delete())
|
||||
{
|
||||
logger.log(Level.WARNING, _("deleteFileError", config));
|
||||
}
|
||||
ess.getUserMap().removeUser(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static User getUserByName(String name)
|
||||
{
|
||||
if (ess == null)
|
||||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
}
|
||||
User user;
|
||||
Player player = Essentials.getStatic().getServer().getPlayer(name);
|
||||
Player player = ess.getServer().getPlayer(name);
|
||||
if (player != null)
|
||||
{
|
||||
user = Essentials.getStatic().getUser(player);
|
||||
user = ess.getUser(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
user = Essentials.getStatic().getOfflineUser(name);
|
||||
user = ess.getOfflineUser(name);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
@@ -76,11 +94,11 @@ public final class Economy
|
||||
public static double getMoney(String name) throws UserDoesNotExistException
|
||||
{
|
||||
User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
if (user == null)
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
// Use UserData to avoid calls to iConomy and Register
|
||||
return ((UserData)user).getMoney();
|
||||
return user.getMoney();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,15 +111,19 @@ public final class Economy
|
||||
public static void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException
|
||||
{
|
||||
User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
if (user == null)
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
if (balance < ess.getSettings().getMinMoney())
|
||||
{
|
||||
throw new NoLoanPermittedException();
|
||||
}
|
||||
if (balance < 0.0 && !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new NoLoanPermittedException();
|
||||
}
|
||||
// Use UserData to avoid calls to iConomy and Register
|
||||
((UserData)user).setMoney(balance);
|
||||
user.setMoney(balance);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,7 +138,7 @@ public final class Economy
|
||||
double result = getMoney(name) + amount;
|
||||
setMoney(name, result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Substracts money from the balance of a user
|
||||
* @param name Name of the user
|
||||
@@ -164,7 +186,11 @@ public final class Economy
|
||||
*/
|
||||
public static void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException
|
||||
{
|
||||
setMoney(name, Essentials.getStatic().getSettings().getStartingBalance());
|
||||
if (ess == null)
|
||||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
}
|
||||
setMoney(name, ess.getSettings().getStartingBalance());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,18 +245,23 @@ public final class Economy
|
||||
*/
|
||||
public static String format(double amount)
|
||||
{
|
||||
return Util.formatCurrency(amount);
|
||||
if (ess == null)
|
||||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
}
|
||||
return Util.displayCurrency(amount, ess);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if a player exists to avoid the UserDoesNotExistException
|
||||
* @param name Name of the user
|
||||
* @return true, if the user exists
|
||||
*/
|
||||
public static boolean playerExists(String name) {
|
||||
public static boolean playerExists(String name)
|
||||
{
|
||||
return getUserByName(name) != null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if a player is a npc
|
||||
* @param name Name of the player
|
||||
@@ -240,12 +271,13 @@ public final class Economy
|
||||
public static boolean isNPC(String name) throws UserDoesNotExistException
|
||||
{
|
||||
User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
if (user == null)
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
return user.isNPC();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates dummy files for a npc, if there is no player yet with that name.
|
||||
* @param name Name of the player
|
||||
@@ -254,7 +286,8 @@ public final class Economy
|
||||
public static boolean createNPC(String name)
|
||||
{
|
||||
User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
if (user == null)
|
||||
{
|
||||
createNPCFile(name);
|
||||
return true;
|
||||
}
|
||||
@@ -269,7 +302,8 @@ public final class Economy
|
||||
public static void removeNPC(String name) throws UserDoesNotExistException
|
||||
{
|
||||
User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
if (user == null)
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
deleteNPC(name);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.util.Map;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
|
||||
|
||||
public interface IAlternativeCommandsHandler
|
||||
{
|
||||
Map<String, String> disabledCommands();
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.perm.IPermissionsHandler;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public interface IEssentials extends Plugin, IReload
|
||||
{
|
||||
void addReloadListener(IReload listener);
|
||||
|
||||
IUser getUser(Object base);
|
||||
|
||||
int broadcastMessage(IUser sender, String message);
|
||||
|
||||
II18n getI18n();
|
||||
|
||||
ISettings getSettings();
|
||||
|
||||
IJails getJail();
|
||||
|
||||
IWarps getWarps();
|
||||
|
||||
IWorth getWorth();
|
||||
|
||||
IItemDb getItemDb();
|
||||
|
||||
IUserMap getUserMap();
|
||||
|
||||
IEssentialsEconomy getEconomy();
|
||||
|
||||
World getWorld(String name);
|
||||
|
||||
Methods getPaymentMethod();
|
||||
|
||||
int scheduleAsyncDelayedTask(Runnable run);
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run);
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run, long delay);
|
||||
|
||||
int scheduleSyncRepeatingTask(Runnable run, long delay, long period);
|
||||
|
||||
IPermissionsHandler getPermissionsHandler();
|
||||
|
||||
IAlternativeCommandsHandler getAlternativeCommandsHandler();
|
||||
|
||||
void showCommandError(CommandSender sender, String commandLabel, Throwable exception);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
|
||||
public interface IEssentialsEconomy
|
||||
{
|
||||
double getMoney(String name) throws UserDoesNotExistException;
|
||||
|
||||
void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
void add(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
void subtract(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
void divide(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
void multiply(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException;
|
||||
|
||||
boolean hasEnough(String name, double amount) throws UserDoesNotExistException;
|
||||
|
||||
boolean hasMore(String name, double amount) throws UserDoesNotExistException;
|
||||
|
||||
boolean hasLess(String name, double amount) throws UserDoesNotExistException;
|
||||
|
||||
boolean isNegative(String name) throws UserDoesNotExistException;
|
||||
|
||||
String format(double amount);
|
||||
|
||||
boolean playerExists(String name);
|
||||
|
||||
boolean isNPC(String name) throws UserDoesNotExistException;
|
||||
|
||||
boolean createNPC(String name);
|
||||
|
||||
void removeNPC(String name) throws UserDoesNotExistException;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
public interface II18n
|
||||
{
|
||||
Locale getCurrentLocale();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public interface IItemDb
|
||||
{
|
||||
ItemStack get(final String name, final int quantity) throws Exception;
|
||||
|
||||
ItemStack get(final String name) throws Exception;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.util.Collection;
|
||||
import org.bukkit.Location;
|
||||
|
||||
|
||||
public interface IJails extends IReload
|
||||
{
|
||||
Location getJail(String jailName) throws Exception;
|
||||
|
||||
Collection<String> getList() throws Exception;
|
||||
|
||||
void removeJail(String jail) throws Exception;
|
||||
|
||||
void sendToJail(com.earth2me.essentials.IUser user, String jail) throws Exception;
|
||||
|
||||
void setJail(String jailName, Location loc) throws Exception;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
|
||||
public interface IReload
|
||||
{
|
||||
void onReload();
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.settings.Settings;
|
||||
import com.earth2me.essentials.storage.IStorageObjectHolder;
|
||||
|
||||
|
||||
public interface ISettings extends IStorageObjectHolder<Settings>
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
|
||||
public interface ITeleport
|
||||
{
|
||||
void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public interface IUser extends Player, IReload
|
||||
{
|
||||
long getLastTeleportTimestamp();
|
||||
|
||||
boolean isAuthorized(String node);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
|
||||
|
||||
void setLastTeleportTimestamp(long time);
|
||||
|
||||
Location getLastLocation();
|
||||
|
||||
Player getBase();
|
||||
|
||||
double getMoney();
|
||||
|
||||
void takeMoney(double value);
|
||||
|
||||
void giveMoney(double value);
|
||||
|
||||
String getGroup();
|
||||
|
||||
void setLastLocation();
|
||||
|
||||
Location getHome(String name) throws Exception;
|
||||
|
||||
Location getHome(Location loc) throws Exception;
|
||||
|
||||
boolean isHidden();
|
||||
|
||||
ITeleport getTeleport();
|
||||
|
||||
void setJail(String jail);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public interface IUserMap
|
||||
{
|
||||
boolean userExists(final String name);
|
||||
|
||||
IUser getUser(final String name);
|
||||
|
||||
void removeUser(final String name);
|
||||
|
||||
Set<String> getAllUniqueUsers();
|
||||
|
||||
int getUniqueUsers();
|
||||
|
||||
File getUserFile(final String name);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import java.util.Collection;
|
||||
import org.bukkit.Location;
|
||||
|
||||
|
||||
public interface IWarps extends IReload
|
||||
{
|
||||
Location getWarp(String warp) throws Exception;
|
||||
|
||||
Collection<String> getWarps();
|
||||
|
||||
void removeWarp(String name) throws Exception;
|
||||
|
||||
void setWarp(String name, Location loc) throws Exception;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public interface IWorth extends IReload
|
||||
{
|
||||
double getPrice(ItemStack itemStack);
|
||||
|
||||
void setPrice(ItemStack itemStack, double price);
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.Util;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
|
||||
|
||||
public class NoLoanPermittedException extends Exception
|
||||
{
|
||||
|
||||
public NoLoanPermittedException()
|
||||
{
|
||||
super(Util.i18n("negativeBalanceError"));
|
||||
super(_("negativeBalanceError"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.Util;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
|
||||
|
||||
public class UserDoesNotExistException extends Exception
|
||||
{
|
||||
|
||||
public UserDoesNotExistException(String name)
|
||||
{
|
||||
super(Util.format("userDoesNotExist", name));
|
||||
super(_("userDoesNotExist", name));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
|
||||
|
||||
public class Commandafk extends EssentialsCommand
|
||||
@@ -15,15 +15,38 @@ public class Commandafk extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
if (args.length > 0 && user.isAuthorized("essentials.afk.others"))
|
||||
{
|
||||
User afkUser = ess.getUser(ess.getServer().matchPlayer(args[0]));
|
||||
if (afkUser != null)
|
||||
{
|
||||
toggleAfk(afkUser);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
toggleAfk(user);
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleAfk(User user)
|
||||
{
|
||||
if (!user.toggleAfk())
|
||||
{
|
||||
user.sendMessage(Util.i18n("markedAsNotAway"));
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
|
||||
} else {
|
||||
user.sendMessage(Util.i18n("markedAsAway"));
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsAway", user.getDisplayName()));
|
||||
//user.sendMessage(_("markedAsNotAway"));
|
||||
if (!user.isHidden())
|
||||
{
|
||||
ess.broadcastMessage(user, _("userIsNotAway", user.getDisplayName()));
|
||||
}
|
||||
user.updateActivity(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
//user.sendMessage(_("markedAsAway"));
|
||||
if (!user.isHidden())
|
||||
{
|
||||
ess.broadcastMessage(user, _("userIsAway", user.getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import net.minecraft.server.EntityTNTPrimed;
|
||||
import net.minecraft.server.World;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.TargetBlock;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
||||
|
||||
public class Commandantioch extends EssentialsCommand
|
||||
@@ -17,17 +15,15 @@ public class Commandantioch extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
ess.broadcastMessage(user.getName(), "...lobbest thou thy Holy Hand Grenade of Antioch towards thy foe,");
|
||||
ess.broadcastMessage(user.getName(), "who being naughty in My sight, shall snuff it.");
|
||||
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.");
|
||||
}
|
||||
|
||||
Location loc = user.getLocation();
|
||||
World world = ((CraftWorld)user.getWorld()).getHandle();
|
||||
loc = new TargetBlock(user).getTargetBlock().getLocation();
|
||||
EntityTNTPrimed tnt = new EntityTNTPrimed(world, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
world.addEntity(tnt);
|
||||
world.makeSound(tnt, "random.fuse", 1.0F, 1.0F);
|
||||
final Location loc = Util.getTarget(user);
|
||||
loc.getWorld().spawn(loc, TNTPrimed.class);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Charge;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
|
||||
|
||||
@@ -14,11 +14,12 @@ public class Commandback extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
Charge charge = new Charge(this.getName(), ess);
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.sendMessage(Util.i18n("backUsageMsg"));
|
||||
user.sendMessage(_("backUsageMsg"));
|
||||
user.getTeleport().back(charge);
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Backup;
|
||||
import com.earth2me.essentials.Util;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -14,15 +14,14 @@ public class Commandbackup extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
Backup backup = ess.getBackup();
|
||||
final Backup backup = ess.getBackup();
|
||||
if (backup == null)
|
||||
{
|
||||
return;
|
||||
throw new Exception();
|
||||
}
|
||||
charge(sender);
|
||||
backup.run();
|
||||
sender.sendMessage(Util.i18n("backupStarted"));
|
||||
sender.sendMessage(_("backupStarted"));
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
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;
|
||||
|
||||
|
||||
@@ -14,24 +15,23 @@ public class Commandbalance extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
sender.sendMessage(Util.format("balance", Util.formatCurrency(getPlayer(server, args, 0).getMoney())));
|
||||
sender.sendMessage(_("balance", Util.displayCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
double bal = (args.length < 1
|
||||
|| !(user.isAuthorized("essentials.balance.others")
|
||||
|| user.isAuthorized("essentials.balance.other"))
|
||||
? user
|
||||
: getPlayer(server, args, 0)).getMoney();
|
||||
user.sendMessage(Util.format("balance", Util.formatCurrency(bal)));
|
||||
final double bal = (args.length < 1
|
||||
|| !(user.isAuthorized("essentials.balance.others")
|
||||
|| user.isAuthorized("essentials.balance.other"))
|
||||
? user
|
||||
: getPlayer(server, args, 0, true)).getMoney();
|
||||
user.sendMessage(_("balance", Util.displayCurrency(bal, ess)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.textreader.ArrayListInput;
|
||||
import com.earth2me.essentials.textreader.TextPager;
|
||||
import java.text.DateFormat;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandbalancetop extends EssentialsCommand
|
||||
{
|
||||
public Commandbalancetop()
|
||||
{
|
||||
super("balancetop");
|
||||
}
|
||||
private static final int CACHETIME = 2 * 60 * 1000;
|
||||
public static final int MINUSERS = 50;
|
||||
private static ArrayListInput cache = new ArrayListInput();
|
||||
private static long cacheage = 0;
|
||||
private static ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
int page = 0;
|
||||
boolean force = false;
|
||||
if (args.length > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
page = Integer.parseInt(args[0]);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("force") && sender.isOp())
|
||||
{
|
||||
force = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!force && lock.readLock().tryLock())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (cacheage > System.currentTimeMillis() - CACHETIME)
|
||||
{
|
||||
outputCache(sender, page);
|
||||
return;
|
||||
}
|
||||
if (ess.getUserMap().getUniqueUsers() > MINUSERS)
|
||||
{
|
||||
sender.sendMessage(_("orderBalances", ess.getUserMap().getUniqueUsers()));
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
ess.scheduleAsyncDelayedTask(new Viewer(sender, page, force));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ess.getUserMap().getUniqueUsers() > MINUSERS)
|
||||
{
|
||||
sender.sendMessage(_("orderBalances", ess.getUserMap().getUniqueUsers()));
|
||||
}
|
||||
ess.scheduleAsyncDelayedTask(new Viewer(sender, page, force));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void outputCache(final CommandSender sender, int page)
|
||||
{
|
||||
final Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeInMillis(cacheage);
|
||||
final DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
sender.sendMessage(_("balanceTop", format.format(cal.getTime())));
|
||||
new TextPager(cache).showPage(Integer.toString(page), "", "balancetop", sender);
|
||||
}
|
||||
|
||||
|
||||
private class Calculator implements Runnable
|
||||
{
|
||||
private final transient Viewer viewer;
|
||||
private final boolean force;
|
||||
|
||||
public Calculator(final Viewer viewer, final boolean force)
|
||||
{
|
||||
this.viewer = viewer;
|
||||
this.force = force;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
lock.writeLock().lock();
|
||||
try
|
||||
{
|
||||
if (force || cacheage <= System.currentTimeMillis() - CACHETIME)
|
||||
{
|
||||
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)
|
||||
{
|
||||
final double userMoney = user.getMoney();
|
||||
user.updateMoneyCache(userMoney);
|
||||
totalMoney += userMoney;
|
||||
balances.put(user.getDisplayName(), userMoney);
|
||||
}
|
||||
}
|
||||
|
||||
final List<Map.Entry<String, Double>> sortedEntries = new ArrayList<Map.Entry<String, Double>>(balances.entrySet());
|
||||
Collections.sort(sortedEntries, new Comparator<Map.Entry<String, Double>>()
|
||||
{
|
||||
@Override
|
||||
public int compare(final Entry<String, Double> entry1, final Entry<String, Double> entry2)
|
||||
{
|
||||
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.displayCurrency(entry.getValue(), ess));
|
||||
pos++;
|
||||
}
|
||||
cacheage = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
ess.scheduleAsyncDelayedTask(viewer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class Viewer implements Runnable
|
||||
{
|
||||
private final transient CommandSender sender;
|
||||
private final transient int page;
|
||||
private final transient boolean force;
|
||||
|
||||
public Viewer(final CommandSender sender, final int page, final boolean force)
|
||||
{
|
||||
this.sender = sender;
|
||||
this.page = page;
|
||||
this.force = force;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
lock.readLock().lock();
|
||||
try
|
||||
{
|
||||
if (!force && cacheage > System.currentTimeMillis() - CACHETIME)
|
||||
{
|
||||
outputCache(sender, page);
|
||||
return;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
ess.scheduleAsyncDelayedTask(new Calculator(new Viewer(sender, page, force), force));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
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;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandban extends EssentialsCommand
|
||||
@@ -15,31 +17,52 @@ public class Commandban extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
User p = null;
|
||||
if (server.matchPlayer(args[0]).isEmpty())
|
||||
final User user = getPlayer(server, args, 0, true);
|
||||
if (user.getBase() instanceof OfflinePlayer)
|
||||
{
|
||||
((CraftServer)server).getHandle().a(args[0]);
|
||||
sender.sendMessage(Util.format("playerBanned",args[0]));
|
||||
if (sender instanceof Player
|
||||
&& !ess.getUser(sender).isAuthorized("essentials.ban.offline"))
|
||||
{
|
||||
sender.sendMessage(_("banExempt"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p = ess.getUser(server.matchPlayer(args[0]).get(0));
|
||||
String banReason = Util.i18n("defaultBanReason");
|
||||
if(args.length > 1) {
|
||||
banReason = getFinalArg(args, 1);
|
||||
p.setBanReason(commandLabel);
|
||||
if (user.isAuthorized("essentials.ban.exempt"))
|
||||
{
|
||||
sender.sendMessage(_("banExempt"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
String banReason;
|
||||
if (args.length > 1)
|
||||
{
|
||||
banReason = getFinalArg(args, 1);
|
||||
user.setBanReason(banReason);
|
||||
}
|
||||
else
|
||||
{
|
||||
banReason = _("defaultBanReason");
|
||||
}
|
||||
user.setBanned(true);
|
||||
user.kickPlayer(banReason);
|
||||
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final User player = ess.getUser(onlinePlayer);
|
||||
if (player.isAuthorized("essentials.ban.notify"))
|
||||
{
|
||||
onlinePlayer.sendMessage(_("playerBanned", senderName, user.getName(), banReason));
|
||||
}
|
||||
p.kickPlayer(banReason);
|
||||
((CraftServer)server).getHandle().a(p.getName());
|
||||
sender.sendMessage(Util.format("playerBanned", p.getName()));
|
||||
}
|
||||
ess.loadBanList();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Util;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
|
||||
|
||||
public class Commandbanip extends EssentialsCommand
|
||||
@@ -14,16 +14,29 @@ public class Commandbanip extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
((CraftServer)server).getHandle().c(args[0]);
|
||||
sender.sendMessage(Util.i18n("banIpAddress"));
|
||||
ess.loadBanList();
|
||||
final User player = ess.getUser(args[0]);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
ess.getServer().banIP(args[0]);
|
||||
sender.sendMessage(_("banIpAddress"));
|
||||
}
|
||||
else
|
||||
{
|
||||
final String ipAddress = player.getLastLoginAddress();
|
||||
if (ipAddress.length() == 0)
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
ess.getServer().banIP(player.getLastLoginAddress());
|
||||
sender.sendMessage(_("banIpAddress"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.TreeType;
|
||||
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.TreeType;
|
||||
|
||||
|
||||
public class Commandbigtree extends EssentialsCommand
|
||||
@@ -15,9 +16,9 @@ public class Commandbigtree extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
TreeType tree = TreeType.TREE;
|
||||
TreeType tree;
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("redwood"))
|
||||
{
|
||||
tree = TreeType.TALL_REDWOOD;
|
||||
@@ -31,39 +32,16 @@ public class Commandbigtree extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
double x = user.getLocation().getX();
|
||||
double y = user.getLocation().getY();
|
||||
double z = user.getLocation().getZ();
|
||||
|
||||
// offset tree in direction player is facing
|
||||
int r = (int)user.getCorrectedYaw();
|
||||
if (r < 68 || r > 292) // north
|
||||
{
|
||||
x -= 3.0D;
|
||||
}
|
||||
else if (r > 112 && r < 248) // south
|
||||
{
|
||||
x += 3.0D;
|
||||
}
|
||||
if (r > 22 && r < 158) // east
|
||||
{
|
||||
z -= 3.0D;
|
||||
}
|
||||
else if (r > 202 && r < 338) // west
|
||||
{
|
||||
z += 3.0D;
|
||||
}
|
||||
|
||||
Location safeLocation = Util.getSafeDestination(new Location(user.getWorld(), x, y, z));
|
||||
boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree);
|
||||
final Location loc = Util.getTarget(user);
|
||||
final Location safeLocation = Util.getSafeDestination(loc);
|
||||
final boolean success = user.getWorld().generateTree(safeLocation, tree);
|
||||
if (success)
|
||||
{
|
||||
charge(user);
|
||||
user.sendMessage(Util.i18n("bigTreeSuccess"));
|
||||
user.sendMessage(_("bigTreeSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.i18n("bigTreeFailure"));
|
||||
throw new Exception(_("bigTreeFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
|
||||
public class Commandbreak extends EssentialsCommand
|
||||
{
|
||||
public Commandbreak()
|
||||
{
|
||||
super("break");
|
||||
}
|
||||
|
||||
//TODO: Switch to use util class
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final Block block = user.getTargetBlock(null, 20);
|
||||
if (block == null)
|
||||
{
|
||||
throw new NoChargeException();
|
||||
}
|
||||
if (block.getType() == Material.AIR)
|
||||
{
|
||||
throw new NoChargeException();
|
||||
}
|
||||
if (block.getType() == Material.BEDROCK && !user.isAuthorized("essentials.break.bedrock"))
|
||||
{
|
||||
throw new Exception("You are not allowed to destroy bedrock."); //TODO: Translation
|
||||
}
|
||||
final BlockBreakEvent event = new BlockBreakEvent(block, user.getBase());
|
||||
server.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled())
|
||||
{
|
||||
throw new NoChargeException();
|
||||
}
|
||||
else
|
||||
{
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Console;
|
||||
import com.earth2me.essentials.Util;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandbroadcast extends EssentialsCommand
|
||||
@@ -15,15 +13,13 @@ public class Commandbroadcast extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
charge(sender);
|
||||
ess.broadcastMessage(sender instanceof Player ? ((Player)sender).getName() : Console.NAME,
|
||||
Util.format("broadcast", getFinalArg(args, 0)));
|
||||
ess.broadcastMessage(null, _("broadcast", getFinalArg(args, 0)));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Util;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -14,18 +14,17 @@ public class Commandburn extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
charge(sender);
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
{
|
||||
p.setFireTicks(Integer.parseInt(args[1]) * 20);
|
||||
sender.sendMessage(Util.format("burnMsg", p.getDisplayName(), Integer.parseInt(args[1])));
|
||||
sender.sendMessage(_("burnMsg", p.getDisplayName(), Integer.parseInt(args[1])));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.List;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.List;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
|
||||
public class Commandclearinventory extends EssentialsCommand
|
||||
@@ -16,47 +15,46 @@ public class Commandclearinventory extends EssentialsCommand
|
||||
super("clearinventory");
|
||||
}
|
||||
|
||||
//TODO: Cleanup
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && user.isAuthorized("essentials.clearinventory.others"))
|
||||
{
|
||||
//TODO: Fix fringe user match case.
|
||||
if (args[0].length() >= 3)
|
||||
{
|
||||
List<Player> online = server.matchPlayer(args[0]);
|
||||
|
||||
if (!online.isEmpty())
|
||||
{
|
||||
charge(user);
|
||||
for (Player p : online)
|
||||
{
|
||||
p.getInventory().clear();
|
||||
user.sendMessage(Util.format("inventoryClearedOthers", p.getDisplayName()));
|
||||
user.sendMessage(_("inventoryClearedOthers", p.getDisplayName()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Player p = server.getPlayer(args[0]);
|
||||
if (p != null)
|
||||
{
|
||||
charge(user);
|
||||
p.getInventory().clear();
|
||||
user.sendMessage(Util.format("inventoryClearedOthers", p.getDisplayName()));
|
||||
user.sendMessage(_("inventoryClearedOthers", p.getDisplayName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
charge(user);
|
||||
user.getInventory().clear();
|
||||
user.sendMessage(Util.i18n("inventoryCleared"));
|
||||
user.sendMessage(_("inventoryCleared"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,11 +75,11 @@ public class Commandclearinventory extends EssentialsCommand
|
||||
for (Player p : online)
|
||||
{
|
||||
p.getInventory().clear();
|
||||
sender.sendMessage(Util.format("inventoryClearedOthers", p.getDisplayName()));
|
||||
sender.sendMessage(_("inventoryClearedOthers", p.getDisplayName()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -89,11 +87,11 @@ public class Commandclearinventory extends EssentialsCommand
|
||||
if (u != null)
|
||||
{
|
||||
u.getInventory().clear();
|
||||
sender.sendMessage(Util.format("inventoryClearedOthers", u.getDisplayName()));
|
||||
sender.sendMessage(_("inventoryClearedOthers", u.getDisplayName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
|
||||
|
||||
public class Commandcompass extends EssentialsCommand
|
||||
@@ -13,20 +13,46 @@ public class Commandcompass extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
int r = (int)user.getCorrectedYaw();
|
||||
final int bearing = (int)(user.getLocation().getYaw() + 180 + 360) % 360;
|
||||
String dir;
|
||||
if (r < 23) dir = "N";
|
||||
else if (r < 68) dir = "NE";
|
||||
else if (r < 113) dir = "E";
|
||||
else if (r < 158) dir = "SE";
|
||||
else if (r < 203) dir = "S";
|
||||
else if (r < 248) dir = "SW";
|
||||
else if (r < 293) dir = "W";
|
||||
else if (r < 338) dir = "NW";
|
||||
else dir = "N";
|
||||
user.sendMessage(Util.format("compassBearing", dir, r));
|
||||
if (bearing < 23)
|
||||
{
|
||||
dir = "N";
|
||||
}
|
||||
else if (bearing < 68)
|
||||
{
|
||||
dir = "NE";
|
||||
}
|
||||
else if (bearing < 113)
|
||||
{
|
||||
dir = "E";
|
||||
}
|
||||
else if (bearing < 158)
|
||||
{
|
||||
dir = "SE";
|
||||
}
|
||||
else if (bearing < 203)
|
||||
{
|
||||
dir = "S";
|
||||
}
|
||||
else if (bearing < 248)
|
||||
{
|
||||
dir = "SW";
|
||||
}
|
||||
else if (bearing < 293)
|
||||
{
|
||||
dir = "W";
|
||||
}
|
||||
else if (bearing < 338)
|
||||
{
|
||||
dir = "NW";
|
||||
}
|
||||
else
|
||||
{
|
||||
dir = "N";
|
||||
}
|
||||
user.sendMessage(_("compassBearing", dir, bearing));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commanddelhome extends EssentialsCommand
|
||||
{
|
||||
public Commanddelhome()
|
||||
{
|
||||
super("delhome");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
User user = ess.getUser(sender);
|
||||
String name;
|
||||
String[] expandedArg;
|
||||
|
||||
//Allowing both formats /sethome khobbits house | /sethome khobbits:house
|
||||
final String[] nameParts = args[0].split(":");
|
||||
if (nameParts[0].length() != args[0].length())
|
||||
{
|
||||
expandedArg = nameParts;
|
||||
}
|
||||
else
|
||||
{
|
||||
expandedArg = args;
|
||||
}
|
||||
|
||||
if (expandedArg.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others")))
|
||||
{
|
||||
user = getPlayer(server, expandedArg, 0, true);
|
||||
name = expandedArg[1];
|
||||
}
|
||||
else if (user == null)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
else
|
||||
{
|
||||
name = expandedArg[0];
|
||||
}
|
||||
//TODO: Think up a nice error message
|
||||
/*
|
||||
* if (name.equalsIgnoreCase("bed")) { throw new Exception("You cannot remove the vanilla home point"); }
|
||||
*/
|
||||
user.delHome(name.toLowerCase(Locale.ENGLISH));
|
||||
sender.sendMessage(_("deleteHome", name));
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,25 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Util;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class Commanddeljail extends EssentialsCommand {
|
||||
|
||||
public Commanddeljail() {
|
||||
public class Commanddeljail extends EssentialsCommand
|
||||
{
|
||||
public Commanddeljail()
|
||||
{
|
||||
super("deljail");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception {
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
charge(sender);
|
||||
ess.getJail().delJail(args[0]);
|
||||
sender.sendMessage(Util.format("deleteJail", args[0]));
|
||||
ess.getJails().removeJail(args[0]);
|
||||
sender.sendMessage(_("deleteJail", args[0]));
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.Util;
|
||||
|
||||
|
||||
public class Commanddelwarp extends EssentialsCommand
|
||||
@@ -13,14 +13,13 @@ public class Commanddelwarp extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
charge(sender);
|
||||
ess.getWarps().delWarp(args[0]);
|
||||
sender.sendMessage(Util.format("deleteWarp", args[0]));
|
||||
sender.sendMessage(_("deleteWarp", args[0]));
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
|
||||
|
||||
public class Commanddepth extends EssentialsCommand
|
||||
@@ -13,21 +13,20 @@ public class Commanddepth extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
int y = user.getLocation().getBlockY() - 63;
|
||||
if (y > 0)
|
||||
final int depth = user.getLocation().getBlockY() - 63;
|
||||
if (depth > 0)
|
||||
{
|
||||
user.sendMessage(Util.format("depthAboveSea", y));
|
||||
user.sendMessage(_("depthAboveSea", depth));
|
||||
}
|
||||
else if (y < 0)
|
||||
else if (depth < 0)
|
||||
{
|
||||
user.sendMessage(Util.format("depthBelowSea", (-y)));
|
||||
user.sendMessage(_("depthBelowSea", (-depth)));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.i18n("depth"));
|
||||
user.sendMessage(_("depth"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.earth2me.essentials.User;
|
||||
|
||||
|
||||
public class Commandeco extends EssentialsCommand
|
||||
@@ -15,7 +16,7 @@ public class Commandeco extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
@@ -25,7 +26,7 @@ public class Commandeco extends EssentialsCommand
|
||||
double amount;
|
||||
try
|
||||
{
|
||||
cmd = EcoCommands.valueOf(args[0].toUpperCase());
|
||||
cmd = EcoCommands.valueOf(args[0].toUpperCase(Locale.ENGLISH));
|
||||
amount = Double.parseDouble(args[2].replaceAll("[^0-9\\.]", ""));
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -33,46 +34,75 @@ public class Commandeco extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException(ex);
|
||||
}
|
||||
|
||||
if (args[1].contentEquals("*"))
|
||||
if (args[1].contentEquals("**"))
|
||||
{
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (String sUser : ess.getUserMap().getAllUniqueUsers())
|
||||
{
|
||||
User u = ess.getUser(p);
|
||||
final User player = ess.getUser(sUser);
|
||||
switch (cmd)
|
||||
{
|
||||
case GIVE:
|
||||
u.giveMoney(amount);
|
||||
player.giveMoney(amount);
|
||||
break;
|
||||
|
||||
case TAKE:
|
||||
u.takeMoney(amount);
|
||||
if (player.canAfford(amount, false))
|
||||
{
|
||||
player.takeMoney(amount);
|
||||
}
|
||||
break;
|
||||
|
||||
case RESET:
|
||||
u.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
||||
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (args[1].contentEquals("*"))
|
||||
{
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final User player = ess.getUser(onlinePlayer);
|
||||
switch (cmd)
|
||||
{
|
||||
case GIVE:
|
||||
player.giveMoney(amount);
|
||||
break;
|
||||
|
||||
case TAKE:
|
||||
if (!player.canAfford(amount, false))
|
||||
{
|
||||
throw new Exception(_("notEnoughMoney"));
|
||||
}
|
||||
player.takeMoney(amount);
|
||||
break;
|
||||
|
||||
case RESET:
|
||||
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Player p : server.matchPlayer(args[1]))
|
||||
final User player = getPlayer(server, args, 1, true);
|
||||
switch (cmd)
|
||||
{
|
||||
User u = ess.getUser(p);
|
||||
switch (cmd)
|
||||
case GIVE:
|
||||
player.giveMoney(amount, sender);
|
||||
break;
|
||||
|
||||
case TAKE:
|
||||
if (!player.canAfford(amount, false))
|
||||
{
|
||||
case GIVE:
|
||||
u.giveMoney(amount);
|
||||
break;
|
||||
|
||||
case TAKE:
|
||||
u.takeMoney(amount);
|
||||
break;
|
||||
|
||||
case RESET:
|
||||
u.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
||||
break;
|
||||
throw new Exception(_("notEnoughMoney"));
|
||||
}
|
||||
player.takeMoney(amount, sender);
|
||||
break;
|
||||
|
||||
case RESET:
|
||||
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Enchantments;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.*;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Commandenchant extends EssentialsCommand
|
||||
{
|
||||
public Commandenchant()
|
||||
{
|
||||
super("enchant");
|
||||
}
|
||||
|
||||
//TODO: Implement charge costs: final Trade charge = new Trade("enchant-" + enchantmentName, ess);
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final ItemStack stack = user.getItemInHand();
|
||||
if (stack == null)
|
||||
{
|
||||
throw new Exception(_("nothingInHand"));
|
||||
}
|
||||
if (args.length == 0)
|
||||
{
|
||||
final Set<String> enchantmentslist = new TreeSet<String>();
|
||||
for (Map.Entry<String, Enchantment> entry : Enchantments.entrySet())
|
||||
{
|
||||
final String enchantmentName = entry.getValue().getName().toLowerCase(Locale.ENGLISH);
|
||||
if (enchantmentslist.contains(enchantmentName) || user.isAuthorized("essentials.enchant." + enchantmentName))
|
||||
{
|
||||
enchantmentslist.add(entry.getKey());
|
||||
//enchantmentslist.add(enchantmentName);
|
||||
}
|
||||
}
|
||||
throw new NotEnoughArgumentsException(_("enchantments", Util.joinList(enchantmentslist.toArray())));
|
||||
}
|
||||
int level = -1;
|
||||
if (args.length > 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
level = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
level = -1;
|
||||
}
|
||||
}
|
||||
final Enchantment enchantment = getEnchantment(args[0], user);
|
||||
if (level < 0 || level > enchantment.getMaxLevel())
|
||||
{
|
||||
level = enchantment.getMaxLevel();
|
||||
}
|
||||
if (level == 0)
|
||||
{
|
||||
stack.removeEnchantment(enchantment);
|
||||
}
|
||||
else
|
||||
{
|
||||
stack.addEnchantment(enchantment, level);
|
||||
}
|
||||
user.getInventory().setItemInHand(stack);
|
||||
user.updateInventory();
|
||||
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
|
||||
if (level == 0)
|
||||
{
|
||||
user.sendMessage(_("enchantmentRemoved", enchantmentName.replace('_', ' ')));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(_("enchantmentApplied", enchantmentName.replace('_', ' ')));
|
||||
}
|
||||
}
|
||||
|
||||
public static Enchantment getEnchantment(final String name, final User user) throws Exception
|
||||
{
|
||||
|
||||
final Enchantment enchantment = Enchantments.getByName(name);
|
||||
if (enchantment == null)
|
||||
{
|
||||
throw new Exception(_("enchantmentNotFound"));
|
||||
}
|
||||
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
|
||||
if (user != null && !user.isAuthorized("essentials.enchant." + enchantmentName))
|
||||
{
|
||||
throw new Exception(_("enchantmentPerm", enchantmentName));
|
||||
}
|
||||
return enchantment;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 558 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user