mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 01:42:32 +01:00
Compare commits
653 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5af856a2a0 | ||
|
|
ea9c6f4d44 | ||
|
|
631b2342b9 | ||
|
|
189ae6fcdb | ||
|
|
7d70edc0ff | ||
|
|
9bfbf85b4b | ||
|
|
ab50b32f60 | ||
|
|
fc4709fe27 | ||
|
|
2cf789d7bf | ||
|
|
8aad439e99 | ||
|
|
0f1f124eb5 | ||
|
|
bb06e193bc | ||
|
|
4377716474 | ||
|
|
cab9850fe3 | ||
|
|
5ae15bfb71 | ||
|
|
1ca57df0c0 | ||
|
|
86cfa5dcb2 | ||
|
|
3c42dd69d5 | ||
|
|
39620f1aab | ||
|
|
60cbf7b8b9 | ||
|
|
a630022bf0 | ||
|
|
cd53ba04b0 | ||
|
|
b55e9c5c0d | ||
|
|
6887ddd570 | ||
|
|
f2be996e3d | ||
|
|
664c9d9953 | ||
|
|
0fa39c4ace | ||
|
|
9e604aed5e | ||
|
|
6afcce4b7c | ||
|
|
3da8955f8a | ||
|
|
49bb7ecba9 | ||
|
|
99e58039a2 | ||
|
|
d2edbe207d | ||
|
|
05d16e7c15 | ||
|
|
253d0ea4c8 | ||
|
|
397c2cc488 | ||
|
|
4f0c55460d | ||
|
|
8f2c424657 | ||
|
|
b10f599a87 | ||
|
|
c1cdba4395 | ||
|
|
bc725f46e8 | ||
|
|
6b99d3e5f1 | ||
|
|
92cc494087 | ||
|
|
3bb7b05d80 | ||
|
|
ed65842e3d | ||
|
|
be4abefd55 | ||
|
|
9e7209ff47 | ||
|
|
71d47eacaa | ||
|
|
ebc87f46f7 | ||
|
|
558e4f4dd0 | ||
|
|
3109ee9c2a | ||
|
|
bb5d003430 | ||
|
|
058cc3aac9 | ||
|
|
43ff0fa41a | ||
|
|
ab8f1a4ea6 | ||
|
|
9ef1c3b5bf | ||
|
|
ea2615aeae | ||
|
|
0a927768f5 | ||
|
|
1470feb958 | ||
|
|
5a54d6e0c5 | ||
|
|
dc6a2b654e | ||
|
|
a3da6b7df5 | ||
|
|
2c417d28c5 | ||
|
|
71e09423fe | ||
|
|
0070333b35 | ||
|
|
49bb3e0a3c | ||
|
|
787ee0220a | ||
|
|
0093f769f0 | ||
|
|
46d0b50c52 | ||
|
|
3e0cc358d0 | ||
|
|
0a8d34a21f | ||
|
|
def65282dd | ||
|
|
4359dc764f | ||
|
|
28c590f079 | ||
|
|
989f12e65b | ||
|
|
ce8ddded92 | ||
|
|
5d55af8183 | ||
|
|
358c333c70 | ||
|
|
d391d12ab5 | ||
|
|
f5a559efa6 | ||
|
|
0c8b944b12 | ||
|
|
7ff02e51f5 | ||
|
|
a40d3f5f9c | ||
|
|
3eb8f6a1a4 | ||
|
|
132388fe3f | ||
|
|
0d14918946 | ||
|
|
7c3b6b9fb3 | ||
|
|
37b5991dcc | ||
|
|
09044016cd | ||
|
|
577badf4d8 | ||
|
|
de1539ac1d | ||
|
|
6e8cfe5ec9 | ||
|
|
9dfcbf1797 | ||
|
|
74b7aa5340 | ||
|
|
0441b062bd | ||
|
|
24bdd10f7f | ||
|
|
8669582e8f | ||
|
|
d0f66ece98 | ||
|
|
1107e9f36a | ||
|
|
95c15df184 | ||
|
|
c3e1cf8681 | ||
|
|
d393e4d124 | ||
|
|
bce418bee8 | ||
|
|
052e3cd997 | ||
|
|
9eb5535c75 | ||
|
|
e9e7d462f7 | ||
|
|
88ab232ccd | ||
|
|
714f829f3e | ||
|
|
7a549ce211 | ||
|
|
63bdc16e2f | ||
|
|
7e9aada919 | ||
|
|
4805097a0c | ||
|
|
86e4a4344b | ||
|
|
9f3e7ba11c | ||
|
|
3301fc3d9d | ||
|
|
653e06dd03 | ||
|
|
a8aed1bf02 | ||
|
|
d10ff590ec | ||
|
|
b86cfb595c | ||
|
|
6733eb93f2 | ||
|
|
e822515403 | ||
|
|
b6a1188bc7 | ||
|
|
d401a69560 | ||
|
|
798cc3bbb3 | ||
|
|
e1644d3c08 | ||
|
|
36a706b7b6 | ||
|
|
36d6221b3b | ||
|
|
99bff1a4f9 | ||
|
|
7dc1a2ba72 | ||
|
|
4d99fe7230 | ||
|
|
dc9acbc3c9 | ||
|
|
d121358ad2 | ||
|
|
0295314dce | ||
|
|
5da59e6f0a | ||
|
|
07296f14d7 | ||
|
|
0a8a843f6e | ||
|
|
3bc317e7b2 | ||
|
|
a83812d11a | ||
|
|
16451550b5 | ||
|
|
c2dc28c2bd | ||
|
|
c48ac9f596 | ||
|
|
dfba78a4cb | ||
|
|
a9eed7c31c | ||
|
|
a9a7719096 | ||
|
|
5038fbadb0 | ||
|
|
a85ca2c984 | ||
|
|
e6e7f10a05 | ||
|
|
212f6ee773 | ||
|
|
53d38cc54c | ||
|
|
a53c8d5c64 | ||
|
|
94a02c9a2e | ||
|
|
07699fa651 | ||
|
|
0aaf02f208 | ||
|
|
0dd9bc1cda | ||
|
|
ccfce843be | ||
|
|
cb3bc755a6 | ||
|
|
719081a77e | ||
|
|
d1c4efa30d | ||
|
|
12fbaa4361 | ||
|
|
abcd586daa | ||
|
|
2f0a3eaadd | ||
|
|
1814d52680 | ||
|
|
d3ed6bb139 | ||
|
|
8eaa58040e | ||
|
|
04e2a212d1 | ||
|
|
fe7ca65f22 | ||
|
|
89ab87b6dd | ||
|
|
e933fbe1bd | ||
|
|
cb9a9282dd | ||
|
|
14f1a91eeb | ||
|
|
1756031eda | ||
|
|
bccb321ce1 | ||
|
|
920f091a85 | ||
|
|
c1103a52f0 | ||
|
|
4f128ebbef | ||
|
|
3f5b2bdcee | ||
|
|
288e82fbc3 | ||
|
|
feb073d159 | ||
|
|
505df87014 | ||
|
|
f6221c1c34 | ||
|
|
0a97c1dc62 | ||
|
|
05cea84dcc | ||
|
|
1ac544511c | ||
|
|
292f14bf87 | ||
|
|
ef17ea6231 | ||
|
|
75c49497ac | ||
|
|
f9b9dddbc8 | ||
|
|
5a8b9fc344 | ||
|
|
e9dae0d633 | ||
|
|
1c866a52e5 | ||
|
|
2f5edb6329 | ||
|
|
30e5410906 | ||
|
|
4f2a0b8260 | ||
|
|
882a457484 | ||
|
|
ed5531d44b | ||
|
|
b2989a8bab | ||
|
|
c032a27d63 | ||
|
|
353ceefd4e | ||
|
|
9a7ea3b6d0 | ||
|
|
6a79d9f244 | ||
|
|
2151fbb6c0 | ||
|
|
3945a681a3 | ||
|
|
592382a5d3 | ||
|
|
72bfe63ebf | ||
|
|
6d883821a8 | ||
|
|
415786d67e | ||
|
|
d8aa3a5f14 | ||
|
|
f5fc941916 | ||
|
|
8254a8ab0f | ||
|
|
fadbaf429d | ||
|
|
a80507078d | ||
|
|
d13549ff6a | ||
|
|
0f89a9e1e8 | ||
|
|
c8f2521670 | ||
|
|
32135d5647 | ||
|
|
dc5b37d560 | ||
|
|
e873902e1b | ||
|
|
fe21aa0aa9 | ||
|
|
19842ebc35 | ||
|
|
ee1e128c5a | ||
|
|
d099bc562b | ||
|
|
69dfd5645a | ||
|
|
5db7225bc4 | ||
|
|
80374333b6 | ||
|
|
885ec70d28 | ||
|
|
8d00468412 | ||
|
|
5d9ac614c2 | ||
|
|
0f8a418efd | ||
|
|
ed2e9a993d | ||
|
|
f689f048b2 | ||
|
|
906bc01b91 | ||
|
|
4641e4701c | ||
|
|
88e40080fb | ||
|
|
e0fa23359f | ||
|
|
4ab71bcf36 | ||
|
|
652a27eb38 | ||
|
|
d56fe82bfd | ||
|
|
6c20df7839 | ||
|
|
423eb97e0f | ||
|
|
0b43dd2747 | ||
|
|
f2fccd4a64 | ||
|
|
a7292c3a2c | ||
|
|
0c1072f7cf | ||
|
|
cea80f98e8 | ||
|
|
985e69c529 | ||
|
|
a2b3e6fa83 | ||
|
|
ee986970fe | ||
|
|
345fa122c5 | ||
|
|
fae5693db8 | ||
|
|
093f368545 | ||
|
|
a41fc22899 | ||
|
|
5f51f7f9b0 | ||
|
|
de2a0403d2 | ||
|
|
e2d13034a8 | ||
|
|
e55006f662 | ||
|
|
64b46a88c9 | ||
|
|
69b7c3077f | ||
|
|
f158858262 | ||
|
|
7aa7de75a2 | ||
|
|
6cc22a3b63 | ||
|
|
649ce1c147 | ||
|
|
1281843d45 | ||
|
|
e31aea3492 | ||
|
|
26e3403ff4 | ||
|
|
e5922bf3e7 | ||
|
|
2b9baaf0ea | ||
|
|
8ad4e20cab | ||
|
|
1511c5737b | ||
|
|
57bf414d59 | ||
|
|
16a0a3364a | ||
|
|
d09512373b | ||
|
|
dfd1e311d1 | ||
|
|
26c9ba0c3b | ||
|
|
d7d1d0b58d | ||
|
|
a0ab16eaa7 | ||
|
|
cae4b47538 | ||
|
|
dd445dbac5 | ||
|
|
4b26732f51 | ||
|
|
bf38fc9819 | ||
|
|
aff6b0925f | ||
|
|
a7f259ea3c | ||
|
|
3a1ee58339 | ||
|
|
6b0c46b634 | ||
|
|
6b36a030f6 | ||
|
|
df92c43578 | ||
|
|
f481741bb5 | ||
|
|
77b0dd725c | ||
|
|
f850c0ead6 | ||
|
|
7ad9b2ed58 | ||
|
|
695d76dcf4 | ||
|
|
19ea6707fe | ||
|
|
649bccb0d0 | ||
|
|
73f1c08366 | ||
|
|
b98120192a | ||
|
|
1cd7181d26 | ||
|
|
fb35e7dd5d | ||
|
|
1c4275ce37 | ||
|
|
3ff9a28fa7 | ||
|
|
04f13ab090 | ||
|
|
e42b9db159 | ||
|
|
deb3a3bd48 | ||
|
|
6708947332 | ||
|
|
1f0fcb119d | ||
|
|
bdb74d4719 | ||
|
|
19ab8b89f5 | ||
|
|
10fa9e5465 | ||
|
|
1fe259eb7a | ||
|
|
cd56dc7f98 | ||
|
|
8cf9601af4 | ||
|
|
b39c02154a | ||
|
|
a2e41f31ed | ||
|
|
5d8b049a45 | ||
|
|
336adf9530 | ||
|
|
708cfc23b6 | ||
|
|
06b2a89646 | ||
|
|
b782225dde | ||
|
|
85640f88b2 | ||
|
|
a372ca34e6 | ||
|
|
4acc0b63fd | ||
|
|
edf6f7560b | ||
|
|
66e0cc33bf | ||
|
|
498e3eb35c | ||
|
|
2aa7e37e13 | ||
|
|
09c5b8727a | ||
|
|
02a67e330a | ||
|
|
37364d6c86 | ||
|
|
86166a58e1 | ||
|
|
935e494705 | ||
|
|
94387045e4 | ||
|
|
20ae2dbeea | ||
|
|
d1b522b534 | ||
|
|
89802e23e2 | ||
|
|
cb4b5d1c71 | ||
|
|
472bfa51da | ||
|
|
162dbaed0f | ||
|
|
6f9fc26ab5 | ||
|
|
b199568ec3 | ||
|
|
ff258e0cbf | ||
|
|
68dd18067e | ||
|
|
799e11c36c | ||
|
|
f274d47c81 | ||
|
|
ca3b7f2172 | ||
|
|
22c9fca915 | ||
|
|
e4d312a11f | ||
|
|
a3f0de1c84 | ||
|
|
4826056bbe | ||
|
|
6f2f99dda0 | ||
|
|
d06ec5e452 | ||
|
|
94cb118a7e | ||
|
|
bebc70634b | ||
|
|
186c9189ca | ||
|
|
324b69cba1 | ||
|
|
802af464cd | ||
|
|
0c8b46acee | ||
|
|
182219f00d | ||
|
|
828f5ad173 | ||
|
|
95da5a4535 | ||
|
|
324bcd9b91 | ||
|
|
98ed75e4e0 | ||
|
|
3d5bb334f6 | ||
|
|
c74f43a1ad | ||
|
|
f5451b7d59 | ||
|
|
3dbaf061ed | ||
|
|
19ac0e6ba6 | ||
|
|
a509b0e9d3 | ||
|
|
5c63e9779e | ||
|
|
9ef9ffd16f | ||
|
|
93e223b2cc | ||
|
|
c4a0ae64aa | ||
|
|
933a7ffc69 | ||
|
|
b0253f9913 | ||
|
|
7eb1d43201 | ||
|
|
1f843bc3a2 | ||
|
|
c17bc7d332 | ||
|
|
c308121c47 | ||
|
|
d0d9868b5f | ||
|
|
8f3dce4ee9 | ||
|
|
de0a6dd3ee | ||
|
|
5d06341612 | ||
|
|
470b29c229 | ||
|
|
c915bb8312 | ||
|
|
f8869c177f | ||
|
|
c0a7b276b4 | ||
|
|
fa35fd9e45 | ||
|
|
3f8077d615 | ||
|
|
3b9e85e976 | ||
|
|
b024b45e02 | ||
|
|
a3cf3401bb | ||
|
|
bc12e0d100 | ||
|
|
96be29ef63 | ||
|
|
0f2029a32d | ||
|
|
aa14c1bc1f | ||
|
|
d052af9207 | ||
|
|
ad2ed37d0a | ||
|
|
1943ce884a | ||
|
|
b23fa36543 | ||
|
|
887f8f3e0c | ||
|
|
227b554488 | ||
|
|
20064f36ef | ||
|
|
decdddb9ec | ||
|
|
1b0fac78ae | ||
|
|
d864a2391e | ||
|
|
b08aead536 | ||
|
|
cca04468de | ||
|
|
e997c32c6c | ||
|
|
a1d5eaa846 | ||
|
|
4e9333e823 | ||
|
|
b75e7470ae | ||
|
|
484cbccc1b | ||
|
|
5d4d4d3498 | ||
|
|
82e34a5b02 | ||
|
|
a9b1ebb063 | ||
|
|
c942feb868 | ||
|
|
7003311b7e | ||
|
|
2549e23fd2 | ||
|
|
40af51fc05 | ||
|
|
06d3d8a18f | ||
|
|
992e6bce86 | ||
|
|
6e59087f6d | ||
|
|
e94473b21b | ||
|
|
8da49ba796 | ||
|
|
bc8f073f3f | ||
|
|
9589924235 | ||
|
|
fed21a7cb9 | ||
|
|
a97783ed86 | ||
|
|
7982e33823 | ||
|
|
7cf549ba88 | ||
|
|
0386d52e7c | ||
|
|
e7b763c8ea | ||
|
|
c805b17929 | ||
|
|
877bf7905b | ||
|
|
c45b03b1d8 | ||
|
|
f4d84dbd52 | ||
|
|
28d73a33ab | ||
|
|
9c9247b9c1 | ||
|
|
50684e9ca0 | ||
|
|
b5e4bebd75 | ||
|
|
b9de8e6d13 | ||
|
|
939344816e | ||
|
|
441015d6a5 | ||
|
|
841832846f | ||
|
|
eb0bf07d2c | ||
|
|
fc622dcde2 | ||
|
|
e77be3350f | ||
|
|
b4637a825e | ||
|
|
a2fc694c8d | ||
|
|
06c0b4cc11 | ||
|
|
ea2ae0b5c3 | ||
|
|
1bf9cfa422 | ||
|
|
3d699e612a | ||
|
|
a202d6168b | ||
|
|
786a5f9325 | ||
|
|
1910b76b13 | ||
|
|
bda72f28ed | ||
|
|
27e60ef85b | ||
|
|
58dc45d344 | ||
|
|
082dcebf9b | ||
|
|
a652fcd026 | ||
|
|
717c2d2869 | ||
|
|
3124712cfb | ||
|
|
081b5f6728 | ||
|
|
71c14ab07b | ||
|
|
900d58a6f4 | ||
|
|
70756c2a2e | ||
|
|
5b40f2e2e9 | ||
|
|
3d60c057ea | ||
|
|
105b8b5a91 | ||
|
|
9278ca4d27 | ||
|
|
d97e97ae5f | ||
|
|
5cbee8a4ab | ||
|
|
fe9db6c9ad | ||
|
|
a4845abc45 | ||
|
|
470b29eeca | ||
|
|
f87f7f6feb | ||
|
|
5e8a8aac53 | ||
|
|
2672e218f4 | ||
|
|
02a728bdea | ||
|
|
3a812612de | ||
|
|
4fdbce24d7 | ||
|
|
52458041f0 | ||
|
|
4a1e5a0dcc | ||
|
|
f6c7ac6d98 | ||
|
|
76675422ea | ||
|
|
7dee6db362 | ||
|
|
e8030c59f1 | ||
|
|
4b642d4953 | ||
|
|
346b7862af | ||
|
|
3ec661cc02 | ||
|
|
d7f066b07e | ||
|
|
e54500fa90 | ||
|
|
a2c83425f2 | ||
|
|
41ce19b835 | ||
|
|
9c11a6ffb0 | ||
|
|
e36cd8109d | ||
|
|
ee83e93269 | ||
|
|
0b4692e303 | ||
|
|
e99b5a4abf | ||
|
|
a419c4d4fe | ||
|
|
ca80a7d463 | ||
|
|
716e6296e5 | ||
|
|
6382bec05a | ||
|
|
20248212ae | ||
|
|
86e373b493 | ||
|
|
b4b0bbd081 | ||
|
|
17bacbf9d6 | ||
|
|
b869fb0ca5 | ||
|
|
c70a23dd5c | ||
|
|
f9e7ae22f2 | ||
|
|
30fb2770a6 | ||
|
|
11e1dc7ec8 | ||
|
|
5645c29dd8 | ||
|
|
44e954efeb | ||
|
|
4ffb20f3bb | ||
|
|
716dd02b3f | ||
|
|
5e93a4c9d3 | ||
|
|
cbeb994b69 | ||
|
|
43e3dd7977 | ||
|
|
598c507849 | ||
|
|
0b30920edd | ||
|
|
6cfd81faf9 | ||
|
|
cc9a6aa9b9 | ||
|
|
c8ff58bb6c | ||
|
|
dc77d9f434 | ||
|
|
7c87fc8316 | ||
|
|
0068a3f07a | ||
|
|
bb70289cb3 | ||
|
|
80abd0db91 | ||
|
|
bbef731be5 | ||
|
|
897f4d3694 | ||
|
|
2c380f609e | ||
|
|
aa9fe544a2 | ||
|
|
230435c29d | ||
|
|
4a2325f244 | ||
|
|
d920702389 | ||
|
|
16d56a45f2 | ||
|
|
3e62697567 | ||
|
|
219372212e | ||
|
|
3d401ac4cb | ||
|
|
20adf4674a | ||
|
|
20fb69fba3 | ||
|
|
173c2c19c8 | ||
|
|
66ac83ed9a | ||
|
|
595d48d1b4 | ||
|
|
ddbb0176e7 | ||
|
|
68da48e19f | ||
|
|
c001bb8d2c | ||
|
|
f3ffbe1ad1 | ||
|
|
b80c73e251 | ||
|
|
892f4935ae | ||
|
|
cb3904246c | ||
|
|
47ed176191 | ||
|
|
151c9ba1d4 | ||
|
|
81ab8692ad | ||
|
|
123e96e39d | ||
|
|
b4a3ddba3c | ||
|
|
2b85ed01ea | ||
|
|
c99fce9143 | ||
|
|
ade31de797 | ||
|
|
b8f4b6e2da | ||
|
|
c95d2a9b84 | ||
|
|
ceca881cd5 | ||
|
|
6b668f5ac8 | ||
|
|
618f075ff2 | ||
|
|
7841fe2434 | ||
|
|
16577f6f23 | ||
|
|
43731bd9f9 | ||
|
|
0ca57f479b | ||
|
|
00d8ed9ec7 | ||
|
|
3fcfde1697 | ||
|
|
e3d04fd940 | ||
|
|
0f41381c98 | ||
|
|
5b3c176192 | ||
|
|
64e6ea86fd | ||
|
|
5404fc8703 | ||
|
|
7693662cea | ||
|
|
388fd364ac | ||
|
|
fdb96a2cf8 | ||
|
|
e82d5db4b3 | ||
|
|
563baea812 | ||
|
|
3613cbd48b | ||
|
|
f937e44018 | ||
|
|
2c7730b478 | ||
|
|
50af20037a | ||
|
|
b7955ea29e | ||
|
|
7cefdedea2 | ||
|
|
647078778d | ||
|
|
61c6cd1b55 | ||
|
|
96a395af23 | ||
|
|
2297c3e0f6 | ||
|
|
401af172ae | ||
|
|
ddf7920c4d | ||
|
|
c46d900833 | ||
|
|
bc9b089a53 | ||
|
|
e68092cae4 | ||
|
|
1aa231c902 | ||
|
|
63d9b30d14 | ||
|
|
b695f9ed27 | ||
|
|
f3283de8dd | ||
|
|
e69c2fd68e | ||
|
|
d1ce5f0be5 | ||
|
|
5b45ea3739 | ||
|
|
6f95d6b60d | ||
|
|
3552b756e0 | ||
|
|
0b5a60e4c6 | ||
|
|
01bbd9bcac | ||
|
|
a61efae527 | ||
|
|
3fef87923a | ||
|
|
c8869c86be | ||
|
|
42ddf648b1 | ||
|
|
fded7cad96 | ||
|
|
23354ce049 | ||
|
|
299f440f63 | ||
|
|
9bd4a0a707 | ||
|
|
7c60217882 | ||
|
|
725056d88d | ||
|
|
f93efe54a5 | ||
|
|
59e6d9781f | ||
|
|
7d19fe68d9 | ||
|
|
486fb5635d | ||
|
|
dfe2d0a585 | ||
|
|
71aac4ea7d | ||
|
|
e1399427f0 | ||
|
|
80cc22efff | ||
|
|
5863efbdd8 | ||
|
|
85fe839e91 | ||
|
|
7e7505381b | ||
|
|
aadfb22f00 | ||
|
|
e0b0fd1d80 | ||
|
|
ff9b6fd98a | ||
|
|
ce3fe8fd21 | ||
|
|
93502810e8 | ||
|
|
ac51683161 | ||
|
|
802be6907d | ||
|
|
3932036a2c | ||
|
|
fd1064a9b9 | ||
|
|
f0146d99c2 | ||
|
|
fa98de77b1 | ||
|
|
328c7d4b5f | ||
|
|
984dbd9b7a | ||
|
|
1cfdfab2b7 | ||
|
|
17d584f911 | ||
|
|
0dddc5a1f7 | ||
|
|
b5c11de15c | ||
|
|
96acb4df97 | ||
|
|
75cf202987 | ||
|
|
fd3cee96f0 | ||
|
|
aee71789f2 | ||
|
|
da9a4b80e4 | ||
|
|
523db7f0a2 | ||
|
|
b3782eddc3 | ||
|
|
1168d363a6 | ||
|
|
2854511252 | ||
|
|
6970174503 |
42
.gitignore
vendored
Normal file
42
.gitignore
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
# Eclipse stuff
|
||||
/.classpath
|
||||
/.project
|
||||
/.settings
|
||||
|
||||
# netbeans
|
||||
/nbproject
|
||||
|
||||
# we use maven!
|
||||
/build.xml
|
||||
|
||||
# maven
|
||||
/target
|
||||
|
||||
# vim
|
||||
.*.sw[a-p]
|
||||
|
||||
# various other potential build files
|
||||
/build
|
||||
/bin
|
||||
/dist
|
||||
/manifest.mf
|
||||
|
||||
/world
|
||||
|
||||
# Mac filesystem dust
|
||||
/.DS_Store
|
||||
|
||||
# intellij
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Project Stuff
|
||||
/src/main/resources/mcMMO
|
||||
|
||||
# Other Libraries
|
||||
*.jar
|
||||
|
||||
# Atlassian Stuff
|
||||
/atlassian-ide-plugin.xml
|
||||
198
Changelog.txt
198
Changelog.txt
@@ -1,5 +1,201 @@
|
||||
Changelog:
|
||||
#Versions without changelogs probably had very small misc fixes, like tweaks to the source code
|
||||
Versions without changelogs probably had very small misc fixes, like tweaks to the source code
|
||||
|
||||
Key:
|
||||
+ Addition
|
||||
= Fix
|
||||
! Change
|
||||
- Removal
|
||||
|
||||
Version 1.3.03
|
||||
+ Added Ocelots to Taming XP tables
|
||||
+ Added ability to summon Ocelots with Call of the Wild
|
||||
+ Added offline user functionality to mmoedit
|
||||
+ Added bookshelves to list of blocks that don't trigger abilities.
|
||||
+ Added 'mcmmo.repair.arcanebypass' permission node to bypass Arcane Repair and keep your enchantments
|
||||
+ Added config option to disable Herbalism's instant wheat replanting
|
||||
+ Added LOTS of new permissions nodes. *CHECK PLUGIN.YML FOR UPDATES*
|
||||
+ Added Italian locale file - thanks Luxius96!
|
||||
+ Added ability to inspect Ocelots with Beast Lore
|
||||
+ Added console functionality to mctop
|
||||
= Fixed Green Terra not awarding Triple Drops
|
||||
= Fixed ClassCastException from Taming preventDamage checks
|
||||
= Fixed issue with Blast Mining not seeing TNT for detonation due to snow
|
||||
= Fixed issue with block interaction returning NPEs
|
||||
= Fixed issue where every block broken had a mining check applied
|
||||
= Fixed issue where every block broken had a herbalism check applied
|
||||
= Fixed issue where blocks weren't being removed from the watchlist
|
||||
= Fixed exploit where you could use /ptp to teleport to anyone
|
||||
= Fixed bug where Green Terra didn't work on Stone Brick
|
||||
= Fixed bug where Tree Feller could be used without permissions
|
||||
= Fixed exploit where falling sand & gravel weren't tracked
|
||||
= Fixed exploit where Acrobatics could be leveled via Dodge on party members.
|
||||
= Fixed exploit where you could gain combat XP on animals summoned by Call of the Wild
|
||||
! Changed mcMMO to save profiles only when the profile is about to be discarded rather than on player quit
|
||||
! Changed MySQL to try to reconnect every 60 seconds rather than infinitely which caused server hangs
|
||||
! Changed mcMMO to be better about saving player information on server shutdown
|
||||
! Changed PTP to prevent teleporting if you've been hurt in the last 30 seconds (configurable)
|
||||
! Changed Chimera Wing failure check to use the maxWorldHeight.
|
||||
! Changed inspect failed message to say inspect rather than whois
|
||||
! Changed Call of the Wild to activate on left-click rather than right-click
|
||||
! Changed Blast Mining to track based on Entity ID vs. Location
|
||||
! Changed mmoedit to save a profile when used (this will make mctop update)
|
||||
! Changed a few Runnable tasks to have their own classes
|
||||
! Changed parties so that a player will leave their existing party if they enter a world where they don't have party permissions.
|
||||
! Changed Call of the Wild to summon animals already tamed.
|
||||
! Changed mob spawner tracking to use new Metadata API
|
||||
! Changed block watch list to use new Metadata API
|
||||
! Changed around a few config options, including the ones for mySQL. *YOU NEED TO REDO YOUR CONFIG FILE*
|
||||
- Removed 'true/false' debug message from Inspect command
|
||||
|
||||
Version 1.3.02
|
||||
+ Added in game guides for Mining, Excavation, and Acrobatics. Simply type /skillname ? to access them
|
||||
! Changed Tree Feller to hand out 1/4 of normal XP for each JUNGLE LOG block it fells
|
||||
! Changed Tree Feller to only fell trees if you have enough durability
|
||||
! Changed Tree Feller to cause injury if your axe splinters from a failed Tree Feller attempt
|
||||
! Changed invincibility checks in EntityDamage listeners to accommodate for vanilla MC behaviour
|
||||
! Changed Ignition to add fire ticks rather than replacing them.
|
||||
! Changed Axes critical to have a max critical rate of 37.5% down from 75%
|
||||
= Fixed bug where Taming defensive checks got called twice
|
||||
= Fixed Shake not working correctly
|
||||
= Fixed bug with Axes command displaying wrong Greater Impact bonus damage
|
||||
= Fixed bug where Impact didn't apply bonus damage
|
||||
= Fixed Impact proccing multiple times in a row
|
||||
= Fixed bug where PVE skills didn't level
|
||||
|
||||
Version 1.3.01
|
||||
= Fixed bug where Tree Feller had no cooldown
|
||||
= Fixed bug with activating Skull Splitter after using Tree Feller
|
||||
|
||||
Version 1.3.00
|
||||
+ Added ability to customize drops for Excavation skill (treasures.yml)
|
||||
+ Added ability to customize drops for Fishing skill (treasures.yml)
|
||||
+ Added messages to nearby players when your abilities wear off
|
||||
+ Added jungle trees to Woodcutting XP tables
|
||||
+ Added player notification for when they stop Bleeding
|
||||
+ Added configuration option to control mcMMO reporting damage events
|
||||
+ Added hunger regain bonuses to Herbalism skill
|
||||
+ Added Blast Mining subskills to Mining
|
||||
+ Added Fast Food Service subskill to Taming
|
||||
+ Added size limit to Tree Feller in config as Tree Feller Threshold
|
||||
+ Added /inspect (works on offline players)
|
||||
+ Added /addlevels commands
|
||||
+ Added /mcremove command which lets you remove users from MySQL or FlatFile
|
||||
+ Added config values for XP multipliers for different hostile mobs
|
||||
+ Added 'mcmmo.commands.inspect' permission node for the new /inspect command
|
||||
+ Added Impact & Greater Impact subskills to Axes
|
||||
+ Re-added mcMMO reporting damage events
|
||||
= Fixed bug with updating MySQL tables to include fishing on servers using custom table prefixes
|
||||
= Fixed bug where Disarm didn't work at all ever
|
||||
= Fixed bug where Swords command showed Bleed Length twice instead of Bleed Chance
|
||||
= Fixed bug where Tree Feller wasn't checking for Tree Feller permission
|
||||
= Fixed bug where Leaf Blower required Tree Feller permissions rather than Woodcutting permissions
|
||||
= Fixed Leaf Blower preventing the use of shears to collect leaves
|
||||
= Fixed Green Thumb & Green Terra not consuming or requiring seeds to replant Wheat
|
||||
= Fixed Super Breaker & Giga Drill Breaker failing to damage tools
|
||||
= Fixed Tree Feller not giving proper XP for different kinds of trees
|
||||
= Fixed Skill Abilities conflicting with NoCheat
|
||||
= Fixed memory leak with mob spawner tracking
|
||||
= Fixed /mcability not respecting permissions
|
||||
= Prettied up new config files
|
||||
= Various skill function optimizations
|
||||
! Changed how mcMMO calculates distance between two points (optimizations)
|
||||
! Changed how mcMMO handles MySQL connections (optimizations)
|
||||
! Changed the description /mcmmo provides to be more up to date and relevant
|
||||
! Changed mcMMO user information to be stored for 2 minutes after log out to reduce lag on rejoins
|
||||
! Changed Food+ to be named Farmer's Diet in Herbalism
|
||||
! Changed default values of Woodcutting XP tables
|
||||
! Changed 'Pine' to be renamed 'Oak' in Woodcutting XP tables
|
||||
! Changed the name of Unarmed Apprentice/Mastery to Iron Arm Style
|
||||
! Changed Axes to gain bonus damage every 50 skill levels
|
||||
! Changed Unarmed to start with a +3 DMG (1 Heart = 2 DMG) bonus from Iron Arm Style to make leveling it more viable
|
||||
! Changed Unarmed to gain bonus damage every 50 skill levels
|
||||
! Changed Unarmed to gain more bonus damage total than before
|
||||
! Changed Unarmed to have a max disarm chance of 33.3% rather than 25%
|
||||
! Changed Tree Feller to take down entire trees
|
||||
! Changed mob spawn tracking to use Unique Entity ID instead of Entity Object
|
||||
! Changed stats command name to mcstats for better plugin compatibility
|
||||
! Changed god mode to turn off if player enters world where he does not have mcgod permission
|
||||
! Changed Taming to also gain XP from animal taming
|
||||
! Changed Swords Bleeding effect to never kill
|
||||
! Changed Bleeding to never go beyond 10 ticks
|
||||
! Changed to use Bukkit's built-in ignoreCancelledEvents system
|
||||
! Changed chat logging for /p & /a
|
||||
! Changed Tree Feller to use per-use ArrayList
|
||||
- Removed /mcstats console functionality
|
||||
- Removed /whois command (replaced with /inspect which has similar functionality)
|
||||
- Removed Master/Apprentice chat notifications to reduce spam
|
||||
- Removed MySpawn system (You can still use Chimaera Wings) due to being outdated and unwanted
|
||||
- Removed duplicate settings in config.yml
|
||||
- Removed unused settings from config.yml (HP Regen)
|
||||
- Removed Nether Brick from Mining XP Tables
|
||||
- Removed Stone Brick from Mining XP Tables
|
||||
|
||||
Version 1.2.12
|
||||
- Fixed issue that caused terrible MySQL performance and negative XP on levelup (Issue #134)
|
||||
- Fixed addxp command taking xprate and skill modifiers into account
|
||||
- Added anonymous usage statistics (you can opt out in plugins/PluginMetrics/config.yml)
|
||||
- Modified onEntityDamage priority to have better compatibility with other plugins (Factions, WorldGuard, etc...)
|
||||
- Fixed /mcgod & /mmoedit permissions defaulting to true
|
||||
- Fixed Fishing not working or handing out XP
|
||||
- Fixed error with Skull Splitter / Serrated Strikes that caused server instability and log spam
|
||||
- Fixed config.yml not having values for End Stone & other new mining blocks
|
||||
- Fixed Green Thumb/Green Terra not correctly planting wheat (Issue #133)
|
||||
|
||||
Version 1.2.11
|
||||
- Removed legacy Permission & PEX dependency. (PEX still works fine with mcMMO)
|
||||
- Made Smooth Brick to Mossy Brick and Dirt to Grass for green thumb configurable (Issue #120)
|
||||
- Added MagmaCube to XP tables
|
||||
- Made optimizations to Skull Splitter/Serrated Strikes
|
||||
- Made it so players take damage if they try to log out with Serrated Strikes stacked onto them (Issue #131)
|
||||
- Changed mcMMO to save data periodically to optimize performance with FlatFile & MySQL (Issue #138)
|
||||
- Added a configurable save interval for the new save system
|
||||
- Fixed a bug with the odds calculations for Serrated Strikes
|
||||
- Fixed several commands not working from console (mmoedit, etc..) (Issue #150)
|
||||
- Added a success message when executing xprate from console
|
||||
|
||||
Version 1.2.10
|
||||
- Fixed issue with receiving Woodcutting XP for all blocks broken (Issue #103)
|
||||
- Fixed issue with Spout images & sounds not working (Issue #93)
|
||||
- Fixed typo with repairing Leather Armor & Bows
|
||||
- Fixed issue with Silk Touch & Double/Triple drops not working properly
|
||||
- Fixed conflict with NoCheat plugin & Super Breaker/Giga Drill Breaker/Berserk/Leaf Blower (Issue #104)
|
||||
- Fixed counter-attacking non-LivingEntity (Issue #100 & Issue #107)
|
||||
- Fixed various bugs with Leaf Blower
|
||||
- Added Monitor & ignoreCancelledEvents to onBlockPlace
|
||||
- Made Anvil ID configurable
|
||||
|
||||
Version 1.2.09
|
||||
- Fixed issue with Repair Mastery (Issue #47)
|
||||
- Made Arcane Forging fully configurable (Pull Request #52)
|
||||
- Made Fishing configurable (Pull Request #60)
|
||||
- Changed timer to be a bit more efficient (Issue #19)
|
||||
- Changed to fire EntityDamageEvents for all damage done by mcMMO
|
||||
- New custom event for developers McMMOPlayerLevelUpEvent
|
||||
- New custom event for developers McMMOItemSpawnEvent
|
||||
- Changed LoadProperties from the old Configuration to FileConfiguration
|
||||
- Removed aliasing from config.yml
|
||||
- Fixed mining procs from Super Break & Silk Touch
|
||||
- Unused smelt property removed
|
||||
- Minor optimizations
|
||||
- Fix for setting properly block damage values
|
||||
- Initial skill level capping added
|
||||
- Initial command alias framework added
|
||||
- Fixed abilities not handling Unbreaking items
|
||||
- Fix for treefeller glitch
|
||||
- Super secret anniversary easter egg!
|
||||
|
||||
Version 1.2.08
|
||||
- Changed Bukkit events to new event system
|
||||
- Changed aliasing to send both the mcmmo command and the command used.
|
||||
- Changes in combat exp (Pull Request #49)
|
||||
- Repair for bows & leather armor (Pull Request #46)
|
||||
- Fixed missing images (Pull Request #45)
|
||||
- POM Changes for dependencies (Pull Request #36)
|
||||
- Fishing & Repair fixes (Pull Request #31)
|
||||
- Fixed CraftOfflinePlayer issue (Issue #212) errors for offline wolf owners
|
||||
- Pull in commit from @NuclearW for issue from previous commit
|
||||
|
||||
Version 1.2.07
|
||||
Fixed mctop not working at all (whoops!)
|
||||
Fixed problem with multithreading in mcMMO causing errors
|
||||
|
||||
346
LICENSE
Normal file
346
LICENSE
Normal file
@@ -0,0 +1,346 @@
|
||||
TERMS AND CONDITIONS
|
||||
0. Definitions.
|
||||
“This License” refers to version 3 of the GNU General Public License.
|
||||
|
||||
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
||||
|
||||
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”.
|
||||
“Licensees” and “recipients” may be individuals or organizations.
|
||||
|
||||
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission,
|
||||
other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work
|
||||
“based on” the earlier work.
|
||||
|
||||
A “covered work” means either the unmodified Program or a work based on the Program.
|
||||
|
||||
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily
|
||||
liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy.
|
||||
Propagation includes copying, distribution (with or without modification), making available to the public, and in some
|
||||
countries other activities as well.
|
||||
|
||||
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction
|
||||
with a user through a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and
|
||||
prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no
|
||||
warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this
|
||||
License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any
|
||||
non-source form of a work.
|
||||
|
||||
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or,
|
||||
in the case of interfaces specified for a particular programming language, one that is widely used among developers
|
||||
working in that language.
|
||||
|
||||
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in
|
||||
the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to
|
||||
enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is
|
||||
available to the public in source code form. A “Major Component”, in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a
|
||||
compiler used to produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and
|
||||
(for an executable work) run the object code and to modify the work, including scripts to control those activities.
|
||||
However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs
|
||||
which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding
|
||||
Source includes interface definition files associated with source files for the work, and the source code for shared
|
||||
libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data
|
||||
communication or control flow between those subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the
|
||||
Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided
|
||||
the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program.
|
||||
The output from running a covered work is covered by this License only if the output, given its content, constitutes a
|
||||
covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey, without conditions so long as your license
|
||||
otherwise remains in force. You may convey covered works to others for the sole purpose of having them make
|
||||
modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do not control copyright. Those thus making or running
|
||||
the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that
|
||||
prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not
|
||||
allowed; section 10 makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling
|
||||
obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or
|
||||
restricting circumvention of such measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the
|
||||
extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you
|
||||
disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users,
|
||||
your or third parties' legal rights to forbid circumvention of technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating
|
||||
that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices
|
||||
of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for
|
||||
a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source
|
||||
code under the terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
||||
b) The work must carry prominent notices stating that it is released under this License and any conditions added under
|
||||
section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
|
||||
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all
|
||||
its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way,
|
||||
but it does not invalidate such permission if you have separately received it.
|
||||
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has
|
||||
interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
||||
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of
|
||||
the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or
|
||||
distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the
|
||||
access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied
|
||||
by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
||||
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied
|
||||
by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for
|
||||
that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all
|
||||
the software in the product that is covered by this License, on a durable physical medium customarily used for software
|
||||
interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2)
|
||||
access to copy the Corresponding Source from a network server at no charge.
|
||||
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source.
|
||||
This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an
|
||||
offer, in accord with subsection 6b.
|
||||
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent
|
||||
access to the Corresponding Source in the same way through the same place at no further charge. You need not require
|
||||
recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a
|
||||
network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports
|
||||
equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it
|
||||
is available for as long as needed to satisfy these requirements.
|
||||
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and
|
||||
Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
||||
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library,
|
||||
need not be included in conveying the object code work.
|
||||
|
||||
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used
|
||||
for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In
|
||||
determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a
|
||||
particular product received by a particular user, “normally used” refers to a typical or common use of that class of
|
||||
product, regardless of the status of the particular user or of the way in which the particular user actually uses, or
|
||||
expects or is expected to use, the product. A product is a consumer product regardless of whether the product has
|
||||
substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of
|
||||
the product.
|
||||
|
||||
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information
|
||||
required to install and execute modified versions of a covered work in that User Product from a modified version of its
|
||||
Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code
|
||||
is in no case prevented or interfered with solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the
|
||||
conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to
|
||||
the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding
|
||||
Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not
|
||||
apply if neither you nor any third party retains the ability to install modified object code on the User Product (for
|
||||
example, the work has been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a requirement to continue to provide support
|
||||
service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product
|
||||
in which it has been modified or installed. Access to a network may be denied when the modification itself materially
|
||||
and adversely affects the operation of the network or violates the rules and protocols for communication across the
|
||||
network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format
|
||||
that is publicly documented (and with an implementation available to the public in source code form), and must require
|
||||
no special password or key for unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its
|
||||
conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were
|
||||
included in this License, to the extent that they are valid under applicable law. If additional permissions apply only
|
||||
to part of the Program, that part may be used separately under those permissions, but the entire Program remains
|
||||
governed by this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or
|
||||
from any part of it. (Additional permissions may be written to require their own removal in certain cases when you
|
||||
modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have
|
||||
or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by
|
||||
the copyright holders of that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
||||
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the
|
||||
Appropriate Legal Notices displayed by works containing it; or
|
||||
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be
|
||||
marked in reasonable ways as different from the original version; or
|
||||
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
||||
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
||||
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified
|
||||
versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual
|
||||
assumptions directly impose on those licensors and authors.
|
||||
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the
|
||||
Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with
|
||||
a term that is a further restriction, you may remove that term. If a license document contains a further restriction but
|
||||
permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of
|
||||
that license document, provided that the further restriction does not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a
|
||||
statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as
|
||||
exceptions; the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to
|
||||
propagate or modify it is void, and will automatically terminate your rights under this License (including any patent
|
||||
licenses granted under the third paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated
|
||||
(a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and
|
||||
(b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days
|
||||
after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you
|
||||
of the violation by some reasonable means, this is the first time you have received notice of violation of this License
|
||||
(for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the licenses of parties who have received copies or
|
||||
rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not
|
||||
qualify to receive new licenses for the same material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a
|
||||
covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not
|
||||
require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered
|
||||
work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run,
|
||||
modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third
|
||||
parties with this License.
|
||||
|
||||
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or
|
||||
subdividing an organization, or merging organizations. If propagation of a covered work results from an entity
|
||||
transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work
|
||||
the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with
|
||||
reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For
|
||||
example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License,
|
||||
and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent
|
||||
claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program
|
||||
is based. The work thus licensed is called the contributor's “contributor version”.
|
||||
|
||||
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already
|
||||
acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or
|
||||
selling its contributor version, but do not include claims that would be infringed only as a consequence of further
|
||||
modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent
|
||||
sublicenses in a manner consistent with the requirements of this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential
|
||||
patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its
|
||||
contributor version.
|
||||
|
||||
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to
|
||||
enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To
|
||||
“grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against
|
||||
the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not
|
||||
available for anyone to copy, free of charge and under the terms of this License, through a publicly available network
|
||||
server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available,
|
||||
or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a
|
||||
manner consistent with the requirements of this License, to extend the patent license to downstream recipients.
|
||||
“Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in
|
||||
a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in
|
||||
that country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring
|
||||
conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing
|
||||
them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is
|
||||
automatically extended to all recipients of the covered work and works based on it.
|
||||
|
||||
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of,
|
||||
or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You
|
||||
may not convey a covered work if you are a party to an arrangement with a third party that is in the business of
|
||||
distributing software, under which you make payment to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a
|
||||
discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from
|
||||
those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered
|
||||
work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to
|
||||
infringement that may otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this
|
||||
License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to
|
||||
satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence
|
||||
you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further
|
||||
conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License
|
||||
would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work
|
||||
licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the
|
||||
resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special
|
||||
requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply
|
||||
to the combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to
|
||||
time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new
|
||||
problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the
|
||||
GNU General Public License “or any later version” applies to it, you have the option of following the terms and
|
||||
conditions either of that numbered version or of any later version published by the Free Software Foundation. If the
|
||||
Program does not specify a version number of the GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used,
|
||||
that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the
|
||||
Program.
|
||||
|
||||
Later license versions may give you additional or different permissions. However, no additional obligations are imposed
|
||||
on any author or copyright holder as a result of your choosing to follow a later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING
|
||||
THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR
|
||||
IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU
|
||||
ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO
|
||||
MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
|
||||
INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO
|
||||
LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
|
||||
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to
|
||||
their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil
|
||||
liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program
|
||||
in return for a fee.
|
||||
@@ -1,27 +1,24 @@
|
||||
== mcMMO
|
||||
**The RPG lovers mod**
|
||||
|
||||
=== Brief Description
|
||||
mcMMO takes core Minecraft game mechanics and expands them to add an extensive RPG experience, the goal of the project has always been a quality RPG experience. Everything in mcMMO is carefully thought out and is constantly improving. mcMMO adds eleven skills to train in and level in, while also offering a high level of customization for server admins. There are countless features, including custom sounds, graphical elements, and more added when running mcMMO in conjunction with Spout. I carefully read feedback and evaluate the mechanics of mcMMO in every update to provide an ever-evolving experience.
|
||||
|
||||
If you want an original RPG experience like no other mod out there, mcMMO is for you.
|
||||
|
||||
=== About the Developer
|
||||
I've always wanted to make games and in the last year I decided to take a swing at developing Minecraft mods as a platform to teach myself programming, the biggest project I have made to date is mcMMO. I went from knowing nothing about Java to what I know now purely from modding Minecraft, and I plan to move onto game development in the not so distant future.
|
||||
|
||||
I take design very seriously, I am not the kind of person who can be satisfied giving a project anything less than my all. As you will see reflected in the quality of the mods I make, I take great care in my work.
|
||||
|
||||
Hearing that people enjoy mcMMO and seeing the daily youtube videos about my mod has become a joy, I really can't believe how popular my mod has gotten!
|
||||
|
||||
=== Compiling
|
||||
|
||||
Required Libraries:
|
||||
* CraftBukkit
|
||||
* Spout API
|
||||
* Permissions
|
||||
* PermissionsEx
|
||||
|
||||
Required to Run:
|
||||
* Bukkit
|
||||
|
||||
== mcMMO
|
||||
**The RPG lovers mod**
|
||||
|
||||
=== Brief Description
|
||||
mcMMO takes core Minecraft game mechanics and expands them to add an extensive RPG experience, the goal of the project has always been a quality RPG experience. Everything in mcMMO is carefully thought out and is constantly improving. mcMMO adds eleven skills to train in and level in, while also offering a high level of customization for server admins. There are countless features, including custom sounds, graphical elements, and more added when running mcMMO in conjunction with Spout. I carefully read feedback and evaluate the mechanics of mcMMO in every update to provide an ever-evolving experience.
|
||||
|
||||
If you want an original RPG experience like no other mod out there, mcMMO is for you.
|
||||
|
||||
=== About the Developer
|
||||
I've always wanted to make games and in the last year I decided to take a swing at developing Minecraft mods as a platform to teach myself programming, the biggest project I have made to date is mcMMO. I went from knowing nothing about Java to what I know now purely from modding Minecraft, and I plan to move onto game development in the not so distant future.
|
||||
|
||||
I take design very seriously, I am not the kind of person who can be satisfied giving a project anything less than my all. As you will see reflected in the quality of the mods I make, I take great care in my work.
|
||||
|
||||
Hearing that people enjoy mcMMO and seeing the daily youtube videos about my mod has become a joy, I really can't believe how popular my mod has gotten!
|
||||
|
||||
=== Compiling
|
||||
|
||||
Required Libraries:
|
||||
* Spout API
|
||||
|
||||
Required to Run:
|
||||
* Bukkit
|
||||
|
||||
http://dev.bukkit.org/server-mods/mcmmo for more up to date information.
|
||||
90
pom.xml
90
pom.xml
@@ -2,12 +2,12 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>1.2.07</version>
|
||||
<version>1.3.03</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/TheYeti/mcMMO</url>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<issueManagement>
|
||||
<system>GitHub</system>
|
||||
<url>https://github.com/TheYeti/mcMMO/issues</url>
|
||||
<url>http://issues.mcmmo.org</url>
|
||||
<system>JIRA</system>
|
||||
</issueManagement>
|
||||
<build>
|
||||
<finalName>mcMMO</finalName>
|
||||
@@ -18,18 +18,49 @@
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/main/resources/</directory>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
<include>*.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>resources</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/main/resources/</directory>
|
||||
<filtering>false</filtering>
|
||||
<directory>${basedir}/src/main/resources/xpbar/</directory>
|
||||
<includes>
|
||||
<include>xpbar*.png</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>resources</targetPath>
|
||||
<filtering>false</filtering>
|
||||
<directory>${basedir}/src/main/resources/healthbar/</directory>
|
||||
<includes>
|
||||
<include>health*.png</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>resources</targetPath>
|
||||
<filtering>false</filtering>
|
||||
<directory>${basedir}/src/main/resources/skillicon/</directory>
|
||||
<includes>
|
||||
<include>*.png</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>resources</targetPath>
|
||||
<filtering>false</filtering>
|
||||
<directory>${basedir}/src/main/resources/sound/</directory>
|
||||
<includes>
|
||||
<include>*.wav</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>com/gmail/nossr50/locale</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/main/resources/locale/</directory>
|
||||
<includes>
|
||||
<include>locale*.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@@ -62,38 +93,37 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>fail</checksumPolicy>
|
||||
</snapshots>
|
||||
<id>bukkit-repo</id>
|
||||
<url>http://repo.bukkit.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>fail</checksumPolicy>
|
||||
</snapshots>
|
||||
<id>spout-repo</id>
|
||||
<url>http://nexus.spout.org/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.0.1-R2-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.0.1-R2-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nijikokun.bukkit</groupId>
|
||||
<artifactId>Permissions</artifactId>
|
||||
<version>3.2</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.tehkode</groupId>
|
||||
<artifactId>PermissionsEx</artifactId>
|
||||
<version>1.18</version>
|
||||
<version>LATEST</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.getspout</groupId>
|
||||
<artifactId>spoutplugin</artifactId>
|
||||
<artifactId>spoutpluginapi</artifactId>
|
||||
<version>dev-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
|
||||
119
src/main/java/com/gmail/nossr50/BlockChecks.java
Normal file
119
src/main/java/com/gmail/nossr50/BlockChecks.java
Normal file
@@ -0,0 +1,119 @@
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
|
||||
public class BlockChecks {
|
||||
|
||||
/**
|
||||
* Checks to see if a block type awards XP.
|
||||
*
|
||||
* @param material The type of Block to check
|
||||
* @return true if the block type awards XP, false otherwise
|
||||
*/
|
||||
public static boolean shouldBeWatched(Material material) {
|
||||
switch (material) {
|
||||
case BROWN_MUSHROOM:
|
||||
case CACTUS:
|
||||
case CLAY:
|
||||
case COAL_ORE:
|
||||
case DIAMOND_ORE:
|
||||
case DIRT:
|
||||
case ENDER_STONE:
|
||||
case GLOWING_REDSTONE_ORE:
|
||||
case GLOWSTONE:
|
||||
case GOLD_ORE:
|
||||
case GRASS:
|
||||
case GRAVEL:
|
||||
case IRON_ORE:
|
||||
case JACK_O_LANTERN:
|
||||
case LAPIS_ORE:
|
||||
case LOG:
|
||||
case MELON_BLOCK:
|
||||
case MOSSY_COBBLESTONE:
|
||||
case MYCEL:
|
||||
case NETHERRACK:
|
||||
case OBSIDIAN:
|
||||
case PUMPKIN:
|
||||
case RED_MUSHROOM:
|
||||
case RED_ROSE:
|
||||
case REDSTONE_ORE:
|
||||
case SAND:
|
||||
case SANDSTONE:
|
||||
case SOUL_SAND:
|
||||
case STONE:
|
||||
case SUGAR_CANE_BLOCK:
|
||||
case VINE:
|
||||
case WATER_LILY:
|
||||
case YELLOW_FLOWER:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a block should allow for the activation of abilities.
|
||||
*
|
||||
* @param material The type of Block to check
|
||||
* @return true if the block should allow ability activation, false otherwise
|
||||
*/
|
||||
public static boolean abilityBlockCheck(Material material) {
|
||||
switch (material) {
|
||||
case BED_BLOCK:
|
||||
case BREWING_STAND:
|
||||
case BOOKSHELF:
|
||||
case BURNING_FURNACE:
|
||||
case CAKE_BLOCK:
|
||||
case CHEST:
|
||||
case DISPENSER:
|
||||
case ENCHANTMENT_TABLE:
|
||||
case FENCE_GATE:
|
||||
case FURNACE:
|
||||
case IRON_DOOR_BLOCK:
|
||||
case JUKEBOX:
|
||||
case LEVER:
|
||||
case NOTE_BLOCK:
|
||||
case STONE_BUTTON:
|
||||
case TRAP_DOOR:
|
||||
case WALL_SIGN:
|
||||
case WOODEN_DOOR:
|
||||
case WORKBENCH:
|
||||
return false;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (Material.getMaterial(LoadProperties.anvilID).equals(material)) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a block type is an ore.
|
||||
*
|
||||
* @param material The type of Block to check
|
||||
* @return true if the Block is an ore, false otherwise
|
||||
*/
|
||||
public static boolean isOre(Material material) {
|
||||
switch (material) {
|
||||
case COAL_ORE:
|
||||
case DIAMOND_ORE:
|
||||
case GLOWING_REDSTONE_ORE:
|
||||
case GOLD_ORE:
|
||||
case IRON_ORE:
|
||||
case LAPIS_ORE:
|
||||
case REDSTONE_ORE:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +1,29 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.FakeEntityDamageByEntityEvent;
|
||||
import com.gmail.nossr50.events.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.runnables.GainXp;
|
||||
import com.gmail.nossr50.runnables.mcBleedTimer;
|
||||
import com.gmail.nossr50.skills.Acrobatics;
|
||||
import com.gmail.nossr50.skills.Archery;
|
||||
import com.gmail.nossr50.skills.Axes;
|
||||
@@ -36,385 +32,437 @@ import com.gmail.nossr50.skills.Swords;
|
||||
import com.gmail.nossr50.skills.Taming;
|
||||
import com.gmail.nossr50.skills.Unarmed;
|
||||
|
||||
public class Combat
|
||||
{
|
||||
public static void combatChecks(EntityDamageEvent event, mcMMO pluginx)
|
||||
{
|
||||
if(event.isCancelled() || event.getDamage() == 0)
|
||||
return;
|
||||
|
||||
if(event instanceof EntityDamageByEntityEvent)
|
||||
{
|
||||
/*
|
||||
* OFFENSIVE CHECKS FOR PLAYERS VERSUS ENTITIES
|
||||
*/
|
||||
if(((EntityDamageByEntityEvent) event).getDamager() instanceof Player)
|
||||
{
|
||||
//Declare Things
|
||||
EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent) event;
|
||||
Player attacker = (Player)((EntityDamageByEntityEvent) event).getDamager();
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
|
||||
//Damage modifiers
|
||||
if(mcPermissions.getInstance().unarmed(attacker) && attacker.getItemInHand().getTypeId() == 0) //Unarmed
|
||||
Unarmed.unarmedBonus(attacker, eventb);
|
||||
if(m.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker) && Users.getProfile(attacker).getSkillLevel(SkillType.AXES) >= 500)
|
||||
event.setDamage(event.getDamage()+4);
|
||||
|
||||
//If there are any abilities to activate
|
||||
combatAbilityChecks(attacker, PPa, pluginx);
|
||||
|
||||
//Check for offensive procs
|
||||
if(!(((EntityDamageByEntityEvent) event).getDamager() instanceof Arrow))
|
||||
{
|
||||
if(mcPermissions.getInstance().axes(attacker))
|
||||
Axes.axeCriticalCheck(attacker, eventb, pluginx); //Axe Criticals
|
||||
|
||||
if(!pluginx.misc.bleedTracker.contains((LivingEntity) event.getEntity())) //Swords Bleed
|
||||
Swords.bleedCheck(attacker, (LivingEntity)event.getEntity(), pluginx);
|
||||
|
||||
if(event.getEntity() instanceof Player && mcPermissions.getInstance().unarmed(attacker))
|
||||
{
|
||||
Player defender = (Player)event.getEntity();
|
||||
Unarmed.disarmProcCheck(attacker, defender);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Modify the event damage if Attacker is Berserk
|
||||
if(PPa.getBerserkMode())
|
||||
event.setDamage(event.getDamage() + (event.getDamage() / 2));
|
||||
|
||||
//Handle Ability Interactions
|
||||
if(PPa.getSkullSplitterMode() && m.isAxes(attacker.getItemInHand()))
|
||||
Axes.applyAoeDamage(attacker, eventb, pluginx);
|
||||
if(PPa.getSerratedStrikesMode() && m.isSwords(attacker.getItemInHand()))
|
||||
Swords.applySerratedStrikes(attacker, eventb, pluginx);
|
||||
|
||||
//Experience
|
||||
if(event.getEntity() instanceof Player)
|
||||
{
|
||||
Player defender = (Player)event.getEntity();
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
if(attacker != null && defender != null && LoadProperties.pvpxp)
|
||||
{
|
||||
if(System.currentTimeMillis() >= (PPd.getRespawnATS()*1000) + 5000
|
||||
&& ((PPd.getLastLogin()+5)*1000) < System.currentTimeMillis()
|
||||
&& defender.getHealth() >= 1)
|
||||
{
|
||||
//Prevent a ridiculous amount of XP being granted by capping it at the remaining health of the mob
|
||||
int hpLeft = defender.getHealth(), xpinc = 0;
|
||||
|
||||
if(hpLeft < event.getDamage())
|
||||
xpinc = event.getDamage();
|
||||
else
|
||||
xpinc = hpLeft;
|
||||
|
||||
int xp = (int) (xpinc * 2 * LoadProperties.pvpxprewardmodifier);
|
||||
|
||||
if(m.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker))
|
||||
PPa.addXP(SkillType.AXES, xp*10, attacker);
|
||||
if(m.isSwords(attacker.getItemInHand()) && mcPermissions.getInstance().swords(attacker))
|
||||
PPa.addXP(SkillType.SWORDS, xp*10, attacker);
|
||||
if(attacker.getItemInHand().getTypeId() == 0 && mcPermissions.getInstance().unarmed(attacker))
|
||||
PPa.addXP(SkillType.UNARMED, xp*10, attacker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!pluginx.misc.mobSpawnerList.contains(event.getEntity()))
|
||||
{
|
||||
int xp = getXp(event.getEntity(), event);
|
||||
public class Combat {
|
||||
|
||||
if(m.isSwords(attacker.getItemInHand()) && mcPermissions.getInstance().swords(attacker))
|
||||
PPa.addXP(SkillType.SWORDS, xp*10, attacker);
|
||||
else if(m.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker))
|
||||
PPa.addXP(SkillType.AXES, xp*10, attacker);
|
||||
else if(attacker.getItemInHand().getTypeId() == 0 && mcPermissions.getInstance().unarmed(attacker))
|
||||
PPa.addXP(SkillType.UNARMED, xp*10, attacker);
|
||||
}
|
||||
Skills.XpCheckAll(attacker);
|
||||
|
||||
if(event.getEntity() instanceof Wolf)
|
||||
{
|
||||
Wolf theWolf = (Wolf)event.getEntity();
|
||||
|
||||
if(attacker.getItemInHand().getTypeId() == 352 && mcPermissions.getInstance().taming(attacker))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
if(theWolf.isTamed())
|
||||
{
|
||||
attacker.sendMessage(mcLocale.getString("Combat.BeastLore")+" "+
|
||||
mcLocale.getString("Combat.BeastLoreOwner", new Object[] {Taming.getOwnerName(theWolf)})+" "+
|
||||
mcLocale.getString("Combat.BeastLoreHealthWolfTamed", new Object[] {theWolf.getHealth()}));
|
||||
}
|
||||
else
|
||||
{
|
||||
attacker.sendMessage(mcLocale.getString("Combat.BeastLore")+" "+
|
||||
mcLocale.getString("Combat.BeastLoreHealthWolf", new Object[] {theWolf.getHealth()}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* OFFENSIVE CHECKS FOR WOLVES VERSUS ENTITIES
|
||||
*/
|
||||
if(event instanceof EntityDamageByEntityEvent && ((EntityDamageByEntityEvent) event).getDamager() instanceof Wolf)
|
||||
{
|
||||
EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent) event;
|
||||
Wolf theWolf = (Wolf) eventb.getDamager();
|
||||
if(theWolf.isTamed() && Taming.ownerOnline(theWolf, pluginx))
|
||||
{
|
||||
if(Taming.getOwner(theWolf, pluginx) == null)
|
||||
return;
|
||||
Player master = Taming.getOwner(theWolf, pluginx);
|
||||
PlayerProfile PPo = Users.getProfile(master);
|
||||
|
||||
if(mcPermissions.getInstance().taming(master))
|
||||
{
|
||||
//Sharpened Claws
|
||||
if(PPo.getSkillLevel(SkillType.TAMING) >= 750)
|
||||
{
|
||||
event.setDamage(event.getDamage() + 2);
|
||||
}
|
||||
|
||||
//Gore
|
||||
if(Math.random() * 1000 <= PPo.getSkillLevel(SkillType.TAMING))
|
||||
{
|
||||
event.setDamage(event.getDamage() * 2);
|
||||
|
||||
if(event.getEntity() instanceof Player)
|
||||
{
|
||||
Player target = (Player)event.getEntity();
|
||||
target.sendMessage(mcLocale.getString("Combat.StruckByGore")); //$NON-NLS-1$
|
||||
Users.getProfile(target).setBleedTicks(2);
|
||||
}
|
||||
else
|
||||
pluginx.misc.addToBleedQue((LivingEntity) event.getEntity());
|
||||
|
||||
master.sendMessage(mcLocale.getString("Combat.Gore")); //$NON-NLS-1$
|
||||
}
|
||||
if(!event.getEntity().isDead() && !pluginx.misc.mobSpawnerList.contains(event.getEntity()))
|
||||
{
|
||||
int xp = getXp(event.getEntity(), event);
|
||||
Users.getProfile(master).addXP(SkillType.TAMING, xp*10, master);
|
||||
|
||||
if(event.getEntity() instanceof Player)
|
||||
{
|
||||
xp = (event.getDamage() * 2);
|
||||
Users.getProfile(master).addXP(SkillType.TAMING, (int)((xp*10)*1.5), master);
|
||||
}
|
||||
Skills.XpCheckSkill(SkillType.TAMING, master);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Another offensive check for Archery
|
||||
if(event instanceof EntityDamageByEntityEvent && event.getCause() == DamageCause.PROJECTILE && ((EntityDamageByEntityEvent) event).getDamager() instanceof Arrow)
|
||||
archeryCheck((EntityDamageByEntityEvent)event, pluginx);
|
||||
|
||||
/*
|
||||
* DEFENSIVE CHECKS
|
||||
*/
|
||||
if(event instanceof EntityDamageByEntityEvent && event.getEntity() instanceof Player)
|
||||
{
|
||||
Swords.counterAttackChecks((EntityDamageByEntityEvent)event);
|
||||
Acrobatics.dodgeChecks((EntityDamageByEntityEvent)event);
|
||||
}
|
||||
/*
|
||||
* DEFENSIVE CHECKS FOR WOLVES
|
||||
*/
|
||||
|
||||
if(event.getEntity() instanceof Wolf)
|
||||
{
|
||||
Wolf theWolf = (Wolf) event.getEntity();
|
||||
|
||||
if(theWolf.isTamed() && Taming.ownerOnline(theWolf, pluginx))
|
||||
{
|
||||
if(Taming.getOwner(theWolf, pluginx) == null)
|
||||
return;
|
||||
|
||||
Player master = Taming.getOwner(theWolf, pluginx);
|
||||
PlayerProfile PPo = Users.getProfile(master);
|
||||
if(mcPermissions.getInstance().taming(master))
|
||||
{
|
||||
//Shock-Proof
|
||||
if((event.getCause() == DamageCause.ENTITY_EXPLOSION || event.getCause() == DamageCause.BLOCK_EXPLOSION) && PPo.getSkillLevel(SkillType.TAMING) >= 500)
|
||||
{
|
||||
event.setDamage(2);
|
||||
}
|
||||
|
||||
//Thick Fur
|
||||
if(PPo.getSkillLevel(SkillType.TAMING) >= 250)
|
||||
event.setDamage(event.getDamage() / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void combatAbilityChecks(Player attacker, PlayerProfile PPa, Plugin pluginx)
|
||||
{
|
||||
//Check to see if any abilities need to be activated
|
||||
if(PPa.getAxePreparationMode())
|
||||
Axes.skullSplitterCheck(attacker);
|
||||
if(PPa.getSwordsPreparationMode())
|
||||
Swords.serratedStrikesActivationCheck(attacker);
|
||||
if(PPa.getFistsPreparationMode())
|
||||
Unarmed.berserkActivationCheck(attacker);
|
||||
}
|
||||
public static void archeryCheck(EntityDamageByEntityEvent event, mcMMO pluginx)
|
||||
{
|
||||
Arrow arrow = (Arrow)event.getDamager();
|
||||
Entity y = arrow.getShooter();
|
||||
Entity x = event.getEntity();
|
||||
if(x instanceof Player)
|
||||
{
|
||||
Player defender = (Player)x;
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
if(PPd == null)
|
||||
Users.addUser(defender);
|
||||
if(mcPermissions.getInstance().unarmed(defender) && defender.getItemInHand().getTypeId() == 0)
|
||||
{
|
||||
if(defender != null && PPd.getSkillLevel(SkillType.UNARMED) >= 1000)
|
||||
{
|
||||
if(Math.random() * 1000 <= 500)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
defender.sendMessage(mcLocale.getString("Combat.ArrowDeflect")); //$NON-NLS-1$
|
||||
return;
|
||||
}
|
||||
} else if(defender != null && Math.random() * 1000 <= (PPd.getSkillLevel(SkillType.UNARMED) / 2))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
defender.sendMessage(mcLocale.getString("Combat.ArrowDeflect")); //$NON-NLS-1$
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* If attacker is player
|
||||
*/
|
||||
if(y instanceof Player)
|
||||
{
|
||||
Player attacker = (Player)y;
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
if(mcPermissions.getInstance().archery(attacker))
|
||||
{
|
||||
Archery.trackArrows(pluginx, x, event, attacker);
|
||||
|
||||
/*
|
||||
* IGNITION
|
||||
*/
|
||||
Archery.ignitionCheck(x, event, attacker);
|
||||
/*
|
||||
* Defender is Monster
|
||||
*/
|
||||
if(!pluginx.misc.mobSpawnerList.contains(x))
|
||||
{
|
||||
int xp = getXp(event.getEntity(), event);
|
||||
PPa.addXP(SkillType.ARCHERY, xp*10, attacker);
|
||||
}
|
||||
/*
|
||||
* Attacker is Player
|
||||
*/
|
||||
if(x instanceof Player){
|
||||
Player defender = (Player)x;
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
/*
|
||||
* Stuff for the daze proc
|
||||
*/
|
||||
if(PPa.inParty() && PPd.inParty())
|
||||
{
|
||||
if(Party.getInstance().inSameParty(defender, attacker))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* PVP XP
|
||||
*/
|
||||
if(LoadProperties.pvpxp && !Party.getInstance().inSameParty(attacker, defender)
|
||||
&& ((PPd.getLastLogin()+5)*1000) < System.currentTimeMillis() && !attacker.getName().equals(defender.getName()))
|
||||
{
|
||||
int xp = (int) ((event.getDamage() * 2) * 10);
|
||||
PPa.addXP(SkillType.ARCHERY, xp, attacker);
|
||||
}
|
||||
/*
|
||||
* DAZE PROC
|
||||
*/
|
||||
Archery.dazeCheck(defender, attacker);
|
||||
}
|
||||
}
|
||||
Skills.XpCheckSkill(SkillType.ARCHERY, attacker);
|
||||
}
|
||||
/**
|
||||
* Apply combat modifiers and process and XP gain.
|
||||
*
|
||||
* @param event The event to run the combat checks on.
|
||||
* @param plugin mcMMO plugin instance
|
||||
*/
|
||||
public static void combatChecks(EntityDamageByEntityEvent event, mcMMO plugin) {
|
||||
if (event.getDamage() == 0 || event.getEntity().isDead()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity damager = event.getDamager();
|
||||
LivingEntity target = (LivingEntity) event.getEntity();
|
||||
EntityType damagerType = damager.getType();
|
||||
EntityType targetType = target.getType();
|
||||
|
||||
switch (damagerType) {
|
||||
case PLAYER:
|
||||
Player attacker = (Player) event.getDamager();
|
||||
ItemStack itemInHand = attacker.getItemInHand();
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
|
||||
combatAbilityChecks(attacker);
|
||||
|
||||
if (ItemChecks.isSword(itemInHand) && mcPermissions.getInstance().swords(attacker)) {
|
||||
if (!mcBleedTimer.contains(target) && mcPermissions.getInstance().swordsBleed(attacker)) {
|
||||
Swords.bleedCheck(attacker, target, plugin);
|
||||
}
|
||||
|
||||
if (PPa.getSerratedStrikesMode()) {
|
||||
applyAbilityAoE(attacker, target, event.getDamage(), plugin, SkillType.SWORDS);
|
||||
}
|
||||
|
||||
startGainXp(attacker, PPa, target, SkillType.SWORDS, plugin);
|
||||
}
|
||||
else if (ItemChecks.isAxe(itemInHand) && mcPermissions.getInstance().axes(attacker)) {
|
||||
if (mcPermissions.getInstance().axeBonus(attacker)) {
|
||||
Axes.axesBonus(attacker, event);
|
||||
}
|
||||
|
||||
if (mcPermissions.getInstance().criticalHit(attacker)) {
|
||||
Axes.axeCriticalCheck(attacker, event);
|
||||
}
|
||||
|
||||
if (mcPermissions.getInstance().impact(attacker)) {
|
||||
Axes.impact(attacker, target, event);
|
||||
}
|
||||
|
||||
if (PPa.getSkullSplitterMode()) {
|
||||
applyAbilityAoE(attacker, target, event.getDamage(), plugin, SkillType.AXES);
|
||||
}
|
||||
|
||||
startGainXp(attacker, PPa, target, SkillType.AXES, plugin);
|
||||
}
|
||||
else if (itemInHand.getType().equals(Material.AIR) && mcPermissions.getInstance().unarmed(attacker)) {
|
||||
if (mcPermissions.getInstance().unarmedBonus(attacker)) {
|
||||
Unarmed.unarmedBonus(PPa, event);
|
||||
}
|
||||
|
||||
if (PPa.getBerserkMode() && mcPermissions.getInstance().berserk(attacker)) {
|
||||
event.setDamage((int) (event.getDamage() * 1.5));
|
||||
}
|
||||
|
||||
if (targetType.equals(EntityType.PLAYER) && mcPermissions.getInstance().disarm(attacker)) {
|
||||
Unarmed.disarmProcCheck(PPa, (Player) target);
|
||||
}
|
||||
|
||||
startGainXp(attacker, PPa, target, SkillType.UNARMED, plugin);
|
||||
}
|
||||
else if (itemInHand.getType().equals(Material.BONE) && mcPermissions.getInstance().beastLore(attacker)) {
|
||||
Taming.beastLore(event, target, attacker);
|
||||
}
|
||||
break;
|
||||
|
||||
case WOLF:
|
||||
Wolf wolf = (Wolf) damager;
|
||||
|
||||
if (wolf.isTamed() && wolf.getOwner() instanceof Player) {
|
||||
Player master = (Player) wolf.getOwner();
|
||||
PlayerProfile PPo = Users.getProfile(master);
|
||||
|
||||
if (mcPermissions.getInstance().taming(master)) {
|
||||
if (mcPermissions.getInstance().fastFoodService(master)) {
|
||||
Taming.fastFoodService(PPo, wolf, event);
|
||||
}
|
||||
|
||||
if (mcPermissions.getInstance().sharpenedclaws(master)) {
|
||||
Taming.sharpenedClaws(PPo, event);
|
||||
}
|
||||
|
||||
if (mcPermissions.getInstance().gore(master)) {
|
||||
Taming.gore(PPo, event, master, plugin);
|
||||
}
|
||||
|
||||
startGainXp(master, PPo, target, SkillType.TAMING, plugin);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ARROW:
|
||||
archeryCheck((EntityDamageByEntityEvent) event, plugin);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (targetType.equals(EntityType.PLAYER)) {
|
||||
Swords.counterAttackChecks(event);
|
||||
Acrobatics.dodgeChecks(event);
|
||||
}
|
||||
}
|
||||
public static void dealDamage(Entity target, int dmg){
|
||||
if(target instanceof Player){
|
||||
((Player) target).damage(dmg);
|
||||
}
|
||||
if(target instanceof Animals){
|
||||
((Animals) target).damage(dmg);
|
||||
}
|
||||
if(target instanceof Monster){
|
||||
((Monster) target).damage(dmg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process combat abilities based on weapon preparation modes.
|
||||
*
|
||||
* @param attacker The player attacking
|
||||
*/
|
||||
public static void combatAbilityChecks(Player attacker) {
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
|
||||
if (PPa.getAxePreparationMode()) {
|
||||
Skills.abilityCheck(attacker, SkillType.AXES);
|
||||
}
|
||||
else if (PPa.getSwordsPreparationMode()) {
|
||||
Skills.abilityCheck(attacker, SkillType.SWORDS);
|
||||
}
|
||||
else if (PPa.getFistsPreparationMode()) {
|
||||
Skills.abilityCheck(attacker, SkillType.UNARMED);
|
||||
}
|
||||
}
|
||||
public static boolean pvpAllowed(EntityDamageByEntityEvent event, World world)
|
||||
{
|
||||
if(!event.getEntity().getWorld().getPVP())
|
||||
return false;
|
||||
//If it made it this far, pvp is enabled
|
||||
return true;
|
||||
|
||||
/**
|
||||
* Process archery abilities.
|
||||
*
|
||||
* @param event The event to run the archery checks on.
|
||||
* @param pluginx mcMMO plugin instance
|
||||
*/
|
||||
public static void archeryCheck(EntityDamageByEntityEvent event, mcMMO pluginx) {
|
||||
Arrow arrow = (Arrow) event.getDamager();
|
||||
LivingEntity shooter = arrow.getShooter();
|
||||
LivingEntity target = (LivingEntity) event.getEntity();
|
||||
|
||||
if (target instanceof Player) {
|
||||
Player defender = (Player) target;
|
||||
|
||||
if (mcPermissions.getInstance().unarmed(defender) && defender.getItemInHand().getType().equals(Material.AIR)) {
|
||||
Unarmed.deflectCheck(defender, event);
|
||||
}
|
||||
}
|
||||
|
||||
if (shooter instanceof Player) {
|
||||
Player attacker = (Player) shooter;
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
int damage = event.getDamage();
|
||||
|
||||
if (mcPermissions.getInstance().archery(attacker) && damage > 0) {
|
||||
if (mcPermissions.getInstance().trackArrows(attacker)) {
|
||||
Archery.trackArrows(pluginx, target, PPa);
|
||||
}
|
||||
|
||||
if (mcPermissions.getInstance().ignition(attacker)) {
|
||||
Archery.ignitionCheck(target, attacker);
|
||||
}
|
||||
|
||||
startGainXp(attacker, PPa, target, SkillType.ARCHERY, pluginx);
|
||||
|
||||
if (target instanceof Player) {
|
||||
Player defender = (Player) target;
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
|
||||
if (PPa.inParty() && PPd.inParty() && Party.getInstance().inSameParty(defender, attacker)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Archery.dazeCheck(defender, attacker);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static int getXp(Entity entity, EntityDamageEvent event)
|
||||
{
|
||||
int xp = 0;
|
||||
if(entity instanceof LivingEntity)
|
||||
{
|
||||
LivingEntity le = (LivingEntity)entity;
|
||||
//Prevent a ridiculous amount of XP being granted by capping it at the remaining health of the entity
|
||||
int hpLeft = le.getHealth(), xpinc = 0;
|
||||
|
||||
if(hpLeft < event.getDamage())
|
||||
xpinc = event.getDamage();
|
||||
else
|
||||
xpinc = hpLeft;
|
||||
|
||||
if(entity instanceof Animals)
|
||||
{
|
||||
xp = (int) (xpinc * 1);
|
||||
} else
|
||||
{
|
||||
if(entity instanceof Enderman)
|
||||
xp = (xpinc * 2);
|
||||
else if(entity instanceof Creeper)
|
||||
xp = (xpinc * 4);
|
||||
else if(entity instanceof Silverfish)
|
||||
xp = (xpinc * 3);
|
||||
else if(entity instanceof CaveSpider)
|
||||
xp = (xpinc * 3);
|
||||
else if(entity instanceof Spider)
|
||||
xp = (xpinc * 3);
|
||||
else if(entity instanceof Skeleton)
|
||||
xp = (xpinc * 2);
|
||||
else if(entity instanceof Zombie)
|
||||
xp = (xpinc * 2);
|
||||
else if(entity instanceof PigZombie)
|
||||
xp = (xpinc * 3);
|
||||
else if(entity instanceof Slime)
|
||||
xp = (xpinc * 2);
|
||||
else if(entity instanceof Ghast)
|
||||
xp = (xpinc * 3);
|
||||
else if(entity instanceof Blaze)
|
||||
xp = (xpinc * 3);
|
||||
else if(entity instanceof EnderDragon)
|
||||
xp = (xpinc * 8);
|
||||
}
|
||||
}
|
||||
return xp;
|
||||
|
||||
/**
|
||||
* Attempt to damage target for value dmg with reason CUSTOM
|
||||
*
|
||||
* @param target LivingEntity which to attempt to damage
|
||||
* @param dmg Amount of damage to attempt to do
|
||||
*/
|
||||
public static void dealDamage(LivingEntity target, int dmg) {
|
||||
dealDamage(target, dmg, EntityDamageEvent.DamageCause.CUSTOM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to damage target for value dmg with reason cause
|
||||
*
|
||||
* @param target LivingEntity which to attempt to damage
|
||||
* @param dmg Amount of damage to attempt to do
|
||||
* @param cause DamageCause to pass to damage event
|
||||
*/
|
||||
private static void dealDamage(LivingEntity target, int dmg, DamageCause cause) {
|
||||
if (LoadProperties.eventCallback) {
|
||||
EntityDamageEvent ede = (EntityDamageEvent) new FakeEntityDamageEvent(target, cause, dmg);
|
||||
Bukkit.getPluginManager().callEvent(ede);
|
||||
|
||||
if (ede.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
target.damage(ede.getDamage());
|
||||
}
|
||||
else {
|
||||
target.damage(dmg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
|
||||
*
|
||||
* @param target LivingEntity which to attempt to damage
|
||||
* @param dmg Amount of damage to attempt to do
|
||||
* @param attacker Player to pass to event as damager
|
||||
*/
|
||||
private static void dealDamage(LivingEntity target, int dmg, Player attacker) {
|
||||
if (LoadProperties.eventCallback) {
|
||||
EntityDamageEvent ede = (EntityDamageByEntityEvent) new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg);
|
||||
Bukkit.getPluginManager().callEvent(ede);
|
||||
|
||||
if (ede.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
target.damage(ede.getDamage());
|
||||
}
|
||||
else {
|
||||
target.damage(dmg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply Area-of-Effect ability actions.
|
||||
*
|
||||
* @param attacker The attacking player
|
||||
* @param target The defending entity
|
||||
* @param damage The initial damage amount
|
||||
* @param plugin mcMMO plugin instance
|
||||
* @param type The type of skill being used
|
||||
*/
|
||||
private static void applyAbilityAoE(Player attacker, LivingEntity target, int damage, mcMMO plugin, SkillType type) {
|
||||
int numberOfTargets = m.getTier(attacker.getItemInHand()); //The higher the weapon tier, the more targets you hit
|
||||
int damageAmount = 0;
|
||||
|
||||
if (type.equals(SkillType.AXES)) {
|
||||
damageAmount = damage / 2;
|
||||
}
|
||||
else if (type.equals(SkillType.SWORDS)) {
|
||||
damageAmount = damage / 4;
|
||||
}
|
||||
|
||||
if (damageAmount < 1) {
|
||||
damageAmount = 1;
|
||||
}
|
||||
|
||||
for (Entity entity : target.getNearbyEntities(2.5, 2.5, 2.5)) {
|
||||
EntityType entityType = entity.getType();
|
||||
|
||||
if (entityType.equals(EntityType.WOLF)) {
|
||||
Wolf wolf = (Wolf) entity;
|
||||
AnimalTamer tamer = wolf.getOwner();
|
||||
|
||||
if (tamer instanceof Player) {
|
||||
Player owner = (Player) tamer;
|
||||
|
||||
if (owner.equals(attacker) || Party.getInstance().inSameParty(attacker, owner)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entity instanceof LivingEntity && numberOfTargets >= 1) {
|
||||
if (entityType.equals(EntityType.PLAYER)) {
|
||||
Player defender = (Player) entity;
|
||||
PlayerProfile PP = Users.getProfile(defender);
|
||||
|
||||
//Reasons why the target shouldn't be hit
|
||||
if (PP.getGodMode()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (defender.getName().equals(attacker.getName())) { //Is this even possible?
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Party.getInstance().inSameParty(attacker, defender)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (defender.isDead()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//Apply effect to players only if PVP is enabled
|
||||
if (target.getWorld().getPVP()) {
|
||||
String message = "";
|
||||
|
||||
if (type.equals(SkillType.AXES)) {
|
||||
message = mcLocale.getString("Axes.HitByCleave");
|
||||
}
|
||||
else if (type.equals(SkillType.SWORDS)) {
|
||||
message = mcLocale.getString("Swords.HitBySerratedStrikes");
|
||||
}
|
||||
|
||||
dealDamage(defender, damageAmount, attacker);
|
||||
defender.sendMessage(message);
|
||||
|
||||
if (type.equals(SkillType.SWORDS)) {
|
||||
PP.addBleedTicks(5);
|
||||
}
|
||||
|
||||
numberOfTargets--;
|
||||
}
|
||||
}
|
||||
else {
|
||||
LivingEntity livingEntity = (LivingEntity) entity;
|
||||
|
||||
if (type.equals(SkillType.SWORDS)) {
|
||||
mcBleedTimer.add(livingEntity);
|
||||
}
|
||||
|
||||
dealDamage(livingEntity, damageAmount, attacker);
|
||||
numberOfTargets--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the task that gives combat XP.
|
||||
*
|
||||
* @param attacker The attacking player
|
||||
* @param PP The player's PlayerProfile
|
||||
* @param target The defending entity
|
||||
* @param skillType The skill being used
|
||||
* @param plugin mcMMO plugin instance
|
||||
*/
|
||||
public static void startGainXp(Player attacker, PlayerProfile PP, LivingEntity target, SkillType skillType, mcMMO pluginx) {
|
||||
double baseXP = 0;
|
||||
|
||||
if (target instanceof Player) {
|
||||
if (!LoadProperties.pvpxp) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player defender = (Player) target;
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
|
||||
if (System.currentTimeMillis() >= (PPd.getRespawnATS() * 1000) + 5000 && ((PPd.getLastLogin() + 5) * 1000) < System.currentTimeMillis() && defender.getHealth() >= 1) {
|
||||
baseXP = 20 * LoadProperties.pvpxprewardmodifier;
|
||||
}
|
||||
}
|
||||
else if (!target.hasMetadata("mcmmoFromMobSpawner")) {
|
||||
if (target instanceof Animals && !target.hasMetadata("mcmmoSummoned")) {
|
||||
baseXP = LoadProperties.animalXP;
|
||||
}
|
||||
else {
|
||||
EntityType type = target.getType();
|
||||
|
||||
switch (type) {
|
||||
case BLAZE:
|
||||
baseXP = LoadProperties.blazeXP;
|
||||
break;
|
||||
|
||||
case CAVE_SPIDER:
|
||||
baseXP = LoadProperties.cavespiderXP;
|
||||
break;
|
||||
|
||||
case CREEPER:
|
||||
baseXP = LoadProperties.creeperXP;
|
||||
break;
|
||||
|
||||
case ENDER_DRAGON:
|
||||
baseXP = LoadProperties.enderdragonXP;
|
||||
break;
|
||||
|
||||
case ENDERMAN:
|
||||
baseXP = LoadProperties.endermanXP;
|
||||
break;
|
||||
|
||||
case GHAST:
|
||||
baseXP = LoadProperties.ghastXP;
|
||||
break;
|
||||
|
||||
case MAGMA_CUBE:
|
||||
baseXP = LoadProperties.magmacubeXP;
|
||||
break;
|
||||
|
||||
case PIG_ZOMBIE:
|
||||
baseXP = LoadProperties.pigzombieXP;
|
||||
break;
|
||||
|
||||
case SILVERFISH:
|
||||
baseXP = LoadProperties.silverfishXP;
|
||||
break;
|
||||
|
||||
case SKELETON:
|
||||
baseXP = LoadProperties.skeletonXP;
|
||||
break;
|
||||
|
||||
case SLIME:
|
||||
baseXP = LoadProperties.slimeXP;
|
||||
break;
|
||||
|
||||
case SPIDER:
|
||||
baseXP = LoadProperties.spiderXP;
|
||||
break;
|
||||
|
||||
case ZOMBIE:
|
||||
baseXP = LoadProperties.zombieXP;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
baseXP *= 10;
|
||||
}
|
||||
|
||||
if (baseXP != 0) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(pluginx, new GainXp(attacker, PP, skillType, baseXP, target), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,211 +1,302 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.DatabaseUpdate;
|
||||
|
||||
public class Database {
|
||||
|
||||
private mcMMO plugin;
|
||||
private String connectionString;
|
||||
private String connectionString = "jdbc:mysql://" + LoadProperties.MySQLserverName + ":" + LoadProperties.MySQLport + "/" + LoadProperties.MySQLdbName + "?user=" + LoadProperties.MySQLuserName + "&password=" + LoadProperties.MySQLdbPass;
|
||||
private Connection conn = null;
|
||||
private mcMMO plugin = null;
|
||||
private long reconnectTimestamp = 0;
|
||||
|
||||
public Database(mcMMO instance) {
|
||||
this.plugin = instance;
|
||||
this.connectionString = "jdbc:mysql://" + LoadProperties.MySQLserverName + ":" + LoadProperties.MySQLport + "/" + LoadProperties.MySQLdbName + "?user=" + LoadProperties.MySQLuserName + "&password=" + LoadProperties.MySQLdbPass;
|
||||
// Load the driver instance
|
||||
try {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
DriverManager.getConnection(connectionString);
|
||||
} catch (ClassNotFoundException e) {
|
||||
plugin.getServer().getLogger().warning(e.getLocalizedMessage());
|
||||
} catch (SQLException e) {
|
||||
plugin.getServer().getLogger().warning(e.getLocalizedMessage());
|
||||
System.out.println("SQLException: " + e.getMessage());
|
||||
System.out.println("SQLState: " + e.getSQLState());
|
||||
System.out.println("VendorError: " + e.getErrorCode());
|
||||
}
|
||||
}
|
||||
//Create the DB structure
|
||||
public void createStructure() {
|
||||
Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "huds` (`user_id` int(10) unsigned NOT NULL,"
|
||||
+ "`hudtype` varchar(50) NOT NULL DEFAULT '',"
|
||||
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "users` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
|
||||
+ "`user` varchar(40) NOT NULL,"
|
||||
+ "`lastlogin` int(32) unsigned NOT NULL,"
|
||||
+ "`party` varchar(100) NOT NULL DEFAULT '',"
|
||||
+ "PRIMARY KEY (`id`),"
|
||||
+ "UNIQUE KEY `user` (`user`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
|
||||
Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "cooldowns` (`user_id` int(10) unsigned NOT NULL,"
|
||||
+ "`taming` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`mining` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`woodcutting` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`repair` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`unarmed` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`herbalism` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`excavation` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`archery` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`swords` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`axes` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`acrobatics` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "skills` (`user_id` int(10) unsigned NOT NULL,"
|
||||
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`mining` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`woodcutting` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`repair` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`unarmed` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`herbalism` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`excavation` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`archery` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`swords` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "experience` (`user_id` int(10) unsigned NOT NULL,"
|
||||
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`mining` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`woodcutting` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`repair` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`unarmed` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`herbalism` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`excavation` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`archery` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`swords` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "spawn` (`user_id` int(10) NOT NULL,"
|
||||
+ "`x` int(64) NOT NULL DEFAULT '0',"
|
||||
+ "`y` int(64) NOT NULL DEFAULT '0',"
|
||||
+ "`z` int(64) NOT NULL DEFAULT '0',"
|
||||
+ "`world` varchar(50) NOT NULL DEFAULT '',"
|
||||
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
|
||||
Write("DROP TABLE IF EXISTS `"+LoadProperties.MySQLtablePrefix+"skills2`");
|
||||
Write("DROP TABLE IF EXISTS `"+LoadProperties.MySQLtablePrefix+"experience2`");
|
||||
|
||||
checkDatabaseStructure();
|
||||
}
|
||||
public Database(mcMMO instance) {
|
||||
plugin = instance;
|
||||
connect(); //Connect to MySQL
|
||||
|
||||
public void checkDatabaseStructure()
|
||||
{
|
||||
String sql = "SELECT * FROM `mcmmo_experience` ORDER BY `"+LoadProperties.MySQLtablePrefix+"experience`.`fishing` ASC LIMIT 0 , 30";
|
||||
|
||||
ResultSet rs = null;
|
||||
HashMap<Integer, ArrayList<String>> Rows = new HashMap<Integer, ArrayList<String>>();
|
||||
try {
|
||||
Connection conn = DriverManager.getConnection(connectionString);
|
||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||
if (stmt.executeQuery() != null) {
|
||||
stmt.executeQuery();
|
||||
rs = stmt.getResultSet();
|
||||
while (rs.next()) {
|
||||
ArrayList<String> Col = new ArrayList<String>();
|
||||
for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
|
||||
Col.add(rs.getString(i));
|
||||
}
|
||||
Rows.put(rs.getRow(), Col);
|
||||
}
|
||||
}
|
||||
conn.close();
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("Updating mcMMO MySQL tables...");
|
||||
Write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "skills` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
|
||||
Write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "experience` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
|
||||
}
|
||||
}
|
||||
|
||||
// write query
|
||||
public boolean Write(String sql) {
|
||||
try {
|
||||
Connection conn = DriverManager.getConnection(connectionString);
|
||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||
stmt.executeUpdate();
|
||||
conn.close();
|
||||
return true;
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("SQLException: " + ex.getMessage());
|
||||
System.out.println("SQLState: " + ex.getSQLState());
|
||||
System.out.println("VendorError: " + ex.getErrorCode());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Load the driver instance
|
||||
try {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
DriverManager.getConnection(connectionString);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
Bukkit.getLogger().warning(e.getLocalizedMessage());
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
Bukkit.getLogger().warning(ex.getLocalizedMessage());
|
||||
printErrors(ex);
|
||||
}
|
||||
}
|
||||
|
||||
// Get Int
|
||||
// only return first row / first field
|
||||
public Integer GetInt(String sql) {
|
||||
ResultSet rs = null;
|
||||
Integer result = 0;
|
||||
try {
|
||||
Connection conn = DriverManager.getConnection(connectionString);
|
||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||
stmt = conn.prepareStatement(sql);
|
||||
if (stmt.executeQuery() != null) {
|
||||
stmt.executeQuery();
|
||||
rs = stmt.getResultSet();
|
||||
if (rs.next()) {
|
||||
result = rs.getInt(1);
|
||||
} else {
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
conn.close();
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("SQLException: " + ex.getMessage());
|
||||
System.out.println("SQLState: " + ex.getSQLState());
|
||||
System.out.println("VendorError: " + ex.getErrorCode());
|
||||
}
|
||||
/**
|
||||
* Attempt to connect to the mySQL database.
|
||||
*/
|
||||
public void connect() {
|
||||
try {
|
||||
System.out.println("[mcMMO] Attempting connection to MySQL...");
|
||||
Properties conProperties = new Properties();
|
||||
conProperties.put("autoReconnect", "false");
|
||||
conProperties.put("maxReconnects", "0");
|
||||
conn = DriverManager.getConnection(connectionString, conProperties);
|
||||
System.out.println("[mcMMO] Connection to MySQL was a success!");
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
System.out.println("[mcMMO] Connection to MySQL failed!");
|
||||
ex.printStackTrace();
|
||||
printErrors(ex);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Attempt to create the database structure.
|
||||
*/
|
||||
public void createStructure() {
|
||||
write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "huds` (`user_id` int(10) unsigned NOT NULL,"
|
||||
+ "`hudtype` varchar(50) NOT NULL DEFAULT '',"
|
||||
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "users` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
|
||||
+ "`user` varchar(40) NOT NULL,"
|
||||
+ "`lastlogin` int(32) unsigned NOT NULL,"
|
||||
+ "`party` varchar(100) NOT NULL DEFAULT '',"
|
||||
+ "PRIMARY KEY (`id`),"
|
||||
+ "UNIQUE KEY `user` (`user`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
|
||||
write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "cooldowns` (`user_id` int(10) unsigned NOT NULL,"
|
||||
+ "`taming` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`mining` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`woodcutting` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`repair` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`unarmed` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`herbalism` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`excavation` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`archery` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`swords` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`axes` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`acrobatics` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`blast_mining` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "skills` (`user_id` int(10) unsigned NOT NULL,"
|
||||
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`mining` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`woodcutting` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`repair` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`unarmed` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`herbalism` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`excavation` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`archery` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`swords` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "experience` (`user_id` int(10) unsigned NOT NULL,"
|
||||
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`mining` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`woodcutting` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`repair` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`unarmed` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`herbalism` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`excavation` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`archery` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`swords` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
|
||||
// read query
|
||||
public HashMap<Integer, ArrayList<String>> Read(String sql) {
|
||||
ResultSet rs = null;
|
||||
HashMap<Integer, ArrayList<String>> Rows = new HashMap<Integer, ArrayList<String>>();
|
||||
try {
|
||||
Connection conn = DriverManager.getConnection(connectionString);
|
||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||
if (stmt.executeQuery() != null) {
|
||||
stmt.executeQuery();
|
||||
rs = stmt.getResultSet();
|
||||
while (rs.next()) {
|
||||
ArrayList<String> Col = new ArrayList<String>();
|
||||
for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
|
||||
Col.add(rs.getString(i));
|
||||
}
|
||||
Rows.put(rs.getRow(), Col);
|
||||
}
|
||||
}
|
||||
conn.close();
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("SQLException: " + ex.getMessage());
|
||||
System.out.println("SQLState: " + ex.getSQLState());
|
||||
System.out.println("VendorError: " + ex.getErrorCode());
|
||||
}
|
||||
return Rows;
|
||||
}
|
||||
}
|
||||
checkDatabaseStructure(DatabaseUpdate.FISHING);
|
||||
checkDatabaseStructure(DatabaseUpdate.BLAST_MINING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check database structure for missing values.
|
||||
*
|
||||
* @param update Type of data to check updates for
|
||||
*/
|
||||
public void checkDatabaseStructure(DatabaseUpdate update) {
|
||||
String sql = null;
|
||||
ResultSet rs = null;
|
||||
HashMap<Integer, ArrayList<String>> Rows = new HashMap<Integer, ArrayList<String>>();
|
||||
|
||||
switch (update) {
|
||||
case BLAST_MINING:
|
||||
sql = "SELECT * FROM `"+LoadProperties.MySQLtablePrefix+"cooldowns` ORDER BY `"+LoadProperties.MySQLtablePrefix+"cooldowns`.`blast_mining` ASC LIMIT 0 , 30";
|
||||
break;
|
||||
case FISHING:
|
||||
sql = "SELECT * FROM `"+LoadProperties.MySQLtablePrefix+"experience` ORDER BY `"+LoadProperties.MySQLtablePrefix+"experience`.`fishing` ASC LIMIT 0 , 30";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||
if (stmt.executeQuery() != null) {
|
||||
stmt.executeQuery();
|
||||
rs = stmt.getResultSet();
|
||||
while (rs.next()) {
|
||||
ArrayList<String> Col = new ArrayList<String>();
|
||||
for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
|
||||
Col.add(rs.getString(i));
|
||||
}
|
||||
Rows.put(rs.getRow(), Col);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
if (update.equals(DatabaseUpdate.BLAST_MINING)) {
|
||||
System.out.println("Updating mcMMO MySQL tables for Blast Mining...");
|
||||
write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "cooldowns` ADD `blast_mining` int(32) NOT NULL DEFAULT '0' ;");
|
||||
}
|
||||
else if (update.equals(DatabaseUpdate.FISHING)) {
|
||||
System.out.println("Updating mcMMO MySQL tables for Fishing...");
|
||||
write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "skills` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
|
||||
write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "experience` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to write the SQL query.
|
||||
*
|
||||
* @param sql Query to write.
|
||||
* @return true if the query was successfully written, false otherwise.
|
||||
*/
|
||||
public boolean write(String sql) {
|
||||
if (isConnected()) {
|
||||
try {
|
||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||
stmt.executeUpdate();
|
||||
return true;
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
attemptReconnect();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Integer. Only return first row / first field.
|
||||
*
|
||||
* @param sql SQL query to execute
|
||||
* @return the value in the first row / first field
|
||||
*/
|
||||
public Integer getInt(String sql) {
|
||||
ResultSet rs = null;
|
||||
Integer result = 0;
|
||||
|
||||
if (isConnected()) {
|
||||
try {
|
||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||
stmt = conn.prepareStatement(sql);
|
||||
if (stmt.executeQuery() != null) {
|
||||
stmt.executeQuery();
|
||||
rs = stmt.getResultSet();
|
||||
if (rs.next()) {
|
||||
result = rs.getInt(1);
|
||||
}
|
||||
else {
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
}
|
||||
}
|
||||
else {
|
||||
attemptReconnect();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get connection status
|
||||
*
|
||||
* @return the boolean value for whether or not we are connected
|
||||
*/
|
||||
public boolean isConnected() {
|
||||
if(conn == null)
|
||||
return false;
|
||||
|
||||
try {
|
||||
return conn.isValid(3);
|
||||
} catch (SQLException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules a Sync Delayed Task with the Bukkit Scheduler to attempt reconnection after a minute has elapsed
|
||||
* This will check for a connection being present or not to prevent unneeded reconnection attempts
|
||||
*/
|
||||
public void attemptReconnect() {
|
||||
if(reconnectTimestamp+60000 < System.currentTimeMillis()) //Only reconnect if another attempt hasn't been made recently
|
||||
{
|
||||
System.out.println("[mcMMO] Connection to MySQL was lost! Attempting to reconnect in 60 seconds...");
|
||||
reconnectTimestamp = System.currentTimeMillis();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
if (!isConnected()) {
|
||||
connect();
|
||||
}
|
||||
}
|
||||
}, 20*60);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read SQL query.
|
||||
*
|
||||
* @param sql SQL query to read
|
||||
* @return the rows in this SQL query
|
||||
*/
|
||||
public HashMap<Integer, ArrayList<String>> read(String sql) {
|
||||
ResultSet rs = null;
|
||||
HashMap<Integer, ArrayList<String>> Rows = new HashMap<Integer, ArrayList<String>>();
|
||||
|
||||
if (isConnected()) {
|
||||
try {
|
||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||
if (stmt.executeQuery() != null) {
|
||||
stmt.executeQuery();
|
||||
rs = stmt.getResultSet();
|
||||
while (rs.next()) {
|
||||
ArrayList<String> Col = new ArrayList<String>();
|
||||
for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
|
||||
Col.add(rs.getString(i));
|
||||
}
|
||||
Rows.put(rs.getRow(), Col);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
}
|
||||
}
|
||||
else {
|
||||
attemptReconnect();
|
||||
}
|
||||
return Rows;
|
||||
}
|
||||
|
||||
private static void printErrors(SQLException ex) {
|
||||
System.out.println("SQLException: " + ex.getMessage());
|
||||
System.out.println("SQLState: " + ex.getSQLState());
|
||||
System.out.println("VendorError: " + ex.getErrorCode());
|
||||
}
|
||||
}
|
||||
@@ -1,104 +1,64 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import com.gmail.nossr50.config.*;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.skills.*;
|
||||
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
|
||||
public class Item {
|
||||
|
||||
public static void itemchecks(Player player, Plugin plugin)
|
||||
{
|
||||
ItemStack inhand = player.getItemInHand();
|
||||
if(LoadProperties.chimaeraWingEnable && inhand.getTypeId() == LoadProperties.chimaeraId)
|
||||
{
|
||||
chimaerawing(player, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void chimaerawing(Player player, Plugin plugin)
|
||||
{
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
ItemStack is = player.getItemInHand();
|
||||
Block block = player.getLocation().getBlock();
|
||||
if(mcPermissions.getInstance().chimaeraWing(player) && is.getTypeId() == LoadProperties.chimaeraId)
|
||||
{
|
||||
if(Skills.cooldownOver(player, PP.getRecentlyHurt(), 60) && is.getAmount() >= LoadProperties.feathersConsumedByChimaeraWing)
|
||||
{
|
||||
Block derp = player.getLocation().getBlock();
|
||||
int y = derp.getY();
|
||||
ItemStack[] inventory = player.getInventory().getContents();
|
||||
for(ItemStack x : inventory){
|
||||
if(x != null && x.getTypeId() == LoadProperties.chimaeraId){
|
||||
if(x.getAmount() >= LoadProperties.feathersConsumedByChimaeraWing + 1)
|
||||
{
|
||||
x.setAmount(x.getAmount() - LoadProperties.feathersConsumedByChimaeraWing);
|
||||
player.getInventory().setContents(inventory);
|
||||
player.updateInventory();
|
||||
break;
|
||||
} else {
|
||||
x.setAmount(0);
|
||||
x.setTypeId(0);
|
||||
player.getInventory().setContents(inventory);
|
||||
player.updateInventory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while(y < 127)
|
||||
{
|
||||
y++;
|
||||
if(player != null)
|
||||
{
|
||||
if(player.getLocation().getWorld().getBlockAt(block.getX(), y, block.getZ()).getType() != Material.AIR)
|
||||
{
|
||||
player.sendMessage(mcLocale.getString("Item.ChimaeraWingFail")); //$NON-NLS-1$
|
||||
player.teleport(player.getLocation().getWorld().getBlockAt(block.getX(), (y - 1), block.getZ()).getLocation());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(PP.getMySpawn(player) != null)
|
||||
{
|
||||
Location mySpawn = PP.getMySpawn(player);
|
||||
if(mySpawn != null){
|
||||
player.teleport(mySpawn); //Do it twice to prevent weird stuff
|
||||
player.teleport(mySpawn);
|
||||
}
|
||||
} else {
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
}
|
||||
player.sendMessage(mcLocale.getString("Item.ChimaeraWingPass")); //$NON-NLS-1$
|
||||
} else if (!Skills.cooldownOver(player, PP.getRecentlyHurt(), 60) && is.getAmount() >= 10)
|
||||
{
|
||||
player.sendMessage(mcLocale.getString("Item.InjuredWait", new Object[] {Skills.calculateTimeLeft(player, PP.getRecentlyHurt(), 60)})); //$NON-NLS-1$
|
||||
} else if (is.getTypeId() == LoadProperties.chimaeraId && is.getAmount() <= 9){
|
||||
player.sendMessage(mcLocale.getString("Item.NeedFeathers")); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for item usage.
|
||||
*
|
||||
* @param player Player whose item usage to check
|
||||
*/
|
||||
public static void itemchecks(Player player) {
|
||||
ItemStack inhand = player.getItemInHand();
|
||||
|
||||
if (LoadProperties.chimaeraWingEnable && inhand.getTypeId() == LoadProperties.chimaeraId) {
|
||||
chimaerawing(player);
|
||||
}
|
||||
}
|
||||
|
||||
private static void chimaerawing(Player player) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
ItemStack is = player.getItemInHand();
|
||||
Block block = player.getLocation().getBlock();
|
||||
int amount = is.getAmount();
|
||||
|
||||
if (mcPermissions.getInstance().chimaeraWing(player) && is.getTypeId() == LoadProperties.chimaeraId) {
|
||||
if (Skills.cooldownOver(PP.getRecentlyHurt(), 60) && amount >= LoadProperties.feathersConsumedByChimaeraWing) {
|
||||
player.setItemInHand(new ItemStack(LoadProperties.chimaeraId, amount - LoadProperties.feathersConsumedByChimaeraWing));
|
||||
|
||||
for (int y = 0; block.getY() + y < player.getWorld().getMaxHeight(); y++) {
|
||||
if (!block.getRelative(0, y, 0).getType().equals(Material.AIR)) {
|
||||
player.sendMessage(mcLocale.getString("Item.ChimaeraWingFail"));
|
||||
player.teleport(block.getRelative(0, y - 1, 0).getLocation());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (player.getBedSpawnLocation() != null && player.getBedSpawnLocation().getBlock().getType().equals(Material.BED_BLOCK)) {
|
||||
player.teleport(player.getBedSpawnLocation());
|
||||
}
|
||||
else {
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
}
|
||||
|
||||
player.sendMessage(mcLocale.getString("Item.ChimaeraWingPass"));
|
||||
}
|
||||
else if (!Skills.cooldownOver(PP.getRecentlyHurt(), 60) && is.getAmount() >= LoadProperties.feathersConsumedByChimaeraWing) {
|
||||
player.sendMessage(mcLocale.getString("Item.InjuredWait", new Object[] {Skills.calculateTimeLeft(PP.getRecentlyHurt(), 60)}));
|
||||
}
|
||||
else if (is.getAmount() <= LoadProperties.feathersConsumedByChimaeraWing) {
|
||||
player.sendMessage(mcLocale.getString("Skills.NeedMore")+ " " + ChatColor.GRAY + m.prettyItemString(LoadProperties.chimaeraId));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
380
src/main/java/com/gmail/nossr50/ItemChecks.java
Normal file
380
src/main/java/com/gmail/nossr50/ItemChecks.java
Normal file
@@ -0,0 +1,380 @@
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ItemChecks {
|
||||
|
||||
/**
|
||||
* Checks if the item is a sword.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a sword, false otherwise
|
||||
*/
|
||||
public static boolean isSword(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case DIAMOND_SWORD:
|
||||
case GOLD_SWORD:
|
||||
case IRON_SWORD:
|
||||
case STONE_SWORD:
|
||||
case WOOD_SWORD:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the item is a hoe.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a hoe, false otherwise
|
||||
*/
|
||||
public static boolean isHoe(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case DIAMOND_HOE:
|
||||
case GOLD_HOE:
|
||||
case IRON_HOE:
|
||||
case STONE_HOE:
|
||||
case WOOD_HOE:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the item is a shovel.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a shovel, false otherwise
|
||||
*/
|
||||
public static boolean isShovel(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case DIAMOND_SPADE:
|
||||
case GOLD_SPADE:
|
||||
case IRON_SPADE:
|
||||
case STONE_SPADE:
|
||||
case WOOD_SPADE:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the item is an axe.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is an axe, false otherwise
|
||||
*/
|
||||
public static boolean isAxe(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case DIAMOND_AXE:
|
||||
case GOLD_AXE:
|
||||
case IRON_AXE:
|
||||
case STONE_AXE:
|
||||
case WOOD_AXE:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the item is a pickaxe.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a pickaxe, false otherwise
|
||||
*/
|
||||
public static boolean isMiningPick(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case DIAMOND_PICKAXE:
|
||||
case GOLD_PICKAXE:
|
||||
case IRON_PICKAXE:
|
||||
case STONE_PICKAXE:
|
||||
case WOOD_PICKAXE:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the item is a helmet.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a helmet, false otherwise
|
||||
*/
|
||||
public static boolean isHelmet(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case DIAMOND_HELMET:
|
||||
case GOLD_HELMET:
|
||||
case IRON_HELMET:
|
||||
case LEATHER_HELMET:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the item is a chestplate.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a chestplate, false otherwise
|
||||
*/
|
||||
public static boolean isChestplate(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case DIAMOND_CHESTPLATE:
|
||||
case GOLD_CHESTPLATE:
|
||||
case IRON_CHESTPLATE:
|
||||
case LEATHER_CHESTPLATE:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the item is a pair of pants.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a pair of pants, false otherwise
|
||||
*/
|
||||
public static boolean isPants(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case DIAMOND_LEGGINGS:
|
||||
case GOLD_LEGGINGS:
|
||||
case IRON_LEGGINGS:
|
||||
case LEATHER_LEGGINGS:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the item is a pair of boots.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a pair of boots, false otherwise
|
||||
*/
|
||||
public static boolean isBoots(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case DIAMOND_BOOTS:
|
||||
case GOLD_BOOTS:
|
||||
case IRON_BOOTS:
|
||||
case LEATHER_BOOTS:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a wearable armor piece.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is armor, false otherwise
|
||||
*/
|
||||
public static boolean isArmor(ItemStack is) {
|
||||
return isLeatherArmor(is) || isGoldArmor(is) || isIronArmor(is) || isDiamondArmor(is);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a leather armor piece.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is leather armor, false otherwise
|
||||
*/
|
||||
public static boolean isLeatherArmor(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case LEATHER_BOOTS:
|
||||
case LEATHER_CHESTPLATE:
|
||||
case LEATHER_HELMET:
|
||||
case LEATHER_LEGGINGS:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a gold armor piece.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is gold armor, false otherwise
|
||||
*/
|
||||
public static boolean isGoldArmor(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case GOLD_BOOTS:
|
||||
case GOLD_CHESTPLATE:
|
||||
case GOLD_HELMET:
|
||||
case GOLD_LEGGINGS:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is an iron armor piece.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is iron armor, false otherwise
|
||||
*/
|
||||
public static boolean isIronArmor(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case IRON_BOOTS:
|
||||
case IRON_CHESTPLATE:
|
||||
case IRON_HELMET:
|
||||
case IRON_LEGGINGS:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a diamond armor piece.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is diamond armor, false otherwise
|
||||
*/
|
||||
public static boolean isDiamondArmor(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case DIAMOND_BOOTS:
|
||||
case DIAMOND_CHESTPLATE:
|
||||
case DIAMOND_HELMET:
|
||||
case DIAMOND_LEGGINGS:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a tool.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a tool, false otherwise
|
||||
*/
|
||||
public static boolean isTool(ItemStack is) {
|
||||
return isStoneTool(is) || isWoodTool(is) || isGoldTool(is) || isIronTool(is) || isDiamondTool(is) || is.getType().equals(Material.BOW);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a stone tool.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a stone tool, false otherwise
|
||||
*/
|
||||
public static boolean isStoneTool(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case STONE_AXE:
|
||||
case STONE_HOE:
|
||||
case STONE_PICKAXE:
|
||||
case STONE_SPADE:
|
||||
case STONE_SWORD:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a wooden tool.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a wooden tool, false otherwise
|
||||
*/
|
||||
public static boolean isWoodTool(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case WOOD_AXE:
|
||||
case WOOD_HOE:
|
||||
case WOOD_PICKAXE:
|
||||
case WOOD_SPADE:
|
||||
case WOOD_SWORD:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a gold tool.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a stone tool, false otherwise
|
||||
*/
|
||||
public static boolean isGoldTool(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case GOLD_AXE:
|
||||
case GOLD_HOE:
|
||||
case GOLD_PICKAXE:
|
||||
case GOLD_SPADE:
|
||||
case GOLD_SWORD:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is an iron tool.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is an iron tool, false otherwise
|
||||
*/
|
||||
public static boolean isIronTool(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case IRON_AXE:
|
||||
case IRON_HOE:
|
||||
case IRON_PICKAXE:
|
||||
case IRON_SPADE:
|
||||
case IRON_SWORD:
|
||||
case SHEARS:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a diamond tool.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a diamond tool, false otherwise
|
||||
*/
|
||||
public static boolean isDiamondTool(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case DIAMOND_AXE:
|
||||
case DIAMOND_HOE:
|
||||
case DIAMOND_PICKAXE:
|
||||
case DIAMOND_SPADE:
|
||||
case DIAMOND_SWORD:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -22,258 +6,286 @@ import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.Tree;
|
||||
|
||||
public class Leaderboard
|
||||
{
|
||||
static String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users"; //$NON-NLS-1$
|
||||
protected static final Logger log = Logger.getLogger("Minecraft"); //$NON-NLS-1$
|
||||
|
||||
/*
|
||||
* Read from the file
|
||||
*/
|
||||
public static void makeLeaderboards()
|
||||
{
|
||||
//Make Trees
|
||||
Tree Mining = new Tree();
|
||||
Tree WoodCutting = new Tree();
|
||||
Tree Herbalism = new Tree();
|
||||
Tree Excavation = new Tree();
|
||||
Tree Acrobatics = new Tree();
|
||||
Tree Repair = new Tree();
|
||||
Tree Swords = new Tree();
|
||||
Tree Axes = new Tree();
|
||||
Tree Archery = new Tree();
|
||||
Tree Unarmed = new Tree();
|
||||
Tree Taming = new Tree();
|
||||
Tree Fishing = new Tree();
|
||||
Tree Enchanting = new Tree();
|
||||
Tree Alchemy = new Tree();
|
||||
Tree PowerLevel = new Tree();
|
||||
|
||||
//Add Data To Trees
|
||||
try {
|
||||
//Open the user file
|
||||
FileReader file = new FileReader(location);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
String line = ""; //$NON-NLS-1$
|
||||
ArrayList<String> players = new ArrayList<String>();
|
||||
while((line = in.readLine()) != null)
|
||||
{
|
||||
String[] character = line.split(":"); //$NON-NLS-1$
|
||||
String p = character[0];
|
||||
|
||||
//Prevent the same player from being added multiple times
|
||||
if(players.contains(p))
|
||||
continue;
|
||||
else
|
||||
players.add(p);
|
||||
public class Leaderboard {
|
||||
static String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
|
||||
|
||||
int Plvl = 0;
|
||||
|
||||
if(character.length > 1 && m.isInt(character[1]))
|
||||
{
|
||||
Mining.add(p, Integer.valueOf(character[1]));
|
||||
Plvl += Integer.valueOf(character[1]);
|
||||
}
|
||||
if(character.length > 5 && m.isInt(character[5])){
|
||||
WoodCutting.add(p, Integer.valueOf(character[5]));
|
||||
Plvl += Integer.valueOf(character[5]);
|
||||
}
|
||||
if(character.length > 7 && m.isInt(character[7])){
|
||||
Repair.add(p, Integer.valueOf(character[7]));
|
||||
Plvl += Integer.valueOf(character[7]);
|
||||
}
|
||||
if(character.length > 8 && m.isInt(character[8])){
|
||||
Unarmed.add(p, Integer.valueOf(character[8]));
|
||||
Plvl += Integer.valueOf(character[8]);
|
||||
}
|
||||
if(character.length > 9 && m.isInt(character[9])){
|
||||
Herbalism.add(p, Integer.valueOf(character[9]));
|
||||
Plvl += Integer.valueOf(character[9]);
|
||||
}
|
||||
if(character.length > 10 && m.isInt(character[10])){
|
||||
Excavation.add(p, Integer.valueOf(character[10]));
|
||||
Plvl += Integer.valueOf(character[10]);
|
||||
}
|
||||
if(character.length > 11 && m.isInt(character[11])){
|
||||
Archery.add(p, Integer.valueOf(character[11]));
|
||||
Plvl += Integer.valueOf(character[11]);
|
||||
}
|
||||
if(character.length > 12 && m.isInt(character[12])){
|
||||
Swords.add(p, Integer.valueOf(character[12]));
|
||||
Plvl += Integer.valueOf(character[12]);
|
||||
}
|
||||
if(character.length > 13 && m.isInt(character[13])){
|
||||
Axes.add(p, Integer.valueOf(character[13]));
|
||||
Plvl += Integer.valueOf(character[13]);
|
||||
}
|
||||
if(character.length > 14 && m.isInt(character[14])){
|
||||
Acrobatics.add(p, Integer.valueOf(character[14]));
|
||||
Plvl += Integer.valueOf(character[14]);
|
||||
}
|
||||
if(character.length > 24 && m.isInt(character[24])){
|
||||
Taming.add(p, Integer.valueOf(character[24]));
|
||||
Plvl += Integer.valueOf(character[24]);
|
||||
}
|
||||
if(character.length > 34 && m.isInt(character[34]))
|
||||
{
|
||||
Fishing.add(p, Integer.valueOf(character[34]));
|
||||
Plvl += Integer.valueOf(character[34]);
|
||||
}
|
||||
|
||||
PowerLevel.add(p, Plvl);
|
||||
}
|
||||
in.close();
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Exception while reading " //$NON-NLS-1$
|
||||
+ location + " (Are you sure you formatted it correctly?)", e); //$NON-NLS-1$
|
||||
/**
|
||||
* Create the leaderboards.
|
||||
*/
|
||||
public static void makeLeaderboards() {
|
||||
//Make Trees
|
||||
Tree Mining = new Tree();
|
||||
Tree WoodCutting = new Tree();
|
||||
Tree Herbalism = new Tree();
|
||||
Tree Excavation = new Tree();
|
||||
Tree Acrobatics = new Tree();
|
||||
Tree Repair = new Tree();
|
||||
Tree Swords = new Tree();
|
||||
Tree Axes = new Tree();
|
||||
Tree Archery = new Tree();
|
||||
Tree Unarmed = new Tree();
|
||||
Tree Taming = new Tree();
|
||||
Tree Fishing = new Tree();
|
||||
Tree PowerLevel = new Tree();
|
||||
|
||||
//Add Data To Trees
|
||||
try {
|
||||
FileReader file = new FileReader(location);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
String line = "";
|
||||
ArrayList<String> players = new ArrayList<String>();
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
String[] character = line.split(":");
|
||||
String p = character[0];
|
||||
int powerLevel = 0;
|
||||
|
||||
//Prevent the same player from being added multiple times
|
||||
if (players.contains(p)) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
players.add(p);
|
||||
}
|
||||
|
||||
if (character.length > 1 && m.isInt(character[1])) {
|
||||
Mining.add(p, Integer.valueOf(character[1]));
|
||||
powerLevel += Integer.valueOf(character[1]);
|
||||
}
|
||||
|
||||
if (character.length > 5 && m.isInt(character[5])) {
|
||||
WoodCutting.add(p, Integer.valueOf(character[5]));
|
||||
powerLevel += Integer.valueOf(character[5]);
|
||||
}
|
||||
|
||||
if (character.length > 7 && m.isInt(character[7])) {
|
||||
Repair.add(p, Integer.valueOf(character[7]));
|
||||
powerLevel += Integer.valueOf(character[7]);
|
||||
}
|
||||
|
||||
if (character.length > 8 && m.isInt(character[8])) {
|
||||
Unarmed.add(p, Integer.valueOf(character[8]));
|
||||
powerLevel += Integer.valueOf(character[8]);
|
||||
}
|
||||
|
||||
if (character.length > 9 && m.isInt(character[9])) {
|
||||
Herbalism.add(p, Integer.valueOf(character[9]));
|
||||
powerLevel += Integer.valueOf(character[9]);
|
||||
}
|
||||
|
||||
if (character.length > 10 && m.isInt(character[10])) {
|
||||
Excavation.add(p, Integer.valueOf(character[10]));
|
||||
powerLevel += Integer.valueOf(character[10]);
|
||||
}
|
||||
|
||||
if (character.length > 11 && m.isInt(character[11])) {
|
||||
Archery.add(p, Integer.valueOf(character[11]));
|
||||
powerLevel += Integer.valueOf(character[11]);
|
||||
}
|
||||
|
||||
if (character.length > 12 && m.isInt(character[12])) {
|
||||
Swords.add(p, Integer.valueOf(character[12]));
|
||||
powerLevel += Integer.valueOf(character[12]);
|
||||
}
|
||||
|
||||
if (character.length > 13 && m.isInt(character[13])) {
|
||||
Axes.add(p, Integer.valueOf(character[13]));
|
||||
powerLevel += Integer.valueOf(character[13]);
|
||||
}
|
||||
|
||||
if (character.length > 14 && m.isInt(character[14])) {
|
||||
Acrobatics.add(p, Integer.valueOf(character[14]));
|
||||
powerLevel += Integer.valueOf(character[14]);
|
||||
}
|
||||
|
||||
if (character.length > 24 && m.isInt(character[24])) {
|
||||
Taming.add(p, Integer.valueOf(character[24]));
|
||||
powerLevel += Integer.valueOf(character[24]);
|
||||
}
|
||||
|
||||
if (character.length > 34 && m.isInt(character[34])) {
|
||||
Fishing.add(p, Integer.valueOf(character[34]));
|
||||
powerLevel += Integer.valueOf(character[34]);
|
||||
}
|
||||
|
||||
PowerLevel.add(p, powerLevel);
|
||||
}
|
||||
in.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Bukkit.getLogger().severe(("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString()));
|
||||
}
|
||||
|
||||
//Write the leader board files
|
||||
leaderWrite(Mining.inOrder(), SkillType.MINING); //$NON-NLS-1$
|
||||
leaderWrite(WoodCutting.inOrder(), SkillType.WOODCUTTING); //$NON-NLS-1$
|
||||
leaderWrite(Repair.inOrder(), SkillType.REPAIR); //$NON-NLS-1$
|
||||
leaderWrite(Unarmed.inOrder(), SkillType.UNARMED); //$NON-NLS-1$
|
||||
leaderWrite(Herbalism.inOrder(), SkillType.HERBALISM); //$NON-NLS-1$
|
||||
leaderWrite(Excavation.inOrder(), SkillType.EXCAVATION); //$NON-NLS-1$
|
||||
leaderWrite(Archery.inOrder(), SkillType.ARCHERY); //$NON-NLS-1$
|
||||
leaderWrite(Swords.inOrder(), SkillType.SWORDS); //$NON-NLS-1$
|
||||
leaderWrite(Axes.inOrder(), SkillType.AXES); //$NON-NLS-1$
|
||||
leaderWrite(Acrobatics.inOrder(), SkillType.ACROBATICS); //$NON-NLS-1$
|
||||
leaderWrite(Taming.inOrder(), SkillType.TAMING); //$NON-NLS-1$
|
||||
leaderWrite(Fishing.inOrder(), SkillType.FISHING); //$NON-NLS-1$
|
||||
leaderWrite(Alchemy.inOrder(), SkillType.ALCHEMY); //$NON-NLS-1$
|
||||
leaderWrite(Enchanting.inOrder(), SkillType.ENCHANTING); //$NON-NLS-1$
|
||||
leaderWrite(PowerLevel.inOrder(), SkillType.ALL); //$NON-NLS-1$
|
||||
}
|
||||
public static void leaderWrite(PlayerStat[] ps, SkillType skillType)
|
||||
{
|
||||
String theLocation = "plugins/mcMMO/FlatFileStuff/Leaderboards/" + skillType + ".mcmmo"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
//CHECK IF THE FILE EXISTS
|
||||
File theDir = new File(theLocation);
|
||||
if(!theDir.exists())
|
||||
{
|
||||
//properties = new PropertiesFile(location);
|
||||
FileWriter writer = null;
|
||||
try {
|
||||
writer = new FileWriter(theLocation);
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Exception while creating " + theLocation, e); //$NON-NLS-1$
|
||||
} finally {
|
||||
try {
|
||||
if (writer != null) {
|
||||
writer.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.log(Level.SEVERE, "Exception while closing writer for " + theLocation, e); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
FileReader file = new FileReader(theLocation);
|
||||
|
||||
//HERP
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
StringBuilder writer = new StringBuilder();
|
||||
|
||||
for(PlayerStat p : ps)
|
||||
{
|
||||
if(p.name.equals("$mcMMO_DummyInfo")) //$NON-NLS-1$
|
||||
continue;
|
||||
if(p.statVal == 0)
|
||||
continue;
|
||||
writer.append(p.name + ":" + p.statVal); //$NON-NLS-1$
|
||||
writer.append("\r\n"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
in.close();
|
||||
//Write the new file
|
||||
FileWriter out = new FileWriter(theLocation);
|
||||
out.write(writer.toString());
|
||||
out.close();
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Exception while writing to " + theLocation + " (Are you sure you formatted it correctly?)", e); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
//Create/open the file
|
||||
//Loop through backward writing each player
|
||||
//Close the file
|
||||
}
|
||||
|
||||
public static String[] retrieveInfo(String skillName, int pagenumber)
|
||||
{
|
||||
String theLocation = "plugins/mcMMO/FlatFileStuff/Leaderboards/" + skillName + ".mcmmo"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
try {
|
||||
FileReader file = new FileReader(theLocation);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
|
||||
int destination = (pagenumber - 1) * 10; //How many lines to skip through
|
||||
int x = 0; //how many lines we've gone through
|
||||
int y = 0; //going through the lines
|
||||
String line = ""; //$NON-NLS-1$
|
||||
String[] info = new String[10]; //what to return
|
||||
while((line = in.readLine()) != null && y < 10)
|
||||
{
|
||||
x++;
|
||||
if(x >= destination && y < 10){
|
||||
info[y] = line.toString();
|
||||
y++;
|
||||
}
|
||||
}
|
||||
in.close();
|
||||
return info;
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Exception while reading " //$NON-NLS-1$
|
||||
+ theLocation + " (Are you sure you formatted it correctly?)", e); //$NON-NLS-1$
|
||||
leaderWrite(Mining.inOrder(), SkillType.MINING);
|
||||
leaderWrite(WoodCutting.inOrder(), SkillType.WOODCUTTING);
|
||||
leaderWrite(Repair.inOrder(), SkillType.REPAIR);
|
||||
leaderWrite(Unarmed.inOrder(), SkillType.UNARMED);
|
||||
leaderWrite(Herbalism.inOrder(), SkillType.HERBALISM);
|
||||
leaderWrite(Excavation.inOrder(), SkillType.EXCAVATION);
|
||||
leaderWrite(Archery.inOrder(), SkillType.ARCHERY);
|
||||
leaderWrite(Swords.inOrder(), SkillType.SWORDS);
|
||||
leaderWrite(Axes.inOrder(), SkillType.AXES);
|
||||
leaderWrite(Acrobatics.inOrder(), SkillType.ACROBATICS);
|
||||
leaderWrite(Taming.inOrder(), SkillType.TAMING);
|
||||
leaderWrite(Fishing.inOrder(), SkillType.FISHING);
|
||||
leaderWrite(PowerLevel.inOrder(), SkillType.ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write to the leaderboards.
|
||||
*
|
||||
* @param ps Stats to write to the leaderboard
|
||||
* @param skillType Skill type to write the leaderboard of
|
||||
*/
|
||||
private static void leaderWrite(PlayerStat[] ps, SkillType skillType) {
|
||||
String theLocation = "plugins/mcMMO/FlatFileStuff/Leaderboards/" + skillType + ".mcmmo";
|
||||
File theDir = new File(theLocation);
|
||||
|
||||
//CHECK IF THE FILE EXISTS
|
||||
if (!theDir.exists()) {
|
||||
FileWriter writer = null;
|
||||
|
||||
try {
|
||||
writer = new FileWriter(theLocation);
|
||||
}
|
||||
catch (Exception e) {
|
||||
Bukkit.getLogger().severe(("Exception while creating " + theLocation + e.toString()));
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if (writer != null) {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
Bukkit.getLogger().severe("Exception while closing writer for " + theLocation + e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
FileReader file = new FileReader(theLocation);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
StringBuilder writer = new StringBuilder();
|
||||
|
||||
for (PlayerStat p : ps) {
|
||||
if (p.name.equals("$mcMMO_DummyInfo")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (p.statVal == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
writer.append(p.name + ":" + p.statVal);
|
||||
writer.append("\r\n");
|
||||
}
|
||||
|
||||
in.close();
|
||||
FileWriter out = new FileWriter(theLocation);
|
||||
out.write(writer.toString());
|
||||
out.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Bukkit.getLogger().severe("Exception while writing to " + theLocation + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve leaderboard info.
|
||||
*
|
||||
* @param skillName Skill to retrieve info on.
|
||||
* @param pagenumber Which page in the leaderboards to retrieve
|
||||
* @return the requested leaderboard information
|
||||
*/
|
||||
public static String[] retrieveInfo(String skillName, int pagenumber) {
|
||||
String theLocation = "plugins/mcMMO/FlatFileStuff/Leaderboards/" + skillName + ".mcmmo"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
try {
|
||||
FileReader file = new FileReader(theLocation);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
int destination = (pagenumber - 1) * 10; //How many lines to skip through
|
||||
int x = 0; //how many lines we've gone through
|
||||
int y = 0; //going through the lines
|
||||
String line = "";
|
||||
String[] info = new String[10]; //what to return
|
||||
|
||||
while ((line = in.readLine()) != null && y < 10) {
|
||||
x++;
|
||||
|
||||
if (x >= destination && y < 10) {
|
||||
info[y] = line.toString();
|
||||
y++;
|
||||
}
|
||||
}
|
||||
|
||||
in.close();
|
||||
return info;
|
||||
}
|
||||
catch (Exception e) {
|
||||
Bukkit.getLogger().severe("Exception while reading " + theLocation + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
|
||||
return null; //Shouldn't get here
|
||||
}
|
||||
public static void updateLeaderboard(PlayerStat ps, SkillType skillType)
|
||||
{
|
||||
if(LoadProperties.useMySQL)
|
||||
return;
|
||||
String theLocation = "plugins/mcMMO/FlatFileStuff/Leaderboards/" + skillType + ".mcmmo"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
try {
|
||||
//Open the file
|
||||
FileReader file = new FileReader(theLocation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the leaderboards.
|
||||
*
|
||||
* @param ps Stats to update the leaderboard with.
|
||||
* @param skillType Skill whose leaderboard is being updated.
|
||||
*/
|
||||
public static void updateLeaderboard(PlayerStat ps, SkillType skillType) {
|
||||
if (LoadProperties.useMySQL) {
|
||||
return;
|
||||
}
|
||||
|
||||
String theLocation = "plugins/mcMMO/FlatFileStuff/Leaderboards/" + skillType + ".mcmmo";
|
||||
|
||||
try {
|
||||
FileReader file = new FileReader(theLocation);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
StringBuilder writer = new StringBuilder();
|
||||
String line = ""; //$NON-NLS-1$
|
||||
Boolean inserted = false;
|
||||
//While not at the end of the file
|
||||
while((line = in.readLine()) != null)
|
||||
{
|
||||
//Insert the player into the line before it finds a smaller one
|
||||
if(Integer.valueOf(line.split(":")[1]) < ps.statVal && !inserted) //$NON-NLS-1$
|
||||
{
|
||||
writer.append(ps.name + ":" + ps.statVal).append("\r\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
inserted = true;
|
||||
}
|
||||
//Write anything that isn't the player already in the file so we remove the duplicate
|
||||
if(!line.split(":")[0].equalsIgnoreCase(ps.name)) //$NON-NLS-1$
|
||||
{
|
||||
writer.append(line).append("\r\n"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
if(!inserted)
|
||||
{
|
||||
writer.append(ps.name + ":" + ps.statVal).append("\r\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
in.close();
|
||||
//Write the new file
|
||||
String line = "";
|
||||
Boolean inserted = false;
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
|
||||
//Insert the player into the line before it finds a smaller one
|
||||
if (Integer.valueOf(line.split(":")[1]) < ps.statVal && !inserted) {
|
||||
writer.append(ps.name + ":" + ps.statVal).append("\r\n");
|
||||
inserted = true;
|
||||
}
|
||||
|
||||
//Write anything that isn't the player already in the file so we remove the duplicate
|
||||
if (!line.split(":")[0].equalsIgnoreCase(ps.name)) {
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
if(!inserted) {
|
||||
writer.append(ps.name + ":" + ps.statVal).append("\r\n");
|
||||
}
|
||||
|
||||
in.close();
|
||||
|
||||
//Write the new file
|
||||
FileWriter out = new FileWriter(theLocation);
|
||||
out.write(writer.toString());
|
||||
out.close();
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Exception while writing to " + theLocation + " (Are you sure you formatted it correctly?)", e); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
Bukkit.getLogger().severe("Exception while writing to " + theLocation + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
541
src/main/java/com/gmail/nossr50/Metrics.java
Normal file
541
src/main/java/com/gmail/nossr50/Metrics.java
Normal file
@@ -0,0 +1,541 @@
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Metrics {
|
||||
|
||||
/**
|
||||
* The current revision number
|
||||
*/
|
||||
private final static int REVISION = 5;
|
||||
|
||||
/**
|
||||
* The base url of the metrics domain
|
||||
*/
|
||||
private static final String BASE_URL = "http://metrics.griefcraft.com";
|
||||
|
||||
/**
|
||||
* The url used to report a server's status
|
||||
*/
|
||||
private static final String REPORT_URL = "/report/%s";
|
||||
|
||||
/**
|
||||
* The file where guid and opt out is stored in
|
||||
*/
|
||||
private static final String CONFIG_FILE = "plugins/PluginMetrics/config.yml";
|
||||
|
||||
/**
|
||||
* The separator to use for custom data. This MUST NOT change unless you are hosting your own
|
||||
* version of metrics and want to change it.
|
||||
*/
|
||||
private static final String CUSTOM_DATA_SEPARATOR = "~~";
|
||||
|
||||
/**
|
||||
* Interval of time to ping (in minutes)
|
||||
*/
|
||||
private final static int PING_INTERVAL = 10;
|
||||
|
||||
/**
|
||||
* A map of all of the graphs for each plugin
|
||||
*/
|
||||
private Map<Plugin, Set<Graph>> graphs = Collections.synchronizedMap(new HashMap<Plugin, Set<Graph>>());
|
||||
|
||||
/**
|
||||
* A convenient map of the default Graph objects (used by addCustomData mainly)
|
||||
*/
|
||||
private Map<Plugin, Graph> defaultGraphs = Collections.synchronizedMap(new HashMap<Plugin, Graph>());
|
||||
|
||||
/**
|
||||
* The plugin configuration file
|
||||
*/
|
||||
private final YamlConfiguration configuration;
|
||||
|
||||
/**
|
||||
* Unique server id
|
||||
*/
|
||||
private String guid;
|
||||
|
||||
public Metrics() throws IOException {
|
||||
// load the config
|
||||
File file = new File(CONFIG_FILE);
|
||||
configuration = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
// add some defaults
|
||||
configuration.addDefault("opt-out", false);
|
||||
configuration.addDefault("guid", UUID.randomUUID().toString());
|
||||
|
||||
// Do we need to create the file?
|
||||
if (configuration.get("guid", null) == null) {
|
||||
configuration.options().header("http://metrics.griefcraft.com").copyDefaults(true);
|
||||
configuration.save(file);
|
||||
}
|
||||
|
||||
// Load the guid then
|
||||
guid = configuration.getString("guid");
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct and create a Graph that can be used to separate specific plotters to their own graphs
|
||||
* on the metrics website. Plotters can be added to the graph object returned.
|
||||
*
|
||||
* @param plugin
|
||||
* @param type
|
||||
* @param name
|
||||
* @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given
|
||||
*/
|
||||
public Graph createGraph(Plugin plugin, Graph.Type type, String name) {
|
||||
if (plugin == null || type == null || name == null) {
|
||||
throw new IllegalArgumentException("All arguments must not be null");
|
||||
}
|
||||
|
||||
// Construct the graph object
|
||||
Graph graph = new Graph(type, name);
|
||||
|
||||
// Get the graphs for the plugin
|
||||
Set<Graph> graphs = getOrCreateGraphs(plugin);
|
||||
|
||||
// Now we can add our graph
|
||||
graphs.add(graph);
|
||||
|
||||
// and return back
|
||||
return graph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a custom data plotter for a given plugin
|
||||
*
|
||||
* @param plugin
|
||||
* @param plotter
|
||||
*/
|
||||
public void addCustomData(Plugin plugin, Plotter plotter) {
|
||||
// The default graph for the plugin
|
||||
Graph graph = getOrCreateDefaultGraph(plugin);
|
||||
|
||||
// Add the plotter to the graph o/
|
||||
graph.addPlotter(plotter);
|
||||
|
||||
// Ensure the default graph is included in the submitted graphs
|
||||
getOrCreateGraphs(plugin).add(graph);
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin measuring a plugin
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
public void beginMeasuringPlugin(final Plugin plugin) {
|
||||
// Did we opt out?
|
||||
if (configuration.getBoolean("opt-out", false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Begin hitting the server with glorious data
|
||||
plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable() {
|
||||
private boolean firstPost = true;
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
// We use the inverse of firstPost because if it is the first time we are posting,
|
||||
// it is not a interval ping, so it evaluates to FALSE
|
||||
// Each time thereafter it will evaluate to TRUE, i.e PING!
|
||||
postPlugin(plugin, !firstPost);
|
||||
|
||||
// After the first post we set firstPost to false
|
||||
// Each post thereafter will be a ping
|
||||
firstPost = false;
|
||||
} catch (IOException e) {
|
||||
System.out.println("[Metrics] " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}, 0, PING_INTERVAL * 1200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method that posts a plugin to the metrics website
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
private void postPlugin(Plugin plugin, boolean isPing) throws IOException {
|
||||
// The plugin's description file containg all of the plugin data such as name, version, author, etc
|
||||
PluginDescriptionFile description = plugin.getDescription();
|
||||
|
||||
// The author string, created with description.getAuthors()
|
||||
// Authors are separated by a comma
|
||||
String authors = "";
|
||||
|
||||
// Add each author to the string
|
||||
for (String author : description.getAuthors()) {
|
||||
authors += author + ", ";
|
||||
}
|
||||
|
||||
// If there were any authors at all, we need to remove the last 2 characters
|
||||
// the last 2 characters are the last comma and space
|
||||
if (!authors.isEmpty()) {
|
||||
authors = authors.substring(0, authors.length() - 2);
|
||||
}
|
||||
|
||||
// Construct the post data
|
||||
String data = encode("guid") + '=' + encode(guid)
|
||||
+ encodeDataPair("authors", authors)
|
||||
+ encodeDataPair("version", description.getVersion())
|
||||
+ encodeDataPair("server", Bukkit.getVersion())
|
||||
+ encodeDataPair("players", Integer.toString(Bukkit.getServer().getOnlinePlayers().length))
|
||||
+ encodeDataPair("revision", String.valueOf(REVISION));
|
||||
|
||||
// If we're pinging, append it
|
||||
if (isPing) {
|
||||
data += encodeDataPair("ping", "true");
|
||||
}
|
||||
|
||||
// Add any custom data available for the plugin
|
||||
Set<Graph> graphs = getOrCreateGraphs(plugin);
|
||||
|
||||
// Acquire a lock on the graphs, which lets us make the assumption we also lock everything
|
||||
// inside of the graph (e.g plotters)
|
||||
synchronized(graphs) {
|
||||
Iterator<Graph> iter = graphs.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
Graph graph = iter.next();
|
||||
|
||||
// Because we have a lock on the graphs set already, it is reasonable to assume
|
||||
// that our lock transcends down to the individual plotters in the graphs also.
|
||||
// Because our methods are private, no one but us can reasonably access this list
|
||||
// without reflection so this is a safe assumption without adding more code.
|
||||
for (Plotter plotter : graph.getPlotters()) {
|
||||
// The key name to send to the metrics server
|
||||
// The format is C-GRAPHNAME-PLOTTERNAME where separator - is defined at the top
|
||||
// Legacy (R4) submitters use the format Custom%s, or CustomPLOTTERNAME
|
||||
String key = String.format("C%s%s%s%s", CUSTOM_DATA_SEPARATOR, graph.getName(), CUSTOM_DATA_SEPARATOR, plotter.getColumnName());
|
||||
|
||||
// The value to send, which for the foreseeable future is just the string
|
||||
// value of plotter.getValue()
|
||||
String value = Integer.toString(plotter.getValue());
|
||||
|
||||
// Add it to the http post data :)
|
||||
data += encodeDataPair(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create the url
|
||||
URL url = new URL(BASE_URL + String.format(REPORT_URL, plugin.getDescription().getName()));
|
||||
|
||||
// Connect to the website
|
||||
URLConnection connection;
|
||||
|
||||
// Mineshafter creates a socks proxy, so we can safely bypass it
|
||||
// It does not reroute POST requests so we need to go around it
|
||||
if (isMineshafterPresent()) {
|
||||
connection = url.openConnection(Proxy.NO_PROXY);
|
||||
} else {
|
||||
connection = url.openConnection();
|
||||
}
|
||||
|
||||
connection.setDoOutput(true);
|
||||
|
||||
// Write the data
|
||||
OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
|
||||
writer.write(data);
|
||||
writer.flush();
|
||||
|
||||
// Now read the response
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String response = reader.readLine();
|
||||
|
||||
// close resources
|
||||
writer.close();
|
||||
reader.close();
|
||||
|
||||
if (response.startsWith("ERR")) {
|
||||
throw new IOException(response); //Throw the exception
|
||||
} else {
|
||||
// Is this the first update this hour?
|
||||
if (response.contains("OK This is your first update this hour")) {
|
||||
synchronized (graphs) {
|
||||
Iterator<Graph> iter = graphs.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
Graph graph = iter.next();
|
||||
|
||||
for (Plotter plotter : graph.getPlotters()) {
|
||||
plotter.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//if (response.startsWith("OK")) - We should get "OK" followed by an optional description if everything goes right
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or create the Set of graphs for a specific plugin
|
||||
*
|
||||
* @param plugin
|
||||
* @return
|
||||
*/
|
||||
private Set<Graph> getOrCreateGraphs(Plugin plugin) {
|
||||
Set<Graph> theGraphs = graphs.get(plugin);
|
||||
|
||||
// Create the Set if it does not already exist
|
||||
if (theGraphs == null) {
|
||||
theGraphs = Collections.synchronizedSet(new HashSet<Graph>());
|
||||
graphs.put(plugin, theGraphs);
|
||||
}
|
||||
|
||||
return theGraphs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default graph for a plugin and if it does not exist, create one
|
||||
*
|
||||
* @param plugin
|
||||
* @return
|
||||
*/
|
||||
private Graph getOrCreateDefaultGraph(Plugin plugin) {
|
||||
Graph graph = defaultGraphs.get(plugin);
|
||||
|
||||
// Not yet created :(
|
||||
if (graph == null) {
|
||||
graph = new Graph(Graph.Type.Line, "Default");
|
||||
defaultGraphs.put(plugin, graph);
|
||||
}
|
||||
|
||||
return graph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if mineshafter is present. If it is, we need to bypass it to send POST requests
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean isMineshafterPresent() {
|
||||
try {
|
||||
Class.forName("mineshafter.MineServer");
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a key/value data pair to be used in a HTTP post request. This INCLUDES a & so the first
|
||||
* key/value pair MUST be included manually, e.g:
|
||||
* <p>
|
||||
* String httpData = encode("guid") + "=" + encode("1234") + encodeDataPair("authors") + "..";
|
||||
* </p>
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
private static String encodeDataPair(String key, String value) throws UnsupportedEncodingException {
|
||||
return "&" + encode(key) + "=" + encode(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode text as UTF-8
|
||||
*
|
||||
* @param text
|
||||
* @return
|
||||
*/
|
||||
private static String encode(String text) throws UnsupportedEncodingException {
|
||||
return URLEncoder.encode(text, "UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom graph on the website
|
||||
*/
|
||||
public static class Graph {
|
||||
|
||||
/**
|
||||
* The graph's type that will be visible on the website
|
||||
*/
|
||||
public static enum Type {
|
||||
|
||||
/**
|
||||
* A simple line graph which also includes a scrollable timeline viewer to view
|
||||
* as little or as much of the data as possible.
|
||||
*/
|
||||
Line,
|
||||
|
||||
/**
|
||||
* An area graph. This is the same as a line graph except the area under the curve is shaded
|
||||
*/
|
||||
Area,
|
||||
|
||||
/**
|
||||
* A column graph, which is a graph where the data is represented by columns on the vertical axis,
|
||||
* i.e they go up and down.
|
||||
*/
|
||||
Column,
|
||||
|
||||
/**
|
||||
* A pie graph. The graph is generated by taking the data for the last hour and summing it
|
||||
* together. Then the percentage for each plotter is calculated via round( (plot / total) * 100, 2 )
|
||||
*/
|
||||
Pie
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* What the graph should be plotted as
|
||||
*/
|
||||
private final Type type;
|
||||
|
||||
/**
|
||||
* The graph's name, alphanumeric and spaces only :)
|
||||
* If it does not comply to the above when submitted, it is rejected
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* The set of plotters that are contained within this graph
|
||||
*/
|
||||
private final Set<Plotter> plotters = new LinkedHashSet<Plotter>();
|
||||
|
||||
private Graph(Type type, String name) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the graph's name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a plotter to the graph, which will be used to plot entries
|
||||
*
|
||||
* @param plotter
|
||||
*/
|
||||
public void addPlotter(Plotter plotter) {
|
||||
plotters.add(plotter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a plotter from the graph
|
||||
*
|
||||
* @param plotter
|
||||
*/
|
||||
public void removePlotter(Plotter plotter) {
|
||||
plotters.remove(plotter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an <b>unmodifiable</b> set of the plotter objects in the graph
|
||||
* @return
|
||||
*/
|
||||
public Set<Plotter> getPlotters() {
|
||||
return Collections.unmodifiableSet(plotters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (type.hashCode() * 17) ^ name.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (!(object instanceof Graph)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Graph graph = (Graph) object;
|
||||
return graph.type == type && graph.name.equals(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface used to collect custom data for a plugin
|
||||
*/
|
||||
public static abstract class Plotter {
|
||||
|
||||
/**
|
||||
* The plot's name
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Construct a plotter with the default plot name
|
||||
*/
|
||||
public Plotter() {
|
||||
this("Default");
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a plotter with a specific plot name
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public Plotter(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value for the plotted point
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract int getValue();
|
||||
|
||||
/**
|
||||
* Get the column name for the plotted point
|
||||
*
|
||||
* @return the plotted point's column name
|
||||
*/
|
||||
public String getColumnName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the website graphs have been updated
|
||||
*/
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getColumnName().hashCode() + getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (!(object instanceof Plotter)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Plotter plotter = (Plotter) object;
|
||||
return plotter.name.equals(name) && plotter.getValue() == getValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,112 +1,142 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Logger;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
|
||||
|
||||
public class Users {
|
||||
private static volatile Users instance;
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
|
||||
String directory = "plugins/mcMMO/FlatFileStuff/";
|
||||
String directoryb = "plugins/mcMMO/FlatFileStuff/Leaderboards/";
|
||||
|
||||
//public static ArrayList<PlayerProfile> players;
|
||||
public static HashMap<Player, PlayerProfile> players = new HashMap<Player, PlayerProfile>();
|
||||
private Properties properties = new Properties();
|
||||
|
||||
//To load
|
||||
public void load() throws IOException {
|
||||
properties.load(new FileInputStream(location));
|
||||
}
|
||||
//To save
|
||||
public void save()
|
||||
{
|
||||
try
|
||||
{
|
||||
properties.store(new FileOutputStream(location), null);
|
||||
}catch(IOException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
public void loadUsers()
|
||||
{
|
||||
new File(directory).mkdir();
|
||||
new File(directoryb).mkdir();
|
||||
|
||||
public static HashMap<String, PlayerProfile> players = new HashMap<String, PlayerProfile>();
|
||||
|
||||
/**
|
||||
* Load users.
|
||||
*/
|
||||
public void loadUsers() {
|
||||
new File(directory).mkdir();
|
||||
new File(directoryb).mkdir();
|
||||
File theDir = new File(location);
|
||||
if(!theDir.exists())
|
||||
{
|
||||
try {
|
||||
FileWriter writer = new FileWriter(theDir);
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (!theDir.exists()) {
|
||||
try {
|
||||
FileWriter writer = new FileWriter(theDir);
|
||||
writer.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void addUser(Player player)
|
||||
{
|
||||
players.put(player, new PlayerProfile(player));
|
||||
}
|
||||
public static void clearUsers()
|
||||
{
|
||||
players.clear();
|
||||
}
|
||||
public static HashMap<Player, PlayerProfile> getProfiles(){
|
||||
return players;
|
||||
}
|
||||
|
||||
public static void removeUser(Player player)
|
||||
{
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if(PP != null)
|
||||
{
|
||||
PP.save();
|
||||
if(players.containsKey(player))
|
||||
players.remove(player);
|
||||
}
|
||||
/**
|
||||
* Add a new user.
|
||||
*
|
||||
* @param player The player to create a user record for
|
||||
*/
|
||||
public static void addUser(Player player) {
|
||||
if (!players.containsKey(player.getName().toLowerCase())) {
|
||||
players.put(player.getName().toLowerCase(), new PlayerProfile(player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
public static PlayerProfile getProfile(Player player){
|
||||
if(players.get(player) != null)
|
||||
return players.get(player);
|
||||
else
|
||||
{
|
||||
players.put(player, new PlayerProfile(player));
|
||||
return players.get(player);
|
||||
}
|
||||
/**
|
||||
* Clear all users.
|
||||
*/
|
||||
public static void clearUsers() {
|
||||
players.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all PlayerProfiles.
|
||||
*
|
||||
* @return a HashMap containing the PlayerProfile of everyone in the database
|
||||
*/
|
||||
public static HashMap<String, PlayerProfile> getProfiles() {
|
||||
return players;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a user from the database.
|
||||
*
|
||||
* @param player The player to remove
|
||||
*/
|
||||
public static void removeUser(Player player) {
|
||||
|
||||
//Only remove PlayerProfile if user is offline and we have it in memory
|
||||
if (!player.isOnline() && players.containsKey(player.getName().toLowerCase())) {
|
||||
players.get(player.getName().toLowerCase()).save();
|
||||
players.remove(player.getName().toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a user from the DB by name.
|
||||
*
|
||||
* @param playerName The name of the player to remove
|
||||
*/
|
||||
public static void removeUserByName(String playerName) {
|
||||
players.remove(playerName.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the profile of an online player.
|
||||
*
|
||||
* @param player The player whose profile to retrieve
|
||||
* @return the player's profile
|
||||
*/
|
||||
public static PlayerProfile getProfile(Player player) {
|
||||
if(players.get(player.getName().toLowerCase()) != null) {
|
||||
return players.get(player.getName().toLowerCase());
|
||||
}
|
||||
else {
|
||||
players.put(player.getName().toLowerCase(), new PlayerProfile(player.getName()));
|
||||
return players.get(player.getName().toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the profile of an online player.
|
||||
*
|
||||
* @param player The player whose profile to retrieve
|
||||
* @return the player's profile
|
||||
*/
|
||||
public static PlayerProfile getProfile(String playerName) {
|
||||
if(players.get(playerName.toLowerCase()) != null) {
|
||||
return players.get(playerName.toLowerCase());
|
||||
}
|
||||
else {
|
||||
players.put(playerName.toLowerCase(), new PlayerProfile(playerName));
|
||||
return players.get(playerName.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the profile of an offline player.
|
||||
*
|
||||
* @param playerName Name of the player whose profile to retrieve
|
||||
* @return the player's profile
|
||||
*/
|
||||
public static PlayerProfile getOfflineProfile(String playerName) {
|
||||
return new PlayerProfile(playerName, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of this class.
|
||||
*
|
||||
* @return an instance of this class
|
||||
*/
|
||||
public static Users getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new Users();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}
|
||||
if (instance == null) {
|
||||
instance = new Users();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
|
||||
public class AddlevelsCommand implements CommandExecutor{
|
||||
private final mcMMO plugin;
|
||||
|
||||
public AddlevelsCommand(mcMMO instance) {
|
||||
this.plugin = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
Player player = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
|
||||
if (player != null && !mcPermissions.getInstance().mmoedit(player)) {
|
||||
sender.sendMessage("This command requires permissions.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
if (args.length < 2) {
|
||||
System.out.println("Usage is /addlevels playername skillname levels");
|
||||
return true;
|
||||
} else if (args.length == 3) {
|
||||
if ((plugin.getServer().getPlayer(args[0]) != null) && m.isInt(args[2]) && Skills.isSkill(args[1])) {
|
||||
int levels = Integer.valueOf(args[2]);
|
||||
Users.getProfile(plugin.getServer().getPlayer(args[0])).addLevels(Skills.getSkillType(args[1]), levels);
|
||||
System.out.println(args[1] + " has been modified for " + plugin.getServer().getPlayer(args[0]).getName() + ".");
|
||||
}
|
||||
} else {
|
||||
System.out.println("Usage is /addlevels playername skillname levels");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if (!mcPermissions.getInstance().mmoedit(player)) {
|
||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
player.sendMessage(ChatColor.RED + "Usage is /addlevels playername skillname levels");
|
||||
return true;
|
||||
}
|
||||
if (args.length == 3) {
|
||||
if ((plugin.getServer().getPlayer(args[0]) != null) && m.isInt(args[2]) && Skills.isSkill(args[1])) {
|
||||
int levels = Integer.valueOf(args[2]);
|
||||
Users.getProfile(plugin.getServer().getPlayer(args[0])).addLevels(Skills.getSkillType(args[1]), levels);
|
||||
player.sendMessage(ChatColor.RED + args[1] + " has been modified.");
|
||||
}
|
||||
} else if (args.length == 2) {
|
||||
if (m.isInt(args[1]) && Skills.isSkill(args[0])) {
|
||||
int levels = Integer.valueOf(args[1]);
|
||||
PP.addLevels(Skills.getSkillType(args[0]), levels);
|
||||
player.sendMessage(ChatColor.RED + args[0] + " has been modified.");
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "Usage is /addlevels playername skillname newvalue");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
|
||||
@@ -23,16 +22,16 @@ public class AddxpCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!mcPermissions.permissionsEnabled) {
|
||||
Player player = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
|
||||
if (player != null && !mcPermissions.getInstance().mmoedit(player)) {
|
||||
sender.sendMessage("This command requires permissions.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!LoadProperties.addxpEnable) {
|
||||
sender.sendMessage("This command is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
if (args.length < 2) {
|
||||
// No console aliasing yet
|
||||
@@ -42,7 +41,7 @@ public class AddxpCommand implements CommandExecutor {
|
||||
} else if (args.length == 3) {
|
||||
if ((plugin.getServer().getPlayer(args[0]) != null) && m.isInt(args[2]) && Skills.isSkill(args[1])) {
|
||||
int newvalue = Integer.valueOf(args[2]);
|
||||
Users.getProfile(plugin.getServer().getPlayer(args[0])).addXP(Skills.getSkillType(args[1]), newvalue, plugin.getServer().getPlayer(args[0]));
|
||||
Users.getProfile(plugin.getServer().getPlayer(args[0])).addXPOverrideNoBonus(Skills.getSkillType(args[1]), newvalue);
|
||||
plugin.getServer().getPlayer(args[0]).sendMessage(ChatColor.GREEN + "Experience granted!");
|
||||
System.out.println(args[1] + " has been modified for " + plugin.getServer().getPlayer(args[0]).getName() + ".");
|
||||
Skills.XpCheckAll(plugin.getServer().getPlayer(args[0]));
|
||||
@@ -55,14 +54,12 @@ public class AddxpCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (!mcPermissions.getInstance().mmoedit(player)) {
|
||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
player.sendMessage(ChatColor.RED + "Usage is /" + LoadProperties.addxp + " playername skillname xp");
|
||||
player.sendMessage(ChatColor.RED + "Usage is /addxp playername skillname xp");
|
||||
return true;
|
||||
}
|
||||
if (args.length == 3) {
|
||||
@@ -78,7 +75,7 @@ public class AddxpCommand implements CommandExecutor {
|
||||
Users.getProfile(player).addXP(Skills.getSkillType(args[0]), newvalue, player);
|
||||
player.sendMessage(ChatColor.RED + args[0] + " has been modified.");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "Usage is /" + LoadProperties.addxp + " playername skillname xp");
|
||||
player.sendMessage(ChatColor.RED + "Usage is /addxp playername skillname xp");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
|
||||
public class ClearmyspawnCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!LoadProperties.clearmyspawnEnable || !LoadProperties.enableMySpawn) {
|
||||
sender.sendMessage("This command is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("This command does not support console useage.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if (!mcPermissions.getInstance().mySpawn(player)) {
|
||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
|
||||
double x = Bukkit.getServer().getWorlds().get(0).getSpawnLocation().getX();
|
||||
double y = Bukkit.getServer().getWorlds().get(0).getSpawnLocation().getY();
|
||||
double z = Bukkit.getServer().getWorlds().get(0).getSpawnLocation().getZ();
|
||||
String worldname = Bukkit.getServer().getWorlds().get(0).getName();
|
||||
PP.setMySpawn(x, y, z, worldname);
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.MyspawnCleared"));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
|
||||
public class InspectCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public InspectCommand(mcMMO instance) {
|
||||
this.plugin = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
|
||||
Player player = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && !mcPermissions.getInstance().inspect(player)) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 1) {
|
||||
sender.sendMessage(ChatColor.RED + "Proper usage is /inspect <playername>");
|
||||
return true;
|
||||
}
|
||||
|
||||
// if split[1] is an online player
|
||||
if (plugin.getServer().getPlayer(args[0]) != null)
|
||||
{
|
||||
Player target = plugin.getServer().getPlayer(args[0]);
|
||||
PlayerProfile PPt = Users.getProfile(target);
|
||||
|
||||
//If they are not an Op they have to be close
|
||||
if(sender instanceof Player && !player.isOp() && !m.isNear(player.getLocation(), target.getLocation(), 5))
|
||||
{
|
||||
sender.sendMessage("You are too far away to inspect that player!");
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "mcMMO Stats for " + ChatColor.YELLOW + target.getName());
|
||||
|
||||
sender.sendMessage(ChatColor.GOLD + "-=GATHERING SKILLS=-");
|
||||
if (mcPermissions.getInstance().excavation(target))
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.ExcavationSkill"), PPt.getSkillLevel(SkillType.EXCAVATION), PPt.getSkillXpLevel(SkillType.EXCAVATION), PPt.getXpToLevel(SkillType.EXCAVATION)));
|
||||
if (mcPermissions.getInstance().fishing(target))
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.FishingSkill"), PPt.getSkillLevel(SkillType.FISHING), PPt.getSkillXpLevel(SkillType.FISHING), PPt.getXpToLevel(SkillType.FISHING)));
|
||||
if (mcPermissions.getInstance().herbalism(target))
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.HerbalismSkill"), PPt.getSkillLevel(SkillType.HERBALISM), PPt.getSkillXpLevel(SkillType.HERBALISM), PPt.getXpToLevel(SkillType.HERBALISM)));
|
||||
if (mcPermissions.getInstance().mining(target))
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.MiningSkill"), PPt.getSkillLevel(SkillType.MINING), PPt.getSkillXpLevel(SkillType.MINING), PPt.getXpToLevel(SkillType.MINING)));
|
||||
if (mcPermissions.getInstance().woodcutting(target))
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.WoodcuttingSkill"), PPt.getSkillLevel(SkillType.WOODCUTTING), PPt.getSkillXpLevel(SkillType.WOODCUTTING), PPt.getXpToLevel(SkillType.WOODCUTTING)));
|
||||
|
||||
sender.sendMessage(ChatColor.GOLD + "-=COMBAT SKILLS=-");
|
||||
if (mcPermissions.getInstance().axes(target))
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AxesSkill"), PPt.getSkillLevel(SkillType.AXES), PPt.getSkillXpLevel(SkillType.AXES), PPt.getXpToLevel(SkillType.AXES)));
|
||||
if (mcPermissions.getInstance().archery(target))
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.ArcherySkill"), PPt.getSkillLevel(SkillType.ARCHERY), PPt.getSkillXpLevel(SkillType.ARCHERY), PPt.getXpToLevel(SkillType.ARCHERY)));
|
||||
if (mcPermissions.getInstance().swords(target))
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.SwordsSkill"), PPt.getSkillLevel(SkillType.SWORDS), PPt.getSkillXpLevel(SkillType.SWORDS), PPt.getXpToLevel(SkillType.SWORDS)));
|
||||
if (mcPermissions.getInstance().taming(target))
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.TamingSkill"), PPt.getSkillLevel(SkillType.TAMING), PPt.getSkillXpLevel(SkillType.TAMING), PPt.getXpToLevel(SkillType.TAMING)));
|
||||
if (mcPermissions.getInstance().unarmed(target))
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.UnarmedSkill"), PPt.getSkillLevel(SkillType.UNARMED), PPt.getSkillXpLevel(SkillType.UNARMED), PPt.getXpToLevel(SkillType.UNARMED)));
|
||||
|
||||
sender.sendMessage(ChatColor.GOLD + "-=MISC SKILLS=-");
|
||||
if (mcPermissions.getInstance().acrobatics(target))
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AcrobaticsSkill"), PPt.getSkillLevel(SkillType.ACROBATICS), PPt.getSkillXpLevel(SkillType.ACROBATICS), PPt.getXpToLevel(SkillType.ACROBATICS)));
|
||||
if (mcPermissions.getInstance().repair(target))
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.RepairSkill"), PPt.getSkillLevel(SkillType.REPAIR), PPt.getSkillXpLevel(SkillType.REPAIR), PPt.getXpToLevel(SkillType.REPAIR)));
|
||||
|
||||
sender.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel") + ChatColor.GREEN + (m.getPowerLevel(target, PPt)));
|
||||
} else {
|
||||
if(sender instanceof Player && !player.isOp())
|
||||
{
|
||||
sender.sendMessage("That player is offline, inspecting offline players is limited to Ops!");
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerProfile PPt = Users.getOfflineProfile(args[0]);
|
||||
|
||||
if(!PPt.isLoaded())
|
||||
{
|
||||
sender.sendMessage("Player does not exist in the database!");
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "mcMMO Stats for Offline Player " + ChatColor.YELLOW + args[0]);
|
||||
|
||||
sender.sendMessage(ChatColor.GOLD + "-=GATHERING SKILLS=-");
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.ExcavationSkill"), PPt.getSkillLevel(SkillType.EXCAVATION), PPt.getSkillXpLevel(SkillType.EXCAVATION), PPt.getXpToLevel(SkillType.EXCAVATION)));
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.FishingSkill"), PPt.getSkillLevel(SkillType.FISHING), PPt.getSkillXpLevel(SkillType.FISHING), PPt.getXpToLevel(SkillType.FISHING)));
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.HerbalismSkill"), PPt.getSkillLevel(SkillType.HERBALISM), PPt.getSkillXpLevel(SkillType.HERBALISM), PPt.getXpToLevel(SkillType.HERBALISM)));
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.MiningSkill"), PPt.getSkillLevel(SkillType.MINING), PPt.getSkillXpLevel(SkillType.MINING), PPt.getXpToLevel(SkillType.MINING)));
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.WoodcuttingSkill"), PPt.getSkillLevel(SkillType.WOODCUTTING), PPt.getSkillXpLevel(SkillType.WOODCUTTING), PPt.getXpToLevel(SkillType.WOODCUTTING)));
|
||||
|
||||
sender.sendMessage(ChatColor.GOLD + "-=COMBAT SKILLS=-");
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AxesSkill"), PPt.getSkillLevel(SkillType.AXES), PPt.getSkillXpLevel(SkillType.AXES), PPt.getXpToLevel(SkillType.AXES)));
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.ArcherySkill"), PPt.getSkillLevel(SkillType.ARCHERY), PPt.getSkillXpLevel(SkillType.ARCHERY), PPt.getXpToLevel(SkillType.ARCHERY)));
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.SwordsSkill"), PPt.getSkillLevel(SkillType.SWORDS), PPt.getSkillXpLevel(SkillType.SWORDS), PPt.getXpToLevel(SkillType.SWORDS)));
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.TamingSkill"), PPt.getSkillLevel(SkillType.TAMING), PPt.getSkillXpLevel(SkillType.TAMING), PPt.getXpToLevel(SkillType.TAMING)));
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.UnarmedSkill"), PPt.getSkillLevel(SkillType.UNARMED), PPt.getSkillXpLevel(SkillType.UNARMED), PPt.getXpToLevel(SkillType.UNARMED)));
|
||||
|
||||
sender.sendMessage(ChatColor.GOLD + "-=MISC SKILLS=-");
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AcrobaticsSkill"), PPt.getSkillLevel(SkillType.ACROBATICS), PPt.getSkillXpLevel(SkillType.ACROBATICS), PPt.getXpToLevel(SkillType.ACROBATICS)));
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.RepairSkill"), PPt.getSkillLevel(SkillType.REPAIR), PPt.getSkillXpLevel(SkillType.REPAIR), PPt.getXpToLevel(SkillType.REPAIR)));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -9,32 +9,31 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
|
||||
public class StatsCommand implements CommandExecutor {
|
||||
public class McstatsCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!LoadProperties.statsEnable) {
|
||||
sender.sendMessage("This command is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("This command does not support console useage.");
|
||||
return true;
|
||||
}
|
||||
Player player = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("This command does not support console useage.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.YourStats"));
|
||||
|
||||
if (mcPermissions.getEnabled())
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.NoSkillNote"));
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.NoSkillNote"));
|
||||
|
||||
ChatColor header = ChatColor.GOLD;
|
||||
|
||||
@@ -57,8 +56,6 @@ public class StatsCommand implements CommandExecutor {
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AxesSkill"), PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES)));
|
||||
if (mcPermissions.getInstance().archery(player))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.ArcherySkill"), PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY)));
|
||||
// if(mcPermissions.getInstance().sorcery(player))
|
||||
// player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.SorcerySkill"), PP.getSkill("sorcery"), PP.getSkill("sorceryXP"), PP.getXpToLevel("excavation")));
|
||||
if (mcPermissions.getInstance().swords(player))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.SwordsSkill"), PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS)));
|
||||
if (mcPermissions.getInstance().taming(player))
|
||||
@@ -71,14 +68,10 @@ public class StatsCommand implements CommandExecutor {
|
||||
player.sendMessage(header + "-=MISC SKILLS=-");
|
||||
if (mcPermissions.getInstance().acrobatics(player))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AcrobaticsSkill"), PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS)));
|
||||
// if(mcPermissions.getInstance().alchemy(player))
|
||||
// player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AlchemySkill"), PP.getSkillLevel(SkillType.ALCHEMY), PP.getSkillXpLevel(SkillType.ALCHEMY), PP.getXpToLevel(SkillType.ALCHEMY)));
|
||||
// if(mcPermissions.getInstance().enchanting(player))
|
||||
// player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.EnchantingSkill"), PP.getSkillLevel(SkillType.ENCHANTING), PP.getSkillXpLevel(SkillType.ENCHANTING), PP.getXpToLevel(SkillType.ENCHANTING)));
|
||||
if (mcPermissions.getInstance().repair(player))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.RepairSkill"), PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR)));
|
||||
}
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel") + ChatColor.GREEN + (m.getPowerLevel(player)));
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel") + ChatColor.GREEN + (m.getPowerLevel(player, PP)));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -8,74 +8,109 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
|
||||
public class MmoeditCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public MmoeditCommand(mcMMO instance) {
|
||||
this.plugin = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!mcPermissions.permissionsEnabled) {
|
||||
Player player = null;
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
player = (Player) sender;
|
||||
}
|
||||
|
||||
if (player != null && !mcPermissions.getInstance().mmoedit(player)) {
|
||||
sender.sendMessage("This command requires permissions.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!LoadProperties.mmoeditEnable) {
|
||||
sender.sendMessage("This command is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
if (args.length < 2) {
|
||||
System.out.println("Usage is /" + LoadProperties.mmoedit + " playername skillname newvalue");
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
System.out.println("Usage is /mmoedit playername skillname newvalue");
|
||||
return true;
|
||||
} else if (args.length == 3) {
|
||||
if ((plugin.getServer().getPlayer(args[0]) != null) && m.isInt(args[2]) && Skills.isSkill(args[1])) {
|
||||
} else if (args.length == 3)
|
||||
{
|
||||
PlayerProfile PPt = null;
|
||||
|
||||
if(Users.players.containsKey(args[0].toLowerCase())) {
|
||||
PPt = Users.players.get(args[0].toLowerCase());
|
||||
}
|
||||
|
||||
if(PPt == null)
|
||||
Users.getOfflineProfile(args[0]); //Only grab offline profile if the above failed
|
||||
|
||||
if(!PPt.isLoaded())
|
||||
{
|
||||
sender.sendMessage("Player does not exist in the database!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m.isInt(args[2]) && Skills.isSkill(args[1]))
|
||||
{
|
||||
int newvalue = Integer.valueOf(args[2]);
|
||||
Users.getProfile(plugin.getServer().getPlayer(args[0])).modifyskill(Skills.getSkillType(args[1]), newvalue);
|
||||
System.out.println(args[1] + " has been modified for " + plugin.getServer().getPlayer(args[0]).getName() + ".");
|
||||
Users.getOfflineProfile(args[0]).modifyskill(Skills.getSkillType(args[1]), newvalue);
|
||||
System.out.println(args[1] + " has been modified for " + args[0] + ".");
|
||||
}
|
||||
} else {
|
||||
System.out.println("Usage is /" + LoadProperties.mmoedit + " playername skillname newvalue");
|
||||
} else
|
||||
{
|
||||
System.out.println("Usage is /mmoedit playername skillname newvalue");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if (!mcPermissions.getInstance().mmoedit(player)) {
|
||||
if (!mcPermissions.getInstance().mmoedit(player))
|
||||
{
|
||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
player.sendMessage(ChatColor.RED + "Usage is /" + LoadProperties.mmoedit + " playername skillname newvalue");
|
||||
|
||||
if (args.length < 2)
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "Usage is /mmoedit playername skillname newvalue");
|
||||
return true;
|
||||
}
|
||||
if (args.length == 3) {
|
||||
if ((plugin.getServer().getPlayer(args[0]) != null) && m.isInt(args[2]) && Skills.isSkill(args[1])) {
|
||||
if (args.length == 3)
|
||||
{
|
||||
PlayerProfile PPt = null;
|
||||
|
||||
if(Users.players.containsKey(args[0].toLowerCase())) {
|
||||
PPt = Users.players.get(args[0].toLowerCase());
|
||||
}
|
||||
|
||||
if(PPt == null)
|
||||
Users.getOfflineProfile(args[0]); //Only grab offline profile if the above failed
|
||||
|
||||
if(!PPt.isLoaded())
|
||||
{
|
||||
sender.sendMessage("Player does not exist in the database!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m.isInt(args[2]) && Skills.isSkill(args[1]))
|
||||
{
|
||||
int newvalue = Integer.valueOf(args[2]);
|
||||
Users.getProfile(plugin.getServer().getPlayer(args[0])).modifyskill(Skills.getSkillType(args[1]), newvalue);
|
||||
player.sendMessage(ChatColor.RED + args[1] + " has been modified.");
|
||||
PPt.modifyskill(Skills.getSkillType(args[1]), newvalue);
|
||||
player.sendMessage(ChatColor.RED + args[1] + " has been modified for "+args[0]);
|
||||
}
|
||||
} else if (args.length == 2) {
|
||||
if (m.isInt(args[1]) && Skills.isSkill(args[0])) {
|
||||
} else if (args.length == 2)
|
||||
{
|
||||
if (m.isInt(args[1]) && Skills.isSkill(args[0]))
|
||||
{
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int newvalue = Integer.valueOf(args[1]);
|
||||
PP.modifyskill(Skills.getSkillType(args[0]), newvalue);
|
||||
player.sendMessage(ChatColor.RED + args[0] + " has been modified.");
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "Usage is /" + LoadProperties.mmoedit + " playername skillname newvalue");
|
||||
} else
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "Usage is /mmoedit playername skillname newvalue");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -8,9 +8,10 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.runnables.SQLConversionTask;
|
||||
|
||||
public class MmoupdateCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -28,7 +29,7 @@ public class MmoupdateCommand implements CommandExecutor {
|
||||
}
|
||||
player.sendMessage(ChatColor.GRAY + "Starting conversion...");
|
||||
Users.clearUsers();
|
||||
m.convertToMySQL();
|
||||
convertToMySQL();
|
||||
for (Player x : Bukkit.getServer().getOnlinePlayers()) {
|
||||
Users.addUser(x);
|
||||
}
|
||||
@@ -36,4 +37,15 @@ public class MmoupdateCommand implements CommandExecutor {
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert FlatFile data to MySQL data.
|
||||
*/
|
||||
private void convertToMySQL() {
|
||||
if (!LoadProperties.useMySQL) {
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(Bukkit.getPluginManager().getPlugin("mcMMO"), new SQLConversionTask(), 1);
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
|
||||
public class MyspawnCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!LoadProperties.myspawnEnable || !LoadProperties.enableMySpawn) {
|
||||
sender.sendMessage("This command is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("This command does not support console useage.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if (!mcPermissions.getInstance().mySpawn(player)) {
|
||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
if (System.currentTimeMillis() < (PP.getMySpawnATS() * 1000) + 3600000) {
|
||||
long x = (((PP.getMySpawnATS() * 1000) + 3600000) - System.currentTimeMillis());
|
||||
int y = (int) (x / 60000);
|
||||
int z = (int) ((x / 1000) - (y * 60));
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.MyspawnTimeNotice", new Object[] { y, z }));
|
||||
return true;
|
||||
}
|
||||
PP.setMySpawnATS(System.currentTimeMillis());
|
||||
if (PP.getMySpawn(player) != null) {
|
||||
Location mySpawn = PP.getMySpawn(player);
|
||||
|
||||
if (mySpawn != null) {
|
||||
// It's done twice because it acts oddly when you are in another world
|
||||
player.teleport(mySpawn);
|
||||
player.teleport(mySpawn);
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.MyspawnNotExist"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
|
||||
public class WhoisCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public WhoisCommand(mcMMO instance) {
|
||||
this.plugin = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!LoadProperties.whoisEnable) {
|
||||
sender.sendMessage("This command is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (!mcPermissions.getInstance().whois(player)) {
|
||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 1) {
|
||||
player.sendMessage(ChatColor.RED + "Proper usage is /" + LoadProperties.whois + " <playername>");
|
||||
return true;
|
||||
}
|
||||
// if split[1] is a player
|
||||
if (plugin.getServer().getPlayer(args[0]) != null) {
|
||||
Player target = plugin.getServer().getPlayer(args[0]);
|
||||
PlayerProfile PPt = Users.getProfile(target);
|
||||
|
||||
player.sendMessage(ChatColor.GREEN + "~~WHOIS RESULTS~~");
|
||||
player.sendMessage(target.getName());
|
||||
if (PPt.inParty())
|
||||
player.sendMessage("Party: " + PPt.getParty());
|
||||
player.sendMessage("Health: " + target.getHealth() + ChatColor.GRAY + " (20 is full health)");
|
||||
player.sendMessage("OP: " + target.isOp());
|
||||
player.sendMessage(ChatColor.GREEN + "mcMMO Stats for " + ChatColor.YELLOW + target.getName());
|
||||
|
||||
player.sendMessage(ChatColor.GOLD + "-=GATHERING SKILLS=-");
|
||||
if (mcPermissions.getInstance().excavation(target))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.ExcavationSkill"), PPt.getSkillLevel(SkillType.EXCAVATION), PPt.getSkillXpLevel(SkillType.EXCAVATION), PPt.getXpToLevel(SkillType.EXCAVATION)));
|
||||
if (mcPermissions.getInstance().fishing(target))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.FishingSkill"), PPt.getSkillLevel(SkillType.FISHING), PPt.getSkillXpLevel(SkillType.FISHING), PPt.getXpToLevel(SkillType.FISHING)));
|
||||
if (mcPermissions.getInstance().herbalism(target))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.HerbalismSkill"), PPt.getSkillLevel(SkillType.HERBALISM), PPt.getSkillXpLevel(SkillType.HERBALISM), PPt.getXpToLevel(SkillType.HERBALISM)));
|
||||
if (mcPermissions.getInstance().mining(target))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.MiningSkill"), PPt.getSkillLevel(SkillType.MINING), PPt.getSkillXpLevel(SkillType.MINING), PPt.getXpToLevel(SkillType.MINING)));
|
||||
if (mcPermissions.getInstance().woodcutting(target))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.WoodcuttingSkill"), PPt.getSkillLevel(SkillType.WOODCUTTING), PPt.getSkillXpLevel(SkillType.WOODCUTTING), PPt.getXpToLevel(SkillType.WOODCUTTING)));
|
||||
|
||||
player.sendMessage(ChatColor.GOLD + "-=COMBAT SKILLS=-");
|
||||
if (mcPermissions.getInstance().axes(target))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AxesSkill"), PPt.getSkillLevel(SkillType.AXES), PPt.getSkillXpLevel(SkillType.AXES), PPt.getXpToLevel(SkillType.AXES)));
|
||||
if (mcPermissions.getInstance().archery(player))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.ArcherySkill"), PPt.getSkillLevel(SkillType.ARCHERY), PPt.getSkillXpLevel(SkillType.ARCHERY), PPt.getXpToLevel(SkillType.ARCHERY)));
|
||||
// if(mcPermissions.getInstance().sorcery(target))
|
||||
// player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.SorcerySkill"), PPt.getSkill("sorcery"), PPt.getSkill("sorceryXP"), PPt.getXpToLevel("excavation")));
|
||||
if (mcPermissions.getInstance().swords(target))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.SwordsSkill"), PPt.getSkillLevel(SkillType.SWORDS), PPt.getSkillXpLevel(SkillType.SWORDS), PPt.getXpToLevel(SkillType.SWORDS)));
|
||||
if (mcPermissions.getInstance().taming(target))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.TamingSkill"), PPt.getSkillLevel(SkillType.TAMING), PPt.getSkillXpLevel(SkillType.TAMING), PPt.getXpToLevel(SkillType.TAMING)));
|
||||
if (mcPermissions.getInstance().unarmed(target))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.UnarmedSkill"), PPt.getSkillLevel(SkillType.UNARMED), PPt.getSkillXpLevel(SkillType.UNARMED), PPt.getXpToLevel(SkillType.UNARMED)));
|
||||
|
||||
player.sendMessage(ChatColor.GOLD + "-=MISC SKILLS=-");
|
||||
if (mcPermissions.getInstance().acrobatics(target))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AcrobaticsSkill"), PPt.getSkillLevel(SkillType.ACROBATICS), PPt.getSkillXpLevel(SkillType.ACROBATICS), PPt.getXpToLevel(SkillType.ACROBATICS)));
|
||||
// if(mcPermissions.getInstance().alchemy(target))
|
||||
// player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AlchemySkill"), PPt.getSkillLevel(SkillType.ALCHEMY), PPt.getSkillXpLevel(SkillType.ALCHEMY), PPt.getXpToLevel(SkillType.ALCHEMY)));
|
||||
// if(mcPermissions.getInstance().enchanting(target))
|
||||
// player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.EnchantingSkill"), PPt.getSkillLevel(SkillType.ENCHANTING), PPt.getSkillXpLevel(SkillType.ENCHANTING), PPt.getXpToLevel(SkillType.ENCHANTING)));
|
||||
if (mcPermissions.getInstance().repair(target))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.RepairSkill"), PPt.getSkillLevel(SkillType.REPAIR), PPt.getSkillXpLevel(SkillType.REPAIR), PPt.getXpToLevel(SkillType.REPAIR)));
|
||||
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel") + ChatColor.GREEN + (m.getPowerLevel(target)));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -19,16 +19,12 @@ public class XprateCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!LoadProperties.xprateEnable) {
|
||||
sender.sendMessage("This command is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
if(args.length <= 0)
|
||||
{
|
||||
System.out.println(mcLocale.getString("Commands.xprate.proper", new Object[] {LoadProperties.xprate}));
|
||||
System.out.println(mcLocale.getString("Commands.xprate.proper2", new Object[] {LoadProperties.xprate}));
|
||||
System.out.println(mcLocale.getString("Commands.xprate.proper", new Object[] {"xprate"}));
|
||||
System.out.println(mcLocale.getString("Commands.xprate.proper2", new Object[] {"xprate"}));
|
||||
}
|
||||
|
||||
if(args.length == 1 && args[0].equalsIgnoreCase("reset"))
|
||||
@@ -67,6 +63,8 @@ public class XprateCommand implements CommandExecutor {
|
||||
x.sendMessage(ChatColor.GOLD+"XP EVENT FOR mcMMO HAS STARTED!");
|
||||
x.sendMessage(ChatColor.GOLD+"mcMMO XP RATE IS NOW "+LoadProperties.xpGainMultiplier+"x!!");
|
||||
}
|
||||
|
||||
System.out.println("The XP RATE was modified to "+LoadProperties.xpGainMultiplier);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -81,8 +79,8 @@ public class XprateCommand implements CommandExecutor {
|
||||
}
|
||||
if(args.length <= 0)
|
||||
{
|
||||
player.sendMessage(mcLocale.getString("Commands.xprate.proper", new Object[] {LoadProperties.xprate}));
|
||||
player.sendMessage(mcLocale.getString("Commands.xprate.proper2", new Object[] {LoadProperties.xprate}));
|
||||
player.sendMessage(mcLocale.getString("Commands.xprate.proper", new Object[] {"xprate"}));
|
||||
player.sendMessage(mcLocale.getString("Commands.xprate.proper2", new Object[] {"xprate"}));
|
||||
}
|
||||
if(args.length == 1 && args[0].equalsIgnoreCase("reset"))
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -7,20 +8,19 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
|
||||
public class McabilityCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!mcPermissions.permissionsEnabled) {
|
||||
sender.sendMessage("This command requires permissions.");
|
||||
return true;
|
||||
}
|
||||
Player player = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
|
||||
if (!LoadProperties.mcabilityEnable) {
|
||||
sender.sendMessage("This command is not enabled.");
|
||||
if (player != null && !mcPermissions.getInstance().mcAbility(player)) {
|
||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ public class McabilityCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if (PP.getAbilityUse()) {
|
||||
|
||||
@@ -7,16 +7,11 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
|
||||
public class MccCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!LoadProperties.mccEnable) {
|
||||
sender.sendMessage("This command is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("This command does not support console useage.");
|
||||
@@ -29,44 +24,39 @@ public class MccCommand implements CommandExecutor {
|
||||
|
||||
if (mcPermissions.getInstance().party(player)) {
|
||||
player.sendMessage(mcLocale.getString("m.mccPartyCommands"));
|
||||
player.sendMessage(LoadProperties.party + " " + mcLocale.getString("m.mccParty"));
|
||||
player.sendMessage(LoadProperties.party + " q " + mcLocale.getString("m.mccPartyQ"));
|
||||
player.sendMessage("/party " + mcLocale.getString("m.mccParty"));
|
||||
player.sendMessage("/party q " + mcLocale.getString("m.mccPartyQ"));
|
||||
|
||||
if (mcPermissions.getInstance().partyChat(player))
|
||||
player.sendMessage("/p " + mcLocale.getString("m.mccPartyToggle"));
|
||||
|
||||
player.sendMessage(LoadProperties.invite + " " + mcLocale.getString("m.mccPartyInvite"));
|
||||
player.sendMessage(LoadProperties.accept + " " + mcLocale.getString("m.mccPartyAccept"));
|
||||
player.sendMessage("/invite " + mcLocale.getString("m.mccPartyInvite"));
|
||||
player.sendMessage("/invite " + mcLocale.getString("m.mccPartyAccept"));
|
||||
|
||||
if (mcPermissions.getInstance().partyTeleport(player))
|
||||
player.sendMessage(LoadProperties.ptp + " " + mcLocale.getString("m.mccPartyTeleport"));
|
||||
player.sendMessage("/ptp " + mcLocale.getString("m.mccPartyTeleport"));
|
||||
}
|
||||
player.sendMessage(mcLocale.getString("m.mccOtherCommands"));
|
||||
player.sendMessage(LoadProperties.stats + ChatColor.RED + " " + mcLocale.getString("m.mccStats"));
|
||||
player.sendMessage("/mcstats " + ChatColor.RED + " " + mcLocale.getString("m.mccStats"));
|
||||
player.sendMessage("/mctop <skillname> <page> " + ChatColor.RED + mcLocale.getString("m.mccLeaderboards"));
|
||||
|
||||
if (mcPermissions.getInstance().mySpawn(player)) {
|
||||
player.sendMessage(LoadProperties.myspawn + " " + ChatColor.RED + mcLocale.getString("m.mccMySpawn"));
|
||||
player.sendMessage(LoadProperties.clearmyspawn + " " + ChatColor.RED + mcLocale.getString("m.mccClearMySpawn"));
|
||||
}
|
||||
|
||||
if (mcPermissions.getInstance().mcAbility(player))
|
||||
player.sendMessage(LoadProperties.mcability + ChatColor.RED + " " + mcLocale.getString("m.mccToggleAbility"));
|
||||
player.sendMessage("/mcability" + ChatColor.RED + " " + mcLocale.getString("m.mccToggleAbility"));
|
||||
|
||||
if (mcPermissions.getInstance().adminChat(player))
|
||||
player.sendMessage("/a " + ChatColor.RED + mcLocale.getString("m.mccAdminToggle"));
|
||||
|
||||
if (mcPermissions.getInstance().whois(player))
|
||||
player.sendMessage(LoadProperties.whois + " " + mcLocale.getString("m.mccWhois"));
|
||||
if (mcPermissions.getInstance().inspect(player))
|
||||
player.sendMessage("/inspect " + mcLocale.getString("m.mccInspect"));
|
||||
|
||||
if (mcPermissions.getInstance().mmoedit(player))
|
||||
player.sendMessage(LoadProperties.mmoedit + mcLocale.getString("m.mccMmoedit"));
|
||||
player.sendMessage("/mmoedit" + mcLocale.getString("m.mccMmoedit"));
|
||||
|
||||
if (mcPermissions.getInstance().mcgod(player))
|
||||
player.sendMessage(LoadProperties.mcgod + ChatColor.RED + " " + mcLocale.getString("m.mccMcGod"));
|
||||
player.sendMessage("/mcgod" + ChatColor.RED + " " + mcLocale.getString("m.mccMcGod"));
|
||||
|
||||
player.sendMessage(mcLocale.getString("m.mccSkillInfo"));
|
||||
player.sendMessage(LoadProperties.mcmmo + " " + mcLocale.getString("m.mccModDescription"));
|
||||
player.sendMessage("/mcmmo " + mcLocale.getString("m.mccModDescription"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8,17 +8,12 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
|
||||
public class McgodCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!LoadProperties.mcgodEnable) {
|
||||
sender.sendMessage("This command is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("This command does not support console useage.");
|
||||
@@ -28,12 +23,12 @@ public class McgodCommand implements CommandExecutor {
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if (mcPermissions.permissionsEnabled) {
|
||||
if (!mcPermissions.getInstance().mcgod(player)) {
|
||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
if (!mcPermissions.getInstance().mcgod(player)) {
|
||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mcPermissions.getInstance().mcgod(player)) {
|
||||
if (PP.getGodMode()) {
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.GodModeDisabled"));
|
||||
PP.toggleGodMode();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -12,12 +11,9 @@ import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
|
||||
public class McmmoCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!LoadProperties.mcmmoEnable) {
|
||||
sender.sendMessage("This command is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("This command does not support console useage.");
|
||||
@@ -26,8 +22,7 @@ public class McmmoCommand implements CommandExecutor {
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
player.sendMessage(ChatColor.RED + "-----[]" + ChatColor.GREEN + "mcMMO" + ChatColor.RED + "[]-----");
|
||||
String description = mcLocale.getString("mcMMO.Description", new Object[] { LoadProperties.mcc });
|
||||
String description = mcLocale.getString("mcMMO.Description", new Object[] { "mcc" });
|
||||
String[] mcSplit = description.split(",");
|
||||
|
||||
for (String x : mcSplit) {
|
||||
@@ -37,10 +32,10 @@ public class McmmoCommand implements CommandExecutor {
|
||||
if (LoadProperties.spoutEnabled && player instanceof SpoutPlayer) {
|
||||
SpoutPlayer sPlayer = (SpoutPlayer) player;
|
||||
if (LoadProperties.donateMessage)
|
||||
sPlayer.sendNotification("[mcMMO] Donate!", "Paypal nossr50@gmail.com", Material.CAKE);
|
||||
sPlayer.sendMessage(ChatColor.YELLOW + "[mcMMO]"+ChatColor.GOLD+" Donate! Paypal "+ChatColor.GREEN+"theno1yeti@gmail.com");
|
||||
} else {
|
||||
if (LoadProperties.donateMessage)
|
||||
player.sendMessage(ChatColor.GREEN + "If you like my work you can donate via Paypal: nossr50@gmail.com");
|
||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO]"+ChatColor.GOLD+" Donate! Paypal "+ChatColor.GREEN+"theno1yeti@gmail.com");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
|
||||
@@ -22,10 +21,6 @@ public class McrefreshCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!LoadProperties.mcrefreshEnable) {
|
||||
sender.sendMessage("This command is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("This command does not support console useage.");
|
||||
@@ -54,37 +49,16 @@ public class McrefreshCommand implements CommandExecutor {
|
||||
PP.setFistsPreparationMode(false);
|
||||
PP.setSwordsPreparationMode(false);
|
||||
PP.setPickaxePreparationMode(false);
|
||||
/*
|
||||
* GREEN TERRA
|
||||
*/
|
||||
PP.setGreenTerraMode(false);
|
||||
PP.setGreenTerraDeactivatedTimeStamp((long) 0);
|
||||
|
||||
/*
|
||||
* GIGA DRILL BREAKER
|
||||
*/
|
||||
|
||||
//RESET COOLDOWNS
|
||||
PP.resetCooldowns();
|
||||
PP.setGreenTerraMode(false);
|
||||
PP.setGigaDrillBreakerMode(false);
|
||||
PP.setGigaDrillBreakerDeactivatedTimeStamp((long) 0);
|
||||
/*
|
||||
* SERRATED STRIKE
|
||||
*/
|
||||
PP.setSerratedStrikesMode(false);
|
||||
PP.setSerratedStrikesDeactivatedTimeStamp((long) 0);
|
||||
/*
|
||||
* SUPER BREAKER
|
||||
*/
|
||||
PP.setSuperBreakerMode(false);
|
||||
PP.setSuperBreakerDeactivatedTimeStamp((long) 0);
|
||||
/*
|
||||
* TREE FELLER
|
||||
*/
|
||||
PP.setTreeFellerMode(false);
|
||||
PP.setTreeFellerDeactivatedTimeStamp((long) 0);
|
||||
/*
|
||||
* BERSERK
|
||||
*/
|
||||
PP.setBerserkMode(false);
|
||||
PP.setBerserkDeactivatedTimeStamp((long) 0);
|
||||
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesRefreshed"));
|
||||
|
||||
|
||||
109
src/main/java/com/gmail/nossr50/commands/mc/McremoveCommand.java
Normal file
109
src/main/java/com/gmail/nossr50/commands/mc/McremoveCommand.java
Normal file
@@ -0,0 +1,109 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
|
||||
public class McremoveCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
Player player = null;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
|
||||
if (player != null && !mcPermissions.getInstance().mcremove(player)) {
|
||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args.length == 0)
|
||||
{
|
||||
sender.sendMessage("Correct usage is /mcremove [Player Name]");
|
||||
return true;
|
||||
}
|
||||
|
||||
String playerName = args[0]; //Player that we are going to remove
|
||||
|
||||
//If the server is using MySQL
|
||||
if(LoadProperties.useMySQL)
|
||||
{
|
||||
int userId = mcMMO.database.getInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + playerName + "'");
|
||||
|
||||
//Remove user from tables
|
||||
mcMMO.database.write("DELETE FROM "
|
||||
+LoadProperties.MySQLdbName+"."
|
||||
+LoadProperties.MySQLtablePrefix+"users WHERE "
|
||||
+LoadProperties.MySQLtablePrefix+"users.id="+userId);
|
||||
|
||||
mcMMO.database.write("DELETE FROM "
|
||||
+LoadProperties.MySQLdbName+"."
|
||||
+LoadProperties.MySQLtablePrefix+"cooldowns WHERE "
|
||||
+LoadProperties.MySQLtablePrefix+"cooldowns.user_id="+userId);
|
||||
|
||||
mcMMO.database.write("DELETE FROM "
|
||||
+LoadProperties.MySQLdbName+"."
|
||||
+LoadProperties.MySQLtablePrefix+"huds WHERE "
|
||||
+LoadProperties.MySQLtablePrefix+"huds.user_id="+userId);
|
||||
|
||||
mcMMO.database.write("DELETE FROM "
|
||||
+LoadProperties.MySQLdbName+"."
|
||||
+LoadProperties.MySQLtablePrefix+"skills WHERE "
|
||||
+LoadProperties.MySQLtablePrefix+"skills.user_id="+userId);
|
||||
|
||||
mcMMO.database.write("DELETE FROM "
|
||||
+LoadProperties.MySQLdbName+"."
|
||||
+LoadProperties.MySQLtablePrefix+"experience WHERE "
|
||||
+LoadProperties.MySQLtablePrefix+"experience.user_id="+userId);
|
||||
|
||||
sender.sendMessage("User "+playerName+" removed from MySQL DB!");
|
||||
} else {
|
||||
//FlatFile removal
|
||||
//TODO: Properly remove users from FlatFile, it's going to be a huge bitch with how our FlatFile system works. Let's adopt SQLite support.
|
||||
if(Bukkit.getServer().getPlayer(playerName) != null)
|
||||
{
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(playerName);
|
||||
if(targetPlayer.isOnline())
|
||||
{
|
||||
Users.getProfile(targetPlayer).resetAllData();
|
||||
sender.sendMessage("User "+playerName+" removed from FlatFile DB!");
|
||||
} else {
|
||||
sender.sendMessage("[mcMMO] This command is not fully functional for FlatFile yet, the player needs to be online.");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage("[mcMMO] This command is not fully functional for FlatFile yet, the player needs to be online.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//Force PlayerProfile stuff to update
|
||||
if(Bukkit.getServer().getPlayer(playerName) != null)
|
||||
{
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(playerName);
|
||||
if(targetPlayer.isOnline())
|
||||
{
|
||||
targetPlayer.kickPlayer("[mcMMO] Stats have been reset! Rejoin!");
|
||||
Users.removeUserByName(playerName);
|
||||
} else {
|
||||
Users.removeUser(targetPlayer);
|
||||
}
|
||||
} else {
|
||||
Users.removeUserByName(playerName);
|
||||
}
|
||||
|
||||
sender.sendMessage("[mcMMO] mcremove operation completed.");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,6 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Leaderboard;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@@ -20,17 +18,6 @@ import com.gmail.nossr50.skills.Skills;
|
||||
public class MctopCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!LoadProperties.mctopEnable) {
|
||||
sender.sendMessage("This command is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("This command does not support console useage.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (LoadProperties.useMySQL == false) {
|
||||
/*
|
||||
@@ -39,7 +26,7 @@ public class MctopCommand implements CommandExecutor {
|
||||
if (args.length == 0) {
|
||||
int p = 1;
|
||||
String[] info = Leaderboard.retrieveInfo(SkillType.ALL.toString(), p);
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevelLeaderboard"));
|
||||
sender.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevelLeaderboard"));
|
||||
int n = 1 * p; // Position
|
||||
for (String x : info) {
|
||||
if (x != null) {
|
||||
@@ -48,7 +35,7 @@ public class MctopCommand implements CommandExecutor {
|
||||
digit = "0" + String.valueOf(n);
|
||||
String[] splitx = x.split(":");
|
||||
// Format: 1. Playername - skill value
|
||||
player.sendMessage(digit + ". " + ChatColor.GREEN + splitx[1] + " - " + ChatColor.WHITE + splitx[0]);
|
||||
sender.sendMessage(digit + ". " + ChatColor.GREEN + splitx[1] + " - " + ChatColor.WHITE + splitx[0]);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
@@ -68,7 +55,7 @@ public class MctopCommand implements CommandExecutor {
|
||||
pt = 10;
|
||||
}
|
||||
String[] info = Leaderboard.retrieveInfo(SkillType.ALL.toString(), p);
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevelLeaderboard"));
|
||||
sender.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevelLeaderboard"));
|
||||
int n = 1 * pt; // Position
|
||||
for (String x : info) {
|
||||
if (x != null) {
|
||||
@@ -77,7 +64,7 @@ public class MctopCommand implements CommandExecutor {
|
||||
digit = "0" + String.valueOf(n);
|
||||
String[] splitx = x.split(":");
|
||||
// Format: 1. Playername - skill value
|
||||
player.sendMessage(digit + ". " + ChatColor.GREEN + splitx[1] + " - " + ChatColor.WHITE + splitx[0]);
|
||||
sender.sendMessage(digit + ". " + ChatColor.GREEN + splitx[1] + " - " + ChatColor.WHITE + splitx[0]);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
@@ -104,7 +91,7 @@ public class MctopCommand implements CommandExecutor {
|
||||
String capitalized = firstLetter.toUpperCase() + remainder.toLowerCase();
|
||||
|
||||
String[] info = Leaderboard.retrieveInfo(args[0].toUpperCase(), p);
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.SkillLeaderboard", new Object[] { capitalized }));
|
||||
sender.sendMessage(mcLocale.getString("mcPlayerListener.SkillLeaderboard", new Object[] { capitalized }));
|
||||
int n = 1 * pt; // Position
|
||||
for (String x : info) {
|
||||
if (x != null) {
|
||||
@@ -113,7 +100,7 @@ public class MctopCommand implements CommandExecutor {
|
||||
digit = "0" + String.valueOf(n);
|
||||
String[] splitx = x.split(":");
|
||||
// Format: 1. Playername - skill value
|
||||
player.sendMessage(digit + ". " + ChatColor.GREEN + splitx[1] + " - " + ChatColor.WHITE + splitx[0]);
|
||||
sender.sendMessage(digit + ". " + ChatColor.GREEN + splitx[1] + " - " + ChatColor.WHITE + splitx[0]);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
@@ -132,7 +119,7 @@ public class MctopCommand implements CommandExecutor {
|
||||
String remainder = args[0].substring(1); // Get remainder of word.
|
||||
String capitalized = firstLetter.toUpperCase() + remainder.toLowerCase();
|
||||
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.SkillLeaderboard", new Object[] { capitalized }));
|
||||
sender.sendMessage(mcLocale.getString("mcPlayerListener.SkillLeaderboard", new Object[] { capitalized }));
|
||||
if (args.length >= 2 && m.isInt(args[1])) {
|
||||
int n = 1; // For the page number
|
||||
int n2 = Integer.valueOf(args[1]);
|
||||
@@ -142,28 +129,28 @@ public class MctopCommand implements CommandExecutor {
|
||||
n = n * (n2 - 1);
|
||||
}
|
||||
// If a page number is specified
|
||||
HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.Read("SELECT " + lowercase + ", user_id FROM " + LoadProperties.MySQLtablePrefix + "skills WHERE " + lowercase + " > 0 ORDER BY `" + LoadProperties.MySQLtablePrefix + "skills`.`" + lowercase + "` DESC ");
|
||||
HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.read("SELECT " + lowercase + ", user_id FROM " + LoadProperties.MySQLtablePrefix + "skills WHERE " + lowercase + " > 0 ORDER BY `" + LoadProperties.MySQLtablePrefix + "skills`.`" + lowercase + "` DESC ");
|
||||
|
||||
for (int i = n; i <= n + 10; i++) {
|
||||
if (i > userslist.size() || mcMMO.database.Read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null)
|
||||
if (i > userslist.size() || mcMMO.database.read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null)
|
||||
break;
|
||||
HashMap<Integer, ArrayList<String>> username = mcMMO.database.Read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'");
|
||||
player.sendMessage(String.valueOf(i) + ". " + ChatColor.GREEN + userslist.get(i).get(0) + " - " + ChatColor.WHITE + username.get(1).get(0));
|
||||
HashMap<Integer, ArrayList<String>> username = mcMMO.database.read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'");
|
||||
sender.sendMessage(String.valueOf(i) + ". " + ChatColor.GREEN + userslist.get(i).get(0) + " - " + ChatColor.WHITE + username.get(1).get(0));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// If no page number is specified
|
||||
HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.Read("SELECT " + lowercase + ", user_id FROM " + LoadProperties.MySQLtablePrefix + "skills WHERE " + lowercase + " > 0 ORDER BY `" + LoadProperties.MySQLtablePrefix + "skills`.`" + lowercase + "` DESC ");
|
||||
HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.read("SELECT " + lowercase + ", user_id FROM " + LoadProperties.MySQLtablePrefix + "skills WHERE " + lowercase + " > 0 ORDER BY `" + LoadProperties.MySQLtablePrefix + "skills`.`" + lowercase + "` DESC ");
|
||||
for (int i = 1; i <= 10; i++) { // i<=userslist.size()
|
||||
if (i > userslist.size() || mcMMO.database.Read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null)
|
||||
if (i > userslist.size() || mcMMO.database.read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null)
|
||||
break;
|
||||
HashMap<Integer, ArrayList<String>> username = mcMMO.database.Read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'");
|
||||
player.sendMessage(String.valueOf(i) + ". " + ChatColor.GREEN + userslist.get(i).get(0) + " - " + ChatColor.WHITE + username.get(1).get(0));
|
||||
HashMap<Integer, ArrayList<String>> username = mcMMO.database.read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'");
|
||||
sender.sendMessage(String.valueOf(i) + ". " + ChatColor.GREEN + userslist.get(i).get(0) + " - " + ChatColor.WHITE + username.get(1).get(0));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (args.length >= 0) {
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevelLeaderboard"));
|
||||
sender.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevelLeaderboard"));
|
||||
if (args.length >= 1 && m.isInt(args[0])) {
|
||||
int n = 1; // For the page number
|
||||
int n2 = Integer.valueOf(args[0]);
|
||||
@@ -173,21 +160,21 @@ public class MctopCommand implements CommandExecutor {
|
||||
n = n * (n2 - 1);
|
||||
}
|
||||
// If a page number is specified
|
||||
HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.Read("SELECT " + powerlevel + ", user_id FROM " + LoadProperties.MySQLtablePrefix + "skills WHERE " + powerlevel + " > 0 ORDER BY " + powerlevel + " DESC ");
|
||||
HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.read("SELECT " + powerlevel + ", user_id FROM " + LoadProperties.MySQLtablePrefix + "skills WHERE " + powerlevel + " > 0 ORDER BY " + powerlevel + " DESC ");
|
||||
for (int i = n; i <= n + 10; i++) {
|
||||
if (i > userslist.size() || mcMMO.database.Read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null)
|
||||
if (i > userslist.size() || mcMMO.database.read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null)
|
||||
break;
|
||||
HashMap<Integer, ArrayList<String>> username = mcMMO.database.Read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'");
|
||||
player.sendMessage(String.valueOf(i) + ". " + ChatColor.GREEN + userslist.get(i).get(0) + " - " + ChatColor.WHITE + username.get(1).get(0));
|
||||
HashMap<Integer, ArrayList<String>> username = mcMMO.database.read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'");
|
||||
sender.sendMessage(String.valueOf(i) + ". " + ChatColor.GREEN + userslist.get(i).get(0) + " - " + ChatColor.WHITE + username.get(1).get(0));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.Read("SELECT " + powerlevel + ", user_id FROM " + LoadProperties.MySQLtablePrefix + "skills WHERE " + powerlevel + " > 0 ORDER BY " + powerlevel + " DESC ");
|
||||
HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.read("SELECT " + powerlevel + ", user_id FROM " + LoadProperties.MySQLtablePrefix + "skills WHERE " + powerlevel + " > 0 ORDER BY " + powerlevel + " DESC ");
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
if (i > userslist.size() || mcMMO.database.Read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null)
|
||||
if (i > userslist.size() || mcMMO.database.read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null)
|
||||
break;
|
||||
HashMap<Integer, ArrayList<String>> username = mcMMO.database.Read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'");
|
||||
player.sendMessage(String.valueOf(i) + ". " + ChatColor.GREEN + userslist.get(i).get(0) + " - " + ChatColor.WHITE + username.get(1).get(0));
|
||||
HashMap<Integer, ArrayList<String>> username = mcMMO.database.read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'");
|
||||
sender.sendMessage(String.valueOf(i) + ". " + ChatColor.GREEN + userslist.get(i).get(0) + " - " + ChatColor.WHITE + username.get(1).get(0));
|
||||
// System.out.println(username.get(1).get(0));
|
||||
// System.out.println("Mining : " + userslist.get(i).get(0) + ", User id : " + userslist.get(i).get(1));
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -12,15 +9,13 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
|
||||
public class ACommand implements CommandExecutor {
|
||||
private Logger log;
|
||||
|
||||
public ACommand() {
|
||||
this.log = Logger.getLogger("Minecraft");
|
||||
}
|
||||
public ACommand() {}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
@@ -34,7 +29,7 @@ public class ACommand implements CommandExecutor {
|
||||
|
||||
String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + "*Console*" + ChatColor.AQUA + "} ";
|
||||
|
||||
log.log(Level.INFO, "[A]<*Console*> " + aMessage);
|
||||
Bukkit.getLogger().info("[A]<*Console*> " + aMessage);
|
||||
|
||||
for (Player herp : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (mcPermissions.getInstance().adminChat(herp) || herp.isOp())
|
||||
@@ -43,10 +38,12 @@ public class ACommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
Player player = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
|
||||
if (!mcPermissions.getInstance().adminChat(player) && !player.isOp()) {
|
||||
if (player != null && !mcPermissions.getInstance().adminChat(player) && !player.isOp()) {
|
||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
@@ -59,8 +56,9 @@ public class ACommand implements CommandExecutor {
|
||||
aMessage = aMessage + " " + args[i];
|
||||
}
|
||||
|
||||
String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + player.getDisplayName() + ChatColor.AQUA + "} ";
|
||||
log.log(Level.INFO, "[A]<" + player.getDisplayName() + "> " + aMessage);
|
||||
String name = (LoadProperties.aDisplayNames) ? player.getDisplayName() : player.getName();
|
||||
String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + name + ChatColor.AQUA + "} ";
|
||||
Bukkit.getLogger().info("[A]<" + name + "> " + aMessage);
|
||||
for (Player herp : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (mcPermissions.getInstance().adminChat(herp) || herp.isOp())
|
||||
herp.sendMessage(aPrefix + aMessage);
|
||||
@@ -68,19 +66,21 @@ public class ACommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PP.getPartyChatMode())
|
||||
PP.togglePartyChat();
|
||||
|
||||
PP.toggleAdminChat();
|
||||
|
||||
if (PP.getAdminChatMode()) {
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOn"));
|
||||
// player.sendMessage(ChatColor.AQUA + "Admin chat toggled " + ChatColor.GREEN + "On");
|
||||
} else {
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOff"));
|
||||
// player.sendMessage(ChatColor.AQUA + "Admin chat toggled " + ChatColor.RED + "Off");
|
||||
if(player != null)
|
||||
{
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if (PP.getPartyChatMode())
|
||||
PP.togglePartyChat();
|
||||
|
||||
PP.toggleAdminChat();
|
||||
|
||||
if (PP.getAdminChatMode()) {
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOn"));
|
||||
} else {
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOff"));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
@@ -16,10 +15,6 @@ import com.gmail.nossr50.party.Party;
|
||||
public class AcceptCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!LoadProperties.acceptEnable) {
|
||||
sender.sendMessage("This command is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("This command does not support console useage.");
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
@@ -23,10 +22,6 @@ public class InviteCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!LoadProperties.inviteEnable) {
|
||||
sender.sendMessage("This command is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("This command does not support console useage.");
|
||||
@@ -48,7 +43,7 @@ public class InviteCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
if (args.length < 1) {
|
||||
player.sendMessage(ChatColor.RED + "Usage is /" + LoadProperties.invite + " <playername>");
|
||||
player.sendMessage(ChatColor.RED + "Usage is /invite <playername>");
|
||||
return true;
|
||||
}
|
||||
if (PP.inParty() && args.length >= 1 && (plugin.getServer().getPlayer(args[0]) != null)) {
|
||||
@@ -61,7 +56,7 @@ public class InviteCommand implements CommandExecutor {
|
||||
// target.sendMessage(ChatColor.RED+"ALERT: "+ChatColor.GREEN+"You have received a party invite for "+PPt.getInvite()+" from "+player.getName());
|
||||
target.sendMessage(mcLocale.getString("mcPlayerListener.ReceivedInvite1", new Object[] { PPt.getInvite(), player.getName() }));
|
||||
// target.sendMessage(ChatColor.YELLOW+"Type "+ChatColor.GREEN+LoadProperties.accept+ChatColor.YELLOW+" to accept the invite");
|
||||
target.sendMessage(mcLocale.getString("mcPlayerListener.ReceivedInvite2", new Object[] { LoadProperties.accept }));
|
||||
target.sendMessage(mcLocale.getString("mcPlayerListener.ReceivedInvite2", new Object[] { "/accept" }));
|
||||
} else {
|
||||
player.sendMessage(mcLocale.getString("Party.Locked"));
|
||||
return true;
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -18,18 +15,10 @@ import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
|
||||
public class PCommand implements CommandExecutor {
|
||||
private Logger log;
|
||||
|
||||
public PCommand() {
|
||||
this.log = Logger.getLogger("Minecraft");
|
||||
}
|
||||
public PCommand() {}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!LoadProperties.partyEnable) {
|
||||
sender.sendMessage("This command is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Console message?
|
||||
if (!(sender instanceof Player)) {
|
||||
@@ -42,7 +31,7 @@ public class PCommand implements CommandExecutor {
|
||||
|
||||
String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE + "*Console*" + ChatColor.GREEN + ") ";
|
||||
|
||||
log.log(Level.INFO, "[P](" + args[0] + ")" + "<*Console*> " + pMessage);
|
||||
Bukkit.getLogger().info("[P](" + args[0] + ")" + "<*Console*> " + pMessage);
|
||||
|
||||
for (Player herp : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (Users.getProfile(herp).inParty()) {
|
||||
@@ -65,13 +54,19 @@ public class PCommand implements CommandExecutor {
|
||||
// Not a toggle, a message
|
||||
|
||||
if (args.length >= 1) {
|
||||
if(!PP.inParty()) {
|
||||
player.sendMessage("You're not in a party."); //TODO: Use mcLocale
|
||||
return true;
|
||||
}
|
||||
|
||||
String pMessage = args[0];
|
||||
for (int i = 1; i <= args.length - 1; i++) {
|
||||
pMessage = pMessage + " " + args[i];
|
||||
}
|
||||
String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE + player.getDisplayName() + ChatColor.GREEN + ") ";
|
||||
|
||||
log.log(Level.INFO, "[P](" + PP.getParty() + ")" + "<" + player.getDisplayName() + "> " + pMessage);
|
||||
String name = (LoadProperties.pDisplayNames) ? player.getDisplayName() : player.getName();
|
||||
String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE + name + ChatColor.GREEN + ") ";
|
||||
Bukkit.getLogger().info("[P](" + PP.getParty() + ")<" + name + "> " + pMessage);
|
||||
|
||||
for (Player herp : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (Users.getProfile(herp).inParty()) {
|
||||
@@ -89,10 +84,8 @@ public class PCommand implements CommandExecutor {
|
||||
PP.togglePartyChat();
|
||||
|
||||
if (PP.getPartyChatMode()) {
|
||||
// player.sendMessage(ChatColor.GREEN + "Party Chat Toggled On");
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.PartyChatOn"));
|
||||
} else {
|
||||
// player.sendMessage(ChatColor.GREEN + "Party Chat Toggled " + ChatColor.RED + "Off");
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.PartyChatOff"));
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
@@ -17,10 +16,6 @@ import com.gmail.nossr50.party.Party;
|
||||
public class PartyCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!LoadProperties.partyEnable) {
|
||||
sender.sendMessage("This command is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("This command does not support console useage.");
|
||||
@@ -42,9 +37,9 @@ public class PartyCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (args.length == 0 && !PP.inParty()) {
|
||||
player.sendMessage(mcLocale.getString("Party.Help1", new Object[] { LoadProperties.party }));
|
||||
player.sendMessage(mcLocale.getString("Party.Help2", new Object[] { LoadProperties.party }));
|
||||
player.sendMessage(mcLocale.getString("Party.Help3", new Object[] { LoadProperties.party }));
|
||||
player.sendMessage(mcLocale.getString("Party.Help1", new Object[] { "/party "}));
|
||||
player.sendMessage(mcLocale.getString("Party.Help2", new Object[] { "/party "}));
|
||||
player.sendMessage(mcLocale.getString("Party.Help3", new Object[] { "/party " }));
|
||||
return true;
|
||||
} else if (args.length == 0 && PP.inParty()) {
|
||||
String tempList = "";
|
||||
@@ -73,6 +68,44 @@ public class PartyCommand implements CommandExecutor {
|
||||
}
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.YouAreInParty", new Object[] { PP.getParty() }));
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.PartyMembers") + " (" + tempList + ChatColor.GREEN + ")");
|
||||
|
||||
//Master Apprentice Stuff
|
||||
//Show the player all their bonuses when they type /party
|
||||
|
||||
/*
|
||||
for(Player a : Party.getInstance().getPartyMembers(player))
|
||||
{
|
||||
if(Party.getInstance().isPartyLeader(a.getName(), PP.getParty()) && !a.getName().equals(player.getName()))
|
||||
{
|
||||
PlayerProfile LP = Users.getProfile(a);
|
||||
for(SkillType type : SkillType.values())
|
||||
{
|
||||
//Skip this one
|
||||
if(type == SkillType.ALL)
|
||||
continue;
|
||||
|
||||
if(LP.getSkillLevel(type) > PP.getSkillLevel(type))
|
||||
{
|
||||
//Tell them what their skill bonus is for this skill
|
||||
int leaderLevel = LP.getSkillLevel(type);
|
||||
int difference = leaderLevel - PP.getSkillLevel(type);
|
||||
|
||||
double bonusModifier = (difference*0.75D)/100D;
|
||||
double trueBonus = bonusModifier * 100;
|
||||
player.sendMessage("You get "+trueBonus+"% more XP from "+type.toString());
|
||||
//double percent = (trueBonus/100)*100;
|
||||
} else
|
||||
{
|
||||
//Tell them they have no bonus.. or not
|
||||
}
|
||||
}
|
||||
} else if(Party.getInstance().isPartyLeader(a.getName(), PP.getParty()) && a.getName().equals(player.getName()))
|
||||
{
|
||||
//Tell them they are providing bonuses
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return true;
|
||||
} else if (args.length == 1) {
|
||||
if (args[0].equals("q") && PP.inParty()) {
|
||||
@@ -81,13 +114,13 @@ public class PartyCommand implements CommandExecutor {
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.LeftParty"));
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("?")) {
|
||||
player.sendMessage(mcLocale.getString("Party.Help4", new Object[] { LoadProperties.party }));
|
||||
player.sendMessage(mcLocale.getString("Party.Help2", new Object[] { LoadProperties.party }));
|
||||
player.sendMessage(mcLocale.getString("Party.Help5", new Object[] { LoadProperties.party }));
|
||||
player.sendMessage(mcLocale.getString("Party.Help6", new Object[] { LoadProperties.party }));
|
||||
player.sendMessage(mcLocale.getString("Party.Help7", new Object[] { LoadProperties.party }));
|
||||
player.sendMessage(mcLocale.getString("Party.Help8", new Object[] { LoadProperties.party }));
|
||||
player.sendMessage(mcLocale.getString("Party.Help9", new Object[] { LoadProperties.party }));
|
||||
player.sendMessage(mcLocale.getString("Party.Help4", new Object[] { "/party " }));
|
||||
player.sendMessage(mcLocale.getString("Party.Help2", new Object[] { "/party " }));
|
||||
player.sendMessage(mcLocale.getString("Party.Help5", new Object[] { "/party " }));
|
||||
player.sendMessage(mcLocale.getString("Party.Help6", new Object[] { "/party " }));
|
||||
player.sendMessage(mcLocale.getString("Party.Help7", new Object[] { "/party " }));
|
||||
player.sendMessage(mcLocale.getString("Party.Help8", new Object[] { "/party " }));
|
||||
player.sendMessage(mcLocale.getString("Party.Help9", new Object[] { "/party " }));
|
||||
} else if (args[0].equalsIgnoreCase("lock")) {
|
||||
if (PP.inParty()) {
|
||||
if (Pinstance.isPartyLeader(player.getName(), PP.getParty())) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
|
||||
public class PtpCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
@@ -22,10 +23,6 @@ public class PtpCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!LoadProperties.ptpEnable) {
|
||||
sender.sendMessage("This command is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("This command does not support console useage.");
|
||||
@@ -39,10 +36,24 @@ public class PtpCommand implements CommandExecutor {
|
||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!Party.getInstance().isParty(PP.getParty()))
|
||||
{
|
||||
player.sendMessage(ChatColor.RED+"You are not in a party!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(PP.getRecentlyHurt()+(LoadProperties.ptpCommandCooldown*1000) > System.currentTimeMillis())
|
||||
{
|
||||
player.sendMessage(ChatColor.RED+"You've been hurt in the last " + LoadProperties.ptpCommandCooldown + " seconds and cannnot teleport.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 1) {
|
||||
player.sendMessage(ChatColor.RED + "Usage is /" + LoadProperties.ptp + " <playername>");
|
||||
player.sendMessage(ChatColor.RED + "Usage is /ptp <playername>");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.getServer().getPlayer(args[0]) == null) {
|
||||
player.sendMessage("That is not a valid player");
|
||||
}
|
||||
@@ -54,9 +65,11 @@ public class PtpCommand implements CommandExecutor {
|
||||
player.teleport(target);
|
||||
player.sendMessage(ChatColor.GREEN + "You have teleported to " + target.getName());
|
||||
target.sendMessage(ChatColor.GREEN + player.getName() + " has teleported to you.");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "That player is in a different party than you.");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,11 +10,13 @@ import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
|
||||
public class AcrobaticsCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
sender.sendMessage("This command does not support console useage.");
|
||||
return true;
|
||||
}
|
||||
@@ -46,7 +48,9 @@ public class AcrobaticsCommand implements CommandExecutor {
|
||||
player.sendMessage(mcLocale.getString("m.AcrobaticsRollChance", new Object[] { percentage }));
|
||||
player.sendMessage(mcLocale.getString("m.AcrobaticsGracefulRollChance", new Object[] { gracepercentage }));
|
||||
player.sendMessage(mcLocale.getString("m.AcrobaticsDodgeChance", new Object[] { dodgepercentage }));
|
||||
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.ACROBATICS, player, args);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
|
||||
public class ArcheryCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -57,6 +58,8 @@ public class ArcheryCommand implements CommandExecutor {
|
||||
player.sendMessage(mcLocale.getString("m.ArcheryDazeChance", new Object[] { percentagedaze }));
|
||||
player.sendMessage(mcLocale.getString("m.ArcheryRetrieveChance", new Object[] { percentage }));
|
||||
player.sendMessage(mcLocale.getString("m.ArcheryIgnitionLength", new Object[] { (ignition / 20) }));
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.ARCHERY, player, args);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -26,11 +26,17 @@ public class AxesCommand implements CommandExecutor {
|
||||
|
||||
float skillvalue = (float) PP.getSkillLevel(SkillType.AXES);
|
||||
if (PP.getSkillLevel(SkillType.AXES) < 750)
|
||||
percentage = String.valueOf((skillvalue / 1000) * 100);
|
||||
percentage = String.valueOf((skillvalue / 2000) * 100);
|
||||
else
|
||||
percentage = "75";
|
||||
percentage = "37.5";
|
||||
|
||||
int bonusDmg = Users.getProfile(player).getSkillLevel(SkillType.AXES)/50;
|
||||
if(bonusDmg > 4)
|
||||
bonusDmg = 4;
|
||||
|
||||
int ticks = 2;
|
||||
short durDmg = 5;
|
||||
durDmg+=Users.getProfile(player).getSkillLevel(SkillType.AXES)/30;
|
||||
int x = PP.getSkillLevel(SkillType.AXES);
|
||||
while (x >= 50) {
|
||||
x -= 50;
|
||||
@@ -47,15 +53,15 @@ public class AxesCommand implements CommandExecutor {
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsAxes1_0"), mcLocale.getString("m.EffectsAxes1_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsAxes2_0"), mcLocale.getString("m.EffectsAxes2_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsAxes3_0"), mcLocale.getString("m.EffectsAxes3_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsAxes4_0"), mcLocale.getString("m.EffectsAxes4_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsAxes5_0"), mcLocale.getString("m.EffectsAxes5_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.SkillHeader", new Object[] { mcLocale.getString("m.YourStats") }));
|
||||
player.sendMessage(mcLocale.getString("m.AxesCritChance", new Object[] { percentage }));
|
||||
|
||||
if (PP.getSkillLevel(SkillType.AXES) < 500)
|
||||
player.sendMessage(mcLocale.getString("m.AbilityLockTemplate", new Object[] { mcLocale.getString("m.AbilLockAxes1") }));
|
||||
else
|
||||
player.sendMessage(mcLocale.getString("m.AbilityBonusTemplate", new Object[] { mcLocale.getString("m.AbilBonusAxes1_0"), mcLocale.getString("m.AbilBonusAxes1_1") }));
|
||||
|
||||
player.sendMessage(mcLocale.getString("m.AxesSkullLength", new Object[] { ticks }));
|
||||
|
||||
player.sendMessage(mcLocale.getString("m.AbilityBonusTemplate", new Object[] { mcLocale.getString("m.AbilBonusAxes1_0"), mcLocale.getString("m.AbilBonusAxes1_1", new Object[] {bonusDmg}) }));
|
||||
player.sendMessage(mcLocale.getString("m.AbilityBonusTemplate", new Object[] { mcLocale.getString("m.AbilBonusAxes2_0"), mcLocale.getString("m.AbilBonusAxes2_1", new Object[] {durDmg}) }));
|
||||
player.sendMessage(mcLocale.getString("m.AbilityBonusTemplate", new Object[] { mcLocale.getString("m.AbilBonusAxes3_0"), mcLocale.getString("m.AbilBonusAxes3_1", new Object[] {2}) }));
|
||||
player.sendMessage(mcLocale.getString("m.AxesSkullLength", new Object[] { ticks }));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
|
||||
public class ExcavationCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -29,6 +30,7 @@ public class ExcavationCommand implements CommandExecutor {
|
||||
ticks++;
|
||||
}
|
||||
|
||||
player.sendMessage("");
|
||||
player.sendMessage(mcLocale.getString("m.SkillHeader", new Object[] { mcLocale.getString("m.SkillExcavation") }));
|
||||
player.sendMessage(mcLocale.getString("m.XPGain", new Object[] { mcLocale.getString("m.XPGainExcavation") }));
|
||||
|
||||
@@ -39,8 +41,10 @@ public class ExcavationCommand implements CommandExecutor {
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsExcavation1_0"), mcLocale.getString("m.EffectsExcavation1_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsExcavation2_0"), mcLocale.getString("m.EffectsExcavation2_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.SkillHeader", new Object[] { mcLocale.getString("m.YourStats") }));
|
||||
player.sendMessage(mcLocale.getString("m.ExcavationGreenTerraLength", new Object[] { ticks }));
|
||||
player.sendMessage(mcLocale.getString("m.ExcavationGigaDrillBreakerLength", new Object[] { ticks }));
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.EXCAVATION, player, args);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.skills.Fishing;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
|
||||
public class FishingCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -41,6 +42,8 @@ public class FishingCommand implements CommandExecutor {
|
||||
player.sendMessage(mcLocale.getString("m.AbilityLockTemplate", new Object[] { mcLocale.getString("m.AbilLockFishing1") }));
|
||||
else
|
||||
player.sendMessage(mcLocale.getString("m.ShakeInfo", new Object[] { Fishing.getFishingLootTier(PP) }));
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.FISHING, player, args);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
|
||||
public class HerbalismCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -29,6 +30,10 @@ public class HerbalismCommand implements CommandExecutor {
|
||||
bonus++;
|
||||
if (PP.getSkillLevel(SkillType.HERBALISM) >= 600)
|
||||
bonus++;
|
||||
if (PP.getSkillLevel(SkillType.HERBALISM) >= 800)
|
||||
bonus++;
|
||||
if (PP.getSkillLevel(SkillType.HERBALISM) >= 1000)
|
||||
bonus++;
|
||||
|
||||
int ticks = 2;
|
||||
int x = PP.getSkillLevel(SkillType.HERBALISM);
|
||||
@@ -51,12 +56,16 @@ public class HerbalismCommand implements CommandExecutor {
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsHerbalism1_0"), mcLocale.getString("m.EffectsHerbalism1_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsHerbalism2_0"), mcLocale.getString("m.EffectsHerbalism2_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsHerbalism3_0"), mcLocale.getString("m.EffectsHerbalism3_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsHerbalism4_0"), mcLocale.getString("m.EffectsHerbalism4_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsHerbalism5_0"), mcLocale.getString("m.EffectsHerbalism5_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.SkillHeader", new Object[] { mcLocale.getString("m.YourStats") }));
|
||||
player.sendMessage(mcLocale.getString("m.HerbalismGreenTerraLength", new Object[] { ticks }));
|
||||
player.sendMessage(mcLocale.getString("m.HerbalismGreenThumbChance", new Object[] { gpercentage }));
|
||||
player.sendMessage(mcLocale.getString("m.HerbalismGreenThumbStage", new Object[] { bonus }));
|
||||
player.sendMessage(mcLocale.getString("m.HerbalismFoodPlus", new Object[] { bonus } ));
|
||||
player.sendMessage(mcLocale.getString("m.HerbalismDoubleDropChance", new Object[] { percentage }));
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.HERBALISM, player, args);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
|
||||
public class MiningCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -30,6 +31,46 @@ public class MiningCommand implements CommandExecutor {
|
||||
x -= 50;
|
||||
ticks++;
|
||||
}
|
||||
|
||||
int rank = 0;
|
||||
int damage = 0;
|
||||
int radius = 0;
|
||||
if(PP.getSkillLevel(SkillType.MINING) >= 125 && PP.getSkillLevel(SkillType.MINING) < 250)
|
||||
rank = 1;
|
||||
if(PP.getSkillLevel(SkillType.MINING) >= 250 && PP.getSkillLevel(SkillType.MINING) < 375){
|
||||
rank = 2;
|
||||
radius = 1;
|
||||
}
|
||||
if(PP.getSkillLevel(SkillType.MINING) >= 375 && PP.getSkillLevel(SkillType.MINING) < 500){
|
||||
rank = 3;
|
||||
radius = 1;
|
||||
}
|
||||
if(PP.getSkillLevel(SkillType.MINING) >= 500 && PP.getSkillLevel(SkillType.MINING) < 625){
|
||||
rank = 4;
|
||||
damage = 25;
|
||||
radius = 2;
|
||||
}
|
||||
if(PP.getSkillLevel(SkillType.MINING) >= 625 && PP.getSkillLevel(SkillType.MINING) < 750){
|
||||
rank = 5;
|
||||
damage = 25;
|
||||
radius = 2;
|
||||
}
|
||||
if(PP.getSkillLevel(SkillType.MINING) >= 750 && PP.getSkillLevel(SkillType.MINING) < 875){
|
||||
rank = 6;
|
||||
damage = 50;
|
||||
radius = 3;
|
||||
}
|
||||
if(PP.getSkillLevel(SkillType.MINING) >= 875 && PP.getSkillLevel(SkillType.MINING) < 1000){
|
||||
rank = 7;
|
||||
damage = 50;
|
||||
radius = 3;
|
||||
}
|
||||
if(PP.getSkillLevel(SkillType.MINING) >= 1000){
|
||||
rank = 8;
|
||||
damage = 100;
|
||||
radius = 4;
|
||||
}
|
||||
|
||||
player.sendMessage(mcLocale.getString("m.SkillHeader", new Object[] { mcLocale.getString("m.SkillMining") }));
|
||||
player.sendMessage(mcLocale.getString("m.XPGain", new Object[] { mcLocale.getString("m.XPGainMining") }));
|
||||
|
||||
@@ -39,10 +80,53 @@ public class MiningCommand implements CommandExecutor {
|
||||
player.sendMessage(mcLocale.getString("m.SkillHeader", new Object[] { mcLocale.getString("m.Effects") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsMining1_0"), mcLocale.getString("m.EffectsMining1_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsMining2_0"), mcLocale.getString("m.EffectsMining2_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsMining3_0"), mcLocale.getString("m.EffectsMining3_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsMining4_0"), mcLocale.getString("m.EffectsMining4_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsMining5_0"), mcLocale.getString("m.EffectsMining5_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.SkillHeader", new Object[] { mcLocale.getString("m.YourStats") }));
|
||||
player.sendMessage(mcLocale.getString("m.MiningDoubleDropChance", new Object[] { percentage }));
|
||||
player.sendMessage(mcLocale.getString("m.MiningSuperBreakerLength", new Object[] { ticks }));
|
||||
|
||||
if (PP.getSkillLevel(SkillType.MINING) < 125)
|
||||
player.sendMessage(mcLocale.getString("m.AbilityLockTemplate", new Object[] { mcLocale.getString("m.AbilLockMining1") }));
|
||||
else{
|
||||
switch (rank){
|
||||
case 1:
|
||||
player.sendMessage(mcLocale.getString("m.MiningBlastMining", new Object[] { rank, mcLocale.getString("m.BlastMining1") }));
|
||||
break;
|
||||
case 2:
|
||||
player.sendMessage(mcLocale.getString("m.MiningBlastMining", new Object[] { rank, mcLocale.getString("m.BlastMining2") }));
|
||||
break;
|
||||
case 3:
|
||||
player.sendMessage(mcLocale.getString("m.MiningBlastMining", new Object[] { rank, mcLocale.getString("m.BlastMining3") }));
|
||||
break;
|
||||
case 4:
|
||||
player.sendMessage(mcLocale.getString("m.MiningBlastMining", new Object[] { rank, mcLocale.getString("m.BlastMining4") }));
|
||||
break;
|
||||
case 5:
|
||||
player.sendMessage(mcLocale.getString("m.MiningBlastMining", new Object[] { rank, mcLocale.getString("m.BlastMining5") }));
|
||||
break;
|
||||
case 6:
|
||||
player.sendMessage(mcLocale.getString("m.MiningBlastMining", new Object[] { rank, mcLocale.getString("m.BlastMining6") }));
|
||||
break;
|
||||
case 7:
|
||||
player.sendMessage(mcLocale.getString("m.MiningBlastMining", new Object[] { rank, mcLocale.getString("m.BlastMining7") }));
|
||||
break;
|
||||
case 8:
|
||||
player.sendMessage(mcLocale.getString("m.MiningBlastMining", new Object[] { rank, mcLocale.getString("m.BlastMining8") }));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (PP.getSkillLevel(SkillType.MINING) < 250)
|
||||
player.sendMessage(mcLocale.getString("m.AbilityLockTemplate", new Object[] { mcLocale.getString("m.AbilLockMining2") }));
|
||||
else
|
||||
player.sendMessage(mcLocale.getString("m.MiningBiggerBombs", new Object[] { radius }));
|
||||
if (PP.getSkillLevel(SkillType.MINING) < 500)
|
||||
player.sendMessage(mcLocale.getString("m.AbilityLockTemplate", new Object[] { mcLocale.getString("m.AbilLockMining3") }));
|
||||
else
|
||||
player.sendMessage(mcLocale.getString("m.MiningDemolitionsExpertDamageDecrease", new Object[] { damage }));
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.MINING, player, args);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.skills.Repair;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
|
||||
public class RepairCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -42,12 +43,12 @@ public class RepairCommand implements CommandExecutor {
|
||||
player.sendMessage(mcLocale.getString("m.SkillHeader", new Object[] { mcLocale.getString("m.YourStats") }));
|
||||
player.sendMessage(mcLocale.getString("m.RepairRepairMastery", new Object[] { repairmastery }));
|
||||
player.sendMessage(mcLocale.getString("m.RepairSuperRepairChance", new Object[] { percentage }));
|
||||
player.sendMessage(mcLocale.getString("m.ArcaneForgingRank", new Object[] { Repair.getArcaneForgingRank(PP) }));
|
||||
player.sendMessage(mcLocale.getString("m.ArcaneEnchantKeepChance", new Object[] { Repair.getEnchantChance(Repair.getArcaneForgingRank(PP)) }));
|
||||
player.sendMessage(mcLocale.getString("m.ArcaneEnchantDowngradeChance", new Object[] { Repair.getDowngradeChance(Repair.getArcaneForgingRank(PP)) }));
|
||||
player.sendMessage(mcLocale.getString("m.ArcaneForgingMilestones"));
|
||||
player.sendMessage(mcLocale.getString("m.ArcaneForgingMilestones2"));
|
||||
|
||||
player.sendMessage(mcLocale.getString("m.ArcaneForgingRank", new Object[] { Repair.getArcaneForgingRank(PP.getSkillLevel(SkillType.REPAIR)) }));
|
||||
player.sendMessage(mcLocale.getString("m.ArcaneEnchantKeepChance", new Object[] { Repair.getEnchantChance(Repair.getArcaneForgingRank(PP.getSkillLevel(SkillType.REPAIR))) }));
|
||||
player.sendMessage(mcLocale.getString("m.ArcaneEnchantDowngradeChance", new Object[] { Repair.getDowngradeChance(Repair.getArcaneForgingRank(PP.getSkillLevel(SkillType.REPAIR))) }));
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.REPAIR, player, args);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
|
||||
public class SwordsCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -61,8 +62,10 @@ public class SwordsCommand implements CommandExecutor {
|
||||
player.sendMessage(mcLocale.getString("m.SwordsCounterAttChance", new Object[] { counterattackpercentage }));
|
||||
player.sendMessage(mcLocale.getString("m.SwordsBleedLength", new Object[] { bleedrank }));
|
||||
player.sendMessage(mcLocale.getString("m.SwordsTickNote"));
|
||||
player.sendMessage(mcLocale.getString("m.SwordsBleedLength", new Object[] { percentage }));
|
||||
player.sendMessage(mcLocale.getString("m.SwordsBleedChance", new Object[] { percentage }));
|
||||
player.sendMessage(mcLocale.getString("m.SwordsSSLength", new Object[] { ticks }));
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.SWORDS, player, args);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
|
||||
public class TamingCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -40,6 +41,7 @@ public class TamingCommand implements CommandExecutor {
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsTaming5_0"), mcLocale.getString("m.EffectsTaming5_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsTaming6_0"), mcLocale.getString("m.EffectsTaming6_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsTaming7_0"), mcLocale.getString("m.EffectsTaming7_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsTaming8_0"), mcLocale.getString("m.EffectsTaming8_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTaming7_2", new Object[] { LoadProperties.bonesConsumedByCOTW }));
|
||||
player.sendMessage(mcLocale.getString("m.SkillHeader", new Object[] { mcLocale.getString("m.YourStats") }));
|
||||
|
||||
@@ -62,8 +64,14 @@ public class TamingCommand implements CommandExecutor {
|
||||
player.sendMessage(mcLocale.getString("m.AbilityLockTemplate", new Object[] { mcLocale.getString("m.AbilLockTaming4") }));
|
||||
else
|
||||
player.sendMessage(mcLocale.getString("m.AbilityBonusTemplate", new Object[] { mcLocale.getString("m.AbilBonusTaming4_0"), mcLocale.getString("m.AbilBonusTaming4_1") }));
|
||||
|
||||
if (PP.getSkillLevel(SkillType.TAMING) < 50)
|
||||
player.sendMessage(mcLocale.getString("m.AbilityLockTemplate", new Object[] { mcLocale.getString("m.AbilLockTaming5") }));
|
||||
else
|
||||
player.sendMessage(mcLocale.getString("m.AbilityBonusTemplate", new Object[] { mcLocale.getString("m.AbilBonusTaming5_0"), mcLocale.getString("m.AbilBonusTaming5_1") }));
|
||||
|
||||
player.sendMessage(mcLocale.getString("m.TamingGoreChance", new Object[] { percentage }));
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.TAMING, player, args);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
|
||||
public class UnarmedCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -26,9 +27,9 @@ public class UnarmedCommand implements CommandExecutor {
|
||||
float skillvalue = (float) PP.getSkillLevel(SkillType.UNARMED);
|
||||
|
||||
if (PP.getSkillLevel(SkillType.UNARMED) < 1000)
|
||||
percentage = String.valueOf((skillvalue / 4000) * 100);
|
||||
percentage = String.valueOf((skillvalue / 3000) * 100);
|
||||
else
|
||||
percentage = "25";
|
||||
percentage = "33.3";
|
||||
|
||||
if (PP.getSkillLevel(SkillType.UNARMED) < 1000)
|
||||
arrowpercentage = String.valueOf(((skillvalue / 1000) * 100) / 2);
|
||||
@@ -41,6 +42,11 @@ public class UnarmedCommand implements CommandExecutor {
|
||||
x -= 50;
|
||||
ticks++;
|
||||
}
|
||||
|
||||
int bonus = 3 + (PP.getSkillLevel(SkillType.UNARMED)/50);
|
||||
|
||||
if(bonus > 8)
|
||||
bonus = 8;
|
||||
|
||||
player.sendMessage(mcLocale.getString("m.SkillHeader", new Object[] { mcLocale.getString("m.SkillUnarmed") }));
|
||||
player.sendMessage(mcLocale.getString("m.XPGain", new Object[] { mcLocale.getString("m.XPGainUnarmed") }));
|
||||
@@ -52,22 +58,17 @@ public class UnarmedCommand implements CommandExecutor {
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsUnarmed1_0"), mcLocale.getString("m.EffectsUnarmed1_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsUnarmed2_0"), mcLocale.getString("m.EffectsUnarmed2_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsUnarmed3_0"), mcLocale.getString("m.EffectsUnarmed3_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsUnarmed4_0"), mcLocale.getString("m.EffectsUnarmed4_1") }));
|
||||
//player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsUnarmed4_0"), mcLocale.getString("m.EffectsUnarmed4_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.EffectsTemplate", new Object[] { mcLocale.getString("m.EffectsUnarmed5_0"), mcLocale.getString("m.EffectsUnarmed5_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.SkillHeader", new Object[] { mcLocale.getString("m.YourStats") }));
|
||||
player.sendMessage(mcLocale.getString("m.UnarmedArrowDeflectChance", new Object[] { arrowpercentage }));
|
||||
player.sendMessage(mcLocale.getString("m.UnarmedDisarmChance", new Object[] { percentage }));
|
||||
|
||||
if (PP.getSkillLevel(SkillType.UNARMED) < 250) {
|
||||
player.sendMessage(mcLocale.getString("m.AbilityLockTemplate", new Object[] { mcLocale.getString("m.AbilLockUnarmed1") }));
|
||||
} else if (PP.getSkillLevel(SkillType.UNARMED) >= 250 && PP.getSkillLevel(SkillType.UNARMED) < 500) {
|
||||
player.sendMessage(mcLocale.getString("m.AbilityBonusTemplate", new Object[] { mcLocale.getString("m.AbilBonusUnarmed1_0"), mcLocale.getString("m.AbilBonusUnarmed1_1") }));
|
||||
player.sendMessage(mcLocale.getString("m.AbilityLockTemplate", new Object[] { mcLocale.getString("m.AbilLockUnarmed2") }));
|
||||
} else {
|
||||
player.sendMessage(mcLocale.getString("m.AbilityBonusTemplate", new Object[] { mcLocale.getString("m.AbilBonusUnarmed2_0"), mcLocale.getString("m.AbilBonusUnarmed2_1") }));
|
||||
}
|
||||
player.sendMessage(mcLocale.getString("m.AbilityBonusTemplate", new Object[] { mcLocale.getString("m.AbilBonusUnarmed2_0"), mcLocale.getString("m.AbilBonusUnarmed2_1", new Object[] {bonus}) }));
|
||||
|
||||
player.sendMessage(mcLocale.getString("m.UnarmedBerserkLength", new Object[] { ticks }));
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.UNARMED, player, args);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
|
||||
public class WoodcuttingCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -51,6 +52,8 @@ public class WoodcuttingCommand implements CommandExecutor {
|
||||
player.sendMessage(mcLocale.getString("m.WoodCuttingDoubleDropChance", new Object[] { percentage }));
|
||||
player.sendMessage(mcLocale.getString("m.WoodCuttingTreeFellerLength", new Object[] { ticks }));
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.WOODCUTTING, player, args);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class XplockCommand implements CommandExecutor {
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if (args.length >= 1 && Skills.isSkill(args[0]) && mcPermissions.permission(player, "mcmmo.skills." + Skills.getSkillType(args[0]).toString().toLowerCase())) {
|
||||
if (args.length >= 1 && Skills.isSkill(args[0]) && mcPermissions.getInstance().permission(player, "mcmmo.skills." + Skills.getSkillType(args[0]).toString().toLowerCase())) {
|
||||
if (PP.getXpBarLocked()) {
|
||||
PP.setSkillLock(Skills.getSkillType(args[0]));
|
||||
player.sendMessage(mcLocale.getString("Commands.xplock.locked", new Object[] { m.getCapitalized(PP.getSkillLock().toString()) }));
|
||||
@@ -52,7 +52,7 @@ public class XplockCommand implements CommandExecutor {
|
||||
}
|
||||
} else if (args.length >= 1 && !Skills.isSkill(args[0])) {
|
||||
player.sendMessage("Commands.xplock.invalid");
|
||||
} else if (args.length >= 2 && Skills.isSkill(args[0]) && !mcPermissions.permission(player, "mcmmo.skills." + Skills.getSkillType(args[0]).toString().toLowerCase())) {
|
||||
} else if (args.length >= 2 && Skills.isSkill(args[0]) && !mcPermissions.getInstance().permission(player, "mcmmo.skills." + Skills.getSkillType(args[0]).toString().toLowerCase())) {
|
||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
|
||||
55
src/main/java/com/gmail/nossr50/config/ConfigLoader.java
Normal file
55
src/main/java/com/gmail/nossr50/config/ConfigLoader.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public abstract class ConfigLoader {
|
||||
|
||||
protected static File configFile;
|
||||
protected static File dataFolder;
|
||||
protected final mcMMO plugin;
|
||||
protected static FileConfiguration config;
|
||||
|
||||
public ConfigLoader(mcMMO plugin, String fileName){
|
||||
this.plugin = plugin;
|
||||
dataFolder = plugin.getDataFolder();
|
||||
configFile = new File(dataFolder, File.separator + fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load this config file.
|
||||
*/
|
||||
protected abstract void load();
|
||||
|
||||
/**
|
||||
* Save this config file.
|
||||
*/
|
||||
private static void saveConfig() {
|
||||
try {
|
||||
config.save(configFile);
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the defaults to this config file.
|
||||
*/
|
||||
protected void addDefaults() {
|
||||
|
||||
// Load from included config.yml
|
||||
config.options().copyDefaults(true);
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the keys from this config file.
|
||||
*/
|
||||
protected abstract void loadKeys();
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
286
src/main/java/com/gmail/nossr50/config/LoadTreasures.java
Normal file
286
src/main/java/com/gmail/nossr50/config/LoadTreasures.java
Normal file
@@ -0,0 +1,286 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.Treasure;
|
||||
|
||||
public class LoadTreasures extends ConfigLoader{
|
||||
|
||||
public static List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
|
||||
public static List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
|
||||
public static List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
|
||||
public static List<ExcavationTreasure> excavationFromGravel = new ArrayList<ExcavationTreasure>();
|
||||
public static List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
|
||||
public static List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
|
||||
public static List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
|
||||
public static List<FishingTreasure> fishingRewardsTier1 = new ArrayList<FishingTreasure>();
|
||||
public static List<FishingTreasure> fishingRewardsTier2 = new ArrayList<FishingTreasure>();
|
||||
public static List<FishingTreasure> fishingRewardsTier3 = new ArrayList<FishingTreasure>();
|
||||
public static List<FishingTreasure> fishingRewardsTier4 = new ArrayList<FishingTreasure>();
|
||||
public static List<FishingTreasure> fishingRewardsTier5 = new ArrayList<FishingTreasure>();
|
||||
|
||||
public LoadTreasures(mcMMO plugin) {
|
||||
super(plugin, "treasures.yml");
|
||||
config = plugin.getTreasuresConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
// If it doesn't exist, copy it from the .jar
|
||||
if (!configFile.exists()) {
|
||||
dataFolder.mkdir();
|
||||
plugin.saveTreasuresConfig();
|
||||
}
|
||||
|
||||
addDefaults();
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
plugin.getLogger().info("Loading mcMMO treasures.yml File...");
|
||||
|
||||
Map<String, Treasure> treasures = new HashMap<String, Treasure>();
|
||||
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures");
|
||||
Set<String> treasureConfigSet = treasureSection.getKeys(false);
|
||||
Iterator<String> iterator = treasureConfigSet.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String treasureName = iterator.next();
|
||||
|
||||
// Validate all the things!
|
||||
List<String> reason = new ArrayList<String>();
|
||||
|
||||
/*
|
||||
* ID, Amount, and Data
|
||||
*/
|
||||
|
||||
if (!config.contains("Treasures." + treasureName + ".ID")) {
|
||||
reason.add("Missing ID");
|
||||
}
|
||||
|
||||
if (!config.contains("Treasures." + treasureName + ".Amount")) {
|
||||
reason.add("Missing Amount");
|
||||
}
|
||||
|
||||
if (!config.contains("Treasures." + treasureName + ".Data")) {
|
||||
reason.add("Missing Data");
|
||||
}
|
||||
|
||||
int id = config.getInt("Treasures." + treasureName + ".ID");
|
||||
int amount = config.getInt("Treasures." + treasureName + ".Amount");
|
||||
int data = config.getInt("Treasures." + treasureName + ".Data");
|
||||
|
||||
if (Material.getMaterial(id) == null) {
|
||||
reason.add("Invlid id: " + id);
|
||||
}
|
||||
|
||||
if (amount < 1) {
|
||||
reason.add("Invalid amount: " + amount);
|
||||
}
|
||||
|
||||
if (data > 127 || data < -128) {
|
||||
reason.add("Invalid data: " + data);
|
||||
}
|
||||
|
||||
/*
|
||||
* XP, Drop Chance, and Drop Level
|
||||
*/
|
||||
|
||||
if (!config.contains("Treasures." + treasureName + ".XP")) {
|
||||
reason.add("Missing XP");
|
||||
}
|
||||
|
||||
if (!config.contains("Treasures." + treasureName + ".Drop_Chance")) {
|
||||
reason.add("Missing Drop_Chance");
|
||||
}
|
||||
|
||||
if (!config.contains("Treasures." + treasureName + ".Drop_Level")) {
|
||||
reason.add("Missing Drop_Level");
|
||||
}
|
||||
|
||||
int xp = config.getInt("Treasures." + treasureName + ".XP");
|
||||
Double dropChance = config.getDouble("Treasures." + treasureName + ".Drop_Chance");
|
||||
int dropLevel = config.getInt("Treasures." + treasureName + ".Drop_Level");
|
||||
|
||||
if (xp < 0) {
|
||||
reason.add("Invalid xp: " + xp);
|
||||
}
|
||||
|
||||
if (dropChance < 0) {
|
||||
reason.add("Invalid Drop_Chance: " + dropChance);
|
||||
}
|
||||
|
||||
if (dropLevel < 0) {
|
||||
reason.add("Invalid Drop_Level: " + dropLevel);
|
||||
}
|
||||
|
||||
/*
|
||||
* Drops From & Max Level
|
||||
*/
|
||||
|
||||
ItemStack item = new ItemStack(id, amount, (short) 0, (byte) data);
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
|
||||
if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) {
|
||||
reason.add("Fishing drops cannot also be excavation drops");
|
||||
}
|
||||
|
||||
if (!config.contains("Treasures." + treasureName + ".Max_Level")) {
|
||||
reason.add("Missing Max_Level");
|
||||
}
|
||||
|
||||
int maxLevel = config.getInt("Treasures." + treasureName + ".Max_Level");
|
||||
|
||||
if (maxLevel < 0) {
|
||||
reason.add("Invalid Max_Level: " + maxLevel);
|
||||
}
|
||||
|
||||
if (noErrorsInTreasure(reason)) {
|
||||
FishingTreasure fTreasure = new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel);
|
||||
treasures.put(treasureName, fTreasure);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ExcavationTreasure eTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Dirt", false)) {
|
||||
eTreasure.setDropsFromDirt();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Grass", false)) {
|
||||
eTreasure.setDropsFromGrass();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Sand", false)) {
|
||||
eTreasure.setDropsFromSand();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Gravel", false)) {
|
||||
eTreasure.setDropsFromGravel();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Clay", false)) {
|
||||
eTreasure.setDropsFromClay();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Mycelium", false)) {
|
||||
eTreasure.setDropsFromMycel();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Soul_Sand", false)) {
|
||||
eTreasure.setDropsFromSoulSand();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
|
||||
reason.add("Excavation drops cannot also be fishing drops");
|
||||
}
|
||||
|
||||
if (noErrorsInTreasure(reason)) {
|
||||
treasures.put(treasureName, eTreasure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
|
||||
List<String> fishingTreasures = config.getStringList("Fishing.Treasure");
|
||||
Iterator<String> treasureIterator = treasures.keySet().iterator();
|
||||
|
||||
while (treasureIterator.hasNext()) {
|
||||
String treasureKey = treasureIterator.next();
|
||||
Treasure treasure = treasures.get(treasureKey);
|
||||
|
||||
if (treasure instanceof FishingTreasure) {
|
||||
if (!fishingTreasures.contains(treasureKey)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FishingTreasure fTreasure = (FishingTreasure) treasure;
|
||||
int dropLevel = fTreasure.getDropLevel();
|
||||
int maxLevel = fTreasure.getMaxLevel();
|
||||
|
||||
if(dropLevel <= LoadProperties.fishingTier1 && maxLevel >= LoadProperties.fishingTier1) {
|
||||
fishingRewardsTier1.add(fTreasure);
|
||||
}
|
||||
|
||||
if(dropLevel <= LoadProperties.fishingTier2 && maxLevel >= LoadProperties.fishingTier2) {
|
||||
fishingRewardsTier2.add(fTreasure);
|
||||
}
|
||||
|
||||
if (dropLevel <= LoadProperties.fishingTier3 && maxLevel >= LoadProperties.fishingTier3) {
|
||||
fishingRewardsTier3.add(fTreasure);
|
||||
}
|
||||
|
||||
if (dropLevel <= LoadProperties.fishingTier4 && maxLevel >= LoadProperties.fishingTier4) {
|
||||
fishingRewardsTier4.add(fTreasure);
|
||||
}
|
||||
|
||||
if (dropLevel <= LoadProperties.fishingTier5 && maxLevel >= LoadProperties.fishingTier5) {
|
||||
fishingRewardsTier5.add(fTreasure);
|
||||
}
|
||||
|
||||
}
|
||||
else if (treasure instanceof ExcavationTreasure) {
|
||||
if (!excavationTreasures.contains(treasureKey)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ExcavationTreasure eTreasure = (ExcavationTreasure) treasure;
|
||||
|
||||
if (eTreasure.getDropsFromDirt()) {
|
||||
excavationFromDirt.add(eTreasure);
|
||||
}
|
||||
|
||||
if (eTreasure.getDropsFromGrass()) {
|
||||
excavationFromGrass.add(eTreasure);
|
||||
}
|
||||
|
||||
if (eTreasure.getDropsFromSand()) {
|
||||
excavationFromSand.add(eTreasure);
|
||||
}
|
||||
|
||||
if (eTreasure.getDropsFromGravel()) {
|
||||
excavationFromGravel.add(eTreasure);
|
||||
}
|
||||
|
||||
if (eTreasure.getDropsFromClay()) {
|
||||
excavationFromClay.add(eTreasure);
|
||||
}
|
||||
|
||||
if (eTreasure.getDropsFromMycel()) {
|
||||
excavationFromMycel.add(eTreasure);
|
||||
}
|
||||
|
||||
if (eTreasure.getDropsFromSoulSand()) {
|
||||
excavationFromSoulSand.add(eTreasure);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean noErrorsInTreasure(List<String> issues) {
|
||||
if (issues.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
for (String issue : issues) {
|
||||
Bukkit.getLogger().warning(issue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class Misc
|
||||
{
|
||||
String location = "mcmmo.properties";
|
||||
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
public ArrayList<Entity> mobSpawnerList = new ArrayList<Entity>();
|
||||
public ArrayList<Block> blockWatchList = new ArrayList<Block>();
|
||||
public ArrayList<Block> treeFeller = new ArrayList<Block>();
|
||||
public HashMap<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
|
||||
public ArrayList<LivingEntity> bleedTracker = new ArrayList<LivingEntity>();
|
||||
mcMMO plugin = null;
|
||||
|
||||
//BLEED QUE STUFF
|
||||
public LivingEntity[] bleedQue = new LivingEntity[20];
|
||||
public int bleedQuePos = 0;
|
||||
public LivingEntity[] bleedRemovalQue = new LivingEntity[20];
|
||||
public int bleedRemovalQuePos = 0;
|
||||
|
||||
public Misc(mcMMO mcMMO)
|
||||
{
|
||||
plugin = mcMMO;
|
||||
}
|
||||
|
||||
public void addToBleedQue(LivingEntity entity)
|
||||
{
|
||||
//Assign entity to empty position
|
||||
bleedQue[bleedQuePos] = entity;
|
||||
|
||||
//Move position up by 1 increment
|
||||
bleedQuePos++;
|
||||
|
||||
//Check if array is full
|
||||
if(bleedQuePos >= bleedQue.length)
|
||||
{
|
||||
//Create new temporary array
|
||||
LivingEntity[] temp = new LivingEntity[bleedQue.length*2];
|
||||
//Copy data from bleedQue to temporary array
|
||||
System.arraycopy(bleedQue, 0, temp, 0, bleedQue.length);
|
||||
//Point bleedQue to new array
|
||||
bleedQue = temp;
|
||||
}
|
||||
}
|
||||
|
||||
public void addToBleedRemovalQue(LivingEntity entity)
|
||||
{
|
||||
//Assign entity to empty position
|
||||
bleedRemovalQue[bleedRemovalQuePos] = entity;
|
||||
|
||||
//Move position up by 1 increment
|
||||
bleedRemovalQuePos++;
|
||||
|
||||
//Check if array is full
|
||||
if(bleedRemovalQuePos >= bleedRemovalQue.length)
|
||||
{
|
||||
//Create new temporary array
|
||||
LivingEntity[] temp = new LivingEntity[bleedRemovalQue.length*2];
|
||||
//Copy data from bleedRemovalQue to temporary array
|
||||
System.arraycopy(bleedRemovalQue, 0, temp, 0, bleedRemovalQue.length);
|
||||
//Point bleedRemovalQue to new array
|
||||
bleedRemovalQue = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
291
src/main/java/com/gmail/nossr50/datatypes/AbilityType.java
Normal file
291
src/main/java/com/gmail/nossr50/datatypes/AbilityType.java
Normal file
@@ -0,0 +1,291 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.skills.Excavation;
|
||||
import com.gmail.nossr50.skills.Herbalism;
|
||||
import com.gmail.nossr50.skills.Mining;
|
||||
|
||||
public enum AbilityType {
|
||||
BERSERK(LoadProperties.berserkCooldown, mcLocale.getString("Skills.BerserkOn"), mcLocale.getString("Skills.BerserkOff"), "Skills.BerserkPlayer", mcLocale.getString("Skills.YourBerserk"), "Skills.BerserkPlayerOff"),
|
||||
SUPER_BREAKER(LoadProperties.superBreakerCooldown, mcLocale.getString("Skills.SuperBreakerOn"), mcLocale.getString("Skills.SuperBreakerOff"), "Skills.SuperBreakerPlayer", mcLocale.getString("Skills.YourSuperBreaker"), "Skills.SuperBreakerPlayerOff"),
|
||||
GIGA_DRILL_BREAKER(LoadProperties.gigaDrillBreakerCooldown, mcLocale.getString("Skills.GigaDrillBreakerOn"), mcLocale.getString("Skills.GigaDrillBreakerOff"), "Skills.GigaDrillBreakerPlayer", mcLocale.getString("Skills.YourGigaDrillBreaker"), "Skills.GigaDrillBreakerPlayerOff"),
|
||||
GREEN_TERRA(LoadProperties.greenTerraCooldown, mcLocale.getString("Skills.GreenTerraOn"), mcLocale.getString("Skills.GreenTerraOff"), "Skills.GreenTerraPlayer", mcLocale.getString("Skills.YourGreenTerra"), mcLocale.getString("Skills.GreenTerraPlayerOff")),
|
||||
SKULL_SPLIITER(LoadProperties.skullSplitterCooldown, mcLocale.getString("Skills.SkullSplitterOn"), mcLocale.getString("Skills.SkullSplitterOff"), "Skills.SkullSplitterPlayer", mcLocale.getString("Skills.YourSkullSplitter"), "Skills.SkullSplitterPlayerOff"),
|
||||
TREE_FELLER(LoadProperties.treeFellerCooldown, mcLocale.getString("Skills.TreeFellerOn"), mcLocale.getString("Skills.TreeFellerOff"), "Skills.TreeFellerPlayer", mcLocale.getString("Skills.YourTreeFeller"), "Skills.TreeFellerPlayerOff"),
|
||||
SERRATED_STRIKES(LoadProperties.skullSplitterCooldown, mcLocale.getString("Skills.SerratedStrikesOn"), mcLocale.getString("Skills.SerratedStrikesOff"), "Skills.SerratedStrikesPlayer", mcLocale.getString("Skills.YourSerratedStrikes"), "Skills.SerratedStrikesPlayerOff"),
|
||||
BLAST_MINING(LoadProperties.blastMiningCooldown, null, null, "Skills.BlastMiningPlayer", mcLocale.getString("Skills.YourBlastMining"), null),
|
||||
LEAF_BLOWER(0, null, null, null, null, null);
|
||||
|
||||
private int cooldown;
|
||||
private String abilityOn;
|
||||
private String abilityOff;
|
||||
private String abilityPlayer;
|
||||
private String abilityRefresh;
|
||||
private String abilityPlayerOff;
|
||||
|
||||
private AbilityType(int cooldown, String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
|
||||
this.cooldown = cooldown;
|
||||
this.abilityOn = abilityOn;
|
||||
this.abilityOff = abilityOff;
|
||||
this.abilityPlayer = abilityPlayer;
|
||||
this.abilityRefresh = abilityRefresh;
|
||||
this.abilityPlayerOff = abilityPlayerOff;
|
||||
}
|
||||
|
||||
public int getCooldown() {
|
||||
return this.cooldown;
|
||||
}
|
||||
|
||||
public String getAbilityOn() {
|
||||
return this.abilityOn;
|
||||
}
|
||||
|
||||
public String getAbilityOff() {
|
||||
return this.abilityOff;
|
||||
}
|
||||
|
||||
public String getAbilityPlayer(Player player) {
|
||||
return mcLocale.getString(this.abilityPlayer, new Object[] {player.getName()});
|
||||
}
|
||||
|
||||
public String getAbilityPlayerOff(Player player) {
|
||||
return mcLocale.getString(this.abilityPlayerOff, new Object[] {player.getName()});
|
||||
}
|
||||
|
||||
public String getAbilityRefresh() {
|
||||
return this.abilityRefresh;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mode of this ability.
|
||||
*
|
||||
* @param PP PlayerProfile of the player using the ability
|
||||
* @return true if the ability is enabled, false otherwise
|
||||
*/
|
||||
public boolean getMode(PlayerProfile PP) {
|
||||
switch (this) {
|
||||
case BERSERK:
|
||||
return PP.getBerserkMode();
|
||||
|
||||
case SUPER_BREAKER:
|
||||
return PP.getSuperBreakerMode();
|
||||
|
||||
case GIGA_DRILL_BREAKER:
|
||||
return PP.getGigaDrillBreakerMode();
|
||||
|
||||
case GREEN_TERRA:
|
||||
return PP.getGreenTerraMode();
|
||||
|
||||
case SKULL_SPLIITER:
|
||||
return PP.getSkullSplitterMode();
|
||||
|
||||
case TREE_FELLER:
|
||||
return PP.getTreeFellerMode();
|
||||
|
||||
case SERRATED_STRIKES:
|
||||
return PP.getSerratedStrikesMode();
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the mode of this ability.
|
||||
*
|
||||
* @param PP PlayerProfile of the player using the ability
|
||||
* @param bool Mode to set the ability to
|
||||
*/
|
||||
public void setMode(PlayerProfile PP, boolean bool) {
|
||||
switch (this) {
|
||||
case BERSERK:
|
||||
PP.setBerserkMode(bool);
|
||||
break;
|
||||
|
||||
case SUPER_BREAKER:
|
||||
PP.setSuperBreakerMode(bool);
|
||||
break;
|
||||
|
||||
case GIGA_DRILL_BREAKER:
|
||||
PP.setGigaDrillBreakerMode(bool);
|
||||
break;
|
||||
|
||||
case GREEN_TERRA:
|
||||
PP.setGreenTerraMode(bool);
|
||||
break;
|
||||
|
||||
case SKULL_SPLIITER:
|
||||
PP.setSkullSplitterMode(bool);
|
||||
break;
|
||||
|
||||
case TREE_FELLER:
|
||||
PP.setTreeFellerMode(bool);
|
||||
break;
|
||||
|
||||
case SERRATED_STRIKES:
|
||||
PP.setSerratedStrikesMode(bool);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the informed state of this ability
|
||||
*
|
||||
* @param PP PlayerProfile of the player using the ability
|
||||
* @return true if the ability is informed, false otherwise
|
||||
*/
|
||||
public boolean getInformed(PlayerProfile PP) {
|
||||
switch (this) {
|
||||
case BERSERK:
|
||||
return PP.getBerserkInformed();
|
||||
|
||||
case BLAST_MINING:
|
||||
return PP.getBlastMiningInformed();
|
||||
|
||||
case SUPER_BREAKER:
|
||||
return PP.getSuperBreakerInformed();
|
||||
|
||||
case GIGA_DRILL_BREAKER:
|
||||
return PP.getGigaDrillBreakerInformed();
|
||||
|
||||
case GREEN_TERRA:
|
||||
return PP.getGreenTerraInformed();
|
||||
|
||||
case SKULL_SPLIITER:
|
||||
return PP.getSkullSplitterInformed();
|
||||
|
||||
case TREE_FELLER:
|
||||
return PP.getTreeFellerInformed();
|
||||
|
||||
case SERRATED_STRIKES:
|
||||
return PP.getSerratedStrikesInformed();
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the informed state of this ability.
|
||||
*
|
||||
* @param PP PlayerProfile of the player using the ability
|
||||
* @param bool Informed state to set the ability to
|
||||
*/
|
||||
public void setInformed(PlayerProfile PP, boolean bool) {
|
||||
switch (this) {
|
||||
case BERSERK:
|
||||
PP.setBerserkInformed(bool);
|
||||
break;
|
||||
|
||||
case BLAST_MINING:
|
||||
PP.setBlastMiningInformed(bool);
|
||||
break;
|
||||
|
||||
case SUPER_BREAKER:
|
||||
PP.setSuperBreakerInformed(bool);
|
||||
break;
|
||||
|
||||
case GIGA_DRILL_BREAKER:
|
||||
PP.setGigaDrillBreakerInformed(bool);
|
||||
break;
|
||||
|
||||
case GREEN_TERRA:
|
||||
PP.setGreenTerraInformed(bool);
|
||||
break;
|
||||
|
||||
case SKULL_SPLIITER:
|
||||
PP.setSkullSplitterInformed(bool);
|
||||
break;
|
||||
|
||||
case TREE_FELLER:
|
||||
PP.setTreeFellerInformed(bool);
|
||||
break;
|
||||
|
||||
case SERRATED_STRIKES:
|
||||
PP.setSerratedStrikesInformed(bool);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the permissions for this ability.
|
||||
*
|
||||
* @param player Player to check permissions for
|
||||
* @return true if the player has permissions, false otherwise
|
||||
*/
|
||||
public boolean getPermissions(Player player) {
|
||||
switch (this) {
|
||||
case BERSERK:
|
||||
return mcPermissions.getInstance().berserk(player);
|
||||
|
||||
case BLAST_MINING:
|
||||
return mcPermissions.getInstance().blastMining(player);
|
||||
|
||||
case GIGA_DRILL_BREAKER:
|
||||
return mcPermissions.getInstance().gigaDrillBreaker(player);
|
||||
|
||||
case GREEN_TERRA:
|
||||
return mcPermissions.getInstance().greenTerra(player);
|
||||
|
||||
case LEAF_BLOWER:
|
||||
return mcPermissions.getInstance().leafBlower(player);
|
||||
|
||||
case SERRATED_STRIKES:
|
||||
return mcPermissions.getInstance().serratedStrikes(player);
|
||||
|
||||
case SKULL_SPLIITER:
|
||||
return mcPermissions.getInstance().skullSplitter(player);
|
||||
|
||||
case SUPER_BREAKER:
|
||||
return mcPermissions.getInstance().superBreaker(player);
|
||||
|
||||
case TREE_FELLER:
|
||||
return mcPermissions.getInstance().treeFeller(player);
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a block is affected by this ability.
|
||||
*
|
||||
* @param material The block type to check
|
||||
* @return true if the block is affected by this ability, false otherwise
|
||||
*/
|
||||
public boolean blockCheck(Material material) {
|
||||
switch (this) {
|
||||
case BERSERK:
|
||||
return (Excavation.canBeGigaDrillBroken(material) || material.equals(Material.SNOW));
|
||||
|
||||
case GIGA_DRILL_BREAKER:
|
||||
return Excavation.canBeGigaDrillBroken(material);
|
||||
|
||||
case GREEN_TERRA:
|
||||
return Herbalism.makeMossy(material);
|
||||
|
||||
case LEAF_BLOWER:
|
||||
return material.equals(Material.LEAVES);
|
||||
|
||||
case SUPER_BREAKER:
|
||||
return Mining.canBeSuperBroken(material);
|
||||
|
||||
case TREE_FELLER:
|
||||
return material.equals(Material.LOG);
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
public enum DatabaseUpdate {
|
||||
FISHING,
|
||||
BLAST_MINING;
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
public class FakeBlockBreakEvent extends BlockBreakEvent {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public FakeBlockBreakEvent(Block theBlock, Player player) {
|
||||
super(theBlock, player);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,8 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
public enum HUDType
|
||||
{
|
||||
DISABLED,
|
||||
STANDARD,
|
||||
SMALL,
|
||||
RETRO;
|
||||
public enum HUDType {
|
||||
DISABLED,
|
||||
STANDARD,
|
||||
SMALL,
|
||||
RETRO;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -252,7 +236,7 @@ public class HUDmmo
|
||||
((GenericTexture) xpicon).setUrl(m.getCapitalized(theType.toString())+".png");
|
||||
xpicon.setDirty(true);
|
||||
|
||||
((GenericTexture) xpbar).setUrl(SpoutStuff.getUrlBar(SpoutStuff.getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.STANDARD)));
|
||||
((GenericTexture) xpbar).setUrl(getUrlBar(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.STANDARD)));
|
||||
xpbar.setDirty(true);
|
||||
|
||||
SpoutManager.getPlayer(player).getMainScreen().setDirty(true);
|
||||
@@ -272,16 +256,82 @@ public class HUDmmo
|
||||
if(theType == null)
|
||||
return;
|
||||
|
||||
Color color = SpoutStuff.getRetroColor(theType);
|
||||
Color color = getRetroColor(theType);
|
||||
|
||||
if(xpicon != null && theType != null)
|
||||
xpicon.setUrl(m.getCapitalized(theType.toString())+"_r.png");
|
||||
|
||||
if(theType != null)
|
||||
xpfill.setBottomColor(color).setTopColor(color).setWidth(SpoutStuff.getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.RETRO)).setDirty(true);
|
||||
xpfill.setBottomColor(color).setTopColor(color).setWidth(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.RETRO)).setDirty(true);
|
||||
else
|
||||
System.out.println("theType was null!");
|
||||
|
||||
SpoutManager.getPlayer(player).getMainScreen().setDirty(true);
|
||||
}
|
||||
|
||||
private static Color getRetroColor(SkillType type) {
|
||||
switch (type) {
|
||||
case ACROBATICS:
|
||||
return new Color((float) LoadProperties.acrobatics_r, (float) LoadProperties.acrobatics_g, (float) LoadProperties.acrobatics_b, 1f);
|
||||
case ARCHERY:
|
||||
return new Color((float) LoadProperties.archery_r, (float)LoadProperties.archery_g, (float)LoadProperties.archery_b, 1f);
|
||||
case AXES:
|
||||
return new Color((float) LoadProperties.axes_r, (float)LoadProperties.axes_g, (float)LoadProperties.axes_b, 1f);
|
||||
case EXCAVATION:
|
||||
return new Color((float)LoadProperties.excavation_r, (float)LoadProperties.excavation_g, (float)LoadProperties.excavation_b, 1f);
|
||||
case HERBALISM:
|
||||
return new Color((float)LoadProperties.herbalism_r, (float)LoadProperties.herbalism_g, (float)LoadProperties.herbalism_b, 1f);
|
||||
case MINING:
|
||||
return new Color((float)LoadProperties.mining_r, (float)LoadProperties.mining_g, (float)LoadProperties.mining_b, 1f);
|
||||
case REPAIR:
|
||||
return new Color((float)LoadProperties.repair_r, (float)LoadProperties.repair_g, (float)LoadProperties.repair_b, 1f);
|
||||
case SWORDS:
|
||||
return new Color((float)LoadProperties.swords_r, (float)LoadProperties.swords_g, (float)LoadProperties.swords_b, 1f);
|
||||
case TAMING:
|
||||
return new Color((float)LoadProperties.taming_r, (float)LoadProperties.taming_g, (float)LoadProperties.taming_b, 1f);
|
||||
case UNARMED:
|
||||
return new Color((float)LoadProperties.unarmed_r, (float)LoadProperties.unarmed_g, (float)LoadProperties.unarmed_b, 1f);
|
||||
case WOODCUTTING:
|
||||
return new Color((float)LoadProperties.woodcutting_r, (float)LoadProperties.woodcutting_g, (float)LoadProperties.woodcutting_b, 1f);
|
||||
case FISHING:
|
||||
return new Color((float)LoadProperties.fishing_r, (float)LoadProperties.fishing_g, (float)LoadProperties.fishing_b, 1f);
|
||||
default:
|
||||
return new Color(0.3f, 0.3f, 0.75f, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getUrlBar(Integer number) {
|
||||
char[] num = number.toString().toCharArray();
|
||||
|
||||
switch (num.length) {
|
||||
case 1:
|
||||
return "xpbar_inc00"+number+".png";
|
||||
|
||||
case 2:
|
||||
return "xpbar_inc0"+number+".png";
|
||||
|
||||
default:
|
||||
return "xpbar_inc"+number+".png";
|
||||
}
|
||||
}
|
||||
|
||||
private static Integer getXpInc(int skillxp, int xptolevel, HUDType hud) {
|
||||
double percentage = (double) skillxp / xptolevel;
|
||||
double inc;
|
||||
|
||||
switch (hud) {
|
||||
case RETRO:
|
||||
inc = 0.0079365079365079;
|
||||
break;
|
||||
|
||||
case STANDARD:
|
||||
inc = 0.0039370078740157;
|
||||
break;
|
||||
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
return (int) (percentage / inc);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,23 +1,6 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
public class PlayerStat
|
||||
{
|
||||
public String name;
|
||||
public int statVal = 0;
|
||||
public class PlayerStat {
|
||||
public String name;
|
||||
public int statVal = 0;
|
||||
}
|
||||
@@ -1,36 +1,96 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
|
||||
public enum SkillType
|
||||
{
|
||||
ACROBATICS,
|
||||
ALCHEMY,
|
||||
ACROBATICS(LoadProperties.levelCapAcrobatics),
|
||||
ALL, //This one is just for convenience
|
||||
ARCHERY,
|
||||
AXES,
|
||||
EXCAVATION,
|
||||
ENCHANTING,
|
||||
FISHING,
|
||||
HERBALISM,
|
||||
MINING,
|
||||
REPAIR,
|
||||
SWORDS,
|
||||
TAMING,
|
||||
UNARMED,
|
||||
WOODCUTTING;
|
||||
ARCHERY(LoadProperties.levelCapArchery),
|
||||
AXES(AbilityType.SKULL_SPLIITER, LoadProperties.levelCapAxes, ToolType.AXE),
|
||||
EXCAVATION(AbilityType.GIGA_DRILL_BREAKER, LoadProperties.levelCapExcavation, ToolType.SHOVEL),
|
||||
FISHING(LoadProperties.levelCapFishing),
|
||||
HERBALISM(AbilityType.GREEN_TERRA, LoadProperties.levelCapHerbalism, ToolType.HOE),
|
||||
MINING(AbilityType.SUPER_BREAKER, LoadProperties.levelCapMining, ToolType.PICKAXE),
|
||||
REPAIR(LoadProperties.levelCapRepair),
|
||||
SWORDS(AbilityType.SERRATED_STRIKES, LoadProperties.levelCapSwords, ToolType.SWORD),
|
||||
TAMING(LoadProperties.levelCapTaming),
|
||||
UNARMED(AbilityType.BERSERK, LoadProperties.levelCapUnarmed, ToolType.FISTS),
|
||||
WOODCUTTING(AbilityType.TREE_FELLER, LoadProperties.levelCapWoodcutting, ToolType.AXE);
|
||||
|
||||
private AbilityType ability;
|
||||
private int maxLevel;
|
||||
private ToolType tool;
|
||||
|
||||
private SkillType()
|
||||
{
|
||||
this.ability = null;
|
||||
this.maxLevel = 0;
|
||||
this.tool = null;
|
||||
}
|
||||
|
||||
private SkillType(AbilityType ability, int maxLevel, ToolType tool)
|
||||
{
|
||||
this.ability = ability;
|
||||
this.maxLevel = maxLevel;
|
||||
this.tool = tool;
|
||||
}
|
||||
|
||||
private SkillType(int maxLevel)
|
||||
{
|
||||
this(null, maxLevel, null);
|
||||
}
|
||||
|
||||
public AbilityType getAbility()
|
||||
{
|
||||
return this.ability;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
if(maxLevel > 0)
|
||||
return maxLevel;
|
||||
else
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public ToolType getTool()
|
||||
{
|
||||
return this.tool;
|
||||
}
|
||||
|
||||
public boolean getPermissions(Player player)
|
||||
{
|
||||
switch(this)
|
||||
{
|
||||
case ACROBATICS:
|
||||
return mcPermissions.getInstance().acrobatics(player);
|
||||
case ARCHERY:
|
||||
return mcPermissions.getInstance().archery(player);
|
||||
case AXES:
|
||||
return mcPermissions.getInstance().axes(player);
|
||||
case EXCAVATION:
|
||||
return mcPermissions.getInstance().excavation(player);
|
||||
case FISHING:
|
||||
return mcPermissions.getInstance().fishing(player);
|
||||
case HERBALISM:
|
||||
return mcPermissions.getInstance().herbalism(player);
|
||||
case MINING:
|
||||
return mcPermissions.getInstance().mining(player);
|
||||
case REPAIR:
|
||||
return mcPermissions.getInstance().repair(player);
|
||||
case SWORDS:
|
||||
return mcPermissions.getInstance().swords(player);
|
||||
case TAMING:
|
||||
return mcPermissions.getInstance().taming(player);
|
||||
case UNARMED:
|
||||
return mcPermissions.getInstance().unarmed(player);
|
||||
case WOODCUTTING:
|
||||
return mcPermissions.getInstance().woodcutting(player);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
147
src/main/java/com/gmail/nossr50/datatypes/ToolType.java
Normal file
147
src/main/java/com/gmail/nossr50/datatypes/ToolType.java
Normal file
@@ -0,0 +1,147 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.ItemChecks;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
|
||||
public enum ToolType
|
||||
{
|
||||
AXE(mcLocale.getString("Skills.LowerAxe"), mcLocale.getString("Skills.ReadyAxe")),
|
||||
FISTS(mcLocale.getString("Skills.LowerFists"), mcLocale.getString("Skills.ReadyFists")),
|
||||
HOE(mcLocale.getString("Skills.LowerHoe"), mcLocale.getString("Skills.ReadyHoe")),
|
||||
PICKAXE(mcLocale.getString("Skills.LowerPickAxe"), mcLocale.getString("Skills.ReadyPickAxe")),
|
||||
SHOVEL(mcLocale.getString("Skills.LowerShovel"), mcLocale.getString("Skills.ReadyShovel")),
|
||||
SWORD(mcLocale.getString("Skills.LowerSword"), mcLocale.getString("Skills.ReadySword"));
|
||||
|
||||
private String lowerTool;
|
||||
private String raiseTool;
|
||||
|
||||
private ToolType(String lowerTool, String raiseTool)
|
||||
{
|
||||
this.lowerTool = lowerTool;
|
||||
this.raiseTool = raiseTool;
|
||||
}
|
||||
|
||||
public String getLowerTool()
|
||||
{
|
||||
return this.lowerTool;
|
||||
}
|
||||
|
||||
public String getRaiseTool()
|
||||
{
|
||||
return this.raiseTool;
|
||||
}
|
||||
|
||||
public boolean getToolMode(PlayerProfile PP)
|
||||
{
|
||||
switch(this)
|
||||
{
|
||||
case AXE:
|
||||
return PP.getAxePreparationMode();
|
||||
case FISTS:
|
||||
return PP.getFistsPreparationMode();
|
||||
case HOE:
|
||||
return PP.getHoePreparationMode();
|
||||
case PICKAXE:
|
||||
return PP.getPickaxePreparationMode();
|
||||
case SHOVEL:
|
||||
return PP.getShovelPreparationMode();
|
||||
case SWORD:
|
||||
return PP.getSwordsPreparationMode();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setToolMode(PlayerProfile PP, boolean bool)
|
||||
{
|
||||
switch(this)
|
||||
{
|
||||
case AXE:
|
||||
PP.setAxePreparationMode(bool);
|
||||
break;
|
||||
case FISTS:
|
||||
PP.setFistsPreparationMode(bool);
|
||||
break;
|
||||
case HOE:
|
||||
PP.setHoePreparationMode(bool);
|
||||
break;
|
||||
case PICKAXE:
|
||||
PP.setPickaxePreparationMode(bool);
|
||||
break;
|
||||
case SHOVEL:
|
||||
PP.setShovelPreparationMode(bool);
|
||||
break;
|
||||
case SWORD:
|
||||
PP.setSwordsPreparationMode(bool);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public long getToolATS(PlayerProfile PP)
|
||||
{
|
||||
switch(this)
|
||||
{
|
||||
case AXE:
|
||||
return PP.getAxePreparationATS();
|
||||
case FISTS:
|
||||
return PP.getFistsPreparationATS();
|
||||
case HOE:
|
||||
return PP.getHoePreparationATS();
|
||||
case PICKAXE:
|
||||
return PP.getPickaxePreparationATS();
|
||||
case SHOVEL:
|
||||
return PP.getShovelPreparationATS();
|
||||
case SWORD:
|
||||
return PP.getSwordsPreparationATS();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setToolATS(PlayerProfile PP, long ats)
|
||||
{
|
||||
switch(this)
|
||||
{
|
||||
case AXE:
|
||||
PP.setAxePreparationATS(ats);
|
||||
break;
|
||||
case FISTS:
|
||||
PP.setFistsPreparationATS(ats);
|
||||
break;
|
||||
case HOE:
|
||||
PP.setHoePreparationATS(ats);
|
||||
break;
|
||||
case PICKAXE:
|
||||
PP.setPickaxePreparationATS(ats);
|
||||
break;
|
||||
case SHOVEL:
|
||||
PP.setShovelPreparationATS(ats);
|
||||
break;
|
||||
case SWORD:
|
||||
PP.setSwordsPreparationATS(ats);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean inHand(ItemStack is)
|
||||
{
|
||||
switch(this)
|
||||
{
|
||||
case AXE:
|
||||
return ItemChecks.isAxe(is);
|
||||
case FISTS:
|
||||
return is.getType().equals(Material.AIR);
|
||||
case HOE:
|
||||
return ItemChecks.isHoe(is);
|
||||
case PICKAXE:
|
||||
return ItemChecks.isMiningPick(is);
|
||||
case SHOVEL:
|
||||
return ItemChecks.isShovel(is);
|
||||
case SWORD:
|
||||
return ItemChecks.isSword(is);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -22,34 +6,49 @@ import com.gmail.nossr50.datatypes.PlayerStat;
|
||||
|
||||
public class Tree {
|
||||
|
||||
TreeNode root = null;
|
||||
private TreeNode root = null;
|
||||
|
||||
public Tree(){}
|
||||
public Tree(){}
|
||||
|
||||
public void add(String p, int in)
|
||||
{
|
||||
if(root == null){
|
||||
root = new TreeNode(p, in);
|
||||
}
|
||||
else
|
||||
root.add(p,in);
|
||||
}
|
||||
|
||||
public PlayerStat[] inOrder()
|
||||
{
|
||||
if(root != null){
|
||||
ArrayList<PlayerStat> order = root.inOrder(new ArrayList<PlayerStat>());
|
||||
return order.toArray(new PlayerStat[order.size()]);
|
||||
} else {
|
||||
//Throw some dummy info in case the users file is empty
|
||||
//It's not a good fix but its better than rewriting the whole system
|
||||
ArrayList<PlayerStat> x = new ArrayList<PlayerStat>();
|
||||
PlayerStat y = new PlayerStat();
|
||||
y.name = "$mcMMO_DummyInfo";
|
||||
y.statVal = 0;
|
||||
x.add(y);
|
||||
return x.toArray(new PlayerStat[x.size()]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Add a node to this tree.
|
||||
*
|
||||
* @param p Player name
|
||||
* @param in Stat value
|
||||
*/
|
||||
public void add(String p, int in) {
|
||||
if (root == null) {
|
||||
root = new TreeNode(p, in);
|
||||
}
|
||||
else {
|
||||
root.add(p, in);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an array of PlayerStats from the Tree.
|
||||
*
|
||||
* @return the player stats of this tree, in order
|
||||
*/
|
||||
public PlayerStat[] inOrder() {
|
||||
if (root != null) {
|
||||
ArrayList<PlayerStat> order = root.inOrder(new ArrayList<PlayerStat>());
|
||||
|
||||
return order.toArray(new PlayerStat[order.size()]);
|
||||
}
|
||||
else {
|
||||
|
||||
/* Throw some dummy info in case the users file is empty.
|
||||
* It's not a good fix but its better than rewriting the whole system.
|
||||
*/
|
||||
ArrayList<PlayerStat> x = new ArrayList<PlayerStat>();
|
||||
PlayerStat y = new PlayerStat();
|
||||
|
||||
y.name = "$mcMMO_DummyInfo";
|
||||
y.statVal = 0;
|
||||
x.add(y);
|
||||
|
||||
return x.toArray(new PlayerStat[x.size()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.datatypes.buttons;
|
||||
|
||||
import org.getspout.spoutapi.gui.GenericButton;
|
||||
|
||||
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.datatypes.buttons;
|
||||
|
||||
import org.getspout.spoutapi.gui.GenericButton;
|
||||
|
||||
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.datatypes.buttons;
|
||||
|
||||
import org.getspout.spoutapi.gui.GenericButton;
|
||||
|
||||
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.datatypes.popups;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.gmail.nossr50.datatypes.treasure;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ExcavationTreasure extends Treasure {
|
||||
// dirt grass sand gravel clay mycel soulsand
|
||||
// 00000001 - dirt 1
|
||||
// 00000010 - grass 2
|
||||
// 00000100 - sand 4
|
||||
// 00001000 - gravel 8
|
||||
// 00010000 - clay 16
|
||||
// 00100000 - mycel 32
|
||||
// 01000000 - soulsand 64
|
||||
private byte dropsFrom = 0x0;
|
||||
|
||||
public ExcavationTreasure(ItemStack drop, int xp, Double dropChance, int dropLevel) {
|
||||
super(drop, xp, dropChance, dropLevel);
|
||||
}
|
||||
|
||||
// Raw getters and setters
|
||||
public byte getDropsFrom() {
|
||||
return dropsFrom;
|
||||
}
|
||||
|
||||
public void setDropsFrom(byte dropsFrom) {
|
||||
this.dropsFrom = dropsFrom;
|
||||
}
|
||||
|
||||
// Getters
|
||||
public boolean getDropsFromDirt() {
|
||||
return getDropFromMask(1);
|
||||
}
|
||||
|
||||
public boolean getDropsFromGrass() {
|
||||
return getDropFromMask(2);
|
||||
}
|
||||
|
||||
public boolean getDropsFromSand() {
|
||||
return getDropFromMask(4);
|
||||
}
|
||||
|
||||
public boolean getDropsFromGravel() {
|
||||
return getDropFromMask(8);
|
||||
}
|
||||
|
||||
public boolean getDropsFromClay() {
|
||||
return getDropFromMask(16);
|
||||
}
|
||||
|
||||
public boolean getDropsFromMycel() {
|
||||
return getDropFromMask(32);
|
||||
}
|
||||
|
||||
public boolean getDropsFromSoulSand() {
|
||||
return getDropFromMask(64);
|
||||
}
|
||||
|
||||
private boolean getDropFromMask(int mask) {
|
||||
return ((dropsFrom & mask) > 0) ? true : false;
|
||||
}
|
||||
|
||||
// Setters
|
||||
public void setDropsFromDirt() {
|
||||
setDropFromMask(1);
|
||||
}
|
||||
|
||||
public void setDropsFromGrass() {
|
||||
setDropFromMask(2);
|
||||
}
|
||||
|
||||
public void setDropsFromSand() {
|
||||
setDropFromMask(4);
|
||||
}
|
||||
|
||||
public void setDropsFromGravel() {
|
||||
setDropFromMask(8);
|
||||
}
|
||||
|
||||
public void setDropsFromClay() {
|
||||
setDropFromMask(16);
|
||||
}
|
||||
|
||||
public void setDropsFromMycel() {
|
||||
setDropFromMask(32);
|
||||
}
|
||||
|
||||
public void setDropsFromSoulSand() {
|
||||
setDropFromMask(64);
|
||||
}
|
||||
|
||||
private void setDropFromMask(int mask) {
|
||||
dropsFrom |= mask;
|
||||
}
|
||||
|
||||
// Un-setters
|
||||
public void unsetDropsFromDirt() {
|
||||
unsetDropFromMask(1);
|
||||
}
|
||||
|
||||
public void unsetDropsFromGrass() {
|
||||
unsetDropFromMask(2);
|
||||
}
|
||||
|
||||
public void unsetDropsFromSand() {
|
||||
unsetDropFromMask(4);
|
||||
}
|
||||
|
||||
public void unsetDropsFromGravel() {
|
||||
unsetDropFromMask(8);
|
||||
}
|
||||
|
||||
public void unsetDropsFromClay() {
|
||||
unsetDropFromMask(16);
|
||||
}
|
||||
|
||||
public void unsetDropsFromMycel() {
|
||||
unsetDropFromMask(32);
|
||||
}
|
||||
|
||||
public void unsetDropsFromSoulSand() {
|
||||
unsetDropFromMask(64);
|
||||
}
|
||||
|
||||
private void unsetDropFromMask(int mask) {
|
||||
dropsFrom &= ~mask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.gmail.nossr50.datatypes.treasure;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class FishingTreasure extends Treasure {
|
||||
private int maxLevel;
|
||||
|
||||
public FishingTreasure(ItemStack drop, int xp, Double dropChance, int dropLevel, int maxLevel) {
|
||||
super(drop, xp, dropChance, dropLevel);
|
||||
this.setMaxLevel(maxLevel);
|
||||
}
|
||||
|
||||
public int getMaxLevel() {
|
||||
return maxLevel;
|
||||
}
|
||||
|
||||
public void setMaxLevel(int maxLevel) {
|
||||
this.maxLevel = maxLevel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.gmail.nossr50.datatypes.treasure;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public abstract class Treasure {
|
||||
private int xp;
|
||||
private Double dropChance;
|
||||
private int dropLevel;
|
||||
|
||||
private ItemStack drop;
|
||||
|
||||
public Treasure(ItemStack drop, int xp, Double dropChance, int dropLevel) {
|
||||
this.drop = drop;
|
||||
this.xp = xp;
|
||||
this.dropChance = dropChance;
|
||||
this.dropLevel = dropLevel;
|
||||
}
|
||||
|
||||
public ItemStack getDrop() {
|
||||
return drop;
|
||||
}
|
||||
|
||||
public void setDrop(ItemStack drop) {
|
||||
this.drop = drop;
|
||||
}
|
||||
|
||||
public int getXp() {
|
||||
return xp;
|
||||
}
|
||||
|
||||
public void setXp(int xp) {
|
||||
this.xp = xp;
|
||||
}
|
||||
|
||||
public Double getDropChance() {
|
||||
return dropChance;
|
||||
}
|
||||
|
||||
public void setDropChance(Double dropChance) {
|
||||
this.dropChance = dropChance;
|
||||
}
|
||||
|
||||
public int getDropLevel() {
|
||||
return dropLevel;
|
||||
}
|
||||
|
||||
public void setDropLevel(int dropLevel) {
|
||||
this.dropLevel = dropLevel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.gmail.nossr50.events;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class FakeBlockBreakEvent extends BlockBreakEvent {
|
||||
|
||||
public FakeBlockBreakEvent(Block theBlock, Player player) {
|
||||
super(theBlock, player, new ArrayList<ItemStack>(theBlock.getDrops()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.gmail.nossr50.events;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent {
|
||||
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, int damage) {
|
||||
super(damager, damagee, cause, damage);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.gmail.nossr50.events;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
public class FakeEntityDamageEvent extends EntityDamageEvent{
|
||||
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, int damage) {
|
||||
super(damagee, cause, damage);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.gmail.nossr50.events;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Called when mcMMO is preparing to drop an item
|
||||
*/
|
||||
public class McMMOItemSpawnEvent extends Event implements Cancellable {
|
||||
private Location location;
|
||||
private ItemStack itemStack;
|
||||
private boolean cancelled;
|
||||
|
||||
public McMMOItemSpawnEvent(Location location, ItemStack itemStack) {
|
||||
this.location = location;
|
||||
this.itemStack = itemStack;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Location where the item will be dropped
|
||||
*/
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param location Location where to drop the item
|
||||
*/
|
||||
public void setLocation(Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ItemStack that will be dropped
|
||||
*/
|
||||
public ItemStack getItemStack() {
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param itemStack ItemStack to drop
|
||||
*/
|
||||
public void setItemStack(ItemStack itemStack) {
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
|
||||
/** Following are required for Cancellable **/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
/** Rest of file is required boilerplate for custom events **/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.gmail.nossr50.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
|
||||
/**
|
||||
* Called when a user levels up in a skill
|
||||
*/
|
||||
public class McMMOPlayerLevelUpEvent extends Event {
|
||||
private Player player;
|
||||
private SkillType skill;
|
||||
private int levelsGained;
|
||||
|
||||
public McMMOPlayerLevelUpEvent(Player player, SkillType skill) {
|
||||
this.player = player;
|
||||
this.skill = skill;
|
||||
this.levelsGained = 1; // Always 1 for now as we call in the loop where the levelups are calculated, could change later!
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player leveling up
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SkillType that is being leveled up
|
||||
*/
|
||||
public SkillType getSkill() {
|
||||
return skill;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The number of levels gained in this event
|
||||
*/
|
||||
public int getLevelsGained() {
|
||||
return levelsGained;
|
||||
}
|
||||
|
||||
/** Rest of file is required boilerplate for custom events **/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.gmail.nossr50.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
|
||||
public class McMMOPlayerXpGainEvent extends Event {
|
||||
private Player player;
|
||||
private SkillType skill;
|
||||
private int xpGained;
|
||||
|
||||
public McMMOPlayerXpGainEvent(Player player, SkillType skill, int xpGained) {
|
||||
this.player = player;
|
||||
this.skill = skill;
|
||||
this.xpGained = xpGained;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player gaining experience (can be null)
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SkillType that is gaining experience
|
||||
*/
|
||||
public SkillType getSkill() {
|
||||
return skill;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The number experience gained in this event
|
||||
*/
|
||||
public int getXpGained() {
|
||||
return xpGained;
|
||||
}
|
||||
|
||||
/** Rest of file is required boilerplate for custom events **/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
@@ -1,451 +1,332 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import java.util.List;
|
||||
|
||||
import com.gmail.nossr50.BlockChecks;
|
||||
import com.gmail.nossr50.ItemChecks;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.Excavation;
|
||||
import com.gmail.nossr50.skills.Herbalism;
|
||||
import com.gmail.nossr50.skills.Mining;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.skills.WoodCutting;
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.CropState;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
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.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
import org.getspout.spoutapi.sound.SoundEffect;
|
||||
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.skills.*;
|
||||
import com.gmail.nossr50.datatypes.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.FakeBlockBreakEvent;
|
||||
|
||||
|
||||
public class mcBlockListener extends BlockListener
|
||||
{
|
||||
public class mcBlockListener implements Listener {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public mcBlockListener(final mcMMO plugin)
|
||||
{
|
||||
public mcBlockListener(final mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
//Setup some basic vars
|
||||
Block block;
|
||||
Player player = event.getPlayer();
|
||||
|
||||
//When blocks are placed on snow this event reports the wrong block.
|
||||
if (event.getBlockReplacedState() != null && event.getBlockReplacedState().getTypeId() == 78)
|
||||
{
|
||||
block = event.getBlockAgainst();
|
||||
}
|
||||
else
|
||||
{
|
||||
block = event.getBlock();
|
||||
}
|
||||
|
||||
//Check if the blocks placed should be monitored so they do not give out XP in the future
|
||||
if(m.shouldBeWatched(block))
|
||||
{
|
||||
if(block.getTypeId() != 17 && block.getTypeId() != 39 && block.getTypeId() != 40 && block.getTypeId() != 91 && block.getTypeId() != 86)
|
||||
block.setData((byte) 5); //Change the byte
|
||||
else if(block.getTypeId() == 17 || block.getTypeId() == 39 || block.getTypeId() == 40 || block.getTypeId() == 91 || block.getTypeId() == 86)
|
||||
plugin.misc.blockWatchList.add(block);
|
||||
}
|
||||
|
||||
if(block.getTypeId() == 42 && LoadProperties.anvilmessages)
|
||||
{
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(LoadProperties.spoutEnabled)
|
||||
{
|
||||
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
|
||||
if(sPlayer.isSpoutCraftEnabled())
|
||||
{
|
||||
if(!PP.getPlacedAnvil())
|
||||
{
|
||||
sPlayer.sendNotification("[mcMMO] Anvil Placed", "Right click to repair!", Material.IRON_BLOCK);
|
||||
PP.togglePlacedAnvil();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!PP.getPlacedAnvil())
|
||||
{
|
||||
event.getPlayer().sendMessage(mcLocale.getString("mcBlockListener.PlacedAnvil")); //$NON-NLS-1$
|
||||
PP.togglePlacedAnvil();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!PP.getPlacedAnvil())
|
||||
{
|
||||
event.getPlayer().sendMessage(mcLocale.getString("mcBlockListener.PlacedAnvil")); //$NON-NLS-1$
|
||||
PP.togglePlacedAnvil();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
Block block = event.getBlock();
|
||||
ItemStack inhand = player.getItemInHand();
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
if (event instanceof FakeBlockBreakEvent)
|
||||
return;
|
||||
|
||||
/*
|
||||
* HERBALISM
|
||||
*/
|
||||
|
||||
//Green Terra
|
||||
if(PP.getHoePreparationMode() && mcPermissions.getInstance().herbalismAbility(player) && block.getTypeId() == 59 && block.getData() == (byte) 0x07)
|
||||
{
|
||||
Herbalism.greenTerraCheck(player, block);
|
||||
}
|
||||
|
||||
//Wheat && Triple drops
|
||||
if(PP.getGreenTerraMode() && Herbalism.canBeGreenTerra(block))
|
||||
{
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||
Herbalism.greenTerraWheat(player, block, event, plugin);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* MINING
|
||||
*/
|
||||
if(mcPermissions.getInstance().mining(player))
|
||||
{
|
||||
if(LoadProperties.miningrequirespickaxe)
|
||||
{
|
||||
if(m.isMiningPick(inhand))
|
||||
{
|
||||
Mining.miningBlockCheck(false, player, block, plugin);
|
||||
}
|
||||
} else
|
||||
{
|
||||
Mining.miningBlockCheck(false, player, block, plugin);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* WOOD CUTTING
|
||||
*/
|
||||
|
||||
if(player != null && block.getTypeId() == 17 && mcPermissions.getInstance().woodcutting(player))
|
||||
{
|
||||
if(LoadProperties.woodcuttingrequiresaxe)
|
||||
{
|
||||
if(m.isAxes(inhand))
|
||||
{
|
||||
if(!plugin.misc.blockWatchList.contains(block))
|
||||
{
|
||||
WoodCutting.woodCuttingProcCheck(player, block);
|
||||
//Default
|
||||
if(block.getData() == (byte)0)
|
||||
PP.addXP(SkillType.WOODCUTTING, LoadProperties.mpine, player);
|
||||
//Spruce
|
||||
if(block.getData() == (byte)1)
|
||||
PP.addXP(SkillType.WOODCUTTING, LoadProperties.mspruce, player);
|
||||
//Birch
|
||||
if(block.getData() == (byte)2)
|
||||
PP.addXP(SkillType.WOODCUTTING, LoadProperties.mbirch, player);
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
if(!plugin.misc.blockWatchList.contains(block))
|
||||
{
|
||||
WoodCutting.woodCuttingProcCheck(player, block);
|
||||
//Default
|
||||
if(block.getData() == (byte)0)
|
||||
PP.addXP(SkillType.WOODCUTTING, LoadProperties.mpine, player);
|
||||
//Spruce
|
||||
if(block.getData() == (byte)1)
|
||||
PP.addXP(SkillType.WOODCUTTING, LoadProperties.mspruce, player);
|
||||
//Birch
|
||||
if(block.getData() == (byte)2)
|
||||
PP.addXP(SkillType.WOODCUTTING, LoadProperties.mbirch, player);
|
||||
}
|
||||
}
|
||||
Skills.XpCheckSkill(SkillType.WOODCUTTING, player);
|
||||
|
||||
/*
|
||||
* IF PLAYER IS USING TREEFELLER
|
||||
*/
|
||||
if(mcPermissions.getInstance().woodCuttingAbility(player)
|
||||
&& PP.getTreeFellerMode()
|
||||
&& block.getTypeId() == 17
|
||||
&& m.blockBreakSimulate(block, player))
|
||||
{
|
||||
if(LoadProperties.spoutEnabled)
|
||||
SpoutStuff.playSoundForPlayer(SoundEffect.EXPLODE, player, block.getLocation());
|
||||
|
||||
WoodCutting.treeFeller(block, player, plugin);
|
||||
for(Block blockx : plugin.misc.treeFeller)
|
||||
{
|
||||
if(blockx != null)
|
||||
{
|
||||
Material mat = Material.getMaterial(block.getTypeId());
|
||||
byte type = 0;
|
||||
if(block.getTypeId() == 17)
|
||||
type = block.getData();
|
||||
ItemStack item = new ItemStack(mat, 1, (byte)0, type);
|
||||
if(blockx.getTypeId() == 17)
|
||||
{
|
||||
blockx.getLocation().getWorld().dropItemNaturally(blockx.getLocation(), item);
|
||||
//XP WOODCUTTING
|
||||
if(!plugin.misc.blockWatchList.contains(block))
|
||||
{
|
||||
WoodCutting.woodCuttingProcCheck(player, blockx);
|
||||
PP.addXP(SkillType.WOODCUTTING, LoadProperties.mpine, player);
|
||||
}
|
||||
}
|
||||
if(blockx.getTypeId() == 18)
|
||||
{
|
||||
mat = Material.SAPLING;
|
||||
|
||||
item = new ItemStack(mat, 1, (short)0, blockx.getData());
|
||||
|
||||
if(Math.random() * 10 > 9)
|
||||
blockx.getLocation().getWorld().dropItemNaturally(blockx.getLocation(), item);
|
||||
}
|
||||
if(blockx.getType() != Material.AIR)
|
||||
player.incrementStatistic(Statistic.MINE_BLOCK, event.getBlock().getType());
|
||||
blockx.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
if(LoadProperties.toolsLoseDurabilityFromAbilities)
|
||||
m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss);
|
||||
plugin.misc.treeFeller.clear();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* EXCAVATION
|
||||
*/
|
||||
if(Excavation.canBeGigaDrillBroken(block) && mcPermissions.getInstance().excavation(player) && block.getData() != (byte) 5)
|
||||
Excavation.excavationProcCheck(block.getData(), block.getType(), block.getLocation(), player);
|
||||
/*
|
||||
* HERBALISM
|
||||
*/
|
||||
if(PP.getHoePreparationMode() && mcPermissions.getInstance().herbalism(player) && Herbalism.canBeGreenTerra(block))
|
||||
{
|
||||
Herbalism.greenTerraCheck(player, block);
|
||||
}
|
||||
if(mcPermissions.getInstance().herbalism(player) && block.getData() != (byte) 5)
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||
|
||||
//Change the byte back when broken
|
||||
if(block.getData() == 5 && m.shouldBeWatched(block))
|
||||
{
|
||||
block.setData((byte) 0);
|
||||
if(plugin.misc.blockWatchList.contains(block))
|
||||
{
|
||||
plugin.misc.blockWatchList.remove(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onBlockDamage(BlockDamageEvent event)
|
||||
{
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
ItemStack inhand = player.getItemInHand();
|
||||
Block block = event.getBlock();
|
||||
|
||||
Skills.monitorSkills(player);
|
||||
|
||||
/*
|
||||
* ABILITY PREPARATION CHECKS
|
||||
*/
|
||||
if(PP.getHoePreparationMode() && Herbalism.canBeGreenTerra(block))
|
||||
Herbalism.greenTerraCheck(player, block);
|
||||
if(PP.getAxePreparationMode() && block.getTypeId() == 17)
|
||||
WoodCutting.treeFellerCheck(player, block);
|
||||
if(PP.getPickaxePreparationMode() && Mining.canBeSuperBroken(block))
|
||||
Mining.superBreakerCheck(player, block);
|
||||
if(PP.getShovelPreparationMode() && Excavation.canBeGigaDrillBroken(block))
|
||||
Excavation.gigaDrillBreakerActivationCheck(player, block);
|
||||
if(PP.getFistsPreparationMode() && (Excavation.canBeGigaDrillBroken(block) || block.getTypeId() == 78))
|
||||
Unarmed.berserkActivationCheck(player);
|
||||
|
||||
/*
|
||||
* TREE FELLAN STUFF
|
||||
*/
|
||||
if(LoadProperties.spoutEnabled && block.getTypeId() == 17 && Users.getProfile(player).getTreeFellerMode())
|
||||
SpoutStuff.playSoundForPlayer(SoundEffect.FIZZ, player, block.getLocation());
|
||||
|
||||
/*
|
||||
* GREEN TERRA STUFF
|
||||
*/
|
||||
if(PP.getGreenTerraMode() && mcPermissions.getInstance().herbalismAbility(player) && PP.getGreenTerraMode())
|
||||
{
|
||||
Herbalism.greenTerra(player, block);
|
||||
}
|
||||
|
||||
/*
|
||||
* GIGA DRILL BREAKER CHECKS
|
||||
*/
|
||||
if(PP.getGigaDrillBreakerMode() && m.blockBreakSimulate(block, player)
|
||||
&& Excavation.canBeGigaDrillBroken(block) && m.isShovel(inhand))
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
while(x < 3)
|
||||
{
|
||||
if(block.getData() != (byte)5)
|
||||
Excavation.excavationProcCheck(block.getData(), block.getType(), block.getLocation(), player);
|
||||
x++;
|
||||
}
|
||||
|
||||
Material mat = Material.getMaterial(block.getTypeId());
|
||||
|
||||
if(block.getType() == Material.GRASS)
|
||||
mat = Material.DIRT;
|
||||
if(block.getType() == Material.CLAY)
|
||||
mat = Material.CLAY_BALL;
|
||||
|
||||
byte type = block.getData();
|
||||
ItemStack item = new ItemStack(mat, 1, (byte)0, type);
|
||||
|
||||
block.setType(Material.AIR);
|
||||
|
||||
player.incrementStatistic(Statistic.MINE_BLOCK, event.getBlock().getType());
|
||||
|
||||
if(LoadProperties.toolsLoseDurabilityFromAbilities)
|
||||
m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss);
|
||||
|
||||
if(item.getType() == Material.CLAY_BALL)
|
||||
{
|
||||
block.getLocation().getWorld().dropItemNaturally(block.getLocation(), item);
|
||||
block.getLocation().getWorld().dropItemNaturally(block.getLocation(), item);
|
||||
block.getLocation().getWorld().dropItemNaturally(block.getLocation(), item);
|
||||
block.getLocation().getWorld().dropItemNaturally(block.getLocation(), item);
|
||||
} else
|
||||
{
|
||||
block.getLocation().getWorld().dropItemNaturally(block.getLocation(), item);
|
||||
}
|
||||
|
||||
//Spout stuff
|
||||
if(LoadProperties.spoutEnabled)
|
||||
SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
||||
}
|
||||
/*
|
||||
* BERSERK MODE CHECKS
|
||||
*/
|
||||
if(PP.getBerserkMode()
|
||||
&& m.blockBreakSimulate(block, player)
|
||||
&& player.getItemInHand().getTypeId() == 0
|
||||
&& (Excavation.canBeGigaDrillBroken(block) || block.getTypeId() == 78))
|
||||
{
|
||||
Material mat = Material.getMaterial(block.getTypeId());
|
||||
|
||||
if(block.getTypeId() == 2)
|
||||
mat = Material.DIRT;
|
||||
if(block.getTypeId() == 78)
|
||||
mat = Material.SNOW_BALL;
|
||||
if(block.getTypeId() == 82)
|
||||
mat = Material.CLAY_BALL;
|
||||
|
||||
byte type = block.getData();
|
||||
|
||||
ItemStack item = new ItemStack(mat, 1, (byte)0, type);
|
||||
player.incrementStatistic(Statistic.MINE_BLOCK, event.getBlock().getType());
|
||||
|
||||
block.setType(Material.AIR);
|
||||
|
||||
if(item.getType() == Material.CLAY_BALL)
|
||||
{
|
||||
block.getLocation().getWorld().dropItemNaturally(block.getLocation(), item);
|
||||
block.getLocation().getWorld().dropItemNaturally(block.getLocation(), item);
|
||||
block.getLocation().getWorld().dropItemNaturally(block.getLocation(), item);
|
||||
block.getLocation().getWorld().dropItemNaturally(block.getLocation(), item);
|
||||
} else
|
||||
{
|
||||
block.getLocation().getWorld().dropItemNaturally(block.getLocation(), item);
|
||||
}
|
||||
|
||||
if(LoadProperties.spoutEnabled)
|
||||
SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
||||
}
|
||||
|
||||
/*
|
||||
* SUPER BREAKER CHECKS
|
||||
*/
|
||||
if(PP.getSuperBreakerMode()
|
||||
&& Mining.canBeSuperBroken(block)
|
||||
&& m.blockBreakSimulate(block, player))
|
||||
{
|
||||
|
||||
if(LoadProperties.miningrequirespickaxe)
|
||||
{
|
||||
if(m.isMiningPick(inhand))
|
||||
Mining.SuperBreakerBlockCheck(player, block, plugin);
|
||||
} else {
|
||||
Mining.SuperBreakerBlockCheck(player, block, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* LEAF BLOWER
|
||||
*/
|
||||
if(block.getTypeId() == 18 && mcPermissions.getInstance().woodcutting(player) && PP.getSkillLevel(SkillType.WOODCUTTING) >= 100 && m.isAxes(player.getItemInHand()) && m.blockBreakSimulate(block, player))
|
||||
{
|
||||
m.damageTool(player, (short)1);
|
||||
if(Math.random() * 10 > 9)
|
||||
{
|
||||
ItemStack x = new ItemStack(Material.SAPLING, 1, (short)0, block.getData());
|
||||
block.getLocation().getWorld().dropItemNaturally(block.getLocation(), x);
|
||||
}
|
||||
block.setType(Material.AIR);
|
||||
player.incrementStatistic(Statistic.MINE_BLOCK, event.getBlock().getType());
|
||||
if(LoadProperties.spoutEnabled)
|
||||
SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
||||
}
|
||||
if(block.getType() == Material.AIR && plugin.misc.blockWatchList.contains(block))
|
||||
{
|
||||
plugin.misc.blockWatchList.remove(block);
|
||||
}
|
||||
}
|
||||
|
||||
public void onBlockFromTo(BlockFromToEvent event)
|
||||
{
|
||||
Block blockFrom = event.getBlock();
|
||||
Block blockTo = event.getToBlock();
|
||||
if(m.shouldBeWatched(blockFrom) && blockFrom.getData() == (byte)5)
|
||||
{
|
||||
blockTo.setData((byte)5);
|
||||
/**
|
||||
* Monitor BlockPistonExtend events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||
List<Block> blocks = event.getBlocks();
|
||||
BlockFace direction = event.getDirection();
|
||||
|
||||
for (Block b : blocks) {
|
||||
if (b.hasMetadata("mcmmoPlacedBlock")) {
|
||||
b.getRelative(direction).setMetadata("mcmmoNeedsTracking", new FixedMetadataValue(plugin, true));
|
||||
b.removeMetadata("mcmmoPlacedBlock", plugin);
|
||||
}
|
||||
}
|
||||
|
||||
for (Block b : blocks) {
|
||||
if (b.getRelative(direction).hasMetadata("mcmmoNeedsTracking")) {
|
||||
b.getRelative(direction).setMetadata("mcmmoPlacedBlock", new FixedMetadataValue(plugin, true));
|
||||
b.getRelative(direction).removeMetadata("mcmmoNeedsTracking", plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor BlockPistonRetract events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
Block block = event.getRetractLocation().getBlock();
|
||||
|
||||
if (block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
block.removeMetadata("mcmmoPlacedBlock", plugin);
|
||||
event.getBlock().getRelative(event.getDirection()).setMetadata("mcmmoPlacedBlock", new FixedMetadataValue(plugin, true));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor BlockPlace events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
Block block;
|
||||
Player player = event.getPlayer();
|
||||
|
||||
//When blocks are placed on snow this event reports the wrong block.
|
||||
if (event.getBlockReplacedState() != null && event.getBlockReplacedState().getType().equals(Material.SNOW)) {
|
||||
block = event.getBlockAgainst();
|
||||
}
|
||||
else {
|
||||
block = event.getBlock();
|
||||
}
|
||||
|
||||
int id = block.getTypeId();
|
||||
Material mat = block.getType();
|
||||
|
||||
/* Code to prevent issues with placed falling Sand/Gravel not being tracked */
|
||||
if (mat.equals(Material.SAND) || mat.equals(Material.GRAVEL)) {
|
||||
for (int y = -1; y + block.getY() >= 0; y--) {
|
||||
if (block.getRelative(0, y, 0).getType().equals(Material.AIR)) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
Block newLocation = block.getRelative(0, y+1, 0);
|
||||
newLocation.setMetadata("mcmmoPlacedBlock", new FixedMetadataValue(plugin, true));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
|
||||
if (BlockChecks.shouldBeWatched(mat)) {
|
||||
block.setMetadata("mcmmoPlacedBlock", new FixedMetadataValue(plugin, true));
|
||||
}
|
||||
|
||||
if (id == LoadProperties.anvilID && LoadProperties.anvilmessages) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if (!PP.getPlacedAnvil()) {
|
||||
if (LoadProperties.spoutEnabled) {
|
||||
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
|
||||
|
||||
if (sPlayer.isSpoutCraftEnabled()) {
|
||||
sPlayer.sendNotification("[mcMMO] Anvil Placed", "Right click to repair!", Material.getMaterial(id));
|
||||
}
|
||||
}
|
||||
else {
|
||||
event.getPlayer().sendMessage(mcLocale.getString("mcBlockListener.PlacedAnvil"));
|
||||
}
|
||||
|
||||
PP.togglePlacedAnvil();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor BlockBreak events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
Block block = event.getBlock();
|
||||
Material mat = block.getType();
|
||||
ItemStack inhand = player.getItemInHand();
|
||||
|
||||
if(event instanceof FakeBlockBreakEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* HERBALISM
|
||||
*/
|
||||
|
||||
/* Green Terra */
|
||||
if (PP.getHoePreparationMode() && mcPermissions.getInstance().greenTerra(player) && ((mat.equals(Material.CROPS) && block.getData() == CropState.RIPE.getData()) || Herbalism.canBeGreenTerra(mat))) {
|
||||
Skills.abilityCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
/* Triple drops */
|
||||
if (PP.getGreenTerraMode() && Herbalism.canBeGreenTerra(mat)) {
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin); //Called twice for triple drop functionality
|
||||
}
|
||||
|
||||
if (mcPermissions.getInstance().herbalismDoubleDrops(player) && Herbalism.canBeGreenTerra(mat)) {
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||
}
|
||||
|
||||
/*
|
||||
* MINING
|
||||
*/
|
||||
|
||||
if (mcPermissions.getInstance().mining(player) && Mining.canBeSuperBroken(mat)) {
|
||||
if (LoadProperties.miningrequirespickaxe && ItemChecks.isMiningPick(inhand)) {
|
||||
Mining.miningBlockCheck(player, block);
|
||||
}
|
||||
else if (!LoadProperties.miningrequirespickaxe) {
|
||||
Mining.miningBlockCheck(player, block);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WOOD CUTTING
|
||||
*/
|
||||
|
||||
if (mcPermissions.getInstance().woodcutting(player) && mat.equals(Material.LOG)) {
|
||||
if (LoadProperties.woodcuttingrequiresaxe && ItemChecks.isAxe(inhand)) {
|
||||
WoodCutting.woodcuttingBlockCheck(player, block);
|
||||
}
|
||||
else if (!LoadProperties.woodcuttingrequiresaxe) {
|
||||
WoodCutting.woodcuttingBlockCheck(player, block);
|
||||
}
|
||||
}
|
||||
|
||||
if (PP.getTreeFellerMode() && mcPermissions.getInstance().treeFeller(player)) {
|
||||
WoodCutting.treeFeller(event);
|
||||
}
|
||||
|
||||
/*
|
||||
* EXCAVATION
|
||||
*/
|
||||
|
||||
if (Excavation.canBeGigaDrillBroken(mat) && mcPermissions.getInstance().excavation(player) && !block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (LoadProperties.excavationRequiresShovel && ItemChecks.isShovel(inhand)) {
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
}
|
||||
else if (!LoadProperties.excavationRequiresShovel) {
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
}
|
||||
}
|
||||
|
||||
//Remove metadata when broken
|
||||
if (block.hasMetadata("mcmmoPlacedBlock") && BlockChecks.shouldBeWatched(mat)) {
|
||||
block.removeMetadata("mcmmoPlacedBlock", plugin);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor BlockDamage events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
final int LEAF_BLOWER_LEVEL = 100;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
ItemStack inhand = player.getItemInHand();
|
||||
Block block = event.getBlock();
|
||||
Material mat = block.getType();
|
||||
|
||||
/*
|
||||
* ABILITY PREPARATION CHECKS
|
||||
*/
|
||||
if (BlockChecks.abilityBlockCheck(mat)) {
|
||||
if (PP.getHoePreparationMode() && (Herbalism.canBeGreenTerra(mat) || Herbalism.makeMossy(mat))) {
|
||||
Skills.abilityCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
else if (PP.getAxePreparationMode() && mat.equals(Material.LOG) && mcPermissions.getInstance().treeFeller(player)) { //Why are we checking the permissions here?
|
||||
Skills.abilityCheck(player, SkillType.WOODCUTTING);
|
||||
}
|
||||
else if (PP.getPickaxePreparationMode() && Mining.canBeSuperBroken(mat)) {
|
||||
Skills.abilityCheck(player, SkillType.MINING);
|
||||
}
|
||||
else if (PP.getShovelPreparationMode() && Excavation.canBeGigaDrillBroken(mat)) {
|
||||
Skills.abilityCheck(player, SkillType.EXCAVATION);
|
||||
}
|
||||
else if (PP.getFistsPreparationMode() && (Excavation.canBeGigaDrillBroken(mat) || mat.equals(Material.SNOW))) {
|
||||
Skills.abilityCheck(player, SkillType.UNARMED);
|
||||
}
|
||||
}
|
||||
|
||||
/* TREE FELLER SOUNDS */
|
||||
if (LoadProperties.spoutEnabled && mat.equals(Material.LOG) && PP.getTreeFellerMode()) {
|
||||
SpoutSounds.playSoundForPlayer(SoundEffect.FIZZ, player, block.getLocation());
|
||||
}
|
||||
|
||||
/*
|
||||
* ABILITY TRIGGER CHECKS
|
||||
*/
|
||||
if (PP.getGreenTerraMode() && mcPermissions.getInstance().greenTerra(player) && Herbalism.makeMossy(mat)) {
|
||||
Herbalism.greenTerra(player, block);
|
||||
}
|
||||
else if (PP.getGigaDrillBreakerMode() && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
|
||||
if (LoadProperties.excavationRequiresShovel && ItemChecks.isShovel(inhand)) {
|
||||
event.setInstaBreak(true);
|
||||
Excavation.gigaDrillBreaker(player, block);
|
||||
}
|
||||
else if (!LoadProperties.excavationRequiresShovel) {
|
||||
event.setInstaBreak(true);
|
||||
Excavation.gigaDrillBreaker(player, block);
|
||||
}
|
||||
}
|
||||
else if (PP.getBerserkMode() && Skills.triggerCheck(player, block, AbilityType.BERSERK)) {
|
||||
if (inhand.getType().equals(Material.AIR)) {
|
||||
PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
|
||||
Bukkit.getPluginManager().callEvent(armswing);
|
||||
|
||||
event.setInstaBreak(true);
|
||||
}
|
||||
|
||||
if (LoadProperties.spoutEnabled) {
|
||||
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
||||
}
|
||||
}
|
||||
else if (PP.getSuperBreakerMode() && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
|
||||
if (LoadProperties.miningrequirespickaxe && ItemChecks.isMiningPick(inhand)) {
|
||||
event.setInstaBreak(true);
|
||||
Mining.SuperBreakerBlockCheck(player, block);
|
||||
}
|
||||
else if (!LoadProperties.miningrequirespickaxe) {
|
||||
event.setInstaBreak(true);
|
||||
Mining.SuperBreakerBlockCheck(player, block);
|
||||
}
|
||||
}
|
||||
else if (PP.getSkillLevel(SkillType.WOODCUTTING) >= LEAF_BLOWER_LEVEL && mat.equals(Material.LEAVES)) {
|
||||
if (LoadProperties.woodcuttingrequiresaxe && ItemChecks.isAxe(inhand)) {
|
||||
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||
event.setInstaBreak(true);
|
||||
WoodCutting.leafBlower(player, block);
|
||||
}
|
||||
}
|
||||
else if (!LoadProperties.woodcuttingrequiresaxe && !inhand.getType().equals(Material.SHEARS)) {
|
||||
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||
event.setInstaBreak(true);
|
||||
WoodCutting.leafBlower(player, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,208 +1,314 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityTameEvent;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import com.gmail.nossr50.Combat;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.events.FakeEntityDamageByEntityEvent;
|
||||
import com.gmail.nossr50.events.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.runnables.mcBleedTimer;
|
||||
import com.gmail.nossr50.skills.Acrobatics;
|
||||
import com.gmail.nossr50.skills.Archery;
|
||||
import com.gmail.nossr50.skills.BlastMining;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.skills.Taming;
|
||||
|
||||
|
||||
public class mcEntityListener extends EntityListener
|
||||
{
|
||||
private final mcMMO plugin;
|
||||
public class mcEntityListener implements Listener {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public mcEntityListener(final mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void onEntityDamage(EntityDamageEvent event)
|
||||
{
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
//Check for world pvp flag
|
||||
if(event instanceof EntityDamageByEntityEvent)
|
||||
{
|
||||
EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent)event;
|
||||
if(eventb.getEntity() instanceof Player && eventb.getDamager() instanceof Player && !event.getEntity().getWorld().getPVP())
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* CHECK FOR INVULNERABILITY
|
||||
*/
|
||||
if(event.getEntity() instanceof Player)
|
||||
{
|
||||
Player defender = (Player)event.getEntity();
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
if(defender != null && PPd.getGodMode())
|
||||
event.setCancelled(true);
|
||||
if(PPd == null)
|
||||
Users.addUser(defender);
|
||||
}
|
||||
|
||||
if(event.getEntity() instanceof LivingEntity)
|
||||
{
|
||||
//CraftEntity cEntity = (CraftEntity)event.getEntity();
|
||||
//if(cEntity.getHandle() instanceof EntityLiving)
|
||||
{
|
||||
LivingEntity entityliving = (LivingEntity)event.getEntity();
|
||||
if(entityliving.getNoDamageTicks() < entityliving.getMaximumNoDamageTicks()/2.0F)
|
||||
{
|
||||
Entity x = event.getEntity();
|
||||
DamageCause type = event.getCause();
|
||||
if(event.getEntity() instanceof Wolf && ((Wolf)event.getEntity()).isTamed() && Taming.getOwner(((Wolf)event.getEntity()), plugin) != null)
|
||||
{
|
||||
Wolf theWolf = (Wolf) event.getEntity();
|
||||
Player master = Taming.getOwner(theWolf, plugin);
|
||||
PlayerProfile PPo = Users.getProfile(master);
|
||||
if(master == null || PPo == null)
|
||||
return;
|
||||
//Environmentally Aware
|
||||
if((event.getCause() == DamageCause.CONTACT || event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.FIRE) && PPo.getSkillLevel(SkillType.TAMING) >= 100)
|
||||
{
|
||||
if(event.getDamage() < ((Wolf) event.getEntity()).getHealth())
|
||||
{
|
||||
event.getEntity().teleport(Taming.getOwner(theWolf, plugin).getLocation());
|
||||
master.sendMessage(mcLocale.getString("mcEntityListener.WolfComesBack")); //$NON-NLS-1$
|
||||
event.getEntity().setFireTicks(0);
|
||||
}
|
||||
}
|
||||
if(event.getCause() == DamageCause.FALL && PPo.getSkillLevel(SkillType.TAMING) >= 100)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
//Thick Fur
|
||||
if(event.getCause() == DamageCause.FIRE_TICK)
|
||||
{
|
||||
event.getEntity().setFireTicks(0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ACROBATICS
|
||||
*/
|
||||
if(x instanceof Player){
|
||||
Player player = (Player)x;
|
||||
if(type == DamageCause.FALL){
|
||||
Acrobatics.acrobaticsCheck(player, event);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Entity Damage by Entity checks
|
||||
*/
|
||||
if(event instanceof EntityDamageByEntityEvent && !event.isCancelled())
|
||||
{
|
||||
EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent) event;
|
||||
Entity f = eventb.getDamager();
|
||||
Entity e = event.getEntity();
|
||||
/*
|
||||
* PARTY CHECKS
|
||||
*/
|
||||
if(event.getEntity() instanceof Player && f instanceof Player)
|
||||
{
|
||||
Player defender = (Player)e;
|
||||
Player attacker = (Player)f;
|
||||
if(Party.getInstance().inSameParty(defender, attacker))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
Combat.combatChecks(event, plugin);
|
||||
}
|
||||
/*
|
||||
* Check to see if the defender took damage so we can apply recently hurt
|
||||
*/
|
||||
if(event.getEntity() instanceof Player)
|
||||
{
|
||||
Player herpderp = (Player)event.getEntity();
|
||||
if(!event.isCancelled() && event.getDamage() >= 1)
|
||||
{
|
||||
Users.getProfile(herpderp).setRecentlyHurt(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor EntityDamageByEntity events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
if (event instanceof FakeEntityDamageByEntityEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity defender = event.getEntity();
|
||||
Entity attacker = event.getDamager();
|
||||
|
||||
if (attacker instanceof Player && defender instanceof Player) {
|
||||
if (!defender.getWorld().getPVP()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Party.getInstance().inSameParty((Player)defender, (Player)attacker)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for invincibility */
|
||||
if (defender instanceof LivingEntity) {
|
||||
LivingEntity livingDefender = (LivingEntity)defender;
|
||||
|
||||
if (!m.isInvincible(livingDefender, event)) {
|
||||
Combat.combatChecks(event, plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onEntityDeath(EntityDeathEvent event)
|
||||
{
|
||||
Entity x = event.getEntity();
|
||||
x.setFireTicks(0);
|
||||
|
||||
//Remove bleed track
|
||||
if(plugin.misc.bleedTracker.contains((LivingEntity)x))
|
||||
plugin.misc.addToBleedRemovalQue((LivingEntity)x);
|
||||
|
||||
Skills.arrowRetrievalCheck(x, plugin);
|
||||
/*
|
||||
if(Config.getInstance().isMobSpawnTracked(x)){
|
||||
Config.getInstance().removeMobSpawnTrack(x);
|
||||
}
|
||||
*/
|
||||
if(x instanceof Player){
|
||||
Player player = (Player)x;
|
||||
Users.getProfile(player).setBleedTicks(0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Monitor EntityDamage events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if (event instanceof FakeEntityDamageEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
EntityType type = entity.getType();
|
||||
DamageCause cause = event.getCause();
|
||||
|
||||
switch(type) {
|
||||
case PLAYER:
|
||||
|
||||
/* Check for invincibility */
|
||||
Player player = (Player) entity;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if (PP.getGodMode()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m.isInvincible(player, event)) {
|
||||
if (cause == DamageCause.FALL && mcPermissions.getInstance().acrobatics(player)) {
|
||||
Acrobatics.acrobaticsCheck(player, event);
|
||||
}
|
||||
else if (cause == DamageCause.BLOCK_EXPLOSION && mcPermissions.getInstance().demolitionsExpertise(player)) {
|
||||
BlastMining.demolitionsExpertise(player, event);
|
||||
}
|
||||
|
||||
if (event.getDamage() >= 1) {
|
||||
PP.setRecentlyHurt(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WOLF:
|
||||
Wolf wolf = (Wolf) entity;
|
||||
|
||||
if ((!m.isInvincible(wolf, event)) && wolf.isTamed() && (wolf.getOwner() instanceof Player)) {
|
||||
Taming.preventDamage(event);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event)
|
||||
{
|
||||
SpawnReason reason = event.getSpawnReason();
|
||||
|
||||
if(reason == SpawnReason.SPAWNER && !LoadProperties.xpGainsMobSpawners)
|
||||
{
|
||||
plugin.misc.mobSpawnerList.add(event.getEntity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor EntityDeath events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
LivingEntity x = event.getEntity();
|
||||
x.setFireTicks(0);
|
||||
|
||||
/* Remove bleed track */
|
||||
mcBleedTimer.remove(x);
|
||||
|
||||
Archery.arrowRetrievalCheck(x, plugin);
|
||||
|
||||
if (x instanceof Player) {
|
||||
Users.getProfile((Player)x).setBleedTicks(0);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBow(ItemStack is){
|
||||
if (is.getTypeId() == 261){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public boolean isPlayer(Entity entity){
|
||||
if (entity instanceof Player) {
|
||||
return true;
|
||||
} else{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor CreatureSpawn events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
if (event.getSpawnReason().equals(SpawnReason.SPAWNER) && !LoadProperties.xpGainsMobSpawners) {
|
||||
event.getEntity().setMetadata("mcmmoFromMobSpawner", new FixedMetadataValue(plugin, true));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor ExplosionPrime events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.LOW)
|
||||
public void onExplosionPrime(ExplosionPrimeEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (entity instanceof TNTPrimed) {
|
||||
int id = entity.getEntityId();
|
||||
|
||||
if (plugin.tntTracker.containsKey(id)) {
|
||||
Player player = plugin.tntTracker.get(id);
|
||||
|
||||
if (mcPermissions.getInstance().biggerBombs(player)) {
|
||||
BlastMining.biggerBombs(player, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor EntityExplode events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.LOW)
|
||||
public void onEnitityExplode(EntityExplodeEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (event.getEntity() instanceof TNTPrimed) {
|
||||
int id = entity.getEntityId();
|
||||
|
||||
if (plugin.tntTracker.containsKey(id)) {
|
||||
Player player = plugin.tntTracker.get(id);
|
||||
BlastMining.dropProcessing(player, event);
|
||||
plugin.tntTracker.remove(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor FoodLevelChange events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.LOW)
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
if (LoadProperties.herbalismHungerBonus) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int currentFoodLevel = player.getFoodLevel();
|
||||
int newFoodLevel = event.getFoodLevel();
|
||||
|
||||
/* Some foods have 3 ranks
|
||||
* Some foods have 5 ranks
|
||||
* The number of ranks is based on how 'common' the item is
|
||||
* We can adjust this quite easily if we find something is giving too much of a bonus
|
||||
*/
|
||||
|
||||
if (newFoodLevel > currentFoodLevel) {
|
||||
Material food = player.getItemInHand().getType();
|
||||
int herbLevel = PP.getSkillLevel(SkillType.HERBALISM);
|
||||
int foodChange = newFoodLevel - currentFoodLevel;
|
||||
int rankChange = 0;
|
||||
|
||||
switch (food) {
|
||||
case BREAD:
|
||||
/* BREAD RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||
rankChange = 200;
|
||||
break;
|
||||
|
||||
case COOKIE:
|
||||
/* COOKIE RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
rankChange = 400;
|
||||
break;
|
||||
|
||||
case MELON:
|
||||
/* MELON RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
rankChange = 400;
|
||||
break;
|
||||
|
||||
case MUSHROOM_SOUP:
|
||||
/* MUSHROOM SOUP RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
rankChange = 200;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 200; i <= 1000; i += rankChange) {
|
||||
if (herbLevel >= i) {
|
||||
foodChange++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure we don't go over the max value */
|
||||
newFoodLevel = currentFoodLevel + foodChange;
|
||||
if (newFoodLevel > 20) {
|
||||
event.setFoodLevel(20);
|
||||
}
|
||||
else {
|
||||
event.setFoodLevel(newFoodLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor EntityTame events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
public void onEntityTame(EntityTameEvent event) {
|
||||
Player player = (Player) event.getOwner();
|
||||
|
||||
if (mcPermissions.getInstance().taming(player) && !event.getEntity().hasMetadata("mcmmoSummoned")) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
EntityType type = event.getEntityType();
|
||||
int xp = 0;
|
||||
|
||||
switch (type) {
|
||||
case WOLF:
|
||||
xp = LoadProperties.mtameWolf;
|
||||
break;
|
||||
|
||||
case OCELOT:
|
||||
xp = LoadProperties.mtameOcelot;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
PP.addXP(SkillType.TAMING, xp, player);
|
||||
Skills.XpCheckSkill(SkillType.TAMING, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,346 +1,366 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.command.ColouredConsoleSender;
|
||||
import org.bukkit.craftbukkit.entity.CraftItem;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Wolf;
|
||||
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.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent.State;
|
||||
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.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.BlockChecks;
|
||||
import com.gmail.nossr50.Combat;
|
||||
import com.gmail.nossr50.Item;
|
||||
import com.gmail.nossr50.ItemChecks;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.commands.general.XprateCommand;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.runnables.RemoveProfileFromMemoryTask;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.spout.mmoHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.skills.BlastMining;
|
||||
import com.gmail.nossr50.skills.Fishing;
|
||||
import com.gmail.nossr50.skills.Herbalism;
|
||||
import com.gmail.nossr50.skills.Repair;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.skills.Taming;
|
||||
|
||||
public class mcPlayerListener implements Listener {
|
||||
private mcMMO plugin;
|
||||
|
||||
public class mcPlayerListener extends PlayerListener
|
||||
{
|
||||
protected static final Logger log = Logger.getLogger("Minecraft"); //$NON-NLS-1$
|
||||
public Location spawn = null;
|
||||
private mcMMO plugin;
|
||||
public mcPlayerListener(mcMMO instance) {
|
||||
plugin = instance;
|
||||
}
|
||||
|
||||
public mcPlayerListener(mcMMO instance)
|
||||
{
|
||||
plugin = instance;
|
||||
}
|
||||
|
||||
public void onPlayerFish(PlayerFishEvent event)
|
||||
{
|
||||
if(mcPermissions.getInstance().fishing(event.getPlayer()))
|
||||
{
|
||||
if(event.getState() == State.CAUGHT_FISH)
|
||||
{
|
||||
if(event.getCaught() instanceof CraftItem)
|
||||
{
|
||||
Fishing.processResults(event);
|
||||
}
|
||||
} else if (event.getState() == State.CAUGHT_ENTITY)
|
||||
{
|
||||
if(Users.getProfile(event.getPlayer()).getSkillLevel(SkillType.FISHING) >= 150 && event.getCaught() instanceof LivingEntity)
|
||||
{
|
||||
Fishing.shakeMob(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onPlayerPickupItem(PlayerPickupItemEvent event)
|
||||
{
|
||||
if(Users.getProfile(event.getPlayer()).getBerserkMode())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Monitor PlayerChangedWorld events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerWorldChangeEvent(PlayerChangedWorldEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event)
|
||||
{
|
||||
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(LoadProperties.enableMySpawn && mcPermissions.getInstance().mySpawn(player))
|
||||
{
|
||||
if(player != null && PP != null)
|
||||
{
|
||||
PP.setRespawnATS(System.currentTimeMillis());
|
||||
|
||||
Location mySpawn = PP.getMySpawn(player);
|
||||
|
||||
if(mySpawn != null)
|
||||
{
|
||||
{
|
||||
event.setRespawnLocation(mySpawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onPlayerLogin(PlayerLoginEvent event)
|
||||
{
|
||||
Users.addUser(event.getPlayer());
|
||||
}
|
||||
if (PP.getGodMode()) {
|
||||
if (!mcPermissions.getInstance().mcgod(player)) {
|
||||
PP.toggleGodMode();
|
||||
player.sendMessage(mcLocale.getString("GodMode.Forbidden"));
|
||||
}
|
||||
}
|
||||
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
|
||||
/*
|
||||
* GARBAGE COLLECTION
|
||||
*/
|
||||
//Discard the PlayerProfile object
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(LoadProperties.spoutEnabled)
|
||||
{
|
||||
if(SpoutStuff.playerHUDs.containsKey(player))
|
||||
SpoutStuff.playerHUDs.remove(player);
|
||||
if(mmoHelper.containers.containsKey(player))
|
||||
mmoHelper.containers.remove(player);
|
||||
}
|
||||
|
||||
Users.removeUser(event.getPlayer());
|
||||
}
|
||||
if (PP.inParty()) {
|
||||
if (!mcPermissions.getInstance().party(player)) {
|
||||
PP.removeParty();
|
||||
player.sendMessage(mcLocale.getString("Party.Forbidden"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if(mcPermissions.getInstance().motd(player) && LoadProperties.enableMotd)
|
||||
{
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.MOTD", new Object[] {plugin.getDescription().getVersion(), LoadProperties.mcmmo}));
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.WIKI"));
|
||||
}
|
||||
//THIS IS VERY BAD WAY TO DO THINGS, NEED BETTER WAY
|
||||
if(XprateCommand.xpevent)
|
||||
player.sendMessage(ChatColor.GOLD+"mcMMO is currently in an XP rate event! XP rate is "+LoadProperties.xpGainMultiplier+"x!");
|
||||
}
|
||||
/**
|
||||
* Monitor PlayerFish events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerFish(PlayerFishEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
Action action = event.getAction();
|
||||
Block block = event.getClickedBlock();
|
||||
if (mcPermissions.getInstance().fishing(player)) {
|
||||
State state = event.getState();
|
||||
|
||||
/*
|
||||
* Ability checks
|
||||
*/
|
||||
if(action == Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
ItemStack is = player.getItemInHand();
|
||||
if(LoadProperties.enableMySpawn && block != null && player != null)
|
||||
{
|
||||
if(block.getTypeId() == 26 && mcPermissions.getInstance().setMySpawn(player))
|
||||
{
|
||||
Location loc = player.getLocation();
|
||||
if(mcPermissions.getInstance().setMySpawn(player)){
|
||||
PP.setMySpawn(loc.getX(), loc.getY(), loc.getZ(), loc.getWorld().getName());
|
||||
}
|
||||
//player.sendMessage(mcLocale.getString("mcPlayerListener.MyspawnSet"));
|
||||
}
|
||||
}
|
||||
switch (state) {
|
||||
case CAUGHT_FISH:
|
||||
Fishing.processResults(event);
|
||||
break;
|
||||
|
||||
if(block != null && player != null && mcPermissions.getInstance().repair(player)
|
||||
&& event.getClickedBlock().getTypeId() == 42 && (Repair.isTools(player.getItemInHand()) || Repair.isArmor(player.getItemInHand())))
|
||||
{
|
||||
Repair.repairCheck(player, is, event.getClickedBlock());
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
}
|
||||
case CAUGHT_ENTITY:
|
||||
if (Users.getProfile(player).getSkillLevel(SkillType.FISHING) >= 150 && mcPermissions.getInstance().shakeMob(player)) {
|
||||
Fishing.shakeMob(event);
|
||||
}
|
||||
break;
|
||||
|
||||
if(LoadProperties.enableAbilities && m.abilityBlockCheck(block))
|
||||
{
|
||||
if(block != null && m.isHoe(player.getItemInHand()) && block.getTypeId() != 3 && block.getTypeId() != 2 && block.getTypeId() != 60){
|
||||
Skills.hoeReadinessCheck(player);
|
||||
}
|
||||
Skills.abilityActivationCheck(player);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//GREEN THUMB
|
||||
if(block != null && mcPermissions.getInstance().herbalism(player) && (block.getType() == Material.COBBLESTONE || block.getType() == Material.DIRT || block.getType() == Material.SMOOTH_BRICK) && player.getItemInHand().getType() == Material.SEEDS)
|
||||
{
|
||||
boolean pass = false;
|
||||
if(Herbalism.hasSeeds(player))
|
||||
{
|
||||
Herbalism.removeSeeds(player);
|
||||
|
||||
if(block.getType() == Material.DIRT || block.getType() == Material.COBBLESTONE || block.getType() == Material.SMOOTH_BRICK)
|
||||
{
|
||||
if(Math.random() * 1500 <= PP.getSkillLevel(SkillType.HERBALISM) && m.blockBreakSimulate(block, player))
|
||||
{
|
||||
switch(block.getType())
|
||||
{
|
||||
case COBBLESTONE:
|
||||
if(LoadProperties.enableCobbleToMossy)
|
||||
{
|
||||
block.setType(Material.MOSSY_COBBLESTONE);
|
||||
pass = true;
|
||||
}
|
||||
break;
|
||||
case DIRT:
|
||||
pass = true;
|
||||
block.setType(Material.GRASS);
|
||||
break;
|
||||
case SMOOTH_BRICK:
|
||||
pass = true;
|
||||
block.setData((byte)1);
|
||||
break;
|
||||
}
|
||||
if(pass == false)
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.GreenThumbFail"));
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(LoadProperties.enableAbilities && action == Action.RIGHT_CLICK_AIR)
|
||||
{
|
||||
Skills.hoeReadinessCheck(player);
|
||||
Skills.abilityActivationCheck(player);
|
||||
}
|
||||
|
||||
/*
|
||||
* ITEM CHECKS
|
||||
*/
|
||||
if(action == Action.RIGHT_CLICK_AIR)
|
||||
Item.itemchecks(player, plugin);
|
||||
if(action == Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
if(m.abilityBlockCheck(event.getClickedBlock()))
|
||||
Item.itemchecks(player, plugin);
|
||||
}
|
||||
|
||||
if(player.isSneaking() && mcPermissions.getInstance().taming(player) && (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK))
|
||||
{
|
||||
if(player.getItemInHand().getType() == Material.BONE && player.getItemInHand().getAmount() > 9)
|
||||
{
|
||||
for(Entity x : player.getNearbyEntities(40, 40, 40))
|
||||
{
|
||||
if(x instanceof Wolf)
|
||||
{
|
||||
player.sendMessage(mcLocale.getString("m.TamingSummonFailed"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
World world = player.getWorld();
|
||||
world.spawnCreature(player.getLocation(), CreatureType.WOLF);
|
||||
|
||||
ItemStack[] inventory = player.getInventory().getContents();
|
||||
for(ItemStack x : inventory){
|
||||
if(x != null && x.getAmount() > LoadProperties.bonesConsumedByCOTW-1 && x.getType() == Material.BONE){
|
||||
if(x.getAmount() >= LoadProperties.bonesConsumedByCOTW)
|
||||
{
|
||||
x.setAmount(x.getAmount() - LoadProperties.bonesConsumedByCOTW);
|
||||
player.getInventory().setContents(inventory);
|
||||
player.updateInventory();
|
||||
break;
|
||||
} else {
|
||||
x.setAmount(0);
|
||||
x.setTypeId(0);
|
||||
player.getInventory().setContents(inventory);
|
||||
player.updateInventory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
player.sendMessage(mcLocale.getString("m.TamingSummon"));
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Monitor PlaterPickupItem events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
||||
if (Users.getProfile(event.getPlayer()).getBerserkMode()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void onPlayerChat(PlayerChatEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(PP.getPartyChatMode())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
String format = ChatColor.GREEN + "(" + ChatColor.WHITE + player.getDisplayName() + ChatColor.GREEN + ") "+event.getMessage();
|
||||
for(Player x : Bukkit.getServer().getOnlinePlayers())
|
||||
{
|
||||
if(Party.getInstance().inSameParty(player, x))
|
||||
x.sendMessage(format);
|
||||
}
|
||||
if(Bukkit.getServer() instanceof ColouredConsoleSender)
|
||||
{
|
||||
ColouredConsoleSender ccs = (ColouredConsoleSender) Bukkit.getServer();
|
||||
ccs.sendMessage(ChatColor.GREEN+"[P]"+format); //Colors, woot!
|
||||
}
|
||||
} else if (PP.getAdminChatMode()) {
|
||||
event.setCancelled(true);
|
||||
String format = ChatColor.AQUA + "{" + ChatColor.WHITE + player.getDisplayName() + ChatColor.AQUA + "} "+event.getMessage();
|
||||
for(Player x : Bukkit.getServer().getOnlinePlayers())
|
||||
{
|
||||
if(x.isOp() || mcPermissions.getInstance().adminChat(x))
|
||||
x.sendMessage(format);
|
||||
}
|
||||
if(Bukkit.getServer() instanceof ColouredConsoleSender)
|
||||
{
|
||||
ColouredConsoleSender ccs = (ColouredConsoleSender) Bukkit.getServer();
|
||||
ccs.sendMessage(ChatColor.AQUA+"[A]"+format); //Colors, woot!
|
||||
} else {
|
||||
log.log(Level.INFO, "[A]"+format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
String message = event.getMessage();
|
||||
if(!message.startsWith("/")) return;
|
||||
String command = message.substring(1).split(" ")[0];
|
||||
if(plugin.aliasMap.containsKey(command)) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().chat(message.replaceFirst(command, plugin.aliasMap.get(command)));
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Monitor PlayerLogin events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
Users.addUser(event.getPlayer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor PlayerQuit events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
/* GARBAGE COLLECTION */
|
||||
|
||||
//Remove Spout Stuff
|
||||
if(LoadProperties.spoutEnabled && SpoutStuff.playerHUDs.containsKey(player)) {
|
||||
SpoutStuff.playerHUDs.remove(player);
|
||||
}
|
||||
|
||||
//Bleed it out
|
||||
if(PP.getBleedTicks() > 0) {
|
||||
Combat.dealDamage(player, PP.getBleedTicks()*2);
|
||||
}
|
||||
|
||||
//Schedule PlayerProfile removal 2 minutes after quitting
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new RemoveProfileFromMemoryTask(player), 2400);
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor PlayerJoin events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (mcPermissions.getInstance().motd(player) && LoadProperties.enableMotd) {
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.MOTD", new Object[] {plugin.getDescription().getVersion(), "mcmmo"}));
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.WIKI"));
|
||||
}
|
||||
|
||||
//THIS IS VERY BAD WAY TO DO THINGS, NEED BETTER WAY
|
||||
if (XprateCommand.xpevent) {
|
||||
player.sendMessage(mcLocale.getString("XPRate.Event", new Object[] {LoadProperties.xpGainMultiplier}));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor PlayerInteract events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
Action action = event.getAction();
|
||||
Block block = event.getClickedBlock();
|
||||
ItemStack is = player.getItemInHand();
|
||||
Material mat;
|
||||
|
||||
/* Fix for NPE on interacting with air */
|
||||
if (block == null) {
|
||||
mat = Material.AIR;
|
||||
}
|
||||
else {
|
||||
mat = block.getType();
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
case RIGHT_CLICK_BLOCK:
|
||||
|
||||
/* REPAIR CHECKS */
|
||||
if (mcPermissions.getInstance().repair(player) && block.getTypeId() == LoadProperties.anvilID && (ItemChecks.isTool(is) || ItemChecks.isArmor(is))) {
|
||||
Repair.repairCheck(player, is);
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
/* ACTIVATION CHECKS */
|
||||
if (LoadProperties.enableAbilities && BlockChecks.abilityBlockCheck(mat)) {
|
||||
if (!mat.equals(Material.DIRT) && !mat.equals(Material.GRASS) && !mat.equals(Material.SOIL)) {
|
||||
Skills.activationCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
Skills.activationCheck(player, SkillType.AXES);
|
||||
Skills.activationCheck(player, SkillType.EXCAVATION);
|
||||
Skills.activationCheck(player, SkillType.MINING);
|
||||
Skills.activationCheck(player, SkillType.SWORDS);
|
||||
Skills.activationCheck(player, SkillType.UNARMED);
|
||||
Skills.activationCheck(player, SkillType.WOODCUTTING);
|
||||
}
|
||||
|
||||
/* GREEN THUMB CHECK */
|
||||
if (mcPermissions.getInstance().greenThumbBlocks(player) && Herbalism.makeMossy(mat) && is.getType().equals(Material.SEEDS)) {
|
||||
Herbalism.greenThumbBlocks(is, player, block);
|
||||
}
|
||||
|
||||
/* ITEM CHECKS */
|
||||
if (BlockChecks.abilityBlockCheck(mat)) {
|
||||
Item.itemchecks(player);
|
||||
}
|
||||
|
||||
/* BLAST MINING CHECK */
|
||||
if (mcPermissions.getInstance().blastMining(player) && is.getTypeId() == LoadProperties.detonatorID) {
|
||||
BlastMining.remoteDetonation(player, plugin);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RIGHT_CLICK_AIR:
|
||||
|
||||
/* ACTIVATION CHECKS */
|
||||
if (LoadProperties.enableAbilities) {
|
||||
Skills.activationCheck(player, SkillType.AXES);
|
||||
Skills.activationCheck(player, SkillType.EXCAVATION);
|
||||
Skills.activationCheck(player, SkillType.HERBALISM);
|
||||
Skills.activationCheck(player, SkillType.MINING);
|
||||
Skills.activationCheck(player, SkillType.SWORDS);
|
||||
Skills.activationCheck(player, SkillType.UNARMED);
|
||||
Skills.activationCheck(player, SkillType.WOODCUTTING);
|
||||
}
|
||||
|
||||
/* ITEM CHECKS */
|
||||
Item.itemchecks(player);
|
||||
|
||||
/* BLAST MINING CHECK */
|
||||
if (mcPermissions.getInstance().blastMining(player) && is.getTypeId() == LoadProperties.detonatorID) {
|
||||
BlastMining.remoteDetonation(player, plugin);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case LEFT_CLICK_AIR:
|
||||
case LEFT_CLICK_BLOCK:
|
||||
|
||||
/* CALL OF THE WILD CHECKS */
|
||||
if (player.isSneaking() && mcPermissions.getInstance().taming(player)) {
|
||||
if (is.getType().equals(Material.RAW_FISH)) {
|
||||
Taming.animalSummon(EntityType.OCELOT, player, plugin);
|
||||
}
|
||||
else if (is.getType().equals(Material.BONE)) {
|
||||
Taming.animalSummon(EntityType.WOLF, player, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor PlayerChat events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerChat(PlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
boolean partyChat = PP.getPartyChatMode();
|
||||
boolean adminChat = PP.getAdminChatMode();
|
||||
|
||||
if (partyChat || adminChat) {
|
||||
event.setCancelled(true);
|
||||
|
||||
String name = "";
|
||||
boolean displayNames = false;
|
||||
ChatColor color = ChatColor.WHITE;
|
||||
String logHeader = "";
|
||||
|
||||
/* Set the pChat & aChat specific stuff */
|
||||
if (partyChat) {
|
||||
if (!PP.inParty()) {
|
||||
player.sendMessage("You're not in a party, type /p to leave party chat mode."); //TODO: Use mcLocale
|
||||
return;
|
||||
}
|
||||
|
||||
displayNames = LoadProperties.pDisplayNames;
|
||||
color = ChatColor.GREEN;
|
||||
logHeader = "[P](" + PP.getParty() + ")<";
|
||||
}
|
||||
else if (adminChat) {
|
||||
displayNames = LoadProperties.aDisplayNames;
|
||||
color = ChatColor.AQUA;
|
||||
logHeader = "[A]<";
|
||||
}
|
||||
|
||||
/* Format & display */
|
||||
if (displayNames) {
|
||||
name = player.getDisplayName();
|
||||
}
|
||||
else {
|
||||
name = player.getName();
|
||||
}
|
||||
|
||||
String format = color + "(" + ChatColor.WHITE + name + color + ") " + event.getMessage();
|
||||
|
||||
for (Player x : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (partyChat && Party.getInstance().inSameParty(player, x))
|
||||
x.sendMessage(format);
|
||||
else if (adminChat && (x.isOp() || mcPermissions.getInstance().adminChat(x))) {
|
||||
x.sendMessage(format);
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.getLogger().info(logHeader + name + ">" + event.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// Dynamically aliasing commands need to be re-done.
|
||||
// For now, using a command with an alias will send both the original command, and the mcMMO command
|
||||
|
||||
/**
|
||||
* Monitor PlayerCommandPreprocess events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
String message = event.getMessage();
|
||||
|
||||
if (!message.startsWith("/")) {
|
||||
return;
|
||||
}
|
||||
|
||||
String command = message.substring(1).split(" ")[0];
|
||||
|
||||
if (plugin.aliasMap.containsKey(command)) {
|
||||
if(command.equalsIgnoreCase(plugin.aliasMap.get(command))) {
|
||||
return;
|
||||
}
|
||||
event.getPlayer().chat(message.replaceFirst(command, plugin.aliasMap.get(command)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.gmail.nossr50.events.McMMOPlayerXpGainEvent;
|
||||
|
||||
/**
|
||||
* Listener for listening to our own events, only really useful for catching errors
|
||||
*/
|
||||
public class mcSelfListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor internal XP gain events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler
|
||||
public void onPlayerXpGain(McMMOPlayerXpGainEvent event) {
|
||||
int xp = event.getXpGained();
|
||||
|
||||
if(xp < 0) {
|
||||
try {
|
||||
throw new Exception("Gained negative XP!");
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,7 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.getspout.spoutapi.event.input.InputListener;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.getspout.spoutapi.event.input.KeyPressedEvent;
|
||||
import org.getspout.spoutapi.gui.ScreenType;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
@@ -26,36 +11,38 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.popups.PopupMMO;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
|
||||
public class mcSpoutInputListener extends InputListener
|
||||
{
|
||||
mcMMO plugin = null;
|
||||
|
||||
public mcSpoutInputListener(mcMMO pluginx)
|
||||
{
|
||||
plugin = pluginx;
|
||||
}
|
||||
|
||||
public void onKeyPressedEvent(KeyPressedEvent event)
|
||||
{
|
||||
if(!event.getPlayer().isSpoutCraftEnabled() || event.getPlayer().getMainScreen().getActivePopup() != null)
|
||||
return;
|
||||
if(event.getScreenType() != ScreenType.GAME_SCREEN)
|
||||
return;
|
||||
|
||||
SpoutPlayer sPlayer = event.getPlayer();
|
||||
|
||||
if(event.getKey() == SpoutStuff.keypress)
|
||||
{
|
||||
if(!SpoutStuff.playerScreens.containsKey(sPlayer))
|
||||
{
|
||||
PopupMMO mmoPop = new PopupMMO(sPlayer, Users.getProfile(sPlayer), plugin);
|
||||
SpoutStuff.playerScreens.put(sPlayer, mmoPop);
|
||||
sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer));
|
||||
sPlayer.getMainScreen().setDirty(true);
|
||||
} else {
|
||||
sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer));
|
||||
sPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public class mcSpoutInputListener implements Listener {
|
||||
private mcMMO plugin;
|
||||
|
||||
public mcSpoutInputListener(mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor Spout KeyPressed events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler
|
||||
public void onKeyPressedEvent(KeyPressedEvent event) {
|
||||
SpoutPlayer sPlayer = event.getPlayer();
|
||||
|
||||
if (!sPlayer.isSpoutCraftEnabled() || sPlayer.getMainScreen().getActivePopup() != null || event.getScreenType() != ScreenType.GAME_SCREEN) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getKey() == SpoutStuff.keypress) {
|
||||
if (!SpoutStuff.playerScreens.containsKey(sPlayer)) {
|
||||
PopupMMO mmoPop = new PopupMMO(sPlayer, Users.getProfile(sPlayer), plugin);
|
||||
|
||||
SpoutStuff.playerScreens.put(sPlayer, mmoPop);
|
||||
sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer));
|
||||
sPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
else {
|
||||
sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer));
|
||||
sPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,49 +1,37 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
||||
import org.getspout.spoutapi.event.spout.SpoutListener;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.HUDmmo;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
|
||||
public class mcSpoutListener extends SpoutListener
|
||||
{
|
||||
mcMMO plugin = null;
|
||||
|
||||
public mcSpoutListener(mcMMO pluginx)
|
||||
{
|
||||
plugin = pluginx;
|
||||
}
|
||||
|
||||
public void onSpoutCraftEnable(SpoutCraftEnableEvent event)
|
||||
{
|
||||
SpoutPlayer sPlayer = event.getPlayer();
|
||||
if(sPlayer.isSpoutCraftEnabled())
|
||||
{
|
||||
//Setup Party HUD stuff
|
||||
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer));
|
||||
public class mcSpoutListener implements Listener {
|
||||
//Why do we have this here? We never use it...
|
||||
mcMMO plugin = null;
|
||||
|
||||
public mcSpoutListener(mcMMO pluginx) {
|
||||
plugin = pluginx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor SpoutCraftEnable events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler
|
||||
public void onSpoutCraftEnable(SpoutCraftEnableEvent event) {
|
||||
SpoutPlayer sPlayer = event.getPlayer();
|
||||
|
||||
//Party.update(sPlayer);
|
||||
Users.getProfile(sPlayer).toggleSpoutEnabled();
|
||||
}
|
||||
}
|
||||
if (sPlayer.isSpoutCraftEnabled()) {
|
||||
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer)); //Setup Party HUD stuff
|
||||
Users.getProfile(sPlayer).toggleSpoutEnabled();
|
||||
sPlayer.setTitle(String.valueOf(m.getPowerLevel(sPlayer, Users.getProfile(sPlayer))));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,9 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
|
||||
import org.getspout.spoutapi.event.screen.ScreenCloseEvent;
|
||||
import org.getspout.spoutapi.event.screen.ScreenListener;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
@@ -32,62 +17,75 @@ import com.gmail.nossr50.datatypes.buttons.ButtonPartyToggle;
|
||||
import com.gmail.nossr50.datatypes.popups.PopupMMO;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
|
||||
public class mcSpoutScreenListener extends ScreenListener
|
||||
{
|
||||
mcMMO plugin = null;
|
||||
public mcSpoutScreenListener(mcMMO pluginx)
|
||||
{
|
||||
plugin = pluginx;
|
||||
}
|
||||
public void onButtonClick(ButtonClickEvent event)
|
||||
{
|
||||
SpoutPlayer sPlayer = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(sPlayer);
|
||||
|
||||
if(event.getButton() instanceof ButtonHUDStyle)
|
||||
{
|
||||
if(SpoutStuff.playerHUDs.containsKey(sPlayer))
|
||||
{
|
||||
SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
|
||||
SpoutStuff.playerHUDs.remove(sPlayer);
|
||||
|
||||
switch(PP.getHUDType())
|
||||
{
|
||||
case RETRO:
|
||||
PP.setHUDType(HUDType.STANDARD);
|
||||
break;
|
||||
case STANDARD:
|
||||
PP.setHUDType(HUDType.SMALL);
|
||||
break;
|
||||
case SMALL:
|
||||
PP.setHUDType(HUDType.DISABLED);
|
||||
break;
|
||||
case DISABLED:
|
||||
PP.setHUDType(HUDType.RETRO);
|
||||
}
|
||||
|
||||
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer));
|
||||
|
||||
SpoutStuff.playerScreens.get(sPlayer).updateButtons(PP);
|
||||
}
|
||||
} else if (event.getButton() instanceof ButtonEscape)
|
||||
{
|
||||
sPlayer.getMainScreen().closePopup();
|
||||
} else if (event.getButton() instanceof ButtonPartyToggle)
|
||||
{
|
||||
PP.togglePartyHUD();
|
||||
ButtonPartyToggle bpt = (ButtonPartyToggle)event.getButton();
|
||||
bpt.updateText(PP);
|
||||
SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
|
||||
SpoutStuff.playerHUDs.get(sPlayer).initializeHUD(sPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
public void onScreenClose(ScreenCloseEvent event)
|
||||
{
|
||||
if(event.getScreen() instanceof PopupMMO)
|
||||
{
|
||||
SpoutStuff.playerScreens.remove(event.getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
public class mcSpoutScreenListener implements Listener {
|
||||
//Why do we have this here? We never use it...
|
||||
mcMMO plugin = null;
|
||||
|
||||
public mcSpoutScreenListener(mcMMO pluginx) {
|
||||
plugin = pluginx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor Spout ButtonClick events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler
|
||||
public void onButtonClick(ButtonClickEvent event) {
|
||||
SpoutPlayer sPlayer = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(sPlayer);
|
||||
|
||||
if (event.getButton() instanceof ButtonHUDStyle) {
|
||||
if (SpoutStuff.playerHUDs.containsKey(sPlayer)) {
|
||||
SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
|
||||
SpoutStuff.playerHUDs.remove(sPlayer);
|
||||
|
||||
switch (PP.getHUDType()) {
|
||||
case RETRO:
|
||||
PP.setHUDType(HUDType.STANDARD);
|
||||
break;
|
||||
|
||||
case STANDARD:
|
||||
PP.setHUDType(HUDType.SMALL);
|
||||
break;
|
||||
|
||||
case SMALL:
|
||||
PP.setHUDType(HUDType.DISABLED);
|
||||
break;
|
||||
|
||||
case DISABLED:
|
||||
PP.setHUDType(HUDType.RETRO);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer));
|
||||
SpoutStuff.playerScreens.get(sPlayer).updateButtons(PP);
|
||||
}
|
||||
}
|
||||
else if (event.getButton() instanceof ButtonEscape) {
|
||||
sPlayer.getMainScreen().closePopup();
|
||||
}
|
||||
else if (event.getButton() instanceof ButtonPartyToggle) {
|
||||
PP.togglePartyHUD();
|
||||
ButtonPartyToggle bpt = (ButtonPartyToggle) event.getButton();
|
||||
bpt.updateText(PP);
|
||||
SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
|
||||
SpoutStuff.playerHUDs.get(sPlayer).initializeHUD(sPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor Spout ScreenClose events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler
|
||||
public void onScreenClose(ScreenCloseEvent event) {
|
||||
if (event.getScreen() instanceof PopupMMO) {
|
||||
SpoutStuff.playerScreens.remove(event.getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.locale;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
@@ -1,521 +1,281 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
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.block.Block;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import com.gmail.nossr50.config.*;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.McMMOItemSpawnEvent;
|
||||
|
||||
public class m
|
||||
{
|
||||
public static final Logger log = Logger.getLogger("Minecraft");
|
||||
/*
|
||||
* I'm storing my misc functions/methods in here in an unorganized manner. Spheal with it.
|
||||
* This is probably the most embarrassing part of my code for mcMMO
|
||||
* I really should find an organized place for these things!
|
||||
*/
|
||||
|
||||
public static String getCapitalized(String target)
|
||||
{
|
||||
String firstLetter = target.substring(0,1);
|
||||
String remainder = target.substring(1);
|
||||
String capitalized = firstLetter.toUpperCase() + remainder.toLowerCase();
|
||||
|
||||
return capitalized;
|
||||
}
|
||||
public static int getInt(String string)
|
||||
{
|
||||
if(isInt(string))
|
||||
{
|
||||
return Integer.parseInt(string);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static Double getDouble(String string)
|
||||
{
|
||||
if(isDouble(string))
|
||||
{
|
||||
return Double.parseDouble(string);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (double) 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isDouble(String string)
|
||||
{
|
||||
try
|
||||
{
|
||||
Double.parseDouble(string);
|
||||
}
|
||||
catch(NumberFormatException nFE) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean shouldBeWatched(Block block)
|
||||
{
|
||||
int id = block.getTypeId();
|
||||
return id == 103 || id == 82 || id == 16 || id == 73 || id == 49 || id == 81 || id == 83 || id == 86 || id == 91 || id == 1 || id == 17 || id == 42 || id == 87 || id == 89 || id == 2 || id == 3 || id == 12 || id == 13 || id == 21 || id == 15 || id == 14 || id == 56 || id == 38 || id == 37 || id == 39 || id == 40 || id == 24;
|
||||
}
|
||||
|
||||
public static int getPowerLevel(Player player)
|
||||
{
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int x = 0;
|
||||
if(mcPermissions.getInstance().taming(player))
|
||||
x+=PP.getSkillLevel(SkillType.TAMING);
|
||||
if(mcPermissions.getInstance().mining(player))
|
||||
x+=PP.getSkillLevel(SkillType.MINING);
|
||||
if(mcPermissions.getInstance().woodcutting(player))
|
||||
x+=PP.getSkillLevel(SkillType.WOODCUTTING);
|
||||
if(mcPermissions.getInstance().unarmed(player))
|
||||
x+=PP.getSkillLevel(SkillType.UNARMED);
|
||||
if(mcPermissions.getInstance().herbalism(player))
|
||||
x+=PP.getSkillLevel(SkillType.HERBALISM);
|
||||
if(mcPermissions.getInstance().excavation(player))
|
||||
x+=PP.getSkillLevel(SkillType.EXCAVATION);
|
||||
if(mcPermissions.getInstance().archery(player))
|
||||
x+=PP.getSkillLevel(SkillType.ARCHERY);
|
||||
if(mcPermissions.getInstance().swords(player))
|
||||
x+=PP.getSkillLevel(SkillType.SWORDS);
|
||||
if(mcPermissions.getInstance().axes(player))
|
||||
x+=PP.getSkillLevel(SkillType.AXES);
|
||||
if(mcPermissions.getInstance().acrobatics(player))
|
||||
x+=PP.getSkillLevel(SkillType.ACROBATICS);
|
||||
if(mcPermissions.getInstance().repair(player))
|
||||
x+=PP.getSkillLevel(SkillType.REPAIR);
|
||||
if(mcPermissions.getInstance().fishing(player))
|
||||
x+=PP.getSkillLevel(SkillType.FISHING);
|
||||
return x;
|
||||
}
|
||||
public class m {
|
||||
|
||||
public static boolean blockBreakSimulate(Block block, Player player)
|
||||
{
|
||||
FakeBlockBreakEvent event = new FakeBlockBreakEvent(block, player);
|
||||
if(block != null && player != null){
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if(!event.isCancelled())
|
||||
{
|
||||
return true; //Return true if not cancelled
|
||||
} else {
|
||||
return false; //Return false if cancelled
|
||||
}
|
||||
} else {
|
||||
return false; //Return false if something went wrong
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets a capitalized version of the target string.
|
||||
*
|
||||
* @param target String to capitalize
|
||||
* @return the capitalized string
|
||||
*/
|
||||
public static String getCapitalized(String target) {
|
||||
String firstLetter = target.substring(0,1);
|
||||
String remainder = target.substring(1);
|
||||
String capitalized = firstLetter.toUpperCase() + remainder.toLowerCase();
|
||||
|
||||
public static void damageTool(Player player, short damage)
|
||||
{
|
||||
if(player.getItemInHand().getTypeId() == 0)
|
||||
return;
|
||||
player.getItemInHand().setDurability((short) (player.getItemInHand().getDurability() + damage));
|
||||
if(player.getItemInHand().getDurability() >= getMaxDurability(getTier(player), player.getItemInHand()))
|
||||
{
|
||||
ItemStack[] inventory = player.getInventory().getContents();
|
||||
for(ItemStack x : inventory)
|
||||
{
|
||||
if(x != null && x.getTypeId() == player.getItemInHand().getTypeId() && x.getDurability() == player.getItemInHand().getDurability()){
|
||||
x.setTypeId(0);
|
||||
x.setAmount(0);
|
||||
player.getInventory().setContents(inventory);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static Integer getTier(Player player)
|
||||
{
|
||||
int i = player.getItemInHand().getTypeId();
|
||||
if(i == 268 || i == 269 || i == 270 || i == 271 || i == 290){
|
||||
return 1; //WOOD
|
||||
} else if (i == 272 || i == 273 || i == 274 || i == 275 || i == 291){
|
||||
return 2; //STONE
|
||||
} else if (i == 256 || i == 257 || i == 258 || i == 267 || i == 292){
|
||||
return 3; //IRON
|
||||
} else if (i == 283 || i == 284 || i == 285 || i == 286 || i == 294){
|
||||
return 1; //GOLD
|
||||
} else if (i == 276 || i == 277 || i == 278 || i == 279 || i == 293){
|
||||
return 4; //DIAMOND
|
||||
} else {
|
||||
return 1; //UNRECOGNIZED
|
||||
}
|
||||
}
|
||||
public static Integer getMaxDurability(Integer tier, ItemStack item)
|
||||
{
|
||||
int id = item.getTypeId();
|
||||
if(tier == 1){
|
||||
if((id == 276 || id == 277 || id == 278 || id == 279 || id == 293)){
|
||||
return 33;
|
||||
} else {
|
||||
return 60;
|
||||
}
|
||||
} else if (tier == 2){
|
||||
return 132;
|
||||
} else if (tier == 3){
|
||||
return 251;
|
||||
} else if (tier == 4){
|
||||
return 1562;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return capitalized;
|
||||
}
|
||||
|
||||
public static double getDistance(Location loca, Location locb)
|
||||
{
|
||||
return Math.sqrt(Math.pow(loca.getX() - locb.getX(), 2) + Math.pow(loca.getY() - locb.getY(), 2)
|
||||
+ Math.pow(loca.getZ() - locb.getZ(), 2));
|
||||
}
|
||||
/**
|
||||
* Gets a nicely formatted string version of an item name from a given item ID.
|
||||
*
|
||||
* @param itemID The ID of the item to convert to string.
|
||||
* @return the nicely formatting string
|
||||
*/
|
||||
public static String prettyItemString(int itemID) {
|
||||
String baseString = Material.getMaterial(itemID).toString();
|
||||
String[] substrings = baseString.split("_");
|
||||
String prettyString = "";
|
||||
int size = 1;
|
||||
|
||||
public static boolean abilityBlockCheck(Block block)
|
||||
{
|
||||
int i = block.getTypeId();
|
||||
if(i == 107 ||i == 117 || i == 116 || i == 96 || i == 68 || i == 355 || i == 26 || i == 323 || i == 25 || i == 54 || i == 69 || i == 92 || i == 77 || i == 58 || i == 61 || i == 62 || i == 42 || i == 71 || i == 64 || i == 84 || i == 324 || i == 330){
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (String s : substrings) {
|
||||
prettyString = prettyString.concat(m.getCapitalized(s));
|
||||
|
||||
public static boolean isBlockAround(Location loc, Integer radius, Integer typeid)
|
||||
{
|
||||
Block blockx = loc.getBlock();
|
||||
int ox = blockx.getX();
|
||||
int oy = blockx.getY();
|
||||
int oz = blockx.getZ();
|
||||
for (int cx = -radius; cx <= radius; cx++) {
|
||||
for (int cy = -radius; cy <= radius; cy++) {
|
||||
for (int cz = -radius; cz <= radius; cz++) {
|
||||
Block block = loc.getWorld().getBlockAt(ox + cx, oy + cy, oz + cz);
|
||||
if (block.getTypeId() == typeid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (size < substrings.length) {
|
||||
prettyString = prettyString.concat(" ");
|
||||
}
|
||||
|
||||
public static Integer calculateHealth(Integer health, Integer newvalue){
|
||||
if((health + newvalue) > 20){
|
||||
return 20;
|
||||
} else {
|
||||
return health+newvalue;
|
||||
}
|
||||
}
|
||||
public Integer calculateMinusHealth(Integer health, Integer newvalue){
|
||||
if((health - newvalue) < 1){
|
||||
return 0;
|
||||
} else {
|
||||
return health-newvalue;
|
||||
}
|
||||
}
|
||||
public static boolean isInt(String string)
|
||||
{
|
||||
try
|
||||
{
|
||||
Integer.parseInt(string);
|
||||
}
|
||||
catch(NumberFormatException nFE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static void mcDropItem(Location loc, int id)
|
||||
{
|
||||
if(loc != null)
|
||||
{
|
||||
Material mat = Material.getMaterial(id);
|
||||
byte damage = 0;
|
||||
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
}
|
||||
}
|
||||
size++;
|
||||
}
|
||||
|
||||
public static boolean isSwords(ItemStack is)
|
||||
{
|
||||
return is.getTypeId() == 268 || is.getTypeId() == 267 || is.getTypeId() == 272 || is.getTypeId() == 283 || is.getTypeId() == 276;
|
||||
}
|
||||
|
||||
public static boolean isHoe(ItemStack is)
|
||||
{
|
||||
int id = is.getTypeId();
|
||||
return id == 290 || id == 291 || id == 292 || id == 293 || id == 294;
|
||||
}
|
||||
|
||||
public static boolean isShovel(ItemStack is){
|
||||
return is.getTypeId() == 269 || is.getTypeId() == 273 || is.getTypeId() == 277 || is.getTypeId() == 284 || is.getTypeId() == 256;
|
||||
}
|
||||
|
||||
public static boolean isAxes(ItemStack is){
|
||||
if(is.getTypeId() == 271 || is.getTypeId() == 258 || is.getTypeId() == 286 || is.getTypeId() == 279 || is.getTypeId() == 275){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static boolean isMiningPick(ItemStack is)
|
||||
{
|
||||
if(is.getTypeId() == 270 || is.getTypeId() == 274 || is.getTypeId() == 285 || is.getTypeId() == 257 || is.getTypeId() == 278)
|
||||
{
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public boolean isGold(ItemStack is)
|
||||
{
|
||||
int i = is.getTypeId();
|
||||
if(i == 283 || i == 284 || i == 285 || i == 286 || i == 294 || i == 314 || i == 315 || i == 316 || i == 317){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static void convertToMySQL()
|
||||
{
|
||||
if(!LoadProperties.useMySQL)
|
||||
return;
|
||||
|
||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(Bukkit.getServer().getPluginManager().getPlugin("mcMMO"), new Runnable(){
|
||||
public void run() {
|
||||
String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
|
||||
try {
|
||||
//Open the user file
|
||||
FileReader file = new FileReader(location);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
String line = "";
|
||||
String playerName = null, mining = null, party = null, miningXP = null, woodcutting = null, woodCuttingXP = null, repair = null, unarmed = null, herbalism = null, excavation = null, archery = null, swords = null, axes = null, acrobatics = null, repairXP = null, unarmedXP = null, herbalismXP = null, excavationXP = null, archeryXP = null, swordsXP = null, axesXP = null, acrobaticsXP = null, taming = null, tamingXP = null, fishing = null, fishingXP = null;
|
||||
int id = 0, theCount = 0;
|
||||
while ((line = in.readLine()) != null) {
|
||||
//Find if the line contains the player we want.
|
||||
String[] character = line.split(":");
|
||||
playerName = character[0];
|
||||
//Check for things we don't want put in the DB
|
||||
if (playerName == null
|
||||
|| playerName.equals("null")
|
||||
|| playerName
|
||||
.equals("#Storage place for user information"))
|
||||
continue;
|
||||
return prettyString;
|
||||
}
|
||||
|
||||
//Get Mining
|
||||
if (character.length > 1)
|
||||
mining = character[1];
|
||||
//Party
|
||||
if (character.length > 3)
|
||||
party = character[3];
|
||||
//Mining XP
|
||||
if (character.length > 4)
|
||||
miningXP = character[4];
|
||||
if (character.length > 5)
|
||||
woodcutting = character[5];
|
||||
if (character.length > 6)
|
||||
woodCuttingXP = character[6];
|
||||
if (character.length > 7)
|
||||
repair = character[7];
|
||||
if (character.length > 8)
|
||||
unarmed = character[8];
|
||||
if (character.length > 9)
|
||||
herbalism = character[9];
|
||||
if (character.length > 10)
|
||||
excavation = character[10];
|
||||
if (character.length > 11)
|
||||
archery = character[11];
|
||||
if (character.length > 12)
|
||||
swords = character[12];
|
||||
if (character.length > 13)
|
||||
axes = character[13];
|
||||
if (character.length > 14)
|
||||
acrobatics = character[14];
|
||||
if (character.length > 15)
|
||||
repairXP = character[15];
|
||||
if (character.length > 16)
|
||||
unarmedXP = character[16];
|
||||
if (character.length > 17)
|
||||
herbalismXP = character[17];
|
||||
if (character.length > 18)
|
||||
excavationXP = character[18];
|
||||
if (character.length > 19)
|
||||
archeryXP = character[19];
|
||||
if (character.length > 20)
|
||||
swordsXP = character[20];
|
||||
if (character.length > 21)
|
||||
axesXP = character[21];
|
||||
if (character.length > 22)
|
||||
acrobaticsXP = character[22];
|
||||
if (character.length > 24)
|
||||
taming = character[24];
|
||||
if (character.length > 25)
|
||||
tamingXP = character[25];
|
||||
if (character.length > 34)
|
||||
fishing = character[34];
|
||||
if (character.length > 35)
|
||||
fishingXP = character[35];
|
||||
/**
|
||||
* Gets the int represented by this string.
|
||||
*
|
||||
* @param string The string to parse
|
||||
* @return the int represented by this string
|
||||
*/
|
||||
public static int getInt(String string) {
|
||||
if (isInt(string)) {
|
||||
return Integer.parseInt(string);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//Check to see if the user is in the DB
|
||||
id = mcMMO.database.GetInt("SELECT id FROM "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "users WHERE user = '" + playerName + "'");
|
||||
/**
|
||||
* Checks to see if an entity is currently invincible.
|
||||
*
|
||||
* @param le The LivingEntity to check
|
||||
* @param event The event the entity is involved in
|
||||
* @return true if the entity is invincible, false otherwise
|
||||
*/
|
||||
public static boolean isInvincible(LivingEntity le, EntityDamageEvent event) {
|
||||
|
||||
if (id > 0) {
|
||||
theCount++;
|
||||
//Update the skill values
|
||||
mcMMO.database.Write("UPDATE "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "users SET lastlogin = " + 0
|
||||
+ " WHERE id = " + id);
|
||||
//if(getDouble(x) > 0 && getDouble(y) > 0 && getDouble(z) > 0)
|
||||
//mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"spawn SET world = '" + myspawnworld + "', x = " +getDouble(x)+", y = "+getDouble(y)+", z = "+getDouble(z)+" WHERE user_id = "+id);
|
||||
mcMMO.database.Write("UPDATE "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "skills SET " + " taming = taming+"
|
||||
+ getInt(taming) + ", mining = mining+"
|
||||
+ getInt(mining) + ", repair = repair+"
|
||||
+ getInt(repair)
|
||||
+ ", woodcutting = woodcutting+"
|
||||
+ getInt(woodcutting)
|
||||
+ ", unarmed = unarmed+" + getInt(unarmed)
|
||||
+ ", herbalism = herbalism+"
|
||||
+ getInt(herbalism)
|
||||
+ ", excavation = excavation+"
|
||||
+ getInt(excavation)
|
||||
+ ", archery = archery+" + getInt(archery)
|
||||
+ ", swords = swords+" + getInt(swords)
|
||||
+ ", axes = axes+" + getInt(axes)
|
||||
+ ", acrobatics = acrobatics+"
|
||||
+ getInt(acrobatics)
|
||||
+ ", fishing = fishing+" + getInt(fishing)
|
||||
+ " WHERE user_id = " + id);
|
||||
mcMMO.database.Write("UPDATE "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "experience SET " + " taming = "
|
||||
+ getInt(tamingXP) + ", mining = "
|
||||
+ getInt(miningXP) + ", repair = "
|
||||
+ getInt(repairXP) + ", woodcutting = "
|
||||
+ getInt(woodCuttingXP) + ", unarmed = "
|
||||
+ getInt(unarmedXP) + ", herbalism = "
|
||||
+ getInt(herbalismXP) + ", excavation = "
|
||||
+ getInt(excavationXP) + ", archery = "
|
||||
+ getInt(archeryXP) + ", swords = "
|
||||
+ getInt(swordsXP) + ", axes = "
|
||||
+ getInt(axesXP) + ", acrobatics = "
|
||||
+ getInt(acrobaticsXP) + ", fishing = "
|
||||
+ getInt(fishingXP) + " WHERE user_id = "
|
||||
+ id);
|
||||
} else {
|
||||
theCount++;
|
||||
//Create the user in the DB
|
||||
mcMMO.database.Write("INSERT INTO "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "users (user, lastlogin) VALUES ('"
|
||||
+ playerName + "',"
|
||||
+ System.currentTimeMillis() / 1000 + ")");
|
||||
id = mcMMO.database
|
||||
.GetInt("SELECT id FROM "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "users WHERE user = '"
|
||||
+ playerName + "'");
|
||||
mcMMO.database.Write("INSERT INTO "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "spawn (user_id) VALUES (" + id + ")");
|
||||
mcMMO.database.Write("INSERT INTO "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "skills (user_id) VALUES (" + id + ")");
|
||||
mcMMO.database.Write("INSERT INTO "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "experience (user_id) VALUES (" + id
|
||||
+ ")");
|
||||
//Update the skill values
|
||||
mcMMO.database.Write("UPDATE "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "users SET lastlogin = " + 0
|
||||
+ " WHERE id = " + id);
|
||||
mcMMO.database.Write("UPDATE "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "users SET party = '" + party
|
||||
+ "' WHERE id = " + id);
|
||||
/*
|
||||
if(getDouble(x) > 0 && getDouble(y) > 0 && getDouble(z) > 0)
|
||||
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"spawn SET world = '" + myspawnworld + "', x = " +getDouble(x)+", y = "+getDouble(y)+", z = "+getDouble(z)+" WHERE user_id = "+id);
|
||||
*/
|
||||
mcMMO.database.Write("UPDATE "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "skills SET " + " taming = "
|
||||
+ getInt(taming) + ", mining = "
|
||||
+ getInt(mining) + ", repair = "
|
||||
+ getInt(repair) + ", woodcutting = "
|
||||
+ getInt(woodcutting) + ", unarmed = "
|
||||
+ getInt(unarmed) + ", herbalism = "
|
||||
+ getInt(herbalism) + ", excavation = "
|
||||
+ getInt(excavation) + ", archery = "
|
||||
+ getInt(archery) + ", swords = "
|
||||
+ getInt(swords) + ", axes = "
|
||||
+ getInt(axes) + ", acrobatics = "
|
||||
+ getInt(acrobatics) + ", fishing = "
|
||||
+ getInt(fishing) + " WHERE user_id = "
|
||||
+ id);
|
||||
mcMMO.database.Write("UPDATE "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "experience SET " + " taming = "
|
||||
+ getInt(tamingXP) + ", mining = "
|
||||
+ getInt(miningXP) + ", repair = "
|
||||
+ getInt(repairXP) + ", woodcutting = "
|
||||
+ getInt(woodCuttingXP) + ", unarmed = "
|
||||
+ getInt(unarmedXP) + ", herbalism = "
|
||||
+ getInt(herbalismXP) + ", excavation = "
|
||||
+ getInt(excavationXP) + ", archery = "
|
||||
+ getInt(archeryXP) + ", swords = "
|
||||
+ getInt(swordsXP) + ", axes = "
|
||||
+ getInt(axesXP) + ", acrobatics = "
|
||||
+ getInt(acrobaticsXP) + ", fishing = "
|
||||
+ getInt(fishingXP) + " WHERE user_id = "
|
||||
+ id);
|
||||
}
|
||||
}
|
||||
System.out
|
||||
.println("[mcMMO] MySQL Updated from users file, "
|
||||
+ theCount
|
||||
+ " items added/updated to MySQL DB");
|
||||
in.close();
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Exception while reading " + location
|
||||
+ " (Are you sure you formatted it correctly?)", e);
|
||||
}
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
/*
|
||||
* So apparently if you do more damage to a LivingEntity than its last damage int you bypass the invincibility.
|
||||
* So yeah, this is for that.
|
||||
*/
|
||||
if (le.getNoDamageTicks() > le.getMaximumNoDamageTicks() / 2.0F && event.getDamage() <= le.getLastDamage()) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the power level of a player.
|
||||
*
|
||||
* @param player The player to get the power level of
|
||||
* @param PP The profile of the player
|
||||
* @return the power level of the player
|
||||
*/
|
||||
public static int getPowerLevel(Player player, PlayerProfile PP) {
|
||||
int powerLevel = 0;
|
||||
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.getPermissions(player)) {
|
||||
powerLevel += PP.getSkillLevel(type);
|
||||
}
|
||||
}
|
||||
|
||||
return powerLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulate a block break event.
|
||||
*
|
||||
* @param block The block to break
|
||||
* @param player The player breaking the block
|
||||
* @param shouldArmSwing true if an armswing event should be fired, false otherwise
|
||||
* @return true if the event wasn't cancelled, false otherwise
|
||||
*/
|
||||
public static boolean blockBreakSimulate(Block block, Player player, Boolean shouldArmSwing) {
|
||||
|
||||
//Support for NoCheat
|
||||
if (shouldArmSwing) {
|
||||
PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
|
||||
Bukkit.getPluginManager().callEvent(armswing);
|
||||
}
|
||||
|
||||
FakeBlockBreakEvent event = new FakeBlockBreakEvent(block, player);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the upgrade tier of the item in hand.
|
||||
*
|
||||
* @param inHand The item to check the tier of
|
||||
* @return the tier of the item
|
||||
*/
|
||||
public static Integer getTier(ItemStack inHand) {
|
||||
int tier = 0;
|
||||
|
||||
if (ItemChecks.isWoodTool(inHand)) {
|
||||
tier = 1;
|
||||
}
|
||||
else if (ItemChecks.isStoneTool(inHand)) {
|
||||
tier = 2;
|
||||
}
|
||||
else if (ItemChecks.isIronTool(inHand)) {
|
||||
tier = 3;
|
||||
}
|
||||
else if(ItemChecks.isGoldTool(inHand)) {
|
||||
tier = 1;
|
||||
}
|
||||
else if(ItemChecks.isDiamondTool(inHand))
|
||||
tier = 4;
|
||||
|
||||
return tier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if two locations are near each other.
|
||||
*
|
||||
* @param first The first location
|
||||
* @param second The second location
|
||||
* @param maxDistance The max distance apart
|
||||
* @return true if the distance between <code>first</code> and <code>second</code> is less than <code>maxDistance</code>, false otherwise
|
||||
*/
|
||||
public static boolean isNear(Location first, Location second, int maxDistance) {
|
||||
double relX = first.getX() - second.getX();
|
||||
double relY = first.getY() - second.getY();
|
||||
double relZ = first.getZ() - second.getZ();
|
||||
double dist = (relX * relX) + (relY * relY) + (relZ * relZ);
|
||||
|
||||
if (dist < maxDistance * maxDistance) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a string represents an Integer
|
||||
*
|
||||
* @param string String to check
|
||||
* @return true if the string is an Integer, false otherwise
|
||||
*/
|
||||
public static boolean isInt(String string) {
|
||||
try {
|
||||
Integer.parseInt(string);
|
||||
return true;
|
||||
}
|
||||
catch (NumberFormatException nFE) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop items at a given location.
|
||||
*
|
||||
* @param location The location to drop the items at
|
||||
* @param is The items to drop
|
||||
* @param quantity The amount of items to drop
|
||||
*/
|
||||
public static void mcDropItems(Location location, ItemStack is, int quantity) {
|
||||
for (int i = 0; i < quantity; i++) {
|
||||
mcDropItem(location, is);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Randomly drop an item at a given location.
|
||||
*
|
||||
* @param location The location to drop the items at
|
||||
* @param is The item to drop
|
||||
* @param chance The percentage chance for the item to drop
|
||||
*/
|
||||
public static void mcRandomDropItem(Location location, ItemStack is, double chance) {
|
||||
if (Math.random() * 100 < chance) {
|
||||
mcDropItem(location, is);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Randomly drop items at a given location.
|
||||
*
|
||||
* @param location The location to drop the items at
|
||||
* @param is The item to drop
|
||||
* @param chance The percentage chance for the item to drop
|
||||
* @param quantity The amount of items to drop
|
||||
*/
|
||||
public static void mcRandomDropItems(Location location, ItemStack is, int chance, int quantity) {
|
||||
for(int i = 0; i < quantity; i++) {
|
||||
mcRandomDropItem(location, is, chance);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop an item at a given location.
|
||||
*
|
||||
* @param location The location to drop the item at
|
||||
* @param itemStack The item to drop
|
||||
*/
|
||||
public static void mcDropItem(Location location, ItemStack itemStack) {
|
||||
|
||||
// We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event.
|
||||
McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(location, itemStack);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
location.getWorld().dropItemNaturally(location, itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a skill level is higher than the max bonus level of the ability.
|
||||
*
|
||||
* @param skillLevel Skill level to check
|
||||
* @param maxLevel Max level of the ability
|
||||
* @return whichever value is lower
|
||||
*/
|
||||
public static int skillCheck(int skillLevel, int maxLevel) {
|
||||
if (skillLevel > maxLevel) {
|
||||
return maxLevel;
|
||||
}
|
||||
else {
|
||||
return skillLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
@@ -24,17 +8,15 @@ import com.gmail.nossr50.commands.mc.*;
|
||||
import com.gmail.nossr50.commands.party.*;
|
||||
import com.gmail.nossr50.commands.general.*;
|
||||
import com.gmail.nossr50.config.*;
|
||||
import com.gmail.nossr50.runnables.mcTimer;
|
||||
import com.gmail.nossr50.runnables.*;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.listeners.mcBlockListener;
|
||||
import com.gmail.nossr50.listeners.mcEntityListener;
|
||||
import com.gmail.nossr50.listeners.mcPlayerListener;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.skills.*;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
@@ -44,375 +26,541 @@ import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
import org.getspout.spoutapi.player.FileManager;
|
||||
|
||||
public class mcMMO extends JavaPlugin {
|
||||
|
||||
public class mcMMO extends JavaPlugin
|
||||
{
|
||||
/*
|
||||
* I never expected mcMMO to get so popular!
|
||||
* Thanks for all the support for the mod
|
||||
* Thanks to the people who have worked on the code
|
||||
* Thanks to the donators who helped me out financially
|
||||
* Thanks to the server admins who use my mod :)
|
||||
*
|
||||
* This mod is open source, and its going to stay that way >:3
|
||||
*
|
||||
* Donate via paypal to nossr50@gmail.com (A million thanks to anyone that does!)
|
||||
*/
|
||||
|
||||
public static String maindirectory = "plugins" + File.separator + "mcMMO";
|
||||
File file = new File(maindirectory + File.separator + "config.yml");
|
||||
static File versionFile = new File(maindirectory + File.separator + "VERSION");
|
||||
public static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final mcPlayerListener playerListener = new mcPlayerListener(this);
|
||||
private final mcBlockListener blockListener = new mcBlockListener(this);
|
||||
private final mcEntityListener entityListener = new mcEntityListener(this);
|
||||
|
||||
public static mcPermissions permissionHandler = new mcPermissions();
|
||||
private Permissions permissions;
|
||||
public static String maindirectory = "plugins" + File.separator + "mcMMO";
|
||||
public static File file = new File(maindirectory + File.separator + "config.yml");
|
||||
public static File versionFile = new File(maindirectory + File.separator + "VERSION");
|
||||
|
||||
private Runnable mcMMO_Timer = new mcTimer(this); //BLEED AND REGENERATION
|
||||
//private Timer mcMMO_SpellTimer = new Timer(true);
|
||||
private final mcPlayerListener playerListener = new mcPlayerListener(this);
|
||||
private final mcBlockListener blockListener = new mcBlockListener(this);
|
||||
private final mcEntityListener entityListener = new mcEntityListener(this);
|
||||
|
||||
//Alias - Command
|
||||
public HashMap<String, String> aliasMap = new HashMap<String, String>();
|
||||
|
||||
public static Database database = null;
|
||||
public Misc misc = new Misc(this);
|
||||
//Alias - Command
|
||||
public HashMap<String, String> aliasMap = new HashMap<String, String>();
|
||||
public HashMap<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
|
||||
public HashMap<Integer, Player> tntTracker = new HashMap<Integer, Player>();
|
||||
|
||||
//Config file stuff
|
||||
LoadProperties config = new LoadProperties();
|
||||
//Jar stuff
|
||||
public static File mcmmo;
|
||||
public static Database database = null;
|
||||
|
||||
public void onEnable()
|
||||
{
|
||||
mcmmo = this.getFile();
|
||||
new File(maindirectory).mkdir();
|
||||
|
||||
if(!versionFile.exists())
|
||||
{
|
||||
updateVersion();
|
||||
} else
|
||||
{
|
||||
String vnum = readVersion();
|
||||
//This will be changed to whatever version preceded when we actually need updater code.
|
||||
//Version 1.0.48 is the first to implement this, no checking before that version can be done.
|
||||
if(vnum.equalsIgnoreCase("1.0.48")) {
|
||||
updateFrom(1);
|
||||
}
|
||||
//Just add in more else if blocks for versions that need updater code. Increment the updateFrom age int as we do so.
|
||||
//Catch all for versions not matching and no specific code being needed
|
||||
else if(!vnum.equalsIgnoreCase(this.getDescription().getVersion())) updateFrom(-1);
|
||||
}
|
||||
|
||||
mcPermissions.initialize(getServer());
|
||||
|
||||
config.configCheck();
|
||||
|
||||
Party.getInstance().loadParties();
|
||||
new Party(this);
|
||||
|
||||
if(!LoadProperties.useMySQL)
|
||||
Users.getInstance().loadUsers(); //Load Users file
|
||||
/*
|
||||
* REGISTER EVENTS
|
||||
*/
|
||||
//Config file stuff
|
||||
LoadProperties config;
|
||||
LoadTreasures config2;
|
||||
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
|
||||
if(pm.getPlugin("Spout") != null)
|
||||
LoadProperties.spoutEnabled = true;
|
||||
else
|
||||
LoadProperties.spoutEnabled = false;
|
||||
//Jar stuff
|
||||
public static File mcmmo;
|
||||
|
||||
//Player Stuff
|
||||
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_CHAT, playerListener, Priority.Lowest, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Priority.Monitor, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_RESPAWN, playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_PICKUP_ITEM, playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_FISH, playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Priority.Lowest, this);
|
||||
/**
|
||||
* Things to be run when the plugin is enabled.
|
||||
*/
|
||||
public void onEnable() {
|
||||
final Plugin thisPlugin = this;
|
||||
mcmmo = this.getFile();
|
||||
new File(maindirectory).mkdir();
|
||||
|
||||
//Block Stuff
|
||||
pm.registerEvent(Event.Type.BLOCK_DAMAGE, blockListener, Priority.Highest, this);
|
||||
pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Monitor, this);
|
||||
pm.registerEvent(Event.Type.BLOCK_FROMTO, blockListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener, Priority.Normal, this);
|
||||
if (!versionFile.exists()) {
|
||||
updateVersion();
|
||||
}
|
||||
else {
|
||||
String vnum = readVersion();
|
||||
|
||||
//Entity Stuff
|
||||
pm.registerEvent(Event.Type.ENTITY_DEATH, entityListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Priority.Monitor, this);
|
||||
pm.registerEvent(Event.Type.CREATURE_SPAWN, entityListener, Priority.Normal, this);
|
||||
//This will be changed to whatever version preceded when we actually need updater code.
|
||||
//Version 1.0.48 is the first to implement this, no checking before that version can be done.
|
||||
if (vnum.equalsIgnoreCase("1.0.48")) {
|
||||
updateFrom(1);
|
||||
}
|
||||
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
mcPermissions.initialize(getServer());
|
||||
//Just add in more else if blocks for versions that need updater code. Increment the updateFrom age int as we do so.
|
||||
//Catch all for versions not matching and no specific code being needed
|
||||
else if (!vnum.equalsIgnoreCase(this.getDescription().getVersion())) {
|
||||
updateFrom(-1);
|
||||
}
|
||||
}
|
||||
|
||||
if(LoadProperties.useMySQL)
|
||||
{
|
||||
database = new Database(this);
|
||||
database.createStructure();
|
||||
} else
|
||||
Leaderboard.makeLeaderboards(); //Make the leaderboards
|
||||
this.config = new LoadProperties(this);
|
||||
this.config.load();
|
||||
|
||||
for(Player player : getServer().getOnlinePlayers()){Users.addUser(player);} //In case of reload add all users back into PlayerProfile
|
||||
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
|
||||
|
||||
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, mcMMO_Timer, 0, 20);
|
||||
|
||||
registerCommands();
|
||||
|
||||
//Spout Stuff
|
||||
if(LoadProperties.spoutEnabled)
|
||||
{
|
||||
SpoutStuff.setupSpoutConfigs();
|
||||
SpoutStuff.registerCustomEvent();
|
||||
SpoutStuff.extractFiles(); //Extract source materials
|
||||
|
||||
FileManager FM = SpoutManager.getFileManager();
|
||||
FM.addToPreLoginCache(this, SpoutStuff.getFiles());
|
||||
|
||||
/*
|
||||
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this,
|
||||
new Runnable() {
|
||||
this.config2 = new LoadTreasures(this);
|
||||
this.config2.load();
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
mmoHelper.updateAll();
|
||||
}
|
||||
}, 20, 20);
|
||||
*/
|
||||
}
|
||||
}
|
||||
Party.getInstance().loadParties();
|
||||
new Party(this);
|
||||
|
||||
public PlayerProfile getPlayerProfile(Player player)
|
||||
{
|
||||
return Users.getProfile(player);
|
||||
}
|
||||
|
||||
public void checkXp(Player player, SkillType skillType)
|
||||
{
|
||||
if(skillType == SkillType.ALL)
|
||||
Skills.XpCheckAll(player);
|
||||
else
|
||||
Skills.XpCheckSkill(skillType, player);
|
||||
}
|
||||
|
||||
public boolean inSameParty(Player playera, Player playerb)
|
||||
{
|
||||
if(Users.getProfile(playera).inParty() && Users.getProfile(playerb).inParty()){
|
||||
if(Users.getProfile(playera).getParty().equals(Users.getProfile(playerb).getParty())){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public ArrayList<String> getParties(){
|
||||
String location = "plugins/mcMMO/mcmmo.users";
|
||||
ArrayList<String> parties = new ArrayList<String>();
|
||||
try {
|
||||
//Open the users file
|
||||
FileReader file = new FileReader(location);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
String line = "";
|
||||
while((line = in.readLine()) != null)
|
||||
{
|
||||
String[] character = line.split(":");
|
||||
String theparty = null;
|
||||
//Party
|
||||
if(character.length > 3)
|
||||
theparty = character[3];
|
||||
if(!parties.contains(theparty))
|
||||
parties.add(theparty);
|
||||
}
|
||||
in.close();
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Exception while reading "
|
||||
+ location + " (Are you sure you formatted it correctly?)", e);
|
||||
}
|
||||
return parties;
|
||||
}
|
||||
public static String getPartyName(Player player){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
return PP.getParty();
|
||||
}
|
||||
public static boolean inParty(Player player){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
return PP.inParty();
|
||||
}
|
||||
public Permissions getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
public void onDisable() {
|
||||
Bukkit.getServer().getScheduler().cancelTasks(this);
|
||||
System.out.println("mcMMO was disabled.");
|
||||
}
|
||||
|
||||
private void registerCommands() {
|
||||
//Register aliases with the aliasmap (used in the playercommandpreprocessevent to ugly alias them to actual commands)
|
||||
//Skills commands
|
||||
aliasMap.put(mcLocale.getString("m.SkillAcrobatics").toLowerCase(), "acrobatics");
|
||||
aliasMap.put(mcLocale.getString("m.SkillArchery").toLowerCase(), "archery");
|
||||
aliasMap.put(mcLocale.getString("m.SkillAxes").toLowerCase(), "axes");
|
||||
aliasMap.put(mcLocale.getString("m.SkillExcavation").toLowerCase(), "excavation");
|
||||
aliasMap.put(mcLocale.getString("m.SkillFishing").toLowerCase(), "fishing");
|
||||
aliasMap.put(mcLocale.getString("m.SkillHerbalism").toLowerCase(), "herbalism");
|
||||
aliasMap.put(mcLocale.getString("m.SkillMining").toLowerCase(), "mining");
|
||||
aliasMap.put(mcLocale.getString("m.SkillRepair").toLowerCase(), "repair");
|
||||
aliasMap.put(mcLocale.getString("m.SkillSwords").toLowerCase(), "swords");
|
||||
aliasMap.put(mcLocale.getString("m.SkillTaming").toLowerCase(), "taming");
|
||||
aliasMap.put(mcLocale.getString("m.SkillUnarmed").toLowerCase(), "unarmed");
|
||||
aliasMap.put(mcLocale.getString("m.SkillWoodCutting").toLowerCase(), "woodcutting");
|
||||
|
||||
//Mc* commands
|
||||
aliasMap.put(LoadProperties.mcability, "mcability");
|
||||
aliasMap.put(LoadProperties.mcc, "mcc");
|
||||
aliasMap.put(LoadProperties.mcgod, "mcgod");
|
||||
aliasMap.put(LoadProperties.mcmmo, "mcmmo");
|
||||
aliasMap.put(LoadProperties.mcrefresh, "mcrefresh");
|
||||
aliasMap.put(LoadProperties.mctop, "mctop");
|
||||
|
||||
//Party commands
|
||||
aliasMap.put(LoadProperties.accept, "accept");
|
||||
//aliasMap.put(null, "a");
|
||||
aliasMap.put(LoadProperties.invite, "invite");
|
||||
aliasMap.put(LoadProperties.party, "party");
|
||||
//aliasMap.put(null, "p");
|
||||
aliasMap.put(LoadProperties.ptp, "ptp");
|
||||
|
||||
//Other commands
|
||||
aliasMap.put(LoadProperties.addxp, "addxp");
|
||||
aliasMap.put(LoadProperties.clearmyspawn, "clearmyspawn");
|
||||
aliasMap.put(LoadProperties.mmoedit, "mmoedit");
|
||||
//aliasMap.put(key, "mmoupdate");
|
||||
aliasMap.put(LoadProperties.myspawn, "myspawn");
|
||||
aliasMap.put(LoadProperties.stats, "stats");
|
||||
aliasMap.put(LoadProperties.whois, "whois");
|
||||
aliasMap.put(LoadProperties.xprate, "xprate");
|
||||
|
||||
//Spout commands
|
||||
//aliasMap.put(null, "mchud");
|
||||
aliasMap.put(LoadProperties.xplock, "xplock");
|
||||
|
||||
|
||||
//Register commands
|
||||
//Skills commands
|
||||
getCommand("acrobatics").setExecutor(new AcrobaticsCommand());
|
||||
getCommand("archery").setExecutor(new ArcheryCommand());
|
||||
getCommand("axes").setExecutor(new AxesCommand());
|
||||
getCommand("excavation").setExecutor(new ExcavationCommand());
|
||||
getCommand("fishing").setExecutor(new FishingCommand());
|
||||
getCommand("herbalism").setExecutor(new HerbalismCommand());
|
||||
getCommand("mining").setExecutor(new MiningCommand());
|
||||
getCommand("repair").setExecutor(new RepairCommand());
|
||||
getCommand("swords").setExecutor(new SwordsCommand());
|
||||
getCommand("taming").setExecutor(new TamingCommand());
|
||||
getCommand("unarmed").setExecutor(new UnarmedCommand());
|
||||
getCommand("woodcutting").setExecutor(new WoodcuttingCommand());
|
||||
|
||||
//Mc* commands
|
||||
getCommand("mcability").setExecutor(new McabilityCommand());
|
||||
getCommand("mcc").setExecutor(new MccCommand());
|
||||
getCommand("mcgod").setExecutor(new McgodCommand());
|
||||
getCommand("mcmmo").setExecutor(new McmmoCommand());
|
||||
getCommand("mcrefresh").setExecutor(new McrefreshCommand(this));
|
||||
getCommand("mctop").setExecutor(new MctopCommand());
|
||||
|
||||
//Party commands
|
||||
getCommand("accept").setExecutor(new AcceptCommand());
|
||||
getCommand("a").setExecutor(new ACommand());
|
||||
getCommand("invite").setExecutor(new InviteCommand(this));
|
||||
getCommand("party").setExecutor(new PartyCommand());
|
||||
getCommand("p").setExecutor(new PCommand());
|
||||
getCommand("ptp").setExecutor(new PtpCommand(this));
|
||||
|
||||
//Other commands
|
||||
getCommand("addxp").setExecutor(new AddxpCommand(this));
|
||||
getCommand("clearmyspawn").setExecutor(new ClearmyspawnCommand());
|
||||
getCommand("mmoedit").setExecutor(new MmoeditCommand(this));
|
||||
getCommand("mmoupdate").setExecutor(new MmoupdateCommand());
|
||||
getCommand("myspawn").setExecutor(new MyspawnCommand());
|
||||
getCommand("stats").setExecutor(new StatsCommand());
|
||||
getCommand("whois").setExecutor(new WhoisCommand(this));
|
||||
getCommand("xprate").setExecutor(new XprateCommand());
|
||||
|
||||
//Spout commands
|
||||
getCommand("mchud").setExecutor(new MchudCommand());
|
||||
getCommand("xplock").setExecutor(new XplockCommand());
|
||||
|
||||
}
|
||||
if (!LoadProperties.useMySQL) {
|
||||
Users.getInstance().loadUsers();
|
||||
}
|
||||
|
||||
/*
|
||||
* It is important to always assume that you are updating from the lowest possible version.
|
||||
* Thus, every block of updater code should be complete and self-contained; finishing all
|
||||
* SQL transactions and closing all file handlers, such that the next block of updater code
|
||||
* if called will handle updating as expected.
|
||||
*/
|
||||
public void updateFrom(int age) {
|
||||
//No updater code needed, just update the version.
|
||||
if(age == -1) {
|
||||
updateVersion();
|
||||
return;
|
||||
}
|
||||
//Updater code from age 1 goes here
|
||||
if(age <= 1) {
|
||||
//Since age 1 is an example for now, we will just let it do nothing.
|
||||
|
||||
}
|
||||
//If we are updating from age 1 but we need more to reach age 2, this will run too.
|
||||
if(age <= 2) {
|
||||
|
||||
}
|
||||
updateVersion();
|
||||
}
|
||||
|
||||
public void updateVersion() {
|
||||
try {
|
||||
versionFile.createNewFile();
|
||||
BufferedWriter vout = new BufferedWriter(new FileWriter(versionFile));
|
||||
vout.write(this.getDescription().getVersion());
|
||||
vout.close();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (SecurityException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
|
||||
public String readVersion() {
|
||||
byte[] buffer = new byte[(int) versionFile.length()];
|
||||
BufferedInputStream f = null;
|
||||
try {
|
||||
f = new BufferedInputStream(new FileInputStream(versionFile));
|
||||
f.read(buffer);
|
||||
} catch (FileNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
if (f != null) try { f.close(); } catch (IOException ignored) { }
|
||||
}
|
||||
|
||||
return new String(buffer);
|
||||
}
|
||||
}
|
||||
if (pm.getPlugin("Spout") != null) {
|
||||
LoadProperties.spoutEnabled = true;
|
||||
}
|
||||
else {
|
||||
LoadProperties.spoutEnabled = false;
|
||||
}
|
||||
|
||||
//Register events
|
||||
pm.registerEvents(playerListener, this);
|
||||
pm.registerEvents(blockListener, this);
|
||||
pm.registerEvents(entityListener, this);
|
||||
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
|
||||
//Setup the leaderboards
|
||||
if (LoadProperties.useMySQL) {
|
||||
database = new Database(this);
|
||||
database.createStructure();
|
||||
}
|
||||
else {
|
||||
Leaderboard.makeLeaderboards();
|
||||
}
|
||||
|
||||
for (Player player : getServer().getOnlinePlayers()) {
|
||||
Users.addUser(player); //In case of reload add all users back into PlayerProfile
|
||||
}
|
||||
|
||||
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
|
||||
|
||||
BukkitScheduler scheduler = getServer().getScheduler();
|
||||
|
||||
//Periodic save timer (Saves every 10 minutes)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new mcSaveTimer(this), 0, LoadProperties.saveInterval * 1200);
|
||||
//Regen & Cooldown timer (Runs every second)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new mcTimer(this), 0, 20);
|
||||
//Bleed timer (Runs every two seconds)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new mcBleedTimer(this), 0, 40);
|
||||
|
||||
registerCommands();
|
||||
|
||||
//Spout Stuff
|
||||
if (LoadProperties.spoutEnabled) {
|
||||
SpoutStuff.setupSpoutConfigs();
|
||||
SpoutStuff.registerCustomEvent();
|
||||
SpoutStuff.extractFiles(); //Extract source materials
|
||||
|
||||
FileManager FM = SpoutManager.getFileManager();
|
||||
FM.addToPreLoginCache(this, SpoutStuff.getFiles());
|
||||
}
|
||||
|
||||
if (LoadProperties.statsTracking) {
|
||||
//Plugin Metrics running in a new thread
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
// create a new metrics object
|
||||
Metrics metrics = new Metrics();
|
||||
|
||||
// 'this' in this context is the Plugin object
|
||||
metrics.beginMeasuringPlugin(thisPlugin);
|
||||
}
|
||||
catch (IOException e) {
|
||||
System.out.println("Failed to submit stats.");
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get profile of the player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player Player whose profile to get
|
||||
* @return the PlayerProfile object
|
||||
*/
|
||||
public PlayerProfile getPlayerProfile(Player player) {
|
||||
return Users.getProfile(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the XP of a player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player
|
||||
* @param skillType
|
||||
*/
|
||||
public void checkXp(Player player, SkillType skillType) {
|
||||
if (skillType == SkillType.ALL) {
|
||||
Skills.XpCheckAll(player);
|
||||
}
|
||||
else {
|
||||
Skills.XpCheckSkill(skillType, player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two players are in the same party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playera The first player to check
|
||||
* @param playerb The second player to check
|
||||
* @return true if the two players are in the same party, false otherwise
|
||||
*/
|
||||
public boolean inSameParty(Player playera, Player playerb) {
|
||||
if (Users.getProfile(playera).inParty() && Users.getProfile(playerb).inParty()) {
|
||||
if (Users.getProfile(playera).getParty().equals(Users.getProfile(playerb).getParty())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all current party names.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @return the list of parties.
|
||||
*/
|
||||
public ArrayList<String> getParties() {
|
||||
String location = "plugins/mcMMO/mcmmo.users";
|
||||
ArrayList<String> parties = new ArrayList<String>();
|
||||
|
||||
try {
|
||||
|
||||
//Open the users file
|
||||
FileReader file = new FileReader(location);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
String line = "";
|
||||
|
||||
while((line = in.readLine()) != null) {
|
||||
String[] character = line.split(":");
|
||||
String theparty = null;
|
||||
|
||||
//Party
|
||||
if (character.length > 3) {
|
||||
theparty = character[3];
|
||||
}
|
||||
|
||||
if (!parties.contains(theparty)) {
|
||||
parties.add(theparty);
|
||||
}
|
||||
}
|
||||
in.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Bukkit.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
return parties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the party a player is in.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check the party name of
|
||||
* @return the name of the player's party
|
||||
*/
|
||||
public static String getPartyName(Player player) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
return PP.getParty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player is in a party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return true if the player is in a party, false otherwise
|
||||
*/
|
||||
public static boolean inParty(Player player) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
return PP.inParty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Things to be run when the plugin is disabled.
|
||||
*/
|
||||
public void onDisable() {
|
||||
|
||||
//Make sure to save player information if the server shuts down
|
||||
for (PlayerProfile x : Users.getProfiles().values()) {
|
||||
x.save();
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().cancelTasks(this); //This removes our tasks
|
||||
System.out.println("mcMMO was disabled."); //How informative!
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands.
|
||||
*/
|
||||
private void registerCommands() {
|
||||
|
||||
//Register aliases with the aliasmap (used in the playercommandpreprocessevent to ugly alias them to actual commands)
|
||||
//Skills commands
|
||||
aliasMap.put(mcLocale.getString("m.SkillAcrobatics").toLowerCase(), "acrobatics");
|
||||
aliasMap.put(mcLocale.getString("m.SkillArchery").toLowerCase(), "archery");
|
||||
aliasMap.put(mcLocale.getString("m.SkillAxes").toLowerCase(), "axes");
|
||||
aliasMap.put(mcLocale.getString("m.SkillExcavation").toLowerCase(), "excavation");
|
||||
aliasMap.put(mcLocale.getString("m.SkillFishing").toLowerCase(), "fishing");
|
||||
aliasMap.put(mcLocale.getString("m.SkillHerbalism").toLowerCase(), "herbalism");
|
||||
aliasMap.put(mcLocale.getString("m.SkillMining").toLowerCase(), "mining");
|
||||
aliasMap.put(mcLocale.getString("m.SkillRepair").toLowerCase(), "repair");
|
||||
aliasMap.put(mcLocale.getString("m.SkillSwords").toLowerCase(), "swords");
|
||||
aliasMap.put(mcLocale.getString("m.SkillTaming").toLowerCase(), "taming");
|
||||
aliasMap.put(mcLocale.getString("m.SkillUnarmed").toLowerCase(), "unarmed");
|
||||
aliasMap.put(mcLocale.getString("m.SkillWoodCutting").toLowerCase(), "woodcutting");
|
||||
|
||||
//Register commands
|
||||
//Skills commands
|
||||
getCommand("acrobatics").setExecutor(new AcrobaticsCommand());
|
||||
getCommand("archery").setExecutor(new ArcheryCommand());
|
||||
getCommand("axes").setExecutor(new AxesCommand());
|
||||
getCommand("excavation").setExecutor(new ExcavationCommand());
|
||||
getCommand("fishing").setExecutor(new FishingCommand());
|
||||
getCommand("herbalism").setExecutor(new HerbalismCommand());
|
||||
getCommand("mining").setExecutor(new MiningCommand());
|
||||
getCommand("repair").setExecutor(new RepairCommand());
|
||||
getCommand("swords").setExecutor(new SwordsCommand());
|
||||
getCommand("taming").setExecutor(new TamingCommand());
|
||||
getCommand("unarmed").setExecutor(new UnarmedCommand());
|
||||
getCommand("woodcutting").setExecutor(new WoodcuttingCommand());
|
||||
|
||||
//mc* commands
|
||||
if (LoadProperties.mcremoveEnable) {
|
||||
getCommand("mcremove").setExecutor(new McremoveCommand());
|
||||
}
|
||||
|
||||
if (LoadProperties.mcabilityEnable) {
|
||||
getCommand("mcability").setExecutor(new McabilityCommand());
|
||||
}
|
||||
|
||||
if (LoadProperties.mccEnable) {
|
||||
getCommand("mcc").setExecutor(new MccCommand());
|
||||
}
|
||||
|
||||
if (LoadProperties.mcgodEnable) {
|
||||
getCommand("mcgod").setExecutor(new McgodCommand());
|
||||
}
|
||||
|
||||
if (LoadProperties.mcmmoEnable) {
|
||||
getCommand("mcmmo").setExecutor(new McmmoCommand());
|
||||
}
|
||||
|
||||
if (LoadProperties.mcrefreshEnable) {
|
||||
getCommand("mcrefresh").setExecutor(new McrefreshCommand(this));
|
||||
}
|
||||
|
||||
if (LoadProperties.mctopEnable) {
|
||||
getCommand("mctop").setExecutor(new MctopCommand());
|
||||
}
|
||||
|
||||
if (LoadProperties.mcstatsEnable) {
|
||||
getCommand("mcstats").setExecutor(new McstatsCommand());
|
||||
}
|
||||
|
||||
//Party commands
|
||||
if (LoadProperties.acceptEnable) {
|
||||
getCommand("accept").setExecutor(new AcceptCommand());
|
||||
}
|
||||
|
||||
if (LoadProperties.aEnable) {
|
||||
getCommand("a").setExecutor(new ACommand());
|
||||
}
|
||||
|
||||
if (LoadProperties.inviteEnable) {
|
||||
getCommand("invite").setExecutor(new InviteCommand(this));
|
||||
}
|
||||
|
||||
if (LoadProperties.partyEnable) {
|
||||
getCommand("party").setExecutor(new PartyCommand());
|
||||
}
|
||||
|
||||
if (LoadProperties.pEnable) {
|
||||
getCommand("p").setExecutor(new PCommand());
|
||||
}
|
||||
|
||||
if (LoadProperties.ptpEnable) {
|
||||
getCommand("ptp").setExecutor(new PtpCommand(this));
|
||||
}
|
||||
|
||||
//Other commands
|
||||
if (LoadProperties.addxpEnable) {
|
||||
getCommand("addxp").setExecutor(new AddxpCommand(this));
|
||||
}
|
||||
|
||||
if (LoadProperties.addlevelsEnable) {
|
||||
getCommand("addlevels").setExecutor(new AddlevelsCommand(this));
|
||||
}
|
||||
|
||||
if (LoadProperties.mmoeditEnable) {
|
||||
getCommand("mmoedit").setExecutor(new MmoeditCommand());
|
||||
}
|
||||
|
||||
if (LoadProperties.inspectEnable) {
|
||||
getCommand("inspect").setExecutor(new InspectCommand(this));
|
||||
}
|
||||
|
||||
if (LoadProperties.xprateEnable) {
|
||||
getCommand("xprate").setExecutor(new XprateCommand());
|
||||
}
|
||||
|
||||
getCommand("mmoupdate").setExecutor(new MmoupdateCommand());
|
||||
|
||||
//Spout commands
|
||||
if (LoadProperties.xplockEnable) {
|
||||
getCommand("xplock").setExecutor(new XplockCommand());
|
||||
}
|
||||
|
||||
getCommand("mchud").setExecutor(new MchudCommand());
|
||||
}
|
||||
|
||||
/**
|
||||
* Update mcMMO from a given version
|
||||
* </p>
|
||||
* It is important to always assume that you are updating from the lowest possible version.
|
||||
* Thus, every block of updater code should be complete and self-contained; finishing all
|
||||
* SQL transactions and closing all file handlers, such that the next block of updater code
|
||||
* if called will handle updating as expected.
|
||||
*
|
||||
* @param age Specifies which updater code to run
|
||||
*/
|
||||
public void updateFrom(int age) {
|
||||
|
||||
//No updater code needed, just update the version.
|
||||
if (age == -1) {
|
||||
updateVersion();
|
||||
return;
|
||||
}
|
||||
|
||||
//Updater code from age 1 goes here
|
||||
if (age <= 1) {
|
||||
//Since age 1 is an example for now, we will just let it do nothing.
|
||||
}
|
||||
|
||||
//If we are updating from age 1 but we need more to reach age 2, this will run too.
|
||||
if (age <= 2) {
|
||||
|
||||
}
|
||||
updateVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the version file.
|
||||
*/
|
||||
public void updateVersion() {
|
||||
try {
|
||||
versionFile.createNewFile();
|
||||
BufferedWriter vout = new BufferedWriter(new FileWriter(versionFile));
|
||||
vout.write(this.getDescription().getVersion());
|
||||
vout.close();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
catch (SecurityException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current mcMMO version.
|
||||
*
|
||||
* @return a String representing the current mcMMO version
|
||||
*/
|
||||
public String readVersion() {
|
||||
byte[] buffer = new byte[(int) versionFile.length()];
|
||||
BufferedInputStream f = null;
|
||||
|
||||
try {
|
||||
f = new BufferedInputStream(new FileInputStream(versionFile));
|
||||
f.read(buffer);
|
||||
}
|
||||
catch (FileNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
if (f != null) {
|
||||
try {
|
||||
f.close();
|
||||
}
|
||||
catch (IOException ignored) {}
|
||||
}
|
||||
}
|
||||
return new String(buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Boilerplate Custom Config Stuff
|
||||
*/
|
||||
|
||||
private FileConfiguration treasuresConfig = null;
|
||||
private File treasuresConfigFile = null;
|
||||
|
||||
/**
|
||||
* Reload the Treasures.yml file.
|
||||
*/
|
||||
public void reloadTreasuresConfig() {
|
||||
if (treasuresConfigFile == null) {
|
||||
treasuresConfigFile = new File(getDataFolder(), "treasures.yml");
|
||||
}
|
||||
|
||||
treasuresConfig = YamlConfiguration.loadConfiguration(treasuresConfigFile);
|
||||
InputStream defConfigStream = getResource("treasures.yml"); // Look for defaults in the jar
|
||||
|
||||
if (defConfigStream != null) {
|
||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
|
||||
treasuresConfig.setDefaults(defConfig);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Treasures config information.
|
||||
*
|
||||
* @return the configuration object for treasures.yml
|
||||
*/
|
||||
public FileConfiguration getTreasuresConfig() {
|
||||
if (treasuresConfig == null) {
|
||||
reloadTreasuresConfig();
|
||||
}
|
||||
|
||||
return treasuresConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the Treasures config informtion.
|
||||
*/
|
||||
public void saveTreasuresConfig() {
|
||||
if (treasuresConfig == null || treasuresConfigFile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
treasuresConfig.save(treasuresConfigFile);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
Bukkit.getLogger().severe("Could not save config to " + treasuresConfigFile + ex.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,352 +1,395 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import ru.tehkode.permissions.PermissionManager;
|
||||
import ru.tehkode.permissions.bukkit.PermissionsEx;
|
||||
|
||||
import com.nijiko.permissions.PermissionHandler;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
|
||||
public class mcPermissions
|
||||
{
|
||||
public class mcPermissions {
|
||||
private static volatile mcPermissions instance;
|
||||
|
||||
private enum PermissionType {
|
||||
PEX, PERMISSIONS, BUKKIT
|
||||
}
|
||||
|
||||
private static PermissionType permissionType;
|
||||
private static Object PHandle;
|
||||
public static boolean permissionsEnabled = false;
|
||||
|
||||
public static void initialize(Server server)
|
||||
{
|
||||
Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
if(permissionsEnabled && permissionType != PermissionType.PERMISSIONS) return;
|
||||
|
||||
Plugin PEXtest = server.getPluginManager().getPlugin("PermissionsEx");
|
||||
Plugin test = server.getPluginManager().getPlugin("Permissions");
|
||||
if(PEXtest != null) {
|
||||
PHandle = (PermissionManager) PermissionsEx.getPermissionManager();
|
||||
permissionType = PermissionType.PEX;
|
||||
permissionsEnabled = true;
|
||||
log.info("[mcMMO] PermissionsEx found, using PermissionsEx.");
|
||||
} else if(test != null) {
|
||||
PHandle = (PermissionHandler) ((Permissions) test).getHandler();
|
||||
permissionType = PermissionType.PERMISSIONS;
|
||||
permissionsEnabled = true;
|
||||
log.info("[mcMMO] Permissions version "+test.getDescription().getVersion()+" found, using Permissions.");
|
||||
} else {
|
||||
permissionType = PermissionType.BUKKIT;
|
||||
permissionsEnabled = true;
|
||||
log.info("[mcMMO] Using Bukkit Permissions.");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean getEnabled()
|
||||
{
|
||||
return permissionsEnabled;
|
||||
}
|
||||
|
||||
public static boolean permission(Player player, String permission)
|
||||
{
|
||||
if(!permissionsEnabled) return player.isOp();
|
||||
switch(permissionType) {
|
||||
case PEX:
|
||||
return ((PermissionManager) PHandle).has(player, permission);
|
||||
case PERMISSIONS:
|
||||
return ((PermissionHandler) PHandle).has(player, permission);
|
||||
case BUKKIT:
|
||||
return player.hasPermission(permission);
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean admin(Player player){
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.admin");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean mcrefresh(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.tools.mcrefresh");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean mmoedit(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.tools.mmoedit");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean herbalismAbility(Player player){
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.ability.herbalism");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean excavationAbility(Player player){
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.ability.excavation");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean unarmedAbility(Player player){
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.ability.unarmed");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean chimaeraWing(Player player){
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.item.chimaerawing");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean miningAbility(Player player){
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.ability.mining");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean axesAbility(Player player){
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.ability.axes");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean swordsAbility(Player player){
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.ability.swords");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean woodCuttingAbility(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.ability.woodcutting");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean mcgod(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.tools.mcgod");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean regeneration(Player player){
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.regeneration");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean motd(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.motd");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean mcAbility(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.commands.ability");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean mySpawn(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.commands.myspawn");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean setMySpawn(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.commands.setmyspawn");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean partyChat(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.chat.partychat");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean partyLock(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.chat.partylock");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean partyTeleport(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.commands.ptp");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean whois(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.commands.whois");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean party(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.commands.party");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean adminChat(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.chat.adminchat");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
public boolean permission(Player player, String perm) {
|
||||
return player.hasPermission(perm);
|
||||
}
|
||||
|
||||
public static mcPermissions getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new mcPermissions();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
if (instance == null) {
|
||||
instance = new mcPermissions();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
/*
|
||||
* GENERIC PERMISSIONS
|
||||
*/
|
||||
|
||||
public boolean motd(Player player) {
|
||||
return player.hasPermission("mcmmo.motd");
|
||||
}
|
||||
|
||||
public boolean admin(Player player) {
|
||||
return player.hasPermission("mcmmo.admin");
|
||||
}
|
||||
|
||||
public boolean arcaneBypass(Player player) {
|
||||
return player.hasPermission(("mcmmo.repair.arcanebypass"));
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.TOOLS.*
|
||||
*/
|
||||
|
||||
public boolean mcrefresh(Player player) {
|
||||
return player.hasPermission("mcmmo.tools.mcrefresh");
|
||||
}
|
||||
|
||||
public boolean mcremove(Player player) {
|
||||
return player.hasPermission("mcmmo.tools.mcremove");
|
||||
}
|
||||
|
||||
public boolean mmoedit(Player player) {
|
||||
return player.hasPermission("mcmmo.tools.mmoedit");
|
||||
}
|
||||
|
||||
public boolean mcgod(Player player) {
|
||||
return player.hasPermission("mcmmo.tools.mcgod");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.ABILITY.TAMING.*
|
||||
*/
|
||||
|
||||
public boolean fastFoodService(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.taming.fastfoodservice");
|
||||
}
|
||||
|
||||
public boolean sharpenedclaws(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.taming.sharpenedclaws");
|
||||
}
|
||||
|
||||
public boolean gore(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.taming.gore");
|
||||
}
|
||||
|
||||
public boolean callOfTheWild(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.taming.callofthewild");
|
||||
}
|
||||
|
||||
public boolean environmentallyAware(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.taming.environmentallyaware");
|
||||
}
|
||||
|
||||
public boolean thickFur(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.taming.thickfur");
|
||||
}
|
||||
|
||||
public boolean shockProof(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.taming.shockproof");
|
||||
}
|
||||
|
||||
public boolean beastLore(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.taming.beastlore");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.ABILITY.FISHING.*
|
||||
*/
|
||||
|
||||
public boolean shakeMob(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.fishing.shakemob");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.ABILITY.MINING.*
|
||||
*/
|
||||
|
||||
public boolean superBreaker(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.mining.superbreaker");
|
||||
}
|
||||
|
||||
public boolean miningDoubleDrops(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.mining.doubledrops");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.ABILITY.WOODCUTTING.*
|
||||
*/
|
||||
|
||||
public boolean treeFeller(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.woodcutting.treefeller");
|
||||
}
|
||||
|
||||
public boolean leafBlower(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.woodcutting.leafblower");
|
||||
}
|
||||
|
||||
public boolean woodcuttingDoubleDrops(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.woodcutting.doubledrops");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.ABILITY.REPAIR.*
|
||||
*/
|
||||
|
||||
public boolean repairBonus(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.repair.repairbonus");
|
||||
}
|
||||
|
||||
public boolean arcaneForging(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.repair.arcaneforging");
|
||||
}
|
||||
|
||||
public boolean stoneRepair(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.repair.stonerepair");
|
||||
}
|
||||
|
||||
public boolean ironRepair(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.repair.ironrepair");
|
||||
}
|
||||
|
||||
public boolean goldRepair(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.repair.goldrepair");
|
||||
}
|
||||
|
||||
public boolean diamondRepair(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.repair.diamondrepair");
|
||||
}
|
||||
|
||||
public boolean armorRepair(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.repair.armorrepair");
|
||||
}
|
||||
|
||||
public boolean toolRepair(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.repair.toolrepair");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.ABILITY.UNARMED.*
|
||||
*/
|
||||
|
||||
public boolean unarmedBonus(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.unarmed.bonusdamage");
|
||||
}
|
||||
|
||||
public boolean disarm(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.unarmed.disarm");
|
||||
}
|
||||
|
||||
public boolean berserk(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.unarmed.berserk");
|
||||
}
|
||||
|
||||
public boolean deflect(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.unarmed.deflect");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.ABILITY.ARCHERY.*
|
||||
*/
|
||||
|
||||
public boolean trackArrows(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.archery.trackarrows");
|
||||
}
|
||||
|
||||
public boolean ignition(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.archery.ignition");
|
||||
}
|
||||
|
||||
public boolean daze(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.archery.daze");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.ABILITY.HERBALISM.*
|
||||
*/
|
||||
|
||||
public boolean herbalismDoubleDrops(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.herbalism.doubledrops");
|
||||
}
|
||||
|
||||
public boolean greenTerra(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.herbalism.greenterra");
|
||||
}
|
||||
|
||||
public boolean greenThumbBlocks(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.herbalism.greenthumbblocks");
|
||||
}
|
||||
|
||||
public boolean greenThumbWheat(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.herbalism.greenthumbwheat");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.ABILITY.EXCAVATION.*
|
||||
*/
|
||||
|
||||
public boolean gigaDrillBreaker(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.excavation.gigadrillbreaker");
|
||||
}
|
||||
|
||||
public boolean excavationTreasures(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.excavation.treasures");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.ABILITY.SWORDS.*
|
||||
*/
|
||||
|
||||
public boolean swordsBleed(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.swords.bleed");
|
||||
}
|
||||
|
||||
public boolean serratedStrikes(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.swords.serratedstrikes");
|
||||
}
|
||||
|
||||
public boolean counterAttack(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.swords.counterattack");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.ABILITY.AXES.*
|
||||
*/
|
||||
|
||||
public boolean skullSplitter(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.axes.skullsplitter");
|
||||
}
|
||||
|
||||
public boolean axeBonus(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.axes.bonusdamage");
|
||||
}
|
||||
|
||||
public boolean criticalHit(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.axes.criticalhit");
|
||||
}
|
||||
|
||||
public boolean impact(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.axes.impact");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.ABILITY.ACROBATICS.*
|
||||
*/
|
||||
|
||||
public boolean roll(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.acrobatics.roll");
|
||||
}
|
||||
|
||||
public boolean gracefulRoll(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.acrobatics.gracefulroll");
|
||||
}
|
||||
|
||||
public boolean dodge(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.acrobatics.dodge");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.ABILITY.BLASTMINING.*
|
||||
*/
|
||||
|
||||
public boolean biggerBombs(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.blastmining.biggerbombs");
|
||||
}
|
||||
|
||||
public boolean demolitionsExpertise(Player player) {
|
||||
return player.hasPermission("mcmmo.ability.blastmining.demolitionsexpertise");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.ITEM.*
|
||||
*/
|
||||
|
||||
public boolean chimaeraWing(Player player) {
|
||||
return player.hasPermission("mcmmo.item.chimaerawing");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.COMMANDS.*
|
||||
*/
|
||||
|
||||
public boolean mcAbility(Player player) {
|
||||
return player.hasPermission("mcmmo.commands.ability");
|
||||
}
|
||||
|
||||
public boolean partyTeleport(Player player) {
|
||||
return player.hasPermission("mcmmo.commands.ptp");
|
||||
}
|
||||
|
||||
public boolean inspect(Player player) {
|
||||
return player.hasPermission("mcmmo.commands.inspect");
|
||||
}
|
||||
|
||||
public boolean party(Player player) {
|
||||
return player.hasPermission("mcmmo.commands.party");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.CHAT.*
|
||||
*/
|
||||
|
||||
public boolean partyChat(Player player) {
|
||||
return player.hasPermission("mcmmo.chat.partychat");
|
||||
}
|
||||
|
||||
public boolean partyLock(Player player) {
|
||||
return player.hasPermission("mcmmo.chat.partylock");
|
||||
}
|
||||
|
||||
public boolean adminChat(Player player) {
|
||||
return player.hasPermission("mcmmo.chat.adminchat");
|
||||
}
|
||||
|
||||
/*
|
||||
* MCMMO.SKILLS.*
|
||||
*/
|
||||
|
||||
public boolean taming(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.skills.taming");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return player.hasPermission("mcmmo.skills.taming");
|
||||
}
|
||||
|
||||
public boolean mining(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.skills.mining");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return player.hasPermission("mcmmo.skills.mining");
|
||||
}
|
||||
|
||||
public boolean blastMining(Player player) {
|
||||
return player.hasPermission("mcmmo.skills.blastmining");
|
||||
}
|
||||
|
||||
public boolean fishing(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.skills.fishing");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean alchemy(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.skills.alchemy");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean enchanting(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.skills.enchanting");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return player.hasPermission("mcmmo.skills.fishing");
|
||||
}
|
||||
|
||||
public boolean woodcutting(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.skills.woodcutting");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return player.hasPermission("mcmmo.skills.woodcutting");
|
||||
}
|
||||
|
||||
public boolean repair(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.skills.repair");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return player.hasPermission("mcmmo.skills.repair");
|
||||
}
|
||||
|
||||
public boolean unarmed(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.skills.unarmed");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return player.hasPermission("mcmmo.skills.unarmed");
|
||||
}
|
||||
|
||||
public boolean archery(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.skills.archery");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return player.hasPermission("mcmmo.skills.archery");
|
||||
}
|
||||
|
||||
public boolean herbalism(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.skills.herbalism");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return player.hasPermission("mcmmo.skills.herbalism");
|
||||
}
|
||||
|
||||
public boolean excavation(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.skills.excavation");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return player.hasPermission("mcmmo.skills.excavation");
|
||||
}
|
||||
|
||||
public boolean swords(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.skills.swords");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return player.hasPermission("mcmmo.skills.swords");
|
||||
}
|
||||
|
||||
public boolean axes(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.skills.axes");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return player.hasPermission("mcmmo.skills.axes");
|
||||
}
|
||||
|
||||
public boolean acrobatics(Player player) {
|
||||
if (permissionsEnabled) {
|
||||
return permission(player, "mcmmo.skills.acrobatics");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return player.hasPermission("mcmmo.skills.acrobatics");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.party;
|
||||
|
||||
import java.io.EOFException;
|
||||
@@ -30,16 +14,14 @@ import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.spout.util.ArrayListString;
|
||||
|
||||
|
||||
public class Party
|
||||
{
|
||||
public class Party {
|
||||
/*
|
||||
* This file is part of mmoMinecraft (http://code.google.com/p/mmo-minecraft/).
|
||||
*
|
||||
@@ -118,7 +100,6 @@ public class Party
|
||||
|
||||
public void informPartyMembers(Player player, Player[] players)
|
||||
{
|
||||
int x = 0;
|
||||
for(Player p : players)
|
||||
{
|
||||
if(player != null && p != null)
|
||||
@@ -126,7 +107,6 @@ public class Party
|
||||
if(inSameParty(player, p) && !p.getName().equals(player.getName()))
|
||||
{
|
||||
p.sendMessage(mcLocale.getString("Party.InformedOnJoin", new Object[] {player.getName()}));
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -148,22 +128,6 @@ public class Party
|
||||
}
|
||||
return players;
|
||||
}
|
||||
public ArrayListString getPartyMembersByName(Player player)
|
||||
{
|
||||
ArrayListString players = new ArrayListString();
|
||||
|
||||
for(Player p : Bukkit.getServer().getOnlinePlayers())
|
||||
{
|
||||
if(p.isOnline())
|
||||
{
|
||||
if(inSameParty(player, p))
|
||||
{
|
||||
players.add(p.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
||||
public void informPartyMembersOwnerChange(String newOwner) {
|
||||
Player newOwnerPlayer = plugin.getServer().getPlayer(newOwner);
|
||||
@@ -171,14 +135,12 @@ public class Party
|
||||
}
|
||||
|
||||
public void informPartyMembersOwnerChange(Player newOwner, Player[] players) {
|
||||
int x = 0;
|
||||
for(Player p : players){
|
||||
if(newOwner != null && p != null){
|
||||
if(inSameParty(newOwner, p))
|
||||
{
|
||||
//TODO: Needs more locale.
|
||||
p.sendMessage(newOwner.getName()+" is the new party owner.");
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,13 +153,11 @@ public class Party
|
||||
|
||||
public void informPartyMembersQuit(Player player, Player[] players)
|
||||
{
|
||||
int x = 0;
|
||||
for(Player p : players){
|
||||
if(player != null && p != null){
|
||||
if(inSameParty(player, p) && !p.getName().equals(player.getName()))
|
||||
{
|
||||
p.sendMessage(mcLocale.getString("Party.InformedOnQuit", new Object[] {player.getName()}));
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -246,7 +206,7 @@ public class Party
|
||||
if(password == null)
|
||||
{
|
||||
//TODO: Needs more locale.
|
||||
player.sendMessage("This party requires a password. Use "+LoadProperties.party+" <party> <password> to join it.");
|
||||
player.sendMessage("This party requires a password. Use /party <party> <password> to join it.");
|
||||
return;
|
||||
} else if(!password.equalsIgnoreCase(getPartyPassword(newParty)))
|
||||
{
|
||||
@@ -417,7 +377,7 @@ public class Party
|
||||
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyPlayersFile));
|
||||
this.partyPlayers = (HashMap<String, HashMap<String, Boolean>>)obj.readObject();
|
||||
} catch (FileNotFoundException e) { e.printStackTrace();
|
||||
} catch (EOFException e) { mcMMO.log.info("partyPlayersFile empty.");
|
||||
} catch (EOFException e) { Bukkit.getLogger().info("partyPlayersFile empty.");
|
||||
} catch (IOException e) { e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) { e.printStackTrace(); }
|
||||
}
|
||||
@@ -427,7 +387,7 @@ public class Party
|
||||
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyLocksFile));
|
||||
this.partyLocks = (HashMap<String, Boolean>)obj.readObject();
|
||||
} catch (FileNotFoundException e) { e.printStackTrace();
|
||||
} catch (EOFException e) { mcMMO.log.info("partyLocksFile empty.");
|
||||
} catch (EOFException e) { Bukkit.getLogger().info("partyLocksFile empty.");
|
||||
} catch (IOException e) { e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) { e.printStackTrace(); }
|
||||
}
|
||||
@@ -437,7 +397,7 @@ public class Party
|
||||
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyPasswordsFile));
|
||||
this.partyPasswords = (HashMap<String, String>)obj.readObject();
|
||||
} catch (FileNotFoundException e) { e.printStackTrace();
|
||||
} catch (EOFException e) { mcMMO.log.info("partyPasswordsFile empty.");
|
||||
} catch (EOFException e) { Bukkit.getLogger().info("partyPasswordsFile empty.");
|
||||
} catch (IOException e) { e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) { e.printStackTrace(); }
|
||||
}
|
||||
|
||||
45
src/main/java/com/gmail/nossr50/runnables/GainXp.java
Normal file
45
src/main/java/com/gmail/nossr50/runnables/GainXp.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
|
||||
public class GainXp implements Runnable {
|
||||
private Player player = null;
|
||||
private PlayerProfile PP = null;
|
||||
private double baseXp = 0;
|
||||
private SkillType skillType = null;
|
||||
private LivingEntity target = null;
|
||||
private int baseHealth = 0;
|
||||
|
||||
public GainXp(Player player, PlayerProfile PP, SkillType skillType, double baseXp, LivingEntity target) {
|
||||
this.player = player;
|
||||
this.PP = PP;
|
||||
this.skillType = skillType;
|
||||
this.baseXp = baseXp;
|
||||
this.target = target;
|
||||
baseHealth = target.getHealth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
int health = target.getHealth();
|
||||
int damage = baseHealth - health;
|
||||
|
||||
//May avoid negative xp, we don't know what other plugins do with the entity health
|
||||
if (damage <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Don't reward the player for overkills
|
||||
if (health < 0) {
|
||||
damage += health;
|
||||
}
|
||||
|
||||
PP.addXP(skillType, (int) (damage * baseXp), player);
|
||||
Skills.XpCheckSkill(skillType, player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import org.bukkit.CropState;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
|
||||
public class GreenThumbTimer implements Runnable {
|
||||
private Block block;
|
||||
private PlayerProfile PP;
|
||||
|
||||
public GreenThumbTimer(Block block, PlayerProfile PP) {
|
||||
this.block = block;
|
||||
this.PP = PP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
block.setType(Material.CROPS);
|
||||
|
||||
//This replants the wheat at a certain stage in development based on Herbalism Skill
|
||||
if (!PP.getGreenTerraMode()) {
|
||||
if (PP.getSkillLevel(SkillType.HERBALISM) >= 600) {
|
||||
block.setData(CropState.MEDIUM.getData());
|
||||
}
|
||||
else if (PP.getSkillLevel(SkillType.HERBALISM) >= 400) {
|
||||
block.setData(CropState.SMALL.getData());
|
||||
}
|
||||
else if (PP.getSkillLevel(SkillType.HERBALISM) >= 200) {
|
||||
block.setData(CropState.VERY_SMALL.getData());
|
||||
}
|
||||
else {
|
||||
block.setData(CropState.GERMINATED.getData());
|
||||
}
|
||||
}
|
||||
else {
|
||||
block.setData(CropState.MEDIUM.getData());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
|
||||
public class RemoveProfileFromMemoryTask implements Runnable {
|
||||
private Player player;
|
||||
|
||||
public RemoveProfileFromMemoryTask(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Users.getProfile(player.getName()).save(); //We save here so players don't quit/reconnect to cause lag
|
||||
Users.removeUserByName(player.getName());
|
||||
}
|
||||
}
|
||||
284
src/main/java/com/gmail/nossr50/runnables/SQLConversionTask.java
Normal file
284
src/main/java/com/gmail/nossr50/runnables/SQLConversionTask.java
Normal file
@@ -0,0 +1,284 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
|
||||
public class SQLConversionTask implements Runnable {
|
||||
public SQLConversionTask() {}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
|
||||
|
||||
try {
|
||||
FileReader file = new FileReader(location);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
String line = "";
|
||||
String playerName = null;
|
||||
String party = null;
|
||||
String mining = null;
|
||||
String woodcutting = null;
|
||||
String repair = null;
|
||||
String unarmed = null;
|
||||
String herbalism = null;
|
||||
String excavation = null;
|
||||
String archery = null;
|
||||
String swords = null;
|
||||
String axes = null;
|
||||
String acrobatics = null;
|
||||
String taming = null;
|
||||
String fishing = null;
|
||||
String miningXP = null;
|
||||
String woodCuttingXP = null;
|
||||
String repairXP = null;
|
||||
String unarmedXP = null;
|
||||
String herbalismXP = null;
|
||||
String excavationXP = null;
|
||||
String archeryXP = null;
|
||||
String swordsXP = null;
|
||||
String axesXP = null;
|
||||
String acrobaticsXP = null;
|
||||
String tamingXP = null;
|
||||
String fishingXP = null;
|
||||
int id = 0;
|
||||
int theCount = 0;
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
|
||||
//Find if the line contains the player we want.
|
||||
String[] character = line.split(":");
|
||||
playerName = character[0];
|
||||
|
||||
//Check for things we don't want put in the DB
|
||||
if (playerName == null || playerName.equals("null") || playerName.equals("#Storage place for user information")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (character.length > 1) {
|
||||
mining = character[1];
|
||||
}
|
||||
|
||||
if (character.length > 3) {
|
||||
party = character[3];
|
||||
}
|
||||
|
||||
if (character.length > 4) {
|
||||
miningXP = character[4];
|
||||
}
|
||||
|
||||
if (character.length > 5) {
|
||||
woodcutting = character[5];
|
||||
}
|
||||
|
||||
if (character.length > 6) {
|
||||
woodCuttingXP = character[6];
|
||||
}
|
||||
|
||||
if (character.length > 7) {
|
||||
repair = character[7];
|
||||
}
|
||||
|
||||
if (character.length > 8) {
|
||||
unarmed = character[8];
|
||||
}
|
||||
|
||||
if (character.length > 9) {
|
||||
herbalism = character[9];
|
||||
}
|
||||
|
||||
if (character.length > 10) {
|
||||
excavation = character[10];
|
||||
}
|
||||
|
||||
if (character.length > 11) {
|
||||
archery = character[11];
|
||||
}
|
||||
|
||||
if (character.length > 12) {
|
||||
swords = character[12];
|
||||
}
|
||||
|
||||
if (character.length > 13) {
|
||||
axes = character[13];
|
||||
}
|
||||
|
||||
if (character.length > 14) {
|
||||
acrobatics = character[14];
|
||||
}
|
||||
|
||||
if (character.length > 15) {
|
||||
repairXP = character[15];
|
||||
}
|
||||
|
||||
if (character.length > 16) {
|
||||
unarmedXP = character[16];
|
||||
}
|
||||
|
||||
if (character.length > 17) {
|
||||
herbalismXP = character[17];
|
||||
}
|
||||
|
||||
if (character.length > 18) {
|
||||
excavationXP = character[18];
|
||||
}
|
||||
|
||||
if (character.length > 19) {
|
||||
archeryXP = character[19];
|
||||
}
|
||||
|
||||
if (character.length > 20) {
|
||||
swordsXP = character[20];
|
||||
}
|
||||
|
||||
if (character.length > 21) {
|
||||
axesXP = character[21];
|
||||
}
|
||||
|
||||
if (character.length > 22) {
|
||||
acrobaticsXP = character[22];
|
||||
}
|
||||
|
||||
if (character.length > 24) {
|
||||
taming = character[24];
|
||||
}
|
||||
|
||||
if (character.length > 25) {
|
||||
tamingXP = character[25];
|
||||
}
|
||||
|
||||
if (character.length > 34) {
|
||||
fishing = character[34];
|
||||
}
|
||||
|
||||
if (character.length > 35) {
|
||||
fishingXP = character[35];
|
||||
}
|
||||
|
||||
//Check to see if the user is in the DB
|
||||
id = mcMMO.database.getInt("SELECT id FROM "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "users WHERE user = '" + playerName + "'");
|
||||
|
||||
if (id > 0) {
|
||||
theCount++;
|
||||
|
||||
//Update the skill values
|
||||
mcMMO.database.write("UPDATE "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "users SET lastlogin = " + 0
|
||||
+ " WHERE id = " + id);
|
||||
mcMMO.database.write("UPDATE "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "skills SET " + " taming = taming+"
|
||||
+ m.getInt(taming) + ", mining = mining+"
|
||||
+ m.getInt(mining) + ", repair = repair+"
|
||||
+ m.getInt(repair)
|
||||
+ ", woodcutting = woodcutting+"
|
||||
+ m.getInt(woodcutting)
|
||||
+ ", unarmed = unarmed+" + m.getInt(unarmed)
|
||||
+ ", herbalism = herbalism+"
|
||||
+ m.getInt(herbalism)
|
||||
+ ", excavation = excavation+"
|
||||
+ m.getInt(excavation)
|
||||
+ ", archery = archery+" + m.getInt(archery)
|
||||
+ ", swords = swords+" + m.getInt(swords)
|
||||
+ ", axes = axes+" + m.getInt(axes)
|
||||
+ ", acrobatics = acrobatics+"
|
||||
+ m.getInt(acrobatics)
|
||||
+ ", fishing = fishing+" + m.getInt(fishing)
|
||||
+ " WHERE user_id = " + id);
|
||||
mcMMO.database.write("UPDATE "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "experience SET " + " taming = "
|
||||
+ m.getInt(tamingXP) + ", mining = "
|
||||
+ m.getInt(miningXP) + ", repair = "
|
||||
+ m.getInt(repairXP) + ", woodcutting = "
|
||||
+ m.getInt(woodCuttingXP) + ", unarmed = "
|
||||
+ m.getInt(unarmedXP) + ", herbalism = "
|
||||
+ m.getInt(herbalismXP) + ", excavation = "
|
||||
+ m.getInt(excavationXP) + ", archery = "
|
||||
+ m.getInt(archeryXP) + ", swords = "
|
||||
+ m.getInt(swordsXP) + ", axes = "
|
||||
+ m.getInt(axesXP) + ", acrobatics = "
|
||||
+ m.getInt(acrobaticsXP) + ", fishing = "
|
||||
+ m.getInt(fishingXP) + " WHERE user_id = "
|
||||
+ id);
|
||||
}
|
||||
else {
|
||||
theCount++;
|
||||
|
||||
//Create the user in the DB
|
||||
mcMMO.database.write("INSERT INTO "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "users (user, lastlogin) VALUES ('"
|
||||
+ playerName + "',"
|
||||
+ System.currentTimeMillis() / 1000 + ")");
|
||||
id = mcMMO.database.getInt("SELECT id FROM "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "users WHERE user = '"
|
||||
+ playerName + "'");
|
||||
mcMMO.database.write("INSERT INTO "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "skills (user_id) VALUES (" + id + ")");
|
||||
mcMMO.database.write("INSERT INTO "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "experience (user_id) VALUES (" + id
|
||||
+ ")");
|
||||
//Update the skill values
|
||||
mcMMO.database.write("UPDATE "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "users SET lastlogin = " + 0
|
||||
+ " WHERE id = " + id);
|
||||
mcMMO.database.write("UPDATE "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "users SET party = '" + party
|
||||
+ "' WHERE id = " + id);
|
||||
mcMMO.database.write("UPDATE "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "skills SET " + " taming = "
|
||||
+ m.getInt(taming) + ", mining = "
|
||||
+ m.getInt(mining) + ", repair = "
|
||||
+ m.getInt(repair) + ", woodcutting = "
|
||||
+ m.getInt(woodcutting) + ", unarmed = "
|
||||
+ m.getInt(unarmed) + ", herbalism = "
|
||||
+ m.getInt(herbalism) + ", excavation = "
|
||||
+ m.getInt(excavation) + ", archery = "
|
||||
+ m.getInt(archery) + ", swords = "
|
||||
+ m.getInt(swords) + ", axes = "
|
||||
+ m.getInt(axes) + ", acrobatics = "
|
||||
+ m.getInt(acrobatics) + ", fishing = "
|
||||
+ m.getInt(fishing) + " WHERE user_id = "
|
||||
+ id);
|
||||
mcMMO.database.write("UPDATE "
|
||||
+ LoadProperties.MySQLtablePrefix
|
||||
+ "experience SET " + " taming = "
|
||||
+ m.getInt(tamingXP) + ", mining = "
|
||||
+ m.getInt(miningXP) + ", repair = "
|
||||
+ m.getInt(repairXP) + ", woodcutting = "
|
||||
+ m.getInt(woodCuttingXP) + ", unarmed = "
|
||||
+ m.getInt(unarmedXP) + ", herbalism = "
|
||||
+ m.getInt(herbalismXP) + ", excavation = "
|
||||
+ m.getInt(excavationXP) + ", archery = "
|
||||
+ m.getInt(archeryXP) + ", swords = "
|
||||
+ m.getInt(swordsXP) + ", axes = "
|
||||
+ m.getInt(axesXP) + ", acrobatics = "
|
||||
+ m.getInt(acrobaticsXP) + ", fishing = "
|
||||
+ m.getInt(fishingXP) + " WHERE user_id = "
|
||||
+ id);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("[mcMMO] MySQL Updated from users file, " + theCount + " items added/updated to MySQL DB");
|
||||
in.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Bukkit.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
142
src/main/java/com/gmail/nossr50/runnables/mcBleedTimer.java
Normal file
142
src/main/java/com/gmail/nossr50/runnables/mcBleedTimer.java
Normal file
@@ -0,0 +1,142 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Combat;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
|
||||
public class mcBleedTimer implements Runnable {
|
||||
private final mcMMO plugin;
|
||||
|
||||
private static HashSet<LivingEntity> bleedList = new HashSet<LivingEntity>();
|
||||
private static HashSet<LivingEntity> bleedAddList = new HashSet<LivingEntity>();
|
||||
private static HashSet<LivingEntity> bleedRemoveList = new HashSet<LivingEntity>();
|
||||
|
||||
private static boolean lock = false;
|
||||
|
||||
public mcBleedTimer(final mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
updateBleedList();
|
||||
|
||||
// Player bleed simulation
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if (PP == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (PP.getBleedTicks() >= 1) {
|
||||
|
||||
//Never kill with Bleeding
|
||||
if (player.getHealth() - 2 < 0) {
|
||||
if (player.getHealth() - 1 > 0) {
|
||||
Combat.dealDamage(player, 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Combat.dealDamage(player, 2);
|
||||
}
|
||||
|
||||
PP.decreaseBleedTicks();
|
||||
|
||||
if (PP.getBleedTicks() == 0) {
|
||||
player.sendMessage(mcLocale.getString("Swords.StoppedBleeding"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Non-player bleed simulation
|
||||
bleedSimulate();
|
||||
}
|
||||
|
||||
private void bleedSimulate() {
|
||||
lock = true;
|
||||
|
||||
// Bleed monsters/animals
|
||||
for (LivingEntity entity : bleedList) {
|
||||
if ((entity == null || entity.isDead())) {
|
||||
remove(entity);
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
Combat.dealDamage(entity, 2);
|
||||
}
|
||||
}
|
||||
|
||||
// Unlock list now that we are done
|
||||
lock = false;
|
||||
}
|
||||
|
||||
private void updateBleedList() {
|
||||
if (lock) {
|
||||
plugin.getLogger().warning("mcBleedTimer attempted to update the bleedList but the list was locked!");
|
||||
}
|
||||
else {
|
||||
bleedList.removeAll(bleedRemoveList);
|
||||
bleedRemoveList.clear();
|
||||
|
||||
bleedList.addAll(bleedAddList);
|
||||
bleedAddList.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a LivingEntity from the bleedList if it is in it
|
||||
*
|
||||
* @param entity LivingEntity to remove
|
||||
*/
|
||||
public static void remove(LivingEntity entity) {
|
||||
if (lock) {
|
||||
if (!bleedRemoveList.contains(entity)) {
|
||||
bleedRemoveList.add(entity);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (bleedList.contains(entity)) {
|
||||
bleedList.remove(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a LivingEntity to the bleedList if it is not in it.
|
||||
*
|
||||
* @param entity LivingEntity to add
|
||||
*/
|
||||
public static void add(LivingEntity entity) {
|
||||
if (lock) {
|
||||
if (!bleedAddList.contains(entity)) {
|
||||
bleedAddList.add(entity);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!bleedList.contains(entity)){
|
||||
bleedList.add(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a LivingEntity is in the bleedList
|
||||
*
|
||||
* @param entity LivingEntity to check if in the bleedList
|
||||
* @return true if in the list, false if not
|
||||
*/
|
||||
public static boolean contains(LivingEntity entity) {
|
||||
return (bleedList.contains(entity) || bleedAddList.contains(entity));
|
||||
}
|
||||
}
|
||||
25
src/main/java/com/gmail/nossr50/runnables/mcSaveTimer.java
Normal file
25
src/main/java/com/gmail/nossr50/runnables/mcSaveTimer.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class mcSaveTimer implements Runnable {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public mcSaveTimer(final mcMMO plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
//All player data will be saved periodically through this
|
||||
for(Player player : plugin.getServer().getOnlinePlayers())
|
||||
{
|
||||
Users.getProfile(player).save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +1,17 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.skills.Swords;
|
||||
|
||||
|
||||
public class mcTimer implements Runnable
|
||||
{
|
||||
private final mcMMO plugin;
|
||||
int thecount = 1;
|
||||
|
||||
public mcTimer(final mcMMO plugin)
|
||||
{
|
||||
@@ -36,6 +20,7 @@ public class mcTimer implements Runnable
|
||||
|
||||
public void run()
|
||||
{
|
||||
long curTime = System.currentTimeMillis();
|
||||
for(Player player : plugin.getServer().getOnlinePlayers())
|
||||
{
|
||||
if(player == null)
|
||||
@@ -48,33 +33,25 @@ public class mcTimer implements Runnable
|
||||
/*
|
||||
* MONITOR SKILLS
|
||||
*/
|
||||
Skills.monitorSkills(player);
|
||||
Skills.monitorSkill(player, PP, curTime, SkillType.AXES);
|
||||
Skills.monitorSkill(player, PP, curTime, SkillType.EXCAVATION);
|
||||
Skills.monitorSkill(player, PP, curTime, SkillType.HERBALISM);
|
||||
Skills.monitorSkill(player, PP, curTime, SkillType.MINING);
|
||||
Skills.monitorSkill(player, PP, curTime, SkillType.SWORDS);
|
||||
Skills.monitorSkill(player, PP, curTime, SkillType.UNARMED);
|
||||
Skills.monitorSkill(player, PP, curTime, SkillType.WOODCUTTING);
|
||||
|
||||
/*
|
||||
* COOLDOWN MONITORING
|
||||
*/
|
||||
Skills.watchCooldowns(player);
|
||||
|
||||
/*
|
||||
* PLAYER BLEED MONITORING
|
||||
*/
|
||||
if(thecount % 2 == 0 && PP.getBleedTicks() >= 1)
|
||||
{
|
||||
player.damage(2);
|
||||
PP.decreaseBleedTicks();
|
||||
}
|
||||
|
||||
/*
|
||||
* NON-PLAYER BLEED MONITORING
|
||||
*/
|
||||
|
||||
if(thecount % 2 == 0)
|
||||
Swords.bleedSimulate(plugin);
|
||||
|
||||
//SETUP FOR HP REGEN/BLEED
|
||||
thecount++;
|
||||
if(thecount >= 81)
|
||||
thecount = 1;
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.SKULL_SPLIITER);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.GIGA_DRILL_BREAKER);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.GREEN_TERRA);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.SUPER_BREAKER);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.SERRATED_STRIKES);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.BERSERK);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.TREE_FELLER);
|
||||
Skills.watchCooldown(player, PP, curTime, AbilityType.BLAST_MINING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,105 +1,125 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
|
||||
public class Acrobatics {
|
||||
public static void acrobaticsCheck(Player player, EntityDamageEvent event)
|
||||
{
|
||||
if(player != null && mcPermissions.getInstance().acrobatics(player))
|
||||
{
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int acrovar = PP.getSkillLevel(SkillType.ACROBATICS);
|
||||
|
||||
if(player.isSneaking())
|
||||
acrovar = acrovar * 2;
|
||||
|
||||
if(Math.random() * 1000 <= acrovar && !event.isCancelled())
|
||||
{
|
||||
int threshold = 7;
|
||||
if(player.isSneaking())
|
||||
threshold = 14;
|
||||
|
||||
int newDamage = event.getDamage() - threshold;
|
||||
if(newDamage < 0)
|
||||
newDamage = 0;
|
||||
/*
|
||||
* Check for death
|
||||
*/
|
||||
if(player.getHealth() - newDamage >= 1){
|
||||
if(!event.isCancelled())
|
||||
PP.addXP(SkillType.ACROBATICS, (event.getDamage() * 8)*10, player);
|
||||
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
|
||||
event.setDamage(newDamage);
|
||||
if(event.getDamage() <= 0)
|
||||
event.setCancelled(true);
|
||||
if(player.isSneaking()){
|
||||
player.sendMessage(ChatColor.GREEN+"**GRACEFUL ROLL**");
|
||||
} else {
|
||||
player.sendMessage("**ROLL**");
|
||||
}
|
||||
}
|
||||
} else if (!event.isCancelled()){
|
||||
if(player.getHealth() - event.getDamage() >= 1){
|
||||
PP.addXP(SkillType.ACROBATICS, (event.getDamage() * 12)*10, player);
|
||||
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for fall damage reduction.
|
||||
*
|
||||
* @param player The player whose fall damage to modify
|
||||
* @param event The event to check
|
||||
*/
|
||||
public static void acrobaticsCheck(Player player, EntityDamageEvent event) {
|
||||
final int ROLL_XP_MODIFIER = 80;
|
||||
final int FALL_XP_MODIFIER = 120;
|
||||
final int MAX_BONUS_LEVEL = 1000;
|
||||
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int acrovar = PP.getSkillLevel(SkillType.ACROBATICS);
|
||||
boolean gracefulRoll = player.isSneaking();
|
||||
int damage = event.getDamage();
|
||||
int health = player.getHealth();
|
||||
|
||||
if (!mcPermissions.getInstance().gracefulRoll(player)) {
|
||||
gracefulRoll = false;
|
||||
}
|
||||
|
||||
if (gracefulRoll) {
|
||||
acrovar = acrovar * 2;
|
||||
}
|
||||
|
||||
if ((acrovar > MAX_BONUS_LEVEL || Math.random() * 1000 <= acrovar) && mcPermissions.getInstance().roll(player)) {
|
||||
int threshold = 7;
|
||||
|
||||
if (gracefulRoll) {
|
||||
threshold = threshold * 2;
|
||||
}
|
||||
|
||||
int newDamage = damage - threshold;
|
||||
|
||||
if (newDamage < 0) {
|
||||
newDamage = 0;
|
||||
}
|
||||
|
||||
/* Check for death */
|
||||
if (health - damage >= 1) {
|
||||
PP.addXP(SkillType.ACROBATICS, damage * ROLL_XP_MODIFIER, player);
|
||||
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
|
||||
|
||||
event.setDamage(newDamage);
|
||||
|
||||
if (event.getDamage() <= 0) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (gracefulRoll) {
|
||||
player.sendMessage(mcLocale.getString("Acrobatics.GracefulRoll"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(mcLocale.getString("Acrobatics.Roll"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (health - damage >= 1) {
|
||||
PP.addXP(SkillType.ACROBATICS, event.getDamage() * FALL_XP_MODIFIER, player);
|
||||
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for dodge damage reduction.
|
||||
*
|
||||
* @param event The event to check
|
||||
*/
|
||||
public static void dodgeChecks(EntityDamageByEntityEvent event) {
|
||||
final int DODGE_MODIFIER = 120;
|
||||
final int MAX_BONUS_LEVEL = 800;
|
||||
|
||||
Player defender = (Player) event.getEntity();
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
int damage = event.getDamage();
|
||||
|
||||
/* PARTY CHECK */
|
||||
if (event.getDamager() instanceof Player) {
|
||||
Player attacker = (Player) event.getDamager();
|
||||
|
||||
if (Party.getInstance().inSameParty(defender, attacker)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (mcPermissions.getInstance().acrobatics(defender)) {
|
||||
int skillLevel = PPd.getSkillLevel(SkillType.ACROBATICS);
|
||||
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||
|
||||
if (Math.random() * 4000 <= skillCheck && mcPermissions.getInstance().dodge(defender)) {
|
||||
defender.sendMessage(mcLocale.getString("Acrobatics.Dodge"));
|
||||
|
||||
if (System.currentTimeMillis() >= (5000 + PPd.getRespawnATS()) && defender.getHealth() >= 1) {
|
||||
PPd.addXP(SkillType.ACROBATICS, damage * DODGE_MODIFIER, defender);
|
||||
Skills.XpCheckSkill(SkillType.ACROBATICS, defender);
|
||||
}
|
||||
|
||||
int newDamage = damage / 2;
|
||||
|
||||
if (newDamage <= 0) {
|
||||
event.setDamage(1);
|
||||
}
|
||||
else {
|
||||
event.setDamage(newDamage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void dodgeChecks(EntityDamageByEntityEvent event){
|
||||
Player defender = (Player) event.getEntity();
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
|
||||
if(mcPermissions.getInstance().acrobatics(defender)){
|
||||
if(PPd.getSkillLevel(SkillType.ACROBATICS) <= 800){
|
||||
if(Math.random() * 4000 <= PPd.getSkillLevel(SkillType.ACROBATICS)){
|
||||
defender.sendMessage(ChatColor.GREEN+"**DODGE**");
|
||||
if(System.currentTimeMillis() >= 5000 + PPd.getRespawnATS() && defender.getHealth() >= 1){
|
||||
PPd.addXP(SkillType.ACROBATICS, (event.getDamage() * 12)*1, defender);
|
||||
Skills.XpCheckSkill(SkillType.ACROBATICS, defender);
|
||||
}
|
||||
event.setDamage(event.getDamage() / 2);
|
||||
//Needs to do minimal damage
|
||||
if(event.getDamage() <= 0)
|
||||
event.setDamage(1);
|
||||
}
|
||||
} else if(Math.random() * 4000 <= 800) {
|
||||
defender.sendMessage(ChatColor.GREEN+"**DODGE**");
|
||||
if(System.currentTimeMillis() >= 5000 + PPd.getRespawnATS() && defender.getHealth() >= 1){
|
||||
PPd.addXP(SkillType.ACROBATICS, (event.getDamage() * 12)*10, defender);
|
||||
Skills.XpCheckSkill(SkillType.ACROBATICS, defender);
|
||||
}
|
||||
event.setDamage(event.getDamage() / 2);
|
||||
//Needs to deal minimal damage
|
||||
if(event.getDamage() <= 0)
|
||||
event.setDamage(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
public class Alchemy {
|
||||
|
||||
}
|
||||
@@ -1,119 +1,124 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
|
||||
public class Archery
|
||||
{
|
||||
public static void trackArrows(mcMMO pluginx, Entity x, EntityDamageByEntityEvent event, Player attacker)
|
||||
{
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
if(!pluginx.misc.arrowTracker.containsKey(x) && event.getDamage() > 0)
|
||||
{
|
||||
pluginx.misc.arrowTracker.put(x, 0);
|
||||
if(attacker != null)
|
||||
{
|
||||
if(Math.random() * 1000 <= PPa.getSkillLevel(SkillType.ARCHERY))
|
||||
{
|
||||
pluginx.misc.arrowTracker.put(x, 1);
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
if(event.getDamage() > 0)
|
||||
{
|
||||
if(attacker != null)
|
||||
{
|
||||
if(Math.random() * 1000 <= PPa.getSkillLevel(SkillType.ARCHERY))
|
||||
{
|
||||
pluginx.misc.arrowTracker.put(x, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void ignitionCheck(Entity x, EntityDamageByEntityEvent event, Player attacker)
|
||||
{
|
||||
//Check to see if PVP for this world is disabled before executing
|
||||
if(!x.getWorld().getPVP())
|
||||
return;
|
||||
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
if(Math.random() * 100 >= 75)
|
||||
{
|
||||
|
||||
int ignition = 20;
|
||||
if(PPa.getSkillLevel(SkillType.ARCHERY) >= 200)
|
||||
ignition+=20;
|
||||
if(PPa.getSkillLevel(SkillType.ARCHERY) >= 400)
|
||||
ignition+=20;
|
||||
if(PPa.getSkillLevel(SkillType.ARCHERY) >= 600)
|
||||
ignition+=20;
|
||||
if(PPa.getSkillLevel(SkillType.ARCHERY) >= 800)
|
||||
ignition+=20;
|
||||
if(PPa.getSkillLevel(SkillType.ARCHERY) >= 1000)
|
||||
ignition+=20;
|
||||
|
||||
if(x instanceof Player)
|
||||
{
|
||||
Player Defender = (Player)x;
|
||||
if(!Party.getInstance().inSameParty(attacker, Defender))
|
||||
{
|
||||
event.getEntity().setFireTicks(ignition);
|
||||
attacker.sendMessage(mcLocale.getString("Combat.Ignition")); //$NON-NLS-1$
|
||||
Defender.sendMessage(mcLocale.getString("Combat.BurningArrowHit")); //$NON-NLS-1$
|
||||
}
|
||||
} else {
|
||||
event.getEntity().setFireTicks(ignition);
|
||||
attacker.sendMessage(mcLocale.getString("Combat.Ignition")); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void dazeCheck(Player defender, Player attacker)
|
||||
{
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
|
||||
Location loc = defender.getLocation();
|
||||
if(Math.random() * 10 > 5)
|
||||
{
|
||||
loc.setPitch(90);
|
||||
} else {
|
||||
loc.setPitch(-90);
|
||||
}
|
||||
if(PPa.getSkillLevel(SkillType.ARCHERY) >= 1000){
|
||||
if(Math.random() * 1000 <= 500){
|
||||
defender.teleport(loc);
|
||||
defender.sendMessage(mcLocale.getString("Combat.TouchedFuzzy")); //$NON-NLS-1$
|
||||
attacker.sendMessage(mcLocale.getString("Combat.TargetDazed")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
} else if(Math.random() * 2000 <= PPa.getSkillLevel(SkillType.ARCHERY)){
|
||||
defender.teleport(loc);
|
||||
defender.sendMessage(mcLocale.getString("Combat.TouchedFuzzy")); //$NON-NLS-1$
|
||||
attacker.sendMessage(mcLocale.getString("Combat.TargetDazed")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
public class Archery {
|
||||
|
||||
/**
|
||||
* Track arrows fired for later retrieval.
|
||||
*
|
||||
* @param plugin mcMMO plugin instance
|
||||
* @param entity Entity damaged by the arrow
|
||||
* @param PPa PlayerProfile of the player firing the arrow
|
||||
*/
|
||||
public static void trackArrows(mcMMO plugin, Entity entity, PlayerProfile PPa) {
|
||||
final int MAX_BONUS_LEVEL = 1000;
|
||||
int skillLevel = PPa.getSkillLevel(SkillType.ARCHERY);
|
||||
|
||||
if (!plugin.arrowTracker.containsKey(entity)) {
|
||||
plugin.arrowTracker.put(entity, 0);
|
||||
}
|
||||
|
||||
if (skillLevel > MAX_BONUS_LEVEL || (Math.random() * 1000 <= skillLevel)) {
|
||||
plugin.arrowTracker.put(entity, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for ignition on arrow hit.
|
||||
*
|
||||
* @param entity Entity damaged by the arrow
|
||||
* @param attacker Player who fired the arrow
|
||||
*/
|
||||
public static void ignitionCheck(Entity entity, Player attacker) {
|
||||
|
||||
//Check to see if PVP for this world is disabled before executing
|
||||
if (!entity.getWorld().getPVP()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int IGNITION_CHANCE = 25;
|
||||
final int MAX_IGNITION_TICKS = 120;
|
||||
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
|
||||
if (Math.random() * 100 <= IGNITION_CHANCE) {
|
||||
int ignition = 20;
|
||||
|
||||
/* Add 20 ticks for every 200 skill levels */
|
||||
ignition += (PPa.getSkillLevel(SkillType.ARCHERY) / 200) * 20;
|
||||
|
||||
if (ignition > MAX_IGNITION_TICKS) {
|
||||
ignition = MAX_IGNITION_TICKS;
|
||||
}
|
||||
|
||||
if (entity instanceof Player) {
|
||||
Player defender = (Player) entity;
|
||||
|
||||
if (!Party.getInstance().inSameParty(attacker, defender)) {
|
||||
defender.setFireTicks(defender.getFireTicks() + ignition);
|
||||
attacker.sendMessage(mcLocale.getString("Combat.Ignition"));
|
||||
defender.sendMessage(mcLocale.getString("Combat.BurningArrowHit"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
entity.setFireTicks(entity.getFireTicks() + ignition);
|
||||
attacker.sendMessage(mcLocale.getString("Combat.Ignition"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for Daze.
|
||||
*
|
||||
* @param defender Defending player
|
||||
* @param attacker Attacking player
|
||||
*/
|
||||
public static void dazeCheck(Player defender, Player attacker) {
|
||||
final int MAX_BONUS_LEVEL = 1000;
|
||||
|
||||
int skillLevel = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY);
|
||||
Location loc = defender.getLocation();
|
||||
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||
|
||||
if (Math.random() * 10 > 5) {
|
||||
loc.setPitch(90);
|
||||
}
|
||||
else {
|
||||
loc.setPitch(-90);
|
||||
}
|
||||
|
||||
if (Math.random() * 2000 <= skillCheck && mcPermissions.getInstance().daze(attacker)) {
|
||||
defender.teleport(loc);
|
||||
defender.sendMessage(mcLocale.getString("Combat.TouchedFuzzy"));
|
||||
attacker.sendMessage(mcLocale.getString("Combat.TargetDazed"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for arrow retrieval.
|
||||
*
|
||||
* @param entity The entity hit by the arrows
|
||||
* @param plugin mcMMO plugin instance
|
||||
*/
|
||||
public static void arrowRetrievalCheck(Entity entity, mcMMO plugin) {
|
||||
if (plugin.arrowTracker.containsKey(entity)) {
|
||||
m.mcDropItems(entity.getLocation(), new ItemStack(Material.ARROW), plugin.arrowTracker.get(entity));
|
||||
}
|
||||
|
||||
plugin.arrowTracker.remove(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,172 +1,159 @@
|
||||
/*
|
||||
This file is part of mcMMO.
|
||||
|
||||
mcMMO is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
mcMMO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.gmail.nossr50.skills;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
|
||||
public class Axes {
|
||||
public static void skullSplitterCheck(Player player){
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(m.isAxes(player.getItemInHand()) && mcPermissions.getInstance().axesAbility(player)){
|
||||
/*
|
||||
* CHECK FOR AXE PREP MODE
|
||||
*/
|
||||
if(PP.getAxePreparationMode())
|
||||
{
|
||||
PP.setAxePreparationMode(false);
|
||||
}
|
||||
int ticks = 2;
|
||||
int x = PP.getSkillLevel(SkillType.AXES);
|
||||
while(x >= 50){
|
||||
x-=50;
|
||||
ticks++;
|
||||
}
|
||||
|
||||
if(!PP.getSkullSplitterMode() && Skills.cooldownOver(player, (PP.getSkullSplitterDeactivatedTimeStamp()*1000), LoadProperties.skullSplitterCooldown))
|
||||
{
|
||||
player.sendMessage(mcLocale.getString("Skills.SkullSplitterOn"));
|
||||
for(Player y : player.getWorld().getPlayers()){
|
||||
if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
|
||||
y.sendMessage(mcLocale.getString("Skills.SkullSplitterPlayer", new Object[] {player.getName()}));
|
||||
}
|
||||
PP.setSkullSplitterActivatedTimeStamp(System.currentTimeMillis());
|
||||
PP.setSkullSplitterDeactivatedTimeStamp(System.currentTimeMillis() + (ticks * 1000));
|
||||
PP.setSkullSplitterMode(true);
|
||||
}
|
||||
if(!PP.getSkullSplitterMode() && !Skills.cooldownOver(player, (PP.getSkullSplitterDeactivatedTimeStamp()*1000), LoadProperties.skullSplitterCooldown)){
|
||||
player.sendMessage(mcLocale.getString("Skills.TooTired")
|
||||
+ChatColor.YELLOW+" ("+Skills.calculateTimeLeft(player, (PP.getSkullSplitterDeactivatedTimeStamp()*1000), LoadProperties.skullSplitterCooldown)+"s)");
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void axeCriticalCheck(Player attacker, EntityDamageByEntityEvent event, Plugin pluginx)
|
||||
{
|
||||
Entity x = event.getEntity();
|
||||
if(x instanceof Wolf){
|
||||
Wolf wolf = (Wolf)x;
|
||||
if(Taming.getOwner(wolf, pluginx) != null)
|
||||
{
|
||||
if(Taming.getOwner(wolf, pluginx) == attacker)
|
||||
return;
|
||||
if(Party.getInstance().inSameParty(attacker, Taming.getOwner(wolf, pluginx)))
|
||||
return;
|
||||
}
|
||||
}
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
if(m.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){
|
||||
if(PPa.getSkillLevel(SkillType.AXES) >= 750){
|
||||
if(Math.random() * 1000 <= 750){
|
||||
if(x instanceof Player){
|
||||
Player player = (Player)x;
|
||||
player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!");
|
||||
}
|
||||
if(x instanceof Player){
|
||||
event.setDamage(event.getDamage() * 2 - event.getDamage() / 2);
|
||||
} else {
|
||||
event.setDamage(event.getDamage() * 2);
|
||||
}
|
||||
attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!");
|
||||
}
|
||||
} else if(Math.random() * 1000 <= PPa.getSkillLevel(SkillType.AXES)){
|
||||
if(x instanceof Player){
|
||||
Player player = (Player)x;
|
||||
player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!");
|
||||
}
|
||||
if(x instanceof Player){
|
||||
event.setDamage(event.getDamage() * 2 - event.getDamage() / 2);
|
||||
} else {
|
||||
event.setDamage(event.getDamage() * 2);
|
||||
}
|
||||
attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyAoeDamage(Player attacker, EntityDamageByEntityEvent event, Plugin pluginx)
|
||||
{
|
||||
int targets = 0;
|
||||
|
||||
if(event.getEntity() instanceof LivingEntity)
|
||||
{
|
||||
LivingEntity x = (LivingEntity) event.getEntity();
|
||||
targets = m.getTier(attacker);
|
||||
|
||||
for(Entity derp : x.getWorld().getEntities())
|
||||
{
|
||||
if(m.getDistance(x.getLocation(), derp.getLocation()) < 5)
|
||||
{
|
||||
|
||||
|
||||
//Make sure the Wolf is not friendly
|
||||
if(derp instanceof Wolf)
|
||||
{
|
||||
Wolf hurrDurr = (Wolf)derp;
|
||||
if(Taming.getOwner(hurrDurr, pluginx) == attacker)
|
||||
continue;
|
||||
if(Party.getInstance().inSameParty(attacker, Taming.getOwner(hurrDurr, pluginx)))
|
||||
continue;
|
||||
}
|
||||
//Damage nearby LivingEntities
|
||||
if(derp instanceof LivingEntity && targets >= 1)
|
||||
{
|
||||
if(derp instanceof Player)
|
||||
{
|
||||
Player target = (Player)derp;
|
||||
|
||||
if(Users.getProfile(target).getGodMode())
|
||||
continue;
|
||||
/**
|
||||
* Apply bonus to damage done by axes.
|
||||
*
|
||||
* @param attacker The attacking player
|
||||
* @param event The event to modify
|
||||
*/
|
||||
public static void axesBonus(Player attacker, EntityDamageByEntityEvent event) {
|
||||
final int MAX_BONUS = 4;
|
||||
|
||||
if(target.getName().equals(attacker.getName()))
|
||||
continue;
|
||||
|
||||
if(Party.getInstance().inSameParty(attacker, target))
|
||||
continue;
|
||||
if(targets >= 1 && derp.getWorld().getPVP())
|
||||
{
|
||||
target.damage(event.getDamage() / 2);
|
||||
target.sendMessage(ChatColor.DARK_RED+"Struck by CLEAVE!");
|
||||
targets--;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LivingEntity target = (LivingEntity)derp;
|
||||
target.damage(event.getDamage() / 2);
|
||||
targets--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int bonus = 0;
|
||||
|
||||
/* Add 1 DMG for every 50 skill levels */
|
||||
bonus += Users.getProfile(attacker).getSkillLevel(SkillType.AXES) / 50;
|
||||
|
||||
if (bonus > MAX_BONUS) {
|
||||
bonus = MAX_BONUS;
|
||||
}
|
||||
|
||||
event.setDamage(event.getDamage() + bonus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for critical chances on axe damage.
|
||||
*
|
||||
* @param attacker The attacking player
|
||||
* @param event The event to modify
|
||||
*/
|
||||
public static void axeCriticalCheck(Player attacker, EntityDamageByEntityEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (entity instanceof Wolf) {
|
||||
Wolf wolf = (Wolf) entity;
|
||||
|
||||
if (wolf.isTamed()) {
|
||||
AnimalTamer tamer = wolf.getOwner();
|
||||
|
||||
if (tamer instanceof Player) {
|
||||
Player owner = (Player) tamer;
|
||||
|
||||
if (owner == attacker || Party.getInstance().inSameParty(attacker, owner)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final int MAX_BONUS_LEVEL = 750;
|
||||
final double PVP_MODIFIER = 1.5;
|
||||
final int PVE_MODIFIER = 2;
|
||||
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
int skillLevel = PPa.getSkillLevel(SkillType.AXES);
|
||||
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||
|
||||
if (Math.random() * 2000 <= skillCheck && !entity.isDead()){
|
||||
int damage = event.getDamage();
|
||||
|
||||
if (entity instanceof Player){
|
||||
event.setDamage((int) (damage * PVP_MODIFIER));
|
||||
Player player = (Player) entity;
|
||||
player.sendMessage(mcLocale.getString("Axes.HitCritically"));
|
||||
}
|
||||
else {
|
||||
event.setDamage(damage * PVE_MODIFIER);
|
||||
}
|
||||
attacker.sendMessage(mcLocale.getString("Axes.CriticalHit"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for Impact ability.
|
||||
*
|
||||
* @param attacker The attacking player
|
||||
* @param target The defending entity
|
||||
* @param event The event to modify
|
||||
*/
|
||||
public static void impact(Player attacker, LivingEntity target, EntityDamageByEntityEvent event) {
|
||||
|
||||
/*
|
||||
* TODO: Finish this skill. The idea is you will greatly damage an opponents armor.
|
||||
* When they are unarmored, you have a proc that will stun them and deal additional damage.
|
||||
*/
|
||||
if (target instanceof Player) {
|
||||
Player targetPlayer = (Player) target;
|
||||
short durabilityDamage = 5; //Start with 5 durability damage
|
||||
|
||||
/* Every 30 Skill Levels you gain 1 durability damage */
|
||||
durabilityDamage += Users.getProfile(attacker).getSkillLevel(SkillType.AXES)/30;
|
||||
|
||||
if (!hasArmor(targetPlayer)) {
|
||||
applyImpact(attacker, target, event);
|
||||
}
|
||||
else {
|
||||
for (ItemStack armor : targetPlayer.getInventory().getArmorContents()) {
|
||||
armor.setDurability((short) (armor.getDurability() + durabilityDamage)); //Damage armor piece
|
||||
}
|
||||
targetPlayer.updateInventory();
|
||||
}
|
||||
}
|
||||
else {
|
||||
applyImpact(attacker, target, event); //Since mobs are technically unarmored, this will always trigger
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply impact ability.
|
||||
*
|
||||
* @param attacker The attacking player
|
||||
* @param target The defending entity
|
||||
* @param event The event to modify
|
||||
*/
|
||||
private static void applyImpact(Player attacker, LivingEntity target, EntityDamageByEntityEvent event) {
|
||||
final int GREATER_IMPACT_CHANCE = 25;
|
||||
final double GREATER_IMPACT_MULTIPLIER = 1.5;
|
||||
|
||||
if (Math.random() * 100 <= GREATER_IMPACT_CHANCE) {
|
||||
event.setDamage(event.getDamage() + 2);
|
||||
target.setVelocity(attacker.getLocation().getDirection().normalize().multiply(GREATER_IMPACT_MULTIPLIER));
|
||||
attacker.sendMessage(mcLocale.getString("Axes.GreaterImpactOnEnemy"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player has armor.
|
||||
*
|
||||
* @param player Player whose armor to check
|
||||
* @return true if the player has armor, false otherwise
|
||||
*/
|
||||
private static boolean hasArmor(Player player) {
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
|
||||
if (inventory.getBoots() != null || inventory.getChestplate() != null || inventory.getHelmet() != null || inventory.getLeggings() != null) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user