mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 09:43:00 +01:00
Compare commits
665 Commits
1.3.12
...
1.4.00-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc33f27899 | ||
|
|
e40095977a | ||
|
|
d1f499f6fd | ||
|
|
610bc42815 | ||
|
|
2006356ccd | ||
|
|
63e827aefb | ||
|
|
1898537149 | ||
|
|
60033d47ec | ||
|
|
b633f36131 | ||
|
|
749443454d | ||
|
|
d68dfe2a32 | ||
|
|
f3b119b91b | ||
|
|
aca3d5c4c6 | ||
|
|
b0acea3353 | ||
|
|
862f5d73e1 | ||
|
|
52bf73aecc | ||
|
|
54e5be1961 | ||
|
|
7fbf3d4f27 | ||
|
|
2df285fd7c | ||
|
|
a3e9d12f6a | ||
|
|
89e5e16aad | ||
|
|
cec132092f | ||
|
|
01723b2d36 | ||
|
|
b463e4ce6f | ||
|
|
8c7fd7b1a6 | ||
|
|
2762a9d1fd | ||
|
|
137864dc04 | ||
|
|
ef775f1c24 | ||
|
|
56617a1c1c | ||
|
|
77e048471e | ||
|
|
7d83dd8283 | ||
|
|
d0c0b9a089 | ||
|
|
75894c4419 | ||
|
|
d3c8a5565a | ||
|
|
bd2cd07f46 | ||
|
|
cd35df17ec | ||
|
|
a1d710fe3d | ||
|
|
c34d269f33 | ||
|
|
01c8b8ad4a | ||
|
|
fc5dda78f5 | ||
|
|
d6e78beb72 | ||
|
|
f324181190 | ||
|
|
5c13661c47 | ||
|
|
8b514d631c | ||
|
|
13a65e875f | ||
|
|
a1d4a4b3f8 | ||
|
|
610b87f462 | ||
|
|
374b758700 | ||
|
|
d32e0962b0 | ||
|
|
1cb9f93f0e | ||
|
|
4a24ade442 | ||
|
|
3f6bd7894d | ||
|
|
cbb941116f | ||
|
|
bcaa7ecacb | ||
|
|
b8eb6186ed | ||
|
|
6d5cf2b139 | ||
|
|
5e6b1fe362 | ||
|
|
1c0cafc6c8 | ||
|
|
8eee0cb0b0 | ||
|
|
bfe8403d75 | ||
|
|
8a852ce22e | ||
|
|
64fc7bcaf8 | ||
|
|
599bbe73b4 | ||
|
|
852872f55c | ||
|
|
62a037a4fd | ||
|
|
637442149c | ||
|
|
9a89c7c49f | ||
|
|
c6ef053aac | ||
|
|
d3b0da4186 | ||
|
|
d09cd49f01 | ||
|
|
bfa29cbf02 | ||
|
|
74d9fa422f | ||
|
|
b43538ee78 | ||
|
|
755b9bc2a1 | ||
|
|
ae49f0b6e4 | ||
|
|
063de93eb8 | ||
|
|
ec997bd2b6 | ||
|
|
20aa312173 | ||
|
|
48b0050451 | ||
|
|
c04b14c751 | ||
|
|
3d8aa29b52 | ||
|
|
ac7ed67d91 | ||
|
|
20f6a55df2 | ||
|
|
60041a1253 | ||
|
|
1e7b54ef0d | ||
|
|
d2cb88d93b | ||
|
|
659e982c47 | ||
|
|
5bf1e49e43 | ||
|
|
5b862a4cee | ||
|
|
2aec202e6d | ||
|
|
f5259decab | ||
|
|
0a17bf69c0 | ||
|
|
6db78d3cda | ||
|
|
0692dd82ad | ||
|
|
088d4ac14a | ||
|
|
92262d0e47 | ||
|
|
1549f66fd7 | ||
|
|
1118cd8ca1 | ||
|
|
d744c6a46d | ||
|
|
765199eba3 | ||
|
|
cb46040309 | ||
|
|
abd8223e41 | ||
|
|
e061acb44a | ||
|
|
cc6850b37d | ||
|
|
a3c92b07cb | ||
|
|
e61581c4e6 | ||
|
|
43dbb94a7f | ||
|
|
d43e61a49c | ||
|
|
7ccadae489 | ||
|
|
251c152efa | ||
|
|
a8fa625b5c | ||
|
|
5151be05b9 | ||
|
|
3f44bd8eac | ||
|
|
2eb593e163 | ||
|
|
2356fda67a | ||
|
|
bff7919c21 | ||
|
|
f1075f800f | ||
|
|
473b9e8bbe | ||
|
|
00c84e775f | ||
|
|
a1a630bad2 | ||
|
|
b91b88a74b | ||
|
|
56e16acce4 | ||
|
|
4692a461eb | ||
|
|
3e04bacf73 | ||
|
|
a0a52a3433 | ||
|
|
188ad359fe | ||
|
|
d601496173 | ||
|
|
85b909a7ab | ||
|
|
18a4f5ed40 | ||
|
|
c4ec9a6df9 | ||
|
|
a4aebdc643 | ||
|
|
b61410b6eb | ||
|
|
51d681974c | ||
|
|
071f7edade | ||
|
|
46f1157030 | ||
|
|
3cca6d9ab4 | ||
|
|
91e8051cee | ||
|
|
c220f0dee5 | ||
|
|
a7be57241c | ||
|
|
a35af4dbe6 | ||
|
|
329f779781 | ||
|
|
95fa688306 | ||
|
|
3d275a4f53 | ||
|
|
06cf0ff2c2 | ||
|
|
ba7ebe1319 | ||
|
|
3efc2138d6 | ||
|
|
9b0cba9dbe | ||
|
|
62a5d2db5c | ||
|
|
96d59a2e81 | ||
|
|
f5179cdcea | ||
|
|
4639b8b939 | ||
|
|
9cdfebda9a | ||
|
|
7c59621c9e | ||
|
|
8736aae2ef | ||
|
|
76a987e1e0 | ||
|
|
9dac898c1c | ||
|
|
ab677e941d | ||
|
|
29d796b6af | ||
|
|
276800f999 | ||
|
|
8d22df0411 | ||
|
|
8d077ff4f2 | ||
|
|
58b01021c1 | ||
|
|
5a6dc8511f | ||
|
|
b7bb3f4487 | ||
|
|
bba23de31c | ||
|
|
973279ed40 | ||
|
|
a4494f0873 | ||
|
|
121354e489 | ||
|
|
531e92bda3 | ||
|
|
135bfc2627 | ||
|
|
a01882aea5 | ||
|
|
a8b5b438bf | ||
|
|
8ccaf3caf2 | ||
|
|
1337c45f1d | ||
|
|
a968019799 | ||
|
|
0a9e1ba42e | ||
|
|
7e91776cfb | ||
|
|
9689c50603 | ||
|
|
bb2eb053da | ||
|
|
de5110310f | ||
|
|
64137995c2 | ||
|
|
6f45e479bd | ||
|
|
53ac857b43 | ||
|
|
6f0e2437e0 | ||
|
|
56d27c3d78 | ||
|
|
7919e591cb | ||
|
|
aabbc2f238 | ||
|
|
fb31cef68b | ||
|
|
2a89e912f8 | ||
|
|
ee91ed8708 | ||
|
|
69475f92c7 | ||
|
|
dc2452231d | ||
|
|
1bbb245e32 | ||
|
|
1548863a21 | ||
|
|
9169f53465 | ||
|
|
b5542effc2 | ||
|
|
6b0e7a9c61 | ||
|
|
00d50953ad | ||
|
|
397dd96383 | ||
|
|
cac5f15a37 | ||
|
|
74c32c4e59 | ||
|
|
e048a6d0d0 | ||
|
|
65d71db72f | ||
|
|
b4fffe154d | ||
|
|
716c4d3783 | ||
|
|
5a9ca96a0f | ||
|
|
cedfb1a538 | ||
|
|
176ffcc3d1 | ||
|
|
91b318e8f7 | ||
|
|
3cc9672ff3 | ||
|
|
946d845987 | ||
|
|
eef5df33b3 | ||
|
|
f0f7dee3c2 | ||
|
|
ddbf5a559a | ||
|
|
67fd45ef25 | ||
|
|
7f8beca33c | ||
|
|
0fcf033ecc | ||
|
|
ea4048dce9 | ||
|
|
0a295f7738 | ||
|
|
0711454e31 | ||
|
|
900623461a | ||
|
|
9512879cc7 | ||
|
|
299c7ff804 | ||
|
|
0276294569 | ||
|
|
06b75386b9 | ||
|
|
16bc359f99 | ||
|
|
c8013421e6 | ||
|
|
c1e82b566e | ||
|
|
f7aba26be2 | ||
|
|
77ffc9c3c2 | ||
|
|
9a6ebb0b9a | ||
|
|
57d1cd5f63 | ||
|
|
b7354779d4 | ||
|
|
0cdb50e538 | ||
|
|
37469232b0 | ||
|
|
0c52260a89 | ||
|
|
a85c9679a9 | ||
|
|
d625edf53e | ||
|
|
643af1c32b | ||
|
|
e7ceef479e | ||
|
|
0545ed434d | ||
|
|
b9bf3f96d2 | ||
|
|
f184e7bd01 | ||
|
|
e1804cded4 | ||
|
|
09eabe98c4 | ||
|
|
173cb001cb | ||
|
|
7d6a4d11fd | ||
|
|
11ea6b269e | ||
|
|
372950071a | ||
|
|
b424ecfd3e | ||
|
|
fc38bbd179 | ||
|
|
00f24fd5bd | ||
|
|
50de88a0a0 | ||
|
|
ca2673f258 | ||
|
|
7d416a90de | ||
|
|
d09526e470 | ||
|
|
ed68f227ac | ||
|
|
f72b1e7eec | ||
|
|
bbd756f0d3 | ||
|
|
87a9c12827 | ||
|
|
ebd83e1f19 | ||
|
|
5b4b99f44e | ||
|
|
d153e3e25c | ||
|
|
e3b3b7cfdb | ||
|
|
2c78bac8f7 | ||
|
|
db1c0647ed | ||
|
|
2f16dbc9b5 | ||
|
|
7e7ab249c2 | ||
|
|
1d2298e5f6 | ||
|
|
b53b5bbc6c | ||
|
|
0dfd2fe9ef | ||
|
|
c0b3a4e929 | ||
|
|
5830bf461d | ||
|
|
857bb00c8a | ||
|
|
c5ae4ca615 | ||
|
|
abb0184e49 | ||
|
|
b11762da99 | ||
|
|
946d00cce6 | ||
|
|
0262255bea | ||
|
|
38a8a6f2ff | ||
|
|
a6446563d8 | ||
|
|
225adb5cce | ||
|
|
a9c722de67 | ||
|
|
49610e372f | ||
|
|
a33768de1b | ||
|
|
790b31c60e | ||
|
|
37c92b8d7c | ||
|
|
07211611a6 | ||
|
|
ea7fee2a53 | ||
|
|
89da8b832f | ||
|
|
5f4c83b6a1 | ||
|
|
2e751b1438 | ||
|
|
1a888d3116 | ||
|
|
2a4fe4aa48 | ||
|
|
4c81eb3058 | ||
|
|
64c20d0e24 | ||
|
|
ff186d5d9d | ||
|
|
734d691e00 | ||
|
|
51777dbe85 | ||
|
|
fb1d48fcae | ||
|
|
41ae8cbbf3 | ||
|
|
9717be3da8 | ||
|
|
67a4efa03e | ||
|
|
fd4f0f4096 | ||
|
|
957605d46b | ||
|
|
55f824e0c8 | ||
|
|
faa22002e3 | ||
|
|
5d0e85452a | ||
|
|
8c61e35fde | ||
|
|
bdfdc61e7f | ||
|
|
b333916f56 | ||
|
|
737d4e2d65 | ||
|
|
c0dfcfd9f6 | ||
|
|
c073c7ed3a | ||
|
|
7fa1a8c6c7 | ||
|
|
037fd890dc | ||
|
|
d673676a8a | ||
|
|
793538d4ef | ||
|
|
92fc00bb0a | ||
|
|
9d70a2a9a6 | ||
|
|
46a5245a1d | ||
|
|
9b94fba3a6 | ||
|
|
a6144f6dee | ||
|
|
615eb9666e | ||
|
|
94a4f628c7 | ||
|
|
d440876bbb | ||
|
|
32c62fd7eb | ||
|
|
65f78ba447 | ||
|
|
9c9a097ff3 | ||
|
|
ff6cdc3e9d | ||
|
|
24367b350d | ||
|
|
e0da44b34a | ||
|
|
ea13ce09c9 | ||
|
|
ef69217b81 | ||
|
|
7e297ac884 | ||
|
|
e6e8470851 | ||
|
|
89a36ae47e | ||
|
|
137c46b8ce | ||
|
|
5512bd7df6 | ||
|
|
96e2cfaad6 | ||
|
|
f7d482e7bc | ||
|
|
6c67308a1f | ||
|
|
6bbdbee669 | ||
|
|
9204b23d51 | ||
|
|
7203a0fcad | ||
|
|
5bdf4b5dcc | ||
|
|
105f088576 | ||
|
|
f40433fc99 | ||
|
|
bbbd12d461 | ||
|
|
81dae8c43d | ||
|
|
ec6a7e79d6 | ||
|
|
630b64462e | ||
|
|
72b8eb85b0 | ||
|
|
a92843533b | ||
|
|
83855268d5 | ||
|
|
67e1defdb8 | ||
|
|
724aad8504 | ||
|
|
5b1337ed07 | ||
|
|
a64e177c21 | ||
|
|
e7aafb7242 | ||
|
|
75e52bbe66 | ||
|
|
348887f799 | ||
|
|
8915a535c6 | ||
|
|
0587741437 | ||
|
|
dd766d5363 | ||
|
|
8e2707d33e | ||
|
|
3390c2dbf2 | ||
|
|
268db10361 | ||
|
|
ed5120eead | ||
|
|
aab532f475 | ||
|
|
00ee75bb29 | ||
|
|
e7e680fd8e | ||
|
|
7b334601c6 | ||
|
|
050cb8c5f4 | ||
|
|
cb8af637e1 | ||
|
|
c1bbc685e6 | ||
|
|
d5d6f7e860 | ||
|
|
c2738d247a | ||
|
|
f73d0dbc40 | ||
|
|
395e243730 | ||
|
|
4d1bcf1cc0 | ||
|
|
eb2c552316 | ||
|
|
664239c567 | ||
|
|
06df8e7f7b | ||
|
|
21a0849a5b | ||
|
|
1f660c8c5b | ||
|
|
14f5a25633 | ||
|
|
606195c78a | ||
|
|
6a7f92b4e2 | ||
|
|
0e1646e3a7 | ||
|
|
ea5af0397e | ||
|
|
6ed0038b1e | ||
|
|
00640fe39b | ||
|
|
4fb7d60eee | ||
|
|
c54755b9c1 | ||
|
|
07c9b614bc | ||
|
|
7bea8f5120 | ||
|
|
ea97dcdb55 | ||
|
|
931bafe962 | ||
|
|
a3a6509410 | ||
|
|
5e26f2e707 | ||
|
|
54ef85e1a3 | ||
|
|
6f29e475ee | ||
|
|
e6607783e9 | ||
|
|
2021a0b065 | ||
|
|
0871a96399 | ||
|
|
2ed5e8e717 | ||
|
|
0c61cc8bdc | ||
|
|
c2bad4419b | ||
|
|
d0e2358fab | ||
|
|
db95085b26 | ||
|
|
08592cbacf | ||
|
|
487e67d208 | ||
|
|
a8abfdae5e | ||
|
|
6496816692 | ||
|
|
364c18b842 | ||
|
|
e20098d462 | ||
|
|
d25a314d3a | ||
|
|
3dde331f9d | ||
|
|
f7e56d9833 | ||
|
|
b554fb342a | ||
|
|
6d9ef91315 | ||
|
|
ce42da5806 | ||
|
|
5b5413c1a2 | ||
|
|
6cdb27aef0 | ||
|
|
2205ad0772 | ||
|
|
637e826c1b | ||
|
|
b19395b40d | ||
|
|
085a25306c | ||
|
|
88c39dbb72 | ||
|
|
91670d3945 | ||
|
|
bdfd7d9839 | ||
|
|
e01b6f175c | ||
|
|
3f899380d9 | ||
|
|
2513b4ca23 | ||
|
|
93180ccd06 | ||
|
|
f43b4ebdc5 | ||
|
|
ff4832a6a2 | ||
|
|
8267a10f41 | ||
|
|
771ef6e16e | ||
|
|
f7ef2b768f | ||
|
|
74c3ce0552 | ||
|
|
67b63f84f1 | ||
|
|
f8c5c380b1 | ||
|
|
2708449089 | ||
|
|
bcfec56300 | ||
|
|
ec6b9d4387 | ||
|
|
621f739831 | ||
|
|
607d2b8bd7 | ||
|
|
c1463c3257 | ||
|
|
e036b7ac70 | ||
|
|
4a4db675f1 | ||
|
|
e193da2cd7 | ||
|
|
c60cbe824c | ||
|
|
8b9432d1d9 | ||
|
|
75a5ffcb10 | ||
|
|
6cc2fc7a6e | ||
|
|
4bb6f68e6f | ||
|
|
00e1521d46 | ||
|
|
1055186e86 | ||
|
|
fc17448473 | ||
|
|
1839f6ce8c | ||
|
|
39e9e426ef | ||
|
|
7c2d590951 | ||
|
|
551b73ea74 | ||
|
|
fca095689e | ||
|
|
e76078fc89 | ||
|
|
2b6b7b899e | ||
|
|
4e6086e8ed | ||
|
|
97a59cd21e | ||
|
|
9ef0ed8516 | ||
|
|
3c919c3af7 | ||
|
|
fbe3c70b85 | ||
|
|
46bf22e36b | ||
|
|
003c89c3a4 | ||
|
|
793bd04afe | ||
|
|
0249ae2724 | ||
|
|
32e0be481a | ||
|
|
e5592c5da8 | ||
|
|
b0500332bc | ||
|
|
78b8ac663e | ||
|
|
e41ab3ac18 | ||
|
|
36d97bbcaf | ||
|
|
f3c89fe48b | ||
|
|
9b31520684 | ||
|
|
660e68b0a3 | ||
|
|
08b46e1a7c | ||
|
|
b78299bbbd | ||
|
|
c8687bfc74 | ||
|
|
a5219055ef | ||
|
|
f79a9e5182 | ||
|
|
3904b172ad | ||
|
|
e0da506d1a | ||
|
|
d2f6191615 | ||
|
|
7c211fa50c | ||
|
|
fadec1a846 | ||
|
|
d2aa19e31f | ||
|
|
ccfe1181be | ||
|
|
85fb12a4ec | ||
|
|
84994c2b2f | ||
|
|
1a2dfb9b19 | ||
|
|
753652dcf9 | ||
|
|
b99d261084 | ||
|
|
aee4bcd65e | ||
|
|
159ec3f04d | ||
|
|
57ff84cd4d | ||
|
|
2933f80d69 | ||
|
|
3d38892f7e | ||
|
|
1d990979ac | ||
|
|
d69cf09d4e | ||
|
|
b8d346d890 | ||
|
|
5d58d85eae | ||
|
|
bc4d34f2fc | ||
|
|
6565d84cf9 | ||
|
|
95ed33b2ce | ||
|
|
e8f6d4107b | ||
|
|
deb0b211b4 | ||
|
|
83888f80d4 | ||
|
|
974862a60a | ||
|
|
2965f35d6d | ||
|
|
6aa300dac0 | ||
|
|
00020a9cbb | ||
|
|
99c6c46d54 | ||
|
|
d183b1b940 | ||
|
|
49fc2a93fa | ||
|
|
1c3066aaf7 | ||
|
|
cdd9745341 | ||
|
|
d0c051a9c2 | ||
|
|
d444e088c4 | ||
|
|
9ae74e0fba | ||
|
|
447aafd106 | ||
|
|
376b79cab3 | ||
|
|
b95ac44a4c | ||
|
|
4161952566 | ||
|
|
5b18abbea0 | ||
|
|
66cc9bc6db | ||
|
|
4f8337c11a | ||
|
|
3aee334fbd | ||
|
|
6d76a14ed0 | ||
|
|
48150e2002 | ||
|
|
d741d9a11e | ||
|
|
3194baffd7 | ||
|
|
7a49fbb0bb | ||
|
|
1ff1704697 | ||
|
|
aeaad41c45 | ||
|
|
15cdf3bfd6 | ||
|
|
146fa474a1 | ||
|
|
11468abc98 | ||
|
|
ef6d47b801 | ||
|
|
bfdb825e0b | ||
|
|
707a388c51 | ||
|
|
d33334708d | ||
|
|
0e853d44b7 | ||
|
|
c598f202f8 | ||
|
|
e607e04af4 | ||
|
|
802d1dfa8e | ||
|
|
00279502e4 | ||
|
|
cc18794a93 | ||
|
|
905e92fa4d | ||
|
|
7a503ea76c | ||
|
|
eed8a57ff9 | ||
|
|
2968803f29 | ||
|
|
6cf6e8ab54 | ||
|
|
3668249267 | ||
|
|
28b092a4e3 | ||
|
|
c0bba7dead | ||
|
|
7fc8d432b5 | ||
|
|
34027ee7c4 | ||
|
|
dc675162c9 | ||
|
|
db370418f8 | ||
|
|
43de871392 | ||
|
|
5e9c483892 | ||
|
|
17169903b4 | ||
|
|
aa70c82824 | ||
|
|
73a5143a17 | ||
|
|
d35e56fd37 | ||
|
|
cafed2d98c | ||
|
|
cd5df82d72 | ||
|
|
5404371b35 | ||
|
|
899bbfee40 | ||
|
|
b9f2aa5eff | ||
|
|
0a028afe7f | ||
|
|
6f1ee88b78 | ||
|
|
e5cc06e822 | ||
|
|
e13ba010bf | ||
|
|
f6bc473eb4 | ||
|
|
b491090037 | ||
|
|
0416f5f4a8 | ||
|
|
5177bf6c1f | ||
|
|
fcd2fb0f12 | ||
|
|
37115d238b | ||
|
|
2c8bfd6573 | ||
|
|
de3bae41ae | ||
|
|
bd1850db69 | ||
|
|
11b5c54c69 | ||
|
|
6f081eb1e4 | ||
|
|
d367dbf767 | ||
|
|
8237bd52b5 | ||
|
|
71471d3bbc | ||
|
|
34169aebaf | ||
|
|
07e98ab79f | ||
|
|
9af66a8e69 | ||
|
|
5e965aec2c | ||
|
|
ecb38693db | ||
|
|
36d5344ded | ||
|
|
6b3bde585d | ||
|
|
f7ea25be61 | ||
|
|
9136530618 | ||
|
|
f4e7e6c74a | ||
|
|
c4766ad3fb | ||
|
|
894a78c0f9 | ||
|
|
c082290cf1 | ||
|
|
4cac324e9f | ||
|
|
493353e774 | ||
|
|
3289215e19 | ||
|
|
cdb5fed5a5 | ||
|
|
bb1dbab984 | ||
|
|
8a97718dd4 | ||
|
|
01142b67c6 | ||
|
|
e0bba80f55 | ||
|
|
34276539fa | ||
|
|
4511dd79fa | ||
|
|
7500685115 | ||
|
|
658e7d64c2 | ||
|
|
569079fed0 | ||
|
|
b042d78186 | ||
|
|
abd051d07b | ||
|
|
8c5b22a8fb | ||
|
|
de93b11c25 | ||
|
|
7f16339bd9 | ||
|
|
42dc6e7c4f | ||
|
|
3153973c2b | ||
|
|
cc044fe41b | ||
|
|
fd5de7b218 | ||
|
|
0037524cfd | ||
|
|
082fa2ca0d | ||
|
|
b1cf9d139a | ||
|
|
9854360ab7 | ||
|
|
b8755b808e | ||
|
|
139812b3bc | ||
|
|
6adbe9a29b | ||
|
|
52f7120392 | ||
|
|
0d2abb95b5 | ||
|
|
6b2adc9359 | ||
|
|
325f89a80d | ||
|
|
e8152a3475 | ||
|
|
6d42d14575 | ||
|
|
2b269ebf54 | ||
|
|
d2493e89ca | ||
|
|
a61423aa99 | ||
|
|
506efec858 | ||
|
|
8e3320ad72 | ||
|
|
ff279bf633 | ||
|
|
a582b07549 | ||
|
|
1e7fef4557 | ||
|
|
f8b44cd8ce | ||
|
|
01f38537de | ||
|
|
adbb20d7c9 | ||
|
|
c3c7fe08b6 | ||
|
|
4a52135a0b | ||
|
|
a56f805787 | ||
|
|
3a467b3da4 | ||
|
|
4500c4d407 | ||
|
|
eebda74bb7 | ||
|
|
e6e8c12735 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -24,7 +24,7 @@
|
||||
/world
|
||||
|
||||
# Mac filesystem dust
|
||||
/.DS_Store
|
||||
*.DS_Store
|
||||
|
||||
# intellij
|
||||
*.iml
|
||||
@@ -39,4 +39,4 @@
|
||||
*.jar
|
||||
|
||||
# Atlassian Stuff
|
||||
/atlassian-ide-plugin.xml
|
||||
/atlassian-ide-plugin.xml
|
||||
|
||||
186
Changelog.txt
186
Changelog.txt
@@ -7,6 +7,168 @@ Key:
|
||||
! Change
|
||||
- Removal
|
||||
|
||||
Version 1.4.00-dev
|
||||
+ Added new Child Skill - Smelting!
|
||||
+ Added new cancellable McMMOPlayerDisarmEvent for Citizens compatibility - fires whenever a player is disarmed.
|
||||
+ Added config options for Hylian Luck skill
|
||||
+ Added display values to Unarmed command for Iron Grip
|
||||
+ Added '/party create <name>' command, use this to create a party
|
||||
+ Added '/party disband' command, kicks out all members and deletes the party
|
||||
+ Added '/ptp toggle' command, to disable party teleportation.
|
||||
+ Added '/ptp accept' and '/ptp acceptall' commands
|
||||
+ Added timeout on party teleport requests
|
||||
+ Added XP bonus for Archery based on distance from shooter to target
|
||||
+ Added ability to config Hylian Luck drops through treasures.yml
|
||||
+ Added party XP sharing
|
||||
+ Added vanilla XP boost for Fishing - includes permissions, config options, etc
|
||||
= Fixed /addlevels not working properly on offline players
|
||||
= Fixed /mmoedit not giving feedback when modifying another players stats
|
||||
= Fixed the guide usage string showing up every time /skillname was called
|
||||
= Fixed Spout not being able to precache our resources properly, and therefore making our XP bars fail
|
||||
= Fixed Spout config files loading / generating when they shouldn't have
|
||||
= Fixed mod config files loading / generating when they shouldn't have
|
||||
= Fixed bug where Green Terra could activate on crops that weren't fully grown.
|
||||
= Fixed several typos relating to locale string display
|
||||
= Fixed bug where all skill guide headers appeared as "Skillname Guide Guide"
|
||||
= Fixed bug where Impact was applied incorrectly due to an inverted method call
|
||||
= Fixed bug where Impact improperly determined the defender's armor
|
||||
= Fixed ArrayIndexOutOfBoundsException resulting from being unranked in a skill when using FlatFile
|
||||
= Fixed Woodcutting accidentally using Mining double drop values.
|
||||
= Fixed Hylian Luck not removing the block-placed flag from flowers.
|
||||
= Fixed Hylian Luck not checking the block-placed flag on flowers.
|
||||
= Fixed Leaf Blower not respecting the unlock level set in advanced.yml
|
||||
= Fixed abilities activating with the wrong tool in hand
|
||||
= Fixed Experience.Gains.Mobspawners.Enabled not being used correctly (the check was inverted)
|
||||
= Fixed bug where Iron Grip was using the attacker's skill values rather than the defender's.
|
||||
= Fixed a bug where /party kick would trigger the PartyChangeEvent for the wrong player
|
||||
= Fixed a bug where party join messages weren't displayed
|
||||
= Fixed a bug where Disarm and Deflect had wrong values
|
||||
= Fixed Magic Hunter (Fishing ability) favoring certain enchants
|
||||
! We're now using Bukkit sounds instead of Spout sounds.
|
||||
! It is now possible to use a negative number for Max_Level in treasures.yml to not use a maximum level, changed default file accordingly
|
||||
! A Fishing catch will now always contains a fish even if a treasure is found
|
||||
! Changed how Berserk handles not picking up items to avoid listening to PlayerPickupItemEvent
|
||||
! Moved Hylian Luck into a separate listener since it actually cancels the event and shouldn't just be on MONITOR.
|
||||
! Changed how Tree Feller is handled, it should now put less stress on the CPU
|
||||
! Changed Fisherman's Diet and Farmer's Diet to use two seperate config values
|
||||
! Major refactoring - please take note, this WILL break any mcMMO-related plugin not properly hooking into the API.
|
||||
! Changed the way party commands work, use /party ? to check how to use the new commands
|
||||
! Changed McMMOChatEvent to contain the plugin that the event originated from.
|
||||
! Changed Excavation to have individual XP values for each block type, rather than a base XP value.
|
||||
! Changed the way party teleportation works. When using /ptp, the target player needs to confirm the teleport before it takes place. (Configurable)
|
||||
! Changed BeastLore: Now also displays offline player names
|
||||
- Removed Party "master/apprentice" system. Replaced with the new party XP share feature.
|
||||
- Removed unused "healthbar" files from the resources
|
||||
- Removed config options for disabling commands from the config.yml. This should instead be done through permissions.
|
||||
|
||||
Version 1.3.14
|
||||
+ Added new Hylian Luck skill to Herbalism.
|
||||
= Fixed a memory leak involving mob tracking
|
||||
- Removed extra durability loss from Leaf Blower
|
||||
|
||||
Version 1.3.13
|
||||
+ Added task & command to prune old and powerless users from the SQL database.
|
||||
+ Added Craftbukkit 1.4.6 / 1.4.7 compatibility
|
||||
+ Added new /mcrank command for showing a players leader board ranking for all skills in one place
|
||||
+ Added a configurable durability cap for ArmorImpact to advanced.yml
|
||||
+ Added the version number to /mcmmo
|
||||
+ Added bats, giants, witches, withers, and wither skeletons to the mcMMO combat experience list, and makes their experience drops configurable
|
||||
+ Added the ability to track mobs spawned by mob spawners or the Taming ability when the chunks they are in unload and reload
|
||||
+ Added wooden button to the list of items that shouldn't trigger abilities
|
||||
+ Added a new feature to fishing. Players will have +10% chance of finding enchanted items when fishing while it's raining
|
||||
+ Added displaying bonus perks on skill commands
|
||||
+ Added config option to disable gaining Acrobatics XP from dodging lightning
|
||||
+ Added missing skill guides. They're finally here!
|
||||
+ Added more localization
|
||||
+ Added a very secret easter egg
|
||||
= Fix issue with Sand/Gravel tracking
|
||||
= Fix possible NPE when using the PartyAPI to add a player to a party that doesn't exist.
|
||||
= Fix mcremove command for mySQL
|
||||
= Fix a java.io.FileNotFoundException when using SQL
|
||||
= Impact now works with mobs wearing armor
|
||||
= Fixed issue with Tree Feller dropping player-placed blocks
|
||||
= Fixed issue with missing default cases from several switch/case statements
|
||||
= Fixed issue with Mining using actual skill level rather than max skill level
|
||||
= Fixed some issues with static access
|
||||
= Fixed ItemStack deprecation issues
|
||||
= Fixed Async deprecation issues
|
||||
= Fixed a bug with MySQL databases (non-alphanumeric characters preventing MySQL access)
|
||||
= Fixed a bug where the /skillreset command was broken
|
||||
= Fixed a bug where skill commands displaying .x% instead of 0.x%
|
||||
= Fixed a bug Unbreaking enchantments being ignored when using Treefelling and when hit by Armor Impact
|
||||
= Fixed a bug where only 1 diamond was needed to fully repair a broken item: Repaired the Repair skill!
|
||||
= Fixed a bug where a infinite loop of errors caused by mySQL database could cause the server to crash
|
||||
= Fixed a bug where PartyChangeEvent was fired even when a player isn't able to change parties
|
||||
= Fixed a bug which caused advanced.yml not to work for Swords
|
||||
= Fixed a bug which caused advanced.yml not to respect every MaxChance node
|
||||
= Fixed a bug where GreenThumb_StageChange wasn't read from advanced.yml
|
||||
= Fixed a bug where Repair would remove enchantments but the glow effect remained
|
||||
= Fixed a bug where dropped items did not retain custom NBT data
|
||||
= Fixed a bug which caused a potentially infinite recursion in a btree structure
|
||||
= Fixed a NPE with custom blocks
|
||||
= Fixed a bug with Blast Mining never dropping debris blocks
|
||||
= Fixed a bug with Blast Mining incorrectly handling reduced TNT damage
|
||||
= Fixed a bug with conflicting fishing enchantments
|
||||
= Fixed a bug where triple drops wouldn't happen
|
||||
= Fixed a bug which caused fishing to ignore max/min levels in treasures.yml
|
||||
= Fixed a bug where treefeller affected player-placed blocks
|
||||
= Fixed bug where Skull Splitter would be applied twice.
|
||||
! GJ stopped being a lazy slacker and got stuff done
|
||||
! Nossr50 actually committed something
|
||||
! Changed code that uses SpoutPlugin to make it compatible with the latest version
|
||||
! Reimplemented skill level and power level caps.
|
||||
! Moved Arcane Forging and Fishing setting from config.yml to advanced.yml
|
||||
! Overall SQL query improvements
|
||||
! Reduced number of SQL queries for mcTop command from 11 to 1, speeding it up immensely
|
||||
! Changed FFS Leaderboards to hold information in memory rather than doing IO work (optimizations)
|
||||
! Improved chunk conversion (less errors)
|
||||
! Changed Fishing Treasure Hunter, chance has increased and now actually is level dependent
|
||||
! Indexed most used mySQL columns for faster queries
|
||||
- Removed dead code relating to null profiles
|
||||
- Removed unused imports
|
||||
- Removed ChunkletUnloader and dependents, since they are no longer necessary.
|
||||
|
||||
Version 1.3.12
|
||||
+ Added Craftbukkit 1.4.5 compatibility
|
||||
+ Added the new 1.3.2 items, xp and double drops for Cocoa beans & Emeralds, EnderChest to the list of blocks that shouldn't trigger abilities
|
||||
+ Added new items from Minecraft 1.4 to Herbalism (potatoes & carrots)
|
||||
+ Added new configuration file for advanced users.
|
||||
+ Added new permission nodes to greenthumb for the 1.4 items
|
||||
+ Added new mobs from Minecraft 1.4 checks for every ability
|
||||
+ Added new active ability for Repair: Salvage
|
||||
+ Added options to 'config.yml' configure shake chance
|
||||
+ Added the option to negate experience earned for Herbalism while in a minecart to prevent afk leveling
|
||||
+ Added Green thumb now converts cobble walls to mossy cobble walls
|
||||
+ Added beacons and anvils to list of blocks that don't trigger abilities
|
||||
+ Added a configuration option to disable experience gains when in a minecraft for Acrobatics and Herbalism, to prevent AFK leveling
|
||||
+ Added a new passive ability for Fishing, Fishermans diet. Increases hunger restored from fish
|
||||
+ Added a feature to display all active perks on login
|
||||
! Changed Fishing, Shake drops changed from guaranteed to based upon fishing level and perks
|
||||
! Changed Woodcutting, the amount of experience earned when using Tree Feller on jungle trees has increased
|
||||
! Changed Herbalism double drop rates for melons and netherwart
|
||||
! Changed filesystem usage, it's reduced a lot. Should help reduce lag on larger servers
|
||||
! Changed database connection handling. Support for aggressive connection timeouts, with exponential backoff for multiple failures
|
||||
! Changed Cobblestone walls are now mossy-able with Greenthumb
|
||||
! Changed the skull drop rates of the shake ability to 3%
|
||||
= Fixed a NPE when Citizens perform certain tasks
|
||||
= Fixed a NPE with Woodcutting, excessive null chunk before earning Woodcutting experience
|
||||
= Fixed a NPE related to skill cooldowns
|
||||
= Fixed a NPE when a players profile was null
|
||||
= Fixed a NPE involving certain explosions
|
||||
= Fixed a dupe bug when for players who were using a 'nuker' client
|
||||
= Fixed a dupe bug where pistons were used to dupe ores
|
||||
= Fixed a dupe bug with Salvage when players were in Creative mode
|
||||
= Fixed a bug where the player was displayed an incorrect cooldown time
|
||||
= Fixed a bug where players could earn experience when they were dealing 0 damage
|
||||
= Fixed a bug where players could get double drops from mossified Cobblestone
|
||||
= Fixed a bug where Herablism magically converted potatoes to carrots
|
||||
= Fixed a bug where you couldn't modify the stats of offline players
|
||||
= Fixed a bug where treefeller didn't work properly on tree's with side-way logs
|
||||
= Fixed a bug where the Arcane forging downgrade chance should've been 0, but actually wasn't
|
||||
= Fixed a bug where Fishing would sometimes give items with empty enchantments
|
||||
= Fixed a bug where the lucky perk for Fishing was actually an unlucky perk
|
||||
- Removed nothing
|
||||
|
||||
Version 1.3.11
|
||||
! Changed axes to start with 1 durability damage instead of 5, gain 1 durability damage every 50 levels instead of 30, and only have a 25% chance on hit to damage armor (per armor piece)
|
||||
+ Added compatibility with bow-wielding NPCs from Citizens/NPC mods
|
||||
@@ -14,9 +176,9 @@ Version 1.3.11
|
||||
= Fixed bug where mcMMO could throw NPE errors if trees cut down were from a custom mod and had an id of 17
|
||||
= Fixed dupe bug where mcMMO would ignore other block-protection plugins for various abilities
|
||||
= Fixed NPE with hardcore mode's vampirism
|
||||
|
||||
|
||||
Version 1.3.10
|
||||
+ Added 1.3.1 compatibility
|
||||
+ Added 1.3.1 compatibility
|
||||
+ Added permission node for Iron Grip ability (mcmmo.ability.unarmed.irongrip)
|
||||
+ Added ability for custom blocks to drop a range of items.
|
||||
+ Added Ability API functions
|
||||
@@ -29,7 +191,7 @@ Version 1.3.10
|
||||
= Fixed menu exit button not working
|
||||
= Fixed Repair enchant downgrade not working
|
||||
= Fixed NPE caused by Spout players after a /reload
|
||||
= Fixed ConcurrentModificationException on world unload
|
||||
= Fixed ConcurrentModificationException on world unload
|
||||
= Fixed players never being removed from memory (memory leak)
|
||||
= Fixed admin chat being seen by everyone
|
||||
= Fixed issue with UTFDataFormatException occurring on occasion when trying to load Chunklets
|
||||
@@ -40,7 +202,7 @@ Version 1.3.10
|
||||
= Fixed custom woodcutting blocks throwing errors.
|
||||
= Fixed possible ClassCastException from catching something other than a mob when using the Shake Mob skill
|
||||
! Changed the format by which Chunklets are stored to be much smaller, and much faster to load
|
||||
! Optimized how player placed blocks are tracked
|
||||
! Optimized how player placed blocks are tracked
|
||||
|
||||
Version 1.3.09
|
||||
+ Added compatibility with AntiCheat (Which I highly recommend to prevent cheating)
|
||||
@@ -156,7 +318,7 @@ Version 1.3.06
|
||||
= Fixed NPE error with Metrics on startup
|
||||
= Fixed bug where Herbalism required double drops permission to give XP
|
||||
= Fixed bug where {0} would be displayed in front of your power level in mcstats
|
||||
= Fixed mmoupdate not being useable from console
|
||||
= Fixed mmoupdate not being useable from console
|
||||
= Fixed bug with repairing wooden tools
|
||||
= Fixed bug with Nether Wart not awarding XP
|
||||
= Fixed bug with fishing treasures when treasures list is empty
|
||||
@@ -169,19 +331,19 @@ Version 1.3.06
|
||||
! Changed how we handled the config file to prevent any bugs when returning values
|
||||
! Changed locale files to use a new naming scheme. This breaks ALL old locale files. If you want to assist with re-translating anything, go to getlocalization.com/mcMMO
|
||||
! Changed /mcremove to check for users in the MySQL DB before sending queries to remove them
|
||||
! Changed how the tree feller threshold worked for the better
|
||||
! Changed how the tree feller threshold worked for the better
|
||||
! Changed /mcremove to no longer kick players when they are removed from database
|
||||
! Changed /mcremove to work on offline users for FlatFile
|
||||
! Changed /mcremove to work on offline users for FlatFile
|
||||
! Changed PlayerProfile constructor to always take a boolean
|
||||
! Changed getPlayerProfile function to work for online & offline users
|
||||
! Changed Archery's Daze to deal 4 DMG on proc (2 Hearts)
|
||||
! Changed /addlevel command to work for offline users
|
||||
! Changed party & admin chat handling to be nicer to developers
|
||||
! Changed party & admin chat handling to be nicer to developers
|
||||
! Changed /mcrefresh to work from console
|
||||
! Changed /mcrefresh to work for offline players
|
||||
! Changed /mcrefresh to work for offline players
|
||||
! Changed UpdateXPBar function to hopefully avoid errors
|
||||
! Changed /party to show offline party members
|
||||
! Changed Blast Mining requirements, now asks for the player to be crouching
|
||||
! Changed Blast Mining requirements, now asks for the player to be crouching
|
||||
|
||||
Version 1.3.05
|
||||
+ Added Skill Shot to Archery which increases damage dealt by 10% every 50 skill levels (caps at 200%)
|
||||
@@ -230,7 +392,7 @@ Version 1.3.03
|
||||
+ 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 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
|
||||
@@ -246,7 +408,7 @@ Version 1.3.03
|
||||
! 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 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)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
== mcMMO
|
||||
**The RPG lovers mod**
|
||||
|
||||
=== Forums
|
||||
http://forums.mcmmo.info Talk with developers and the community about mcMMO here
|
||||
=== Dev builds
|
||||
http://ci.mcmmo.info Download the latest dev build of mcMMO here.
|
||||
|
||||
=== 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.
|
||||
@@ -20,8 +20,9 @@ Hearing that people enjoy mcMMO and seeing the daily youtube videos about my mod
|
||||
|
||||
Required Libraries:
|
||||
* Spout API
|
||||
* JUnit
|
||||
|
||||
Required to Run:
|
||||
* Bukkit
|
||||
|
||||
http://dev.bukkit.org/server-mods/mcmmo for more up to date information.
|
||||
http://dev.bukkit.org/server-mods/mcmmo for more up to date information.
|
||||
|
||||
54
pom.xml
54
pom.xml
@@ -2,12 +2,12 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>1.3.12</version>
|
||||
<version>1.4.00-beta1</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<issueManagement>
|
||||
<url>http://issues.mcmmo.org</url>
|
||||
<system>JIRA</system>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO/issues</url>
|
||||
<system>GitHub</system>
|
||||
</issueManagement>
|
||||
<build>
|
||||
<finalName>mcMMO</finalName>
|
||||
@@ -54,12 +54,12 @@
|
||||
</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>
|
||||
<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>
|
||||
@@ -92,6 +92,13 @@
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-file</artifactId>
|
||||
<version>2.2</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
@@ -109,8 +116,8 @@
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>fail</checksumPolicy>
|
||||
</snapshots>
|
||||
<id>spout-repo</id>
|
||||
<url>http://nexus.spout.org/content/groups/public/</url>
|
||||
<id>spout-repo</id>
|
||||
<url>http://nexus.spout.org/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
@@ -122,26 +129,25 @@
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<groupId>org.getspout</groupId>
|
||||
<artifactId>spoutplugin</artifactId>
|
||||
<version>LATEST</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.getspout</groupId>
|
||||
<artifactId>spoutpluginapi</artifactId>
|
||||
<version>dev-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit-dep</artifactId>
|
||||
<version>4.10</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit-dep</artifactId>
|
||||
<version>4.10</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>mcmmo-repo</id>
|
||||
<url>file:///var/lib/jenkins/repo</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
@@ -2,10 +2,11 @@ package com.gmail.nossr50.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.skills.utilities.AbilityType;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class AbilityAPI {
|
||||
public final class AbilityAPI {
|
||||
private AbilityAPI() {}
|
||||
|
||||
public static boolean berserkEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.BERSERK);
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.chat.ChatManager;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
|
||||
public final class ChatAPI {
|
||||
|
||||
private ChatAPI() {}
|
||||
|
||||
/**
|
||||
@@ -18,29 +13,44 @@ public final class ChatAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender
|
||||
* @param displayName The display name of the sender
|
||||
* @param party The name of the party to send to
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendPartyChat(Plugin plugin, String sender, String displayName, String party, String message) {
|
||||
ChatManager.handlePartyChat(plugin, PartyManager.getParty(party), sender, displayName, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to all members of a party
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param party The name of the party to send to
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendPartyChat(Plugin plugin, String sender, String party, String message) {
|
||||
ChatManager.handlePartyChat(plugin, PartyManager.getParty(party), sender, sender, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to all members of a party
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @deprecated Replaced by sendPartyChat(Plugin, String, String, String)
|
||||
*
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param party The name of the party to send to
|
||||
* @param message The message to send
|
||||
*/
|
||||
@Deprecated
|
||||
public static void sendPartyChat(String sender, String party, String message) {
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(sender, party, message);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE + chatEvent.getSender() + ChatColor.GREEN + ") ";
|
||||
|
||||
mcMMO.p.getLogger().info("[P](" + chatEvent.getParty() + ")" + "<" + chatEvent.getSender() + "> " + chatEvent.getMessage());
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
if (Users.getProfile(player).inParty()) {
|
||||
if (Users.getProfile(player).getParty().getName().equalsIgnoreCase(chatEvent.getParty())) {
|
||||
player.sendMessage(pPrefix + chatEvent.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
sendPartyChat(null, party, sender, sender, message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,24 +58,40 @@ public final class ChatAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender
|
||||
* @param displayName The display name of the sender
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendAdminChat(Plugin plugin, String sender, String displayName, String message) {
|
||||
ChatManager.handleAdminChat(plugin, sender, displayName, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to administrators
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param plugin The plugin sending the message
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendAdminChat(Plugin plugin, String sender, String message) {
|
||||
ChatManager.handleAdminChat(plugin, sender, sender, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to administrators
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @deprecated Replaced by sendAdminChat(Plugin, String, String)
|
||||
*
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param message The message to send
|
||||
*/
|
||||
@Deprecated
|
||||
public static void sendAdminChat(String sender, String message) {
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(sender, message);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + chatEvent.getSender() + ChatColor.AQUA + "} ";
|
||||
|
||||
mcMMO.p.getLogger().info("[A]<" + chatEvent.getSender() + "> " + chatEvent.getMessage());
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
if (Permissions.getInstance().adminChat(player) || player.isOp())
|
||||
player.sendMessage(aPrefix + chatEvent.getMessage());
|
||||
}
|
||||
sendAdminChat(null, sender, sender, message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,11 @@ package com.gmail.nossr50.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public final class ExperienceAPI {
|
||||
|
||||
private ExperienceAPI() {}
|
||||
|
||||
/**
|
||||
@@ -18,10 +17,10 @@ public final class ExperienceAPI {
|
||||
*/
|
||||
private static void checkXP(Player player, SkillType skillType) {
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
Skills.xpCheckAll(player, Users.getProfile(player));
|
||||
SkillTools.xpCheckAll(player, Users.getProfile(player));
|
||||
}
|
||||
else {
|
||||
Skills.xpCheckSkill(skillType, player, Users.getProfile(player));
|
||||
SkillTools.xpCheckSkill(skillType, player, Users.getProfile(player));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +34,7 @@ public final class ExperienceAPI {
|
||||
* @param XP The amount of XP to add
|
||||
*/
|
||||
public static void addRawXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getPlayer(player).addXPOverride(skillType, XP);
|
||||
Users.getPlayer(player).addXpOverride(skillType, XP);
|
||||
checkXP(player, skillType);
|
||||
}
|
||||
|
||||
@@ -49,7 +48,7 @@ public final class ExperienceAPI {
|
||||
* @param XP The amount of XP to add
|
||||
*/
|
||||
public static void addMultipliedXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getPlayer(player).addXPOverrideBonus(skillType, XP);
|
||||
Users.getPlayer(player).addXpOverrideBonus(skillType, XP);
|
||||
checkXP(player, skillType);
|
||||
}
|
||||
|
||||
@@ -63,7 +62,7 @@ public final class ExperienceAPI {
|
||||
* @param XP The amount of XP to add
|
||||
*/
|
||||
public static void addXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getPlayer(player).addXP(skillType, XP);
|
||||
Users.getPlayer(player).addXp(skillType, XP);
|
||||
checkXP(player, skillType);
|
||||
}
|
||||
|
||||
@@ -159,7 +158,7 @@ public final class ExperienceAPI {
|
||||
* @param newValue The value to set the XP to
|
||||
*/
|
||||
public static void setXP(Player player, SkillType skillType, int newValue) {
|
||||
Users.getProfile(player).setSkillXPLevel(skillType, newValue);
|
||||
Users.getProfile(player).setSkillXpLevel(skillType, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,6 +171,6 @@ public final class ExperienceAPI {
|
||||
* @param xp The amount of XP to remove
|
||||
*/
|
||||
public static void removeXP(Player player, SkillType skillType, int xp) {
|
||||
Users.getProfile(player).removeXP(skillType, xp);
|
||||
Users.getProfile(player).removeXp(skillType, xp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public final class PartyAPI {
|
||||
|
||||
private PartyAPI() {}
|
||||
|
||||
/**
|
||||
@@ -46,7 +45,7 @@ public final class PartyAPI {
|
||||
* @return true if the two players are in the same party, false otherwise
|
||||
*/
|
||||
public static boolean inSameParty(Player playera, Player playerb) {
|
||||
return PartyManager.getInstance().inSameParty(playera, playerb);
|
||||
return PartyManager.inSameParty(playera, playerb);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,7 +56,7 @@ public final class PartyAPI {
|
||||
* @return the list of parties.
|
||||
*/
|
||||
public static List<Party> getParties() {
|
||||
return PartyManager.getInstance().getParties();
|
||||
return PartyManager.getParties();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,7 +68,16 @@ public final class PartyAPI {
|
||||
* @param partyName The party to add the player to
|
||||
*/
|
||||
public static void addToParty(Player player, String partyName) {
|
||||
PartyManager.getInstance().addToParty(player.getName(), Users.getProfile(player), PartyManager.getInstance().getParty(partyName)); //TODO this will throw a NPE if the party doesn't exist
|
||||
Party party = PartyManager.getParty(partyName);
|
||||
String playerName = player.getName();
|
||||
|
||||
if (party == null) {
|
||||
party = new Party();
|
||||
party.setName(partyName);
|
||||
party.setLeader(playerName);
|
||||
}
|
||||
|
||||
PartyManager.addToParty(playerName, Users.getProfile(player), party);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +88,7 @@ public final class PartyAPI {
|
||||
* @param player The player to remove
|
||||
*/
|
||||
public static void removeFromParty(Player player) {
|
||||
PartyManager.getInstance().removeFromParty(player.getName(), Users.getProfile(player).getParty());
|
||||
PartyManager.removeFromParty(player.getName(), Users.getProfile(player).getParty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +100,7 @@ public final class PartyAPI {
|
||||
* @return the leader of the party
|
||||
*/
|
||||
public static String getPartyLeader(String partyName) {
|
||||
return PartyManager.getInstance().getPartyLeader(partyName);
|
||||
return PartyManager.getPartyLeader(partyName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,7 +112,7 @@ public final class PartyAPI {
|
||||
* @param player The player to set as leader
|
||||
*/
|
||||
public static void setPartyLeader(String partyName, String player) {
|
||||
PartyManager.getInstance().setPartyLeader(player, PartyManager.getInstance().getParty(partyName));
|
||||
PartyManager.setPartyLeader(player, PartyManager.getParty(partyName));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,7 +124,7 @@ public final class PartyAPI {
|
||||
* @return all the players in the player's party
|
||||
*/
|
||||
public static List<String> getAllMembers(Player player) {
|
||||
return PartyManager.getInstance().getAllMembers(player);
|
||||
return PartyManager.getAllMembers(player);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,7 +136,7 @@ public final class PartyAPI {
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(String partyName) {
|
||||
return PartyManager.getInstance().getOnlineMembers(partyName);
|
||||
return PartyManager.getOnlineMembers(partyName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,6 +148,6 @@ public final class PartyAPI {
|
||||
* @return all online players in the player's party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(Player player) {
|
||||
return PartyManager.getInstance().getOnlineMembers(player);
|
||||
return PartyManager.getOnlineMembers(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,18 +5,17 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.ToolType;
|
||||
import com.gmail.nossr50.skills.utilities.ToolType;
|
||||
|
||||
public final class SpoutToolsAPI {
|
||||
|
||||
private SpoutToolsAPI() {}
|
||||
|
||||
public static final List<ItemStack> spoutSwords = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutAxes = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutPickaxes = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutHoes = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutShovels = new ArrayList<ItemStack>();
|
||||
|
||||
private SpoutToolsAPI() {}
|
||||
|
||||
/**
|
||||
* Add a custom Spout tool to mcMMO for XP gain & ability use.
|
||||
* </br>
|
||||
|
||||
67
src/main/java/com/gmail/nossr50/chat/ChatManager.java
Normal file
67
src/main/java/com/gmail/nossr50/chat/ChatManager.java
Normal file
@@ -0,0 +1,67 @@
|
||||
package com.gmail.nossr50.chat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public final class ChatManager {
|
||||
public ChatManager () {}
|
||||
|
||||
public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message) {
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(Config.getInstance().getAdminDisplayNames())
|
||||
displayName = chatEvent.getDisplayName();
|
||||
else
|
||||
displayName = chatEvent.getSender();
|
||||
|
||||
String adminMessage = chatEvent.getMessage();
|
||||
|
||||
for (Player otherPlayer : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
if (Permissions.adminChat(otherPlayer) || otherPlayer.isOp()) {
|
||||
otherPlayer.sendMessage(LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {displayName}) + adminMessage);
|
||||
}
|
||||
}
|
||||
|
||||
displayName = ChatColor.stripColor(displayName);
|
||||
mcMMO.p.getLogger().info("[A]<" + displayName + "> " + adminMessage);
|
||||
}
|
||||
|
||||
public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message) {
|
||||
String partyName = party.getName();
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(plugin, playerName, displayName, partyName, message);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(Config.getInstance().getPartyDisplayNames())
|
||||
displayName = chatEvent.getDisplayName();
|
||||
else
|
||||
displayName = chatEvent.getSender();
|
||||
|
||||
String partyMessage = chatEvent.getMessage();
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
member.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Prefix", new Object[] {displayName}) + partyMessage);
|
||||
}
|
||||
|
||||
displayName = ChatColor.stripColor(displayName);
|
||||
mcMMO.p.getLogger().info("[P](" + partyName + ")" + "<" + displayName + "> " + partyMessage);
|
||||
}
|
||||
}
|
||||
73
src/main/java/com/gmail/nossr50/chat/commands/ACommand.java
Normal file
73
src/main/java/com/gmail/nossr50/chat/commands/ACommand.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package com.gmail.nossr50.chat.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.chat.ChatManager;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class ACommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"a", "<" + LocaleLoader.getString("Commands.Usage.Message") + ">"});
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.chat.adminchat")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (sender instanceof Player) {
|
||||
profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (profile.getPartyChatMode()) {
|
||||
profile.togglePartyChat();
|
||||
}
|
||||
|
||||
profile.toggleAdminChat();
|
||||
|
||||
if (profile.getAdminChatMode()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.AdminChat.On"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.AdminChat.Off"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(args[0]);
|
||||
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
builder.append(" ");
|
||||
builder.append(args[i]);
|
||||
}
|
||||
|
||||
String message = builder.toString();
|
||||
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
ChatManager.handleAdminChat(mcMMO.p, player.getName(), player.getDisplayName(), message);
|
||||
}
|
||||
else {
|
||||
String ssender = LocaleLoader.getString("Commands.Chat.Console");
|
||||
ChatManager.handleAdminChat(mcMMO.p, ssender, ssender, message);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
package com.gmail.nossr50.chat.commands;
|
||||
|
||||
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.mcMMO;
|
||||
import com.gmail.nossr50.chat.ChatManager;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
@@ -25,7 +24,7 @@ public class PCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
String usage = ChatColor.RED + "Proper usage is /p <party-name> <message>"; //TODO: Needs more locale.
|
||||
String usage = LocaleLoader.getString("Commands.Usage.2", new Object[] {"p", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">", "<" + LocaleLoader.getString("Commands.Usage.Message") + ">"});
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) {
|
||||
return true;
|
||||
@@ -65,31 +64,16 @@ public class PCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(args[0]);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(args[0]);
|
||||
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
buffer.append(" ");
|
||||
buffer.append(args[i]);
|
||||
builder.append(" ");
|
||||
builder.append(args[i]);
|
||||
}
|
||||
|
||||
String message = buffer.toString();
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), party.getName(), message);
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
message = chatEvent.getMessage();
|
||||
String prefix = ChatColor.GREEN + "(" + ChatColor.WHITE + player.getName() + ChatColor.GREEN + ") ";
|
||||
|
||||
plugin.getLogger().info("[P](" + party.getName() + ")" + "<" + player.getName() + "> " + message);
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
member.sendMessage(prefix + message);
|
||||
}
|
||||
String message = builder.toString();
|
||||
ChatManager.handlePartyChat(plugin, party, player.getName(), player.getDisplayName(), message);
|
||||
}
|
||||
else {
|
||||
if (args.length < 2) {
|
||||
@@ -97,36 +81,25 @@ public class PCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!PartyManager.getInstance().isParty(args[0])) {
|
||||
Party party = PartyManager.getParty(args[0]);
|
||||
|
||||
if (party == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
|
||||
return true;
|
||||
}
|
||||
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(args[1]);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(args[1]);
|
||||
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
buffer.append(" ");
|
||||
buffer.append(args[i]);
|
||||
builder.append(" ");
|
||||
builder.append(args[i]);
|
||||
}
|
||||
|
||||
String message = buffer.toString();
|
||||
String ssender = LocaleLoader.getString("Commands.Chat.Console");
|
||||
String message = builder.toString();
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent("Console", args[0], message);
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
message = chatEvent.getMessage();
|
||||
String prefix = ChatColor.GREEN + "(" + ChatColor.WHITE + "*Console*" + ChatColor.GREEN + ") ";
|
||||
|
||||
plugin.getLogger().info("[P](" + args[0] + ")" + "<*Console*> " + message);
|
||||
|
||||
for (Player member : PartyManager.getInstance().getOnlineMembers(args[0])) {
|
||||
member.sendMessage(prefix + message);
|
||||
}
|
||||
ChatManager.handlePartyChat(plugin, party, ssender, ssender, message);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -4,13 +4,13 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class CommandHelper {
|
||||
public final class CommandHelper {
|
||||
private CommandHelper() {}
|
||||
|
||||
/**
|
||||
* Checks for command permissions.
|
||||
@@ -23,7 +23,7 @@ public class CommandHelper {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (!Permissions.getInstance().permission(player, permission)) {
|
||||
if (!Permissions.hasPermission(player, permission)) {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
@@ -32,6 +32,15 @@ public class CommandHelper {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean noCommandPermissions(Player player, String permission) {
|
||||
if (!Permissions.hasPermission(player, permission)) {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean noConsoleUsage(CommandSender sender) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.NoConsole"));
|
||||
@@ -45,116 +54,98 @@ public class CommandHelper {
|
||||
* Print out details on Gathering skills. Only for online players.
|
||||
*
|
||||
* @param inspect The player to retrieve stats for
|
||||
* @param profile The player's profile
|
||||
* @param display The sender to display stats to
|
||||
*/
|
||||
public static void printGatheringSkills(Player inspect, CommandSender display) {
|
||||
if (Skills.hasGatheringSkills(inspect)) {
|
||||
PlayerProfile profile = Users.getProfile(inspect);
|
||||
|
||||
if (profile == null) {
|
||||
display.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return;
|
||||
}
|
||||
|
||||
public static void printGatheringSkills(Player inspect, PlayerProfile profile, CommandSender display) {
|
||||
if (SkillTools.hasGatheringSkills(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
||||
|
||||
if (Permissions.getInstance().excavation(inspect)) {
|
||||
if (Permissions.excavation(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().fishing(inspect)) {
|
||||
if (Permissions.fishing(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().herbalism(inspect)) {
|
||||
if (Permissions.herbalism(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().mining(inspect)) {
|
||||
if (Permissions.mining(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().woodcutting(inspect)) {
|
||||
if (Permissions.woodcutting(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Woodcutting.Listener"), profile.getSkillLevel(SkillType.WOODCUTTING), profile.getSkillXpLevel(SkillType.WOODCUTTING), profile.getXpToLevel(SkillType.WOODCUTTING) }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void printGatheringSkills(Player player) {
|
||||
printGatheringSkills(player, player);
|
||||
public static void printGatheringSkills(Player player, PlayerProfile profile) {
|
||||
printGatheringSkills(player, profile, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print out details on Combat skills. Only for online players.
|
||||
*
|
||||
* @param inspect The player to retrieve stats for
|
||||
* @param profile The player's profile
|
||||
* @param display The sender to display stats to
|
||||
*/
|
||||
public static void printCombatSkills(Player inspect, CommandSender display) {
|
||||
if (Skills.hasCombatSkills(inspect)) {
|
||||
PlayerProfile profile = Users.getProfile(inspect);
|
||||
|
||||
if (profile == null) {
|
||||
display.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return;
|
||||
}
|
||||
|
||||
public static void printCombatSkills(Player inspect, PlayerProfile profile, CommandSender display) {
|
||||
if (SkillTools.hasCombatSkills(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
|
||||
|
||||
if (Permissions.getInstance().axes(inspect)) {
|
||||
if (Permissions.axes(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().archery(inspect)) {
|
||||
if (Permissions.archery(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().swords(inspect)) {
|
||||
if (Permissions.swords(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().taming(inspect)) {
|
||||
if (Permissions.taming(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().unarmed(inspect)) {
|
||||
if (Permissions.unarmed(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Unarmed.Listener"), profile.getSkillLevel(SkillType.UNARMED), profile.getSkillXpLevel(SkillType.UNARMED), profile.getXpToLevel(SkillType.UNARMED) }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void printCombatSkills(Player player) {
|
||||
printCombatSkills(player, player);
|
||||
public static void printCombatSkills(Player player, PlayerProfile profile) {
|
||||
printCombatSkills(player, profile, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print out details on Misc skills. Only for online players.
|
||||
*
|
||||
* @param inspect The player to retrieve stats for
|
||||
* @param profile The player's profile
|
||||
* @param display The sender to display stats to
|
||||
*/
|
||||
public static void printMiscSkills(Player inspect, CommandSender display) {
|
||||
if (Skills.hasMiscSkills(inspect)) {
|
||||
PlayerProfile profile = Users.getProfile(inspect);
|
||||
|
||||
if (profile == null) {
|
||||
display.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return;
|
||||
}
|
||||
|
||||
public static void printMiscSkills(Player inspect, PlayerProfile profile, CommandSender display) {
|
||||
if (SkillTools.hasMiscSkills(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
|
||||
|
||||
if (Permissions.getInstance().acrobatics(inspect)) {
|
||||
if (Permissions.acrobatics(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().repair(inspect)) {
|
||||
if (Permissions.repair(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR) }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void printMiscSkills(Player player) {
|
||||
printMiscSkills(player, player);
|
||||
public static void printMiscSkills(Player player, PlayerProfile profile) {
|
||||
printMiscSkills(player, profile, player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.PluginCommand;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.admin.AddlevelsCommand;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsCommand;
|
||||
import com.gmail.nossr50.skills.archery.ArcheryCommand;
|
||||
import com.gmail.nossr50.skills.axes.AxesCommand;
|
||||
import com.gmail.nossr50.skills.excavation.ExcavationCommand;
|
||||
import com.gmail.nossr50.skills.fishing.FishingCommand;
|
||||
import com.gmail.nossr50.skills.herbalism.HerbalismCommand;
|
||||
import com.gmail.nossr50.skills.mining.MiningCommand;
|
||||
import com.gmail.nossr50.skills.repair.RepairCommand;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingCommand;
|
||||
import com.gmail.nossr50.skills.swords.SwordsCommand;
|
||||
import com.gmail.nossr50.skills.taming.TamingCommand;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedCommand;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingCommand;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public final class CommandRegistrationHelper {
|
||||
private CommandRegistrationHelper() {};
|
||||
|
||||
private static String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission");
|
||||
|
||||
public static void registerSkillCommands() {
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill != SkillType.ALL) {
|
||||
String commandName = skill.toString().toLowerCase();
|
||||
String localizedName = LocaleLoader.getString(Misc.getCapitalized(commandName) + ".SkillName").toLowerCase();
|
||||
|
||||
List<String> aliasList = new ArrayList<String>();
|
||||
aliasList.add(localizedName);
|
||||
|
||||
PluginCommand command;
|
||||
|
||||
// Make us play nice with Essentials
|
||||
if (skill == SkillType.REPAIR && mcMMO.p.getServer().getPluginManager().isPluginEnabled("Essentials")) {
|
||||
command = mcMMO.p.getCommand("mcrepair");
|
||||
}
|
||||
else {
|
||||
command = mcMMO.p.getCommand(commandName);
|
||||
}
|
||||
|
||||
command.setAliases(aliasList);
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.Skill", new Object[] { Misc.getCapitalized(localizedName) }));
|
||||
command.setPermission("mcmmo.skills." + commandName);
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
|
||||
switch (skill) {
|
||||
case ACROBATICS:
|
||||
command.setExecutor(new AcrobaticsCommand());
|
||||
break;
|
||||
|
||||
case ARCHERY:
|
||||
command.setExecutor(new ArcheryCommand());
|
||||
break;
|
||||
|
||||
case AXES:
|
||||
command.setExecutor(new AxesCommand());
|
||||
break;
|
||||
|
||||
case EXCAVATION:
|
||||
command.setExecutor(new ExcavationCommand());
|
||||
break;
|
||||
|
||||
case FISHING:
|
||||
command.setExecutor(new FishingCommand());
|
||||
break;
|
||||
|
||||
case HERBALISM:
|
||||
command.setExecutor(new HerbalismCommand());
|
||||
break;
|
||||
|
||||
case MINING:
|
||||
command.setExecutor(new MiningCommand());
|
||||
break;
|
||||
|
||||
case REPAIR:
|
||||
command.setExecutor(new RepairCommand());
|
||||
break;
|
||||
|
||||
case SMELTING:
|
||||
command.setExecutor(new SmeltingCommand());
|
||||
break;
|
||||
|
||||
case SWORDS:
|
||||
command.setExecutor(new SwordsCommand());
|
||||
break;
|
||||
|
||||
case TAMING:
|
||||
command.setExecutor(new TamingCommand());
|
||||
break;
|
||||
|
||||
case UNARMED:
|
||||
command.setExecutor(new UnarmedCommand());
|
||||
break;
|
||||
|
||||
case WOODCUTTING:
|
||||
command.setExecutor(new WoodcuttingCommand());
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerAddlevelsCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("addlevels");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.addlevels"));
|
||||
command.setPermission("mcmmo.commands.addlevels");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.3", new Object[] {"addlevels", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">" }));
|
||||
command.setExecutor(new AddlevelsCommand());
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public abstract class SkillCommand implements CommandExecutor {
|
||||
private SkillType skill;
|
||||
private String skillString;
|
||||
private String permission;
|
||||
|
||||
protected Player player;
|
||||
protected PlayerProfile profile;
|
||||
protected float skillValue;
|
||||
|
||||
protected DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
protected Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
public SkillCommand(SkillType skill) {
|
||||
this.skill = skill;
|
||||
this.skillString = Misc.getCapitalized(skill.toString());
|
||||
this.permission = "mcmmo.skills." + skillString.toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, permission)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
player = (Player) sender;
|
||||
profile = Users.getProfile(player);
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
skillValue = profile.getSkillLevel(skill);
|
||||
dataCalculations();
|
||||
permissionsCheck();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString(skillString + ".SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain." + skillString) }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill) }));
|
||||
|
||||
if (effectsHeaderPermissions()) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
}
|
||||
|
||||
effectsDisplay();
|
||||
|
||||
if (statsHeaderPermissions()) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
}
|
||||
|
||||
statsDisplay();
|
||||
|
||||
Page.grabGuidePageForSkill(skill, player, args);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected abstract void dataCalculations();
|
||||
|
||||
protected abstract void permissionsCheck();
|
||||
|
||||
protected abstract boolean effectsHeaderPermissions();
|
||||
|
||||
protected abstract void effectsDisplay();
|
||||
|
||||
protected abstract boolean statsHeaderPermissions();
|
||||
|
||||
protected abstract void statsDisplay();
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class AddlevelsCommand implements CommandExecutor{
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
int levels;
|
||||
SkillType skill;
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (sender instanceof Player) {
|
||||
if (!SkillTools.isSkill(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Misc.isInt(args[1])) {
|
||||
levels = Integer.valueOf(args[1]);
|
||||
skill = SkillTools.getSkillType(args[0]);
|
||||
profile = Users.getPlayer((Player) sender).getProfile();
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", new Object[] {levels}));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", new Object[] {levels, Misc.getCapitalized(skill.toString())}));
|
||||
}
|
||||
|
||||
profile.addLevels(skill, levels);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
case 3:
|
||||
if (!Permissions.hasPermission(sender, "mcmmo.commands.addlevels.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!SkillTools.isSkill(args[1])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Misc.isInt(args[2])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
levels = Integer.valueOf(args[2]);
|
||||
skill = SkillTools.getSkillType(args[1]);
|
||||
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
profile.addLevels(skill, levels);
|
||||
profile.save(); // Since this is a temporary profile, we save it here.
|
||||
}
|
||||
else {
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
profile.addLevels(skill, levels);
|
||||
|
||||
// Check if the player is online before we try to send them a message.
|
||||
if (player.isOnline()) {
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", new Object[] {levels}));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", new Object[] {levels, Misc.getCapitalized(skill.toString())}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", new Object[] {args[0]}));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", new Object[] {Misc.getCapitalized(skill.toString()), args[0]}));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -10,36 +9,30 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
//TODO: Any way we can make this work for offline use?
|
||||
public class AddxpCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public AddxpCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
Player modifiedPlayer;
|
||||
int xp;
|
||||
SkillType skill;
|
||||
String skillName;
|
||||
String usage = ChatColor.RED + "Proper usage is /addxp [playername] <skill> <xp>"; //TODO: Needs more locale.
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
|
||||
return true;
|
||||
}
|
||||
String usage = LocaleLoader.getString("Commands.Usage.3", new Object[] {"addxp", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.XP") + ">" });
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.addxp")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof Player) {
|
||||
if (!Skills.isSkill(args[1])) {
|
||||
if (!SkillTools.isSkill(args[1])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
@@ -47,26 +40,24 @@ public class AddxpCommand implements CommandExecutor {
|
||||
if (Misc.isInt(args[1])) {
|
||||
modifiedPlayer = (Player) sender;
|
||||
xp = Integer.valueOf(args[1]);
|
||||
skill = Skills.getSkillType(args[0]);
|
||||
skill = SkillTools.getSkillType(args[0]);
|
||||
|
||||
PlayerProfile profile = Users.getProfile(modifiedPlayer);
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(modifiedPlayer);
|
||||
mcMMOPlayer.addXPOverride(skill, xp);
|
||||
mcMMOPlayer.addXpOverride(skill, xp);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", new Object[] {xp}));
|
||||
}
|
||||
else {
|
||||
skillName = Misc.getCapitalized(skill.toString());
|
||||
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", new Object[] {xp, Misc.getCapitalized(skill.toString())}));
|
||||
}
|
||||
|
||||
modifiedPlayer.sendMessage(ChatColor.GREEN + "You were awarded " + xp + " experience in " + skillName + "!"); //TODO: Needs more locale.
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
Skills.xpCheckAll(modifiedPlayer, profile);
|
||||
SkillTools.xpCheckAll(modifiedPlayer, profile);
|
||||
}
|
||||
else {
|
||||
Skills.xpCheckSkill(skill, modifiedPlayer, profile);
|
||||
SkillTools.xpCheckSkill(skill, modifiedPlayer, profile);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -80,50 +71,46 @@ public class AddxpCommand implements CommandExecutor {
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
modifiedPlayer = plugin.getServer().getPlayer(args[0]);
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.addxp.others")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
modifiedPlayer = mcMMO.p.getServer().getPlayer(args[0]);
|
||||
String playerName = modifiedPlayer.getName();
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(modifiedPlayer);
|
||||
PlayerProfile profile = Users.getProfile(modifiedPlayer);
|
||||
|
||||
if (profile == null) {
|
||||
|
||||
// TODO: Not sure if we actually need a null check here
|
||||
if (profile == null || !profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Skills.isSkill(args[1])) {
|
||||
if (!SkillTools.isSkill(args[1])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Misc.isInt(args[2])) {
|
||||
xp = Integer.valueOf(args[2]);
|
||||
skill = Skills.getSkillType(args[1]);
|
||||
String message;
|
||||
skill = SkillTools.getSkillType(args[1]);
|
||||
|
||||
mcMMOPlayer.addXPOverride(skill, xp);
|
||||
mcMMOPlayer.addXpOverride(skill, xp);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
message = ChatColor.RED + "All skills have been modified for " + playerName + "."; //TODO: Use locale
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", new Object[] {playerName}));
|
||||
}
|
||||
else {
|
||||
skillName = Misc.getCapitalized(skill.toString());
|
||||
message = ChatColor.RED + skillName + " has been modified for " + playerName + "."; //TODO: Use locale
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", new Object[] {Misc.getCapitalized(skill.toString()), playerName}));
|
||||
}
|
||||
|
||||
sender.sendMessage(message);
|
||||
modifiedPlayer.sendMessage(ChatColor.GREEN + "You were awarded " + xp + " experience in " + skillName + "!"); //TODO: Needs more locale.
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
Skills.xpCheckAll(modifiedPlayer, profile);
|
||||
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", new Object[] {xp}));
|
||||
SkillTools.xpCheckAll(modifiedPlayer, profile);
|
||||
}
|
||||
else {
|
||||
Skills.xpCheckSkill(skill, modifiedPlayer, profile);
|
||||
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", new Object[] {xp, Misc.getCapitalized(skill.toString())}));
|
||||
SkillTools.xpCheckSkill(skill, modifiedPlayer, profile);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McgodCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Permissions.mcgodCommand(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (profile.getGodMode()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
|
||||
}
|
||||
|
||||
profile.toggleGodMode();
|
||||
return true;
|
||||
case 1:
|
||||
if (!Permissions.hasPermission(sender, "mcmmo.commands.mcgod.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and
|
||||
// check if it's present in the database. If it's not, abort the process.
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
// Check if the player is online before we try to send them a message.
|
||||
if (player.isOnline()) {
|
||||
if (profile.getGodMode()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
profile.toggleGodMode();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -14,17 +13,11 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McrefreshCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public McrefreshCommand(mcMMO instance) {
|
||||
this.plugin = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
OfflinePlayer player;
|
||||
PlayerProfile profile;
|
||||
String usage = ChatColor.RED + "Proper usage is /mcrefresh [player]"; //TODO: Needs more locale
|
||||
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"mcrefresh", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"});
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcrefresh")) {
|
||||
return true;
|
||||
@@ -43,7 +36,7 @@ public class McrefreshCommand implements CommandExecutor {
|
||||
break;
|
||||
|
||||
case 1:
|
||||
player = plugin.getServer().getOfflinePlayer(args[0]);
|
||||
player = mcMMO.p.getServer().getOfflinePlayer(args[0]);
|
||||
profile = Users.getProfile(player);
|
||||
String playerName = player.getName();
|
||||
|
||||
@@ -57,7 +50,7 @@ public class McrefreshCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage("You have refreshed " + playerName + "'s cooldowns!"); //TODO: Use locale
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", new Object[] {playerName}));
|
||||
|
||||
break;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -9,10 +8,11 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class MmoeditCommand implements CommandExecutor {
|
||||
@@ -22,16 +22,16 @@ public class MmoeditCommand implements CommandExecutor {
|
||||
int newValue;
|
||||
SkillType skill;
|
||||
String skillName;
|
||||
String usage = ChatColor.RED + "Proper usage is /mmoedit [player] <skill> <level>"; //TODO: Needs more locale.
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
|
||||
return true;
|
||||
}
|
||||
String usage = LocaleLoader.getString("Commands.Usage.3", new Object[] {"mmoedit", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">" });
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mmoedit")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof Player) {
|
||||
if (!Skills.isSkill(args[0])) {
|
||||
if (!SkillTools.isSkill(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
@@ -39,18 +39,17 @@ public class MmoeditCommand implements CommandExecutor {
|
||||
if (Misc.isInt(args[1])) {
|
||||
Player player = (Player) sender;
|
||||
newValue = Integer.valueOf(args[1]);
|
||||
skill = Skills.getSkillType(args[0]);
|
||||
skill = SkillTools.getSkillType(args[0]);
|
||||
profile = Users.getProfile(player);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", new Object[] { newValue }));
|
||||
}
|
||||
else {
|
||||
skillName = Misc.getCapitalized(skill.toString());
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", new Object[] { Misc.getCapitalized(skill.toString()), newValue }));
|
||||
}
|
||||
|
||||
profile.modifySkill(skill, newValue);
|
||||
sender.sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
@@ -63,25 +62,22 @@ public class MmoeditCommand implements CommandExecutor {
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mmoedit.others")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Misc.isInt(args[2])) {
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
|
||||
skill = Skills.getSkillType(args[1]);
|
||||
skill = SkillTools.getSkillType(args[1]);
|
||||
|
||||
if (skill == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
}
|
||||
else {
|
||||
skillName = Misc.getCapitalized(skill.toString());
|
||||
}
|
||||
|
||||
newValue = Integer.valueOf(args[2]);
|
||||
McMMOPlayer mcmmoPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
@@ -94,17 +90,20 @@ public class MmoeditCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
profile.modifySkill(skill, newValue);
|
||||
mcmmoPlayer.getPlayer().sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
|
||||
sender.sendMessage(ChatColor.RED + skillName + " has been modified for " + args[0] + "."); //TODO: Use locale
|
||||
if (skill == SkillType.ALL) {
|
||||
mcmmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", new Object[] { newValue }));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", new Object[] { args[0] }));
|
||||
}
|
||||
else {
|
||||
skillName = Misc.getCapitalized(skill.toString());
|
||||
|
||||
mcmmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", new Object[] { skillName, newValue }));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", new Object[] { skillName, args[0] }));
|
||||
}
|
||||
}
|
||||
else {
|
||||
profile = new PlayerProfile(args[0], false); //Temporary Profile
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
@@ -112,6 +111,13 @@ public class MmoeditCommand implements CommandExecutor {
|
||||
|
||||
profile.modifySkill(skill, newValue);
|
||||
profile.save();
|
||||
|
||||
if (skill == SkillType.ALL) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", new Object[] { args[0] }));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", new Object[] { Misc.getCapitalized(skill.toString()), args[0] }));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SkillResetCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
OfflinePlayer modifiedPlayer;
|
||||
PlayerProfile profile;
|
||||
SkillType skill;
|
||||
String usage = LocaleLoader.getString("Commands.Usage.3", new Object[] {"skillreset", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">"});
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (sender instanceof Player) {
|
||||
if (!SkillTools.isSkill(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
skill = SkillTools.getSkillType(args[0]);
|
||||
|
||||
if (CommandHelper.noCommandPermissions((Player) sender, "mcmmo.commands.skillreset." + skill.toString().toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
modifiedPlayer = (Player) sender;
|
||||
profile = Users.getProfile(modifiedPlayer);
|
||||
profile.modifySkill(skill, 0);
|
||||
|
||||
if (skill == SkillType.ALL) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", new Object[] { Misc.getCapitalized(skill.toString()) }));
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
modifiedPlayer = mcMMO.p.getServer().getOfflinePlayer(args[0]);
|
||||
profile = Users.getProfile(modifiedPlayer);
|
||||
|
||||
// TODO:Not sure if we actually need a null check here
|
||||
if (profile == null || !profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!SkillTools.isSkill(args[1])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
skill = SkillTools.getSkillType(args[1]);
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.skillreset.others." + skill.toString().toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
profile.modifySkill(skill, 0);
|
||||
|
||||
if (modifiedPlayer.isOnline()) {
|
||||
if (skill == SkillType.ALL) {
|
||||
((Player)modifiedPlayer).sendMessage(LocaleLoader.getString("Commands.Reset.All"));
|
||||
}
|
||||
else {
|
||||
((Player)modifiedPlayer).sendMessage(LocaleLoader.getString("Commands.Reset.Single", new Object[] { Misc.getCapitalized(skill.toString()) }));
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", new Object[] { Misc.getCapitalized(skill.toString()), args[0] }));
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -12,13 +12,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class XprateCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
private static double oldRate = Config.getInstance().xpGainMultiplier;
|
||||
private static boolean xpEvent = false;
|
||||
|
||||
public XprateCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
@@ -26,23 +20,29 @@ public class XprateCommand implements CommandExecutor {
|
||||
String usage2 = LocaleLoader.getString("Commands.xprate.proper.1");
|
||||
String usage3 = LocaleLoader.getString("Commands.xprate.proper.2");
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) {
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.xprate")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean xpEventEnabled = mcMMO.p.isXPEventEnabled();
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("reset")) {
|
||||
if (xpEvent) {
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.xprate.reset")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (xpEventEnabled) {
|
||||
for (Player x : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
x.sendMessage(LocaleLoader.getString("Commands.xprate.over"));
|
||||
}
|
||||
|
||||
xpEvent = !xpEvent;
|
||||
Config.getInstance().xpGainMultiplier = oldRate;
|
||||
mcMMO.p.setXPEventEnabled(!xpEventEnabled);
|
||||
Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
|
||||
}
|
||||
else {
|
||||
Config.getInstance().xpGainMultiplier = oldRate;
|
||||
Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
|
||||
}
|
||||
}
|
||||
else if (Misc.isInt(args[0])) {
|
||||
@@ -56,25 +56,27 @@ public class XprateCommand implements CommandExecutor {
|
||||
|
||||
case 2:
|
||||
if (Misc.isInt(args[0])) {
|
||||
oldRate = Config.getInstance().xpGainMultiplier;
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.xprate.set")) {
|
||||
return true;
|
||||
}
|
||||
if (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")) {
|
||||
xpEvent = Boolean.valueOf(args[1]);
|
||||
mcMMO.p.setXPEventEnabled(Boolean.valueOf(args[1]));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage3);
|
||||
}
|
||||
|
||||
Config.getInstance().xpGainMultiplier = Misc.getInt(args[0]);
|
||||
int newRate = Misc.getInt(args[0]);
|
||||
Config.getInstance().setExperienceGainsGlobalMultiplier(newRate);
|
||||
|
||||
if (xpEvent) {
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
if (xpEventEnabled) {
|
||||
for (Player x : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
x.sendMessage(LocaleLoader.getString("Commands.xprate.started.0"));
|
||||
x.sendMessage(LocaleLoader.getString("Commands.xprate.started.1", new Object[] {Config.getInstance().xpGainMultiplier}));
|
||||
x.sendMessage(LocaleLoader.getString("Commands.xprate.started.1", new Object[] {newRate}));
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage("The XP RATE was modified to " + Config.getInstance().xpGainMultiplier); //TODO: Locale
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", new Object[] {newRate}));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -90,8 +92,4 @@ public class XprateCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isXpEventRunning() {
|
||||
return xpEvent;
|
||||
}
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class AddlevelsCommand implements CommandExecutor{
|
||||
private final mcMMO plugin;
|
||||
|
||||
public AddlevelsCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
OfflinePlayer modifiedPlayer;
|
||||
PlayerProfile profile;
|
||||
int levels;
|
||||
SkillType skill;
|
||||
String skillName;
|
||||
String usage = ChatColor.RED + "Proper usage is /addlevels [player] <skill> <level>"; //TODO: Needs more locale.
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (sender instanceof Player) {
|
||||
if (!Skills.isSkill(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Misc.isInt(args[1])) {
|
||||
modifiedPlayer = (Player) sender;
|
||||
levels = Integer.valueOf(args[1]);
|
||||
skill = Skills.getSkillType(args[0]);
|
||||
profile = Users.getProfile(modifiedPlayer);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
}
|
||||
else {
|
||||
skillName = Misc.getCapitalized(skill.toString());
|
||||
}
|
||||
|
||||
profile.addLevels(skill, levels);
|
||||
sender.sendMessage(ChatColor.GREEN + "You were awarded " + levels + " levels in " + skillName + "!"); //TODO: Needs more locale.
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
modifiedPlayer = plugin.getServer().getOfflinePlayer(args[0]);
|
||||
String playerName = modifiedPlayer.getName();
|
||||
profile = Users.getProfile(modifiedPlayer);
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Skills.isSkill(args[1])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Misc.isInt(args[2])) {
|
||||
levels = Integer.valueOf(args[2]);
|
||||
skill = Skills.getSkillType(args[1]);
|
||||
String message;
|
||||
|
||||
Users.getProfile(modifiedPlayer).addLevels(skill, levels);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
message = ChatColor.RED + "All skills have been modified for " + playerName + "."; //TODO: Use locale
|
||||
}
|
||||
else {
|
||||
skillName = Misc.getCapitalized(skill.toString());
|
||||
message = ChatColor.RED + skillName + " has been modified for " + playerName + "."; //TODO: Use locale
|
||||
}
|
||||
|
||||
sender.sendMessage(message);
|
||||
|
||||
if (modifiedPlayer.isOnline()) {
|
||||
((Player) modifiedPlayer).sendMessage(ChatColor.GREEN + "You were awarded " + levels + " levels in " + skillName + "!"); //TODO: Needs more locale.
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class InspectCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String usage = "Proper usage is /inspect <player>"; //TODO: Needs more locale.
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.inspect")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
McMMOPlayer mcmmoPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
if (mcmmoPlayer != null) {
|
||||
Player target = mcmmoPlayer.getPlayer();
|
||||
|
||||
if (sender instanceof Player && !sender.isOp() && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !Permissions.getInstance().inspectDistanceBypass((Player) sender)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", new Object[] { target.getName() }));
|
||||
CommandHelper.printGatheringSkills(target, sender);
|
||||
CommandHelper.printCombatSkills(target, sender);
|
||||
CommandHelper.printMiscSkills(target, sender);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { mcmmoPlayer.getPowerLevel() }));
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if (sender instanceof Player && !sender.isOp() && !Permissions.getInstance().inspectOfflineBypass((Player) sender)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerProfile profile = new PlayerProfile(args[0], false); //Temporary Profile
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", new Object[] { args[0] }));
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Woodcutting.Listener"), profile.getSkillLevel(SkillType.WOODCUTTING), profile.getSkillXpLevel(SkillType.WOODCUTTING), profile.getXpToLevel(SkillType.WOODCUTTING) }));
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Unarmed.Listener"), profile.getSkillLevel(SkillType.UNARMED), profile.getSkillXpLevel(SkillType.UNARMED), profile.getXpToLevel(SkillType.UNARMED) }));
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR) }));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McstatsCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
||||
|
||||
CommandHelper.printGatheringSkills(player);
|
||||
CommandHelper.printCombatSkills(player);
|
||||
CommandHelper.printMiscSkills(player);
|
||||
|
||||
int powerLevelCap = Config.getInstance().getPowerLevelCap();
|
||||
|
||||
if (powerLevelCap > 0)
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", new Object[] { String.valueOf(Users.getPlayer(player).getPowerLevel()), String.valueOf(powerLevelCap) }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { String.valueOf(Users.getPlayer(player).getPowerLevel()) }));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SkillResetCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//ensure they have the skillreset perm
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skillreset")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
SkillType skillType = null; //simple initialization
|
||||
|
||||
//make sure there's only one argument. output at least some kind of error if not
|
||||
if (args.length != 1 && args[0] != null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//parse the skilltype that they sent
|
||||
try
|
||||
{
|
||||
skillType = SkillType.valueOf(args[0].toUpperCase().trim()); //ucase needed to match enum since it's case sensitive. trim to be nice
|
||||
}catch(IllegalArgumentException ex)
|
||||
{
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
//reset the values in the hash table and persist them
|
||||
PlayerProfile profile = Users.getProfile((Player)sender);
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
profile.resetSkill(skillType);
|
||||
profile.save();
|
||||
|
||||
//display a success message to the user
|
||||
if (skillType == SkillType.ALL)
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
|
||||
else
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", new Object[] { args[0] }));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McabilityCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.ability")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerProfile profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (profile.getAbilityUse()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
||||
}
|
||||
|
||||
profile.toggleAbilityUse();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McgodCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcgod")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerProfile profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (profile.getGodMode()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
|
||||
}
|
||||
|
||||
profile.toggleGodMode();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,182 +0,0 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
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.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.SpoutHud;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McremoveCommand implements CommandExecutor {
|
||||
private final String location;
|
||||
private final mcMMO plugin;
|
||||
|
||||
public McremoveCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
this.location = mcMMO.getUsersFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String playerName;
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
String databaseName = Config.getInstance().getMySQLDatabaseName();
|
||||
String usage = ChatColor.RED + "Proper usage is /mcremove <player>"; //TODO: Needs more locale.
|
||||
String success;
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcremove")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
playerName = args[0];
|
||||
success = ChatColor.GREEN + playerName + " was successfully removed from the database!"; //TODO: Locale
|
||||
break;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* MySQL */
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
int userId = 0;
|
||||
userId = database.getInt("SELECT id FROM " + tablePrefix + "users WHERE user = '" + playerName + "'");
|
||||
|
||||
if (userId > 0) {
|
||||
database.write("DELETE FROM "
|
||||
+ databaseName + "."
|
||||
+ tablePrefix + "users WHERE "
|
||||
+ tablePrefix + "users.id=" + userId);
|
||||
|
||||
database.write("DELETE FROM "
|
||||
+ databaseName + "."
|
||||
+ tablePrefix + "cooldowns WHERE "
|
||||
+ tablePrefix + "cooldowns.user_id=" + userId);
|
||||
|
||||
database.write("DELETE FROM "
|
||||
+ databaseName + "."
|
||||
+ tablePrefix + "huds WHERE "
|
||||
+ tablePrefix + "huds.user_id=" + userId);
|
||||
|
||||
database.write("DELETE FROM "
|
||||
+ databaseName + "."
|
||||
+ tablePrefix + "skills WHERE "
|
||||
+ tablePrefix + "skills.user_id=" + userId);
|
||||
|
||||
database.write("DELETE FROM "
|
||||
+ databaseName + "."
|
||||
+ tablePrefix + "experience WHERE "
|
||||
+ tablePrefix + "experience.user_id=" + userId);
|
||||
|
||||
sender.sendMessage(success);
|
||||
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (removeFlatFileUser(playerName)) {
|
||||
sender.sendMessage(success);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
}
|
||||
}
|
||||
|
||||
//Force PlayerProfile stuff to update
|
||||
McMMOPlayer mcmmoPlayer = Users.getPlayer(playerName);
|
||||
|
||||
if (mcmmoPlayer != null) {
|
||||
Player player = mcmmoPlayer.getPlayer();
|
||||
SpoutHud spoutHud = mcmmoPlayer.getProfile().getSpoutHud();
|
||||
|
||||
if (spoutHud != null) {
|
||||
spoutHud.removeWidgets();
|
||||
}
|
||||
|
||||
Users.remove(playerName);
|
||||
|
||||
if (player.isOnline()) {
|
||||
Users.addUser(player);
|
||||
|
||||
if (mcMMO.spoutEnabled) {
|
||||
SpoutStuff.reloadSpoutPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean removeFlatFileUser(String playerName) {
|
||||
boolean worked = false;
|
||||
|
||||
BufferedReader in = null;
|
||||
FileWriter out = null;
|
||||
|
||||
try {
|
||||
FileReader file = new FileReader(location);
|
||||
in = new BufferedReader(file);
|
||||
StringBuilder writer = new StringBuilder();
|
||||
String line = "";
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
|
||||
/* Write out the same file but when we get to the player we want to remove, we skip his line. */
|
||||
if (!line.split(":")[0].equalsIgnoreCase(playerName)) {
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
else {
|
||||
System.out.println("User found, removing...");
|
||||
worked = true;
|
||||
continue; //Skip the player
|
||||
}
|
||||
}
|
||||
|
||||
out = new FileWriter(location); //Write out the new file
|
||||
out.write(writer.toString());
|
||||
}
|
||||
catch (Exception e) {
|
||||
plugin.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return worked;
|
||||
}
|
||||
}
|
||||
@@ -1,158 +0,0 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.util.Leaderboard;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class MctopCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String usage = ChatColor.RED + "Proper usage is /mctop [skill] [page]"; //TODO: Needs more locale.
|
||||
|
||||
if (!Config.getInstance().getUseMySQL()) {
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
flatfileDisplay(1, "ALL", sender);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (Misc.isInt(args[0])) {
|
||||
flatfileDisplay(Integer.valueOf(args[0]), "ALL", sender);
|
||||
}
|
||||
else if (Skills.isSkill(args[0])) {
|
||||
flatfileDisplay(1, args[0].toUpperCase(), sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (!Skills.isSkill(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Misc.isInt(args[1])) {
|
||||
flatfileDisplay(Integer.valueOf(args[1]), args[0].toUpperCase(), sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
String powerlevel = "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing";
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
sqlDisplay(1, powerlevel, sender);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (Misc.isInt(args[0])) {
|
||||
sqlDisplay(Integer.valueOf(args[0]), powerlevel, sender);
|
||||
}
|
||||
else if (Skills.isSkill(args[0])) {
|
||||
sqlDisplay(1, args[0].toLowerCase(), sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (!Skills.isSkill(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Misc.isInt(args[1])) {
|
||||
sqlDisplay(Integer.valueOf(args[1]), args[0].toLowerCase(), sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void flatfileDisplay(int page, String skill, CommandSender sender) {
|
||||
String[] info = Leaderboard.retrieveInfo(skill, page);
|
||||
|
||||
if (skill.equals("ALL")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", new Object[] { Misc.getCapitalized(skill) }));
|
||||
}
|
||||
|
||||
int n = (page * 10) - 9; // Position
|
||||
for (String x : info) {
|
||||
if (x != null) {
|
||||
String digit = String.valueOf(n);
|
||||
|
||||
if (n < 10) {
|
||||
digit = "0" + digit;
|
||||
}
|
||||
|
||||
String[] splitx = x.split(":");
|
||||
|
||||
// Format: 1. Playername - skill value
|
||||
sender.sendMessage(digit + ". " + ChatColor.GREEN + splitx[1] + " - " + ChatColor.WHITE + splitx[0]);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sqlDisplay(int page, String query, CommandSender sender) {
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
|
||||
HashMap<Integer, ArrayList<String>> userslist = database.read("SELECT " + query + ", user_id FROM " + tablePrefix + "skills WHERE " + query + " > 0 ORDER BY " + query + " DESC ");
|
||||
|
||||
if (query.equals("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", new Object[] { Misc.getCapitalized(query) }));
|
||||
}
|
||||
|
||||
for (int i = (page * 10) - 9; i <= (page * 10); i++) {
|
||||
if (i > userslist.size() || database.read("SELECT user FROM " + tablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
HashMap<Integer, ArrayList<String>> username = database.read("SELECT user FROM " + tablePrefix + "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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
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.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class ACommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public ACommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
String usage = ChatColor.RED + "Proper usage is /a <message>"; //TODO: Needs more locale.
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.chat.adminchat")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (sender instanceof Player) {
|
||||
profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (profile.getPartyChatMode()) {
|
||||
profile.togglePartyChat();
|
||||
}
|
||||
|
||||
profile.toggleAdminChat();
|
||||
|
||||
if (profile.getAdminChatMode()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.AdminChat.On"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.AdminChat.Off"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(args[0]);
|
||||
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
buffer.append(" ");
|
||||
buffer.append(args[i]);
|
||||
}
|
||||
|
||||
String message = buffer.toString();
|
||||
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), message);
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
message = chatEvent.getMessage();
|
||||
String prefix = ChatColor.AQUA + "{" + ChatColor.WHITE + player.getName() + ChatColor.AQUA + "} ";
|
||||
|
||||
plugin.getLogger().info("[A]<" + player.getName() + "> " + message);
|
||||
|
||||
for (Player otherPlayer : plugin.getServer().getOnlinePlayers()) {
|
||||
if (Permissions.getInstance().adminChat(otherPlayer) || otherPlayer.isOp()) {
|
||||
otherPlayer.sendMessage(prefix + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent("Console", message);
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
message = chatEvent.getMessage();
|
||||
String prefix = ChatColor.AQUA + "{" + ChatColor.WHITE + "*Console*" + ChatColor.AQUA + "} ";
|
||||
|
||||
plugin.getLogger().info("[A]<*Console*> " + message);
|
||||
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
if (Permissions.getInstance().adminChat(player) || player.isOp()) {
|
||||
player.sendMessage(prefix + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class AcceptCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public AcceptCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
|
||||
if (playerProfile.hasPartyInvite()) {
|
||||
PartyManager partyManagerInstance = PartyManager.getInstance();
|
||||
|
||||
if (playerProfile.inParty()) {
|
||||
Party party = playerProfile.getParty();
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), playerProfile.getInvite().getName(), EventReason.CHANGED_PARTIES);
|
||||
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
partyManagerInstance.removeFromParty(player.getName(), party);
|
||||
}
|
||||
else {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, playerProfile.getInvite().getName(), EventReason.JOINED_PARTY);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
partyManagerInstance.joinInvitedParty(player, playerProfile);
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
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.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
//TODO: Make this work from console.
|
||||
public class InviteCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public InviteCommand(mcMMO instance) {
|
||||
this.plugin = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String usage = ChatColor.RED + "Proper usage is /invite <player>"; //TODO: Needs more locale.
|
||||
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
|
||||
if (!playerProfile.inParty()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = plugin.getServer().getPlayer(args[0]);
|
||||
|
||||
if (target != null) {
|
||||
if (PartyManager.getInstance().canInvite(player, playerProfile)) {
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
Users.getProfile(target).setInvite(party);
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", new Object[] {party.getName(), player.getName()}));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,242 +0,0 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PartyCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public PartyCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
String playerName = player.getName();
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
|
||||
PartyManager partyManagerInstance = PartyManager.getInstance();
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (party == null) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.0"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.2"));
|
||||
}
|
||||
else {
|
||||
Server server = plugin.getServer();
|
||||
String leader = party.getLeader();
|
||||
StringBuffer tempList = new StringBuffer();
|
||||
|
||||
for (String otherPlayerName : party.getMembers()) {
|
||||
if (leader.equals(otherPlayerName)) {
|
||||
tempList.append(ChatColor.GOLD);
|
||||
}
|
||||
else if (server.getPlayer(otherPlayerName) != null) {
|
||||
tempList.append(ChatColor.WHITE);
|
||||
}
|
||||
else {
|
||||
tempList.append(ChatColor.GRAY);
|
||||
}
|
||||
|
||||
tempList.append(otherPlayerName + " ");
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.InParty", new Object[] {party.getName()}));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Members", new Object[] {tempList}));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("q")) {
|
||||
if (party != null) {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), null, EventReason.LEFT_PARTY);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
partyManagerInstance.removeFromParty(playerName, party);
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage("Commands.Party.None");
|
||||
}
|
||||
}
|
||||
else if (args[0].equals("?")) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.3"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.4"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.5"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.6"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.7"));
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("lock")) {
|
||||
if (party != null) {
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
if (party.isLocked()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.IsLocked"));
|
||||
}
|
||||
else {
|
||||
party.setLocked(true);
|
||||
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage("Commands.Party.None");
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("unlock")) {
|
||||
if (party != null) {
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
if (!party.isLocked()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.IsntLocked"));
|
||||
}
|
||||
else {
|
||||
party.setLocked(false);
|
||||
player.sendMessage(LocaleLoader.getString("Party.Unlocked"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage("Commands.Party.None");
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (party != null) {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), args[0], EventReason.CHANGED_PARTIES);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
partyManagerInstance.removeFromParty(playerName, party);
|
||||
}
|
||||
else {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
partyManagerInstance.joinParty(player, playerProfile, args[0], null);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (playerProfile.inParty()) {
|
||||
if (args[0].equalsIgnoreCase("password")) {
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
party.setLocked(true);
|
||||
party.setPassword(args[1]);
|
||||
player.sendMessage(LocaleLoader.getString("Party.PasswordSet", new Object[] {args[1]}));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("kick")) {
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
if (!party.getMembers().contains(args[1])) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]}));
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
String partyName = party.getName();
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, null, EventReason.KICKED_FROM_PARTY);
|
||||
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
partyManagerInstance.removeFromParty(args[1], party);
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("owner")) {
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
if (!party.getMembers().contains(args[1])) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]}));
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
partyManagerInstance.setPartyLeader(args[1], party);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), args[0], EventReason.CHANGED_PARTIES);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
partyManagerInstance.removeFromParty(playerName, party);
|
||||
partyManagerInstance.joinParty(player, playerProfile, args[0], args[1]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
partyManagerInstance.joinParty(player, playerProfile, args[0], args[1]);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.0"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.2"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
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.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PtpCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public PtpCommand(mcMMO instance) {
|
||||
this.plugin = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String usage = ChatColor.RED + "Proper usage is /ptp <player>"; //TODO: Needs more locale.
|
||||
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.ptp")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (profile.getRecentlyHurt() + (Config.getInstance().getPTPCommandCooldown() * 1000) > System.currentTimeMillis()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", new Object[] { Config.getInstance().getPTPCommandCooldown() }));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = plugin.getServer().getPlayer(args[0]);
|
||||
|
||||
if (player.equals(target)) {
|
||||
player.sendMessage("You can't teleport to yourself!"); //TODO: Use locale
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target == null) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target.isDead()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PartyManager.getInstance().inSameParty(player, target)) {
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, profile.getParty().getName());
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
player.teleport(target);
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Player", new Object[] { target.getName() }));
|
||||
target.sendMessage(LocaleLoader.getString("Party.Teleport.Target", new Object[] { player.getName() }));
|
||||
profile.setRecentlyHurt(System.currentTimeMillis());
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { target.getName() }));
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class InspectCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"inspect", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"});
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.inspect")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
McMMOPlayer mcmmoPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
if (mcmmoPlayer != null) {
|
||||
Player target = mcmmoPlayer.getPlayer();
|
||||
|
||||
if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !Permissions.inspectFar((Player) sender)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerProfile profile = mcmmoPlayer.getProfile();
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", new Object[] { target.getName() }));
|
||||
CommandHelper.printGatheringSkills(target, profile, sender);
|
||||
CommandHelper.printCombatSkills(target, profile, sender);
|
||||
CommandHelper.printMiscSkills(target, profile, sender);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { mcmmoPlayer.getPowerLevel() }));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && !Permissions.inspectOffline((Player) sender)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerProfile profile = new PlayerProfile(args[0], false); //Temporary Profile
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", new Object[] { args[0] }));
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Woodcutting.Listener"), profile.getSkillLevel(SkillType.WOODCUTTING), profile.getSkillXpLevel(SkillType.WOODCUTTING), profile.getXpToLevel(SkillType.WOODCUTTING) }));
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Unarmed.Listener"), profile.getSkillLevel(SkillType.UNARMED), profile.getSkillXpLevel(SkillType.UNARMED), profile.getXpToLevel(SkillType.UNARMED) }));
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR) }));
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McabilityCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"mcability", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"});
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcability")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (profile.getAbilityUse()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
||||
}
|
||||
|
||||
profile.toggleAbilityUse();
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcability.others")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
OfflinePlayer modifiedPlayer = mcMMO.p.getServer().getOfflinePlayer(args[0]);
|
||||
profile = Users.getProfile(modifiedPlayer);
|
||||
|
||||
// TODO:Not sure if we actually need a null check here
|
||||
if (profile == null || !profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (profile.getAbilityUse()) {
|
||||
((Player) modifiedPlayer).sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
||||
}
|
||||
else {
|
||||
((Player) modifiedPlayer).sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
||||
}
|
||||
|
||||
profile.toggleAbilityUse();
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,16 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
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.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
//TODO: Rework this whole thing. It's ugly. Also is missing all the admin & spout commands.
|
||||
public class MccCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
@@ -22,21 +19,22 @@ public class MccCommand implements CommandExecutor {
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
player.sendMessage(ChatColor.RED + "---[]" + ChatColor.YELLOW + "mcMMO Commands" + ChatColor.RED + "[]---"); //TODO: Needs more locale.
|
||||
player.sendMessage(LocaleLoader.getString("Commands.mcc.Header"));
|
||||
|
||||
if (Permissions.getInstance().party(player)) {
|
||||
if (Permissions.party(player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Commands"));
|
||||
player.sendMessage("/party " + LocaleLoader.getString("Commands.Party"));
|
||||
player.sendMessage("/party q " + LocaleLoader.getString("Commands.Party.Quit"));
|
||||
player.sendMessage("/party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1"));
|
||||
player.sendMessage("/party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2"));
|
||||
player.sendMessage("/party quit " + LocaleLoader.getString("Commands.Party.Quit"));
|
||||
|
||||
if (Permissions.getInstance().partyChat(player)) {
|
||||
if (Permissions.partyChat(player)) {
|
||||
player.sendMessage("/p " + LocaleLoader.getString("Commands.Party.Toggle"));
|
||||
}
|
||||
|
||||
player.sendMessage("/invite " + LocaleLoader.getString("Commands.Party.Invite"));
|
||||
player.sendMessage("/accept " + LocaleLoader.getString("Commands.Party.Accept"));
|
||||
player.sendMessage("/party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite"));
|
||||
player.sendMessage("/party accept " + LocaleLoader.getString("Commands.Party.Accept"));
|
||||
|
||||
if (Permissions.getInstance().partyTeleport(player)) {
|
||||
if (Permissions.partyTeleport(player)) {
|
||||
player.sendMessage("/ptp " + LocaleLoader.getString("Commands.Party.Teleport"));
|
||||
}
|
||||
}
|
||||
@@ -45,27 +43,27 @@ public class MccCommand implements CommandExecutor {
|
||||
player.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
|
||||
player.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards"));
|
||||
|
||||
if (Config.getInstance().getCommandSkillResetEnabled() && Permissions.getInstance().skillReset(player)) {
|
||||
if (Permissions.skillReset(player)) {
|
||||
player.sendMessage("/skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().mcAbility(player)) {
|
||||
|
||||
if (Permissions.mcAbility(player)) {
|
||||
player.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().adminChat(player)) {
|
||||
if (Permissions.adminChat(player)) {
|
||||
player.sendMessage("/a " + LocaleLoader.getString("Commands.AdminToggle"));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().inspect(player)) {
|
||||
if (Permissions.inspect(player)) {
|
||||
player.sendMessage("/inspect " + LocaleLoader.getString("Commands.Inspect"));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().mmoedit(player)) {
|
||||
if (Permissions.mmoedit(player)) {
|
||||
player.sendMessage("/mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().mcgod(player)) {
|
||||
if (Permissions.mcgod(player)) {
|
||||
player.sendMessage("/mcgod " + LocaleLoader.getString("Commands.mcgod"));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@@ -10,6 +10,7 @@ import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Anniversary;
|
||||
|
||||
public class McmmoCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -22,13 +23,15 @@ public class McmmoCommand implements CommandExecutor {
|
||||
if (mcMMO.spoutEnabled && sender instanceof SpoutPlayer) {
|
||||
SpoutPlayer spoutPlayer = (SpoutPlayer) sender;
|
||||
|
||||
spoutPlayer.sendNotification(ChatColor.YELLOW + "[mcMMO]" + ChatColor.GOLD + " Donate!", ChatColor.GREEN + "mcmmodev@gmail.com", Material.DIAMOND);
|
||||
spoutPlayer.sendNotification(LocaleLoader.getString("Spout.Donate"), ChatColor.GREEN + "gjmcferrin@gmail.com", Material.DIAMOND);
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + "Donation Info:");
|
||||
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "mcmmodev@gmail.com" + ChatColor.GOLD + " Paypal");
|
||||
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
|
||||
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("MOTD.Version", new Object[] {mcMMO.p.getDescription().getVersion()}));
|
||||
|
||||
Anniversary.anniversaryCheck(sender);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.McRankAsync;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Leaderboard;
|
||||
|
||||
public class McrankCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
//TODO: Better input handling, add usage string
|
||||
|
||||
if (!Config.getInstance().getUseMySQL()) {
|
||||
Leaderboard.updateLeaderboards(); //Make sure the information is up to date
|
||||
}
|
||||
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
String playerName;
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
playerName = player.getName();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
playerName = args[0];
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
sqlDisplay(sender, playerName);
|
||||
}
|
||||
else {
|
||||
flatfileDisplay(sender, playerName);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void flatfileDisplay(CommandSender sender, String playerName) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", new Object[] {playerName}));
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
int[] rankInts = Leaderboard.getPlayerRank(playerName, skillType);
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
continue; // We want the overall ranking to be at the bottom
|
||||
}
|
||||
|
||||
if (rankInts[1] == 0) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {SkillTools.localizeSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked")} )); //Don't bother showing ranking for players without skills
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {SkillTools.localizeSkillName(skillType), String.valueOf(rankInts[0])} ));
|
||||
}
|
||||
}
|
||||
|
||||
//Show the powerlevel ranking
|
||||
int[] rankInts = Leaderboard.getPlayerRank(playerName, SkillType.ALL);
|
||||
|
||||
if (rankInts[1] == 0) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overalll", new Object[] {LocaleLoader.getString("Commands.mcrank.Unranked")} )); //Don't bother showing ranking for players without skills
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", new Object[] {String.valueOf(rankInts[0])} ));
|
||||
}
|
||||
}
|
||||
|
||||
private void sqlDisplay(CommandSender sender, String playerName) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getPluginManager().getPlugin("mcMMO"), new McRankAsync(playerName, sender));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McstatsCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcstats")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile profile = Users.getPlayer(player).getProfile();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
||||
|
||||
CommandHelper.printGatheringSkills(player, profile);
|
||||
CommandHelper.printCombatSkills(player, profile);
|
||||
CommandHelper.printMiscSkills(player, profile);
|
||||
|
||||
int powerLevelCap = Config.getInstance().getPowerLevelCap();
|
||||
|
||||
if (powerLevelCap > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", new Object[] { String.valueOf(Users.getPlayer(player).getPowerLevel()), String.valueOf(powerLevelCap) }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { String.valueOf(Users.getPlayer(player).getPowerLevel()) }));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Leaderboard;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class MctopCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String usage = LocaleLoader.getString("Commands.Usage.2", new Object[] {"mctop", "[" + LocaleLoader.getString("Commands.Usage.Skill") + "]", "[" + LocaleLoader.getString("Commands.Usage.Page") + "]"});
|
||||
|
||||
if (!Config.getInstance().getUseMySQL()) {
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
flatfileDisplay(1, "ALL", sender);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (Misc.isInt(args[0])) {
|
||||
flatfileDisplay(Integer.valueOf(args[0]), "ALL", sender);
|
||||
}
|
||||
else if (SkillTools.isSkill(args[0])) {
|
||||
flatfileDisplay(1, args[0].toUpperCase(), sender);
|
||||
}
|
||||
else if (SkillTools.isLocalizedSkill(args[0])) {
|
||||
flatfileDisplay(1, SkillTools.translateLocalizedSkill(args[0]).toUpperCase(), sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (Misc.isInt(args[1])) {
|
||||
if (SkillTools.isSkill(args[0])) {
|
||||
flatfileDisplay(Integer.valueOf(args[1]), args[0].toUpperCase(), sender);
|
||||
}
|
||||
else if (SkillTools.isLocalizedSkill(args[0])) {
|
||||
flatfileDisplay(Integer.valueOf(args[1]), SkillTools.translateLocalizedSkill(args[0]).toUpperCase(), sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
String powerlevel = "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing";
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
sqlDisplay(1, powerlevel, sender);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (Misc.isInt(args[0])) {
|
||||
sqlDisplay(Integer.valueOf(args[0]), powerlevel, sender);
|
||||
}
|
||||
else if (SkillTools.isSkill(args[0])) {
|
||||
sqlDisplay(1, args[0].toLowerCase(), sender);
|
||||
}
|
||||
else if (SkillTools.isLocalizedSkill(args[0])) {
|
||||
sqlDisplay(1, SkillTools.translateLocalizedSkill(args[0]).toLowerCase(), sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (Misc.isInt(args[1])) {
|
||||
if (SkillTools.isSkill(args[0])) {
|
||||
sqlDisplay(Integer.valueOf(args[1]), args[0].toLowerCase(), sender);
|
||||
}
|
||||
else if (SkillTools.isLocalizedSkill(args[0])) {
|
||||
sqlDisplay(Integer.valueOf(args[1]), SkillTools.translateLocalizedSkill(args[0]).toLowerCase(), sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void flatfileDisplay(int page, String skill, CommandSender sender) {
|
||||
Leaderboard.updateLeaderboards(); //Make sure we have the latest information
|
||||
SkillType skillType = SkillType.getSkill(skill);
|
||||
String[] info = Leaderboard.retrieveInfo(skillType, page);
|
||||
|
||||
if (skill.equalsIgnoreCase("ALL")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", new Object[] { Misc.getCapitalized(skill) }));
|
||||
}
|
||||
|
||||
int n = (page * 10) - 9; // Position
|
||||
for (String x : info) {
|
||||
if (x != null) {
|
||||
String digit = String.valueOf(n);
|
||||
|
||||
if (n < 10) {
|
||||
digit = "0" + digit;
|
||||
}
|
||||
|
||||
String[] splitx = x.split(":");
|
||||
|
||||
// Format: 1. Playername - skill value
|
||||
sender.sendMessage(digit + ". " + ChatColor.GREEN + splitx[1] + " - " + ChatColor.WHITE + splitx[0]);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
||||
}
|
||||
|
||||
private void sqlDisplay(int page, String query, CommandSender sender) {
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
HashMap<Integer, ArrayList<String>> userslist = Database.read("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 ORDER BY " + query + " DESC, user LIMIT "+((page * 10) - 10)+",10");
|
||||
|
||||
if (query.equals("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", new Object[] { Misc.getCapitalized(query) }));
|
||||
}
|
||||
int place = (page * 10) - 9;
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
if(userslist.get(i) == null) {
|
||||
break;
|
||||
}
|
||||
sender.sendMessage(String.valueOf(place) + ". " + ChatColor.GREEN + userslist.get(i).get(1) + " - " + ChatColor.WHITE + userslist.get(i).get(0));
|
||||
place++;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.commands.SkillCommand;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class AcrobaticsCommand extends SkillCommand {
|
||||
private String dodgeChance;
|
||||
private String rollChance;
|
||||
private String gracefulRollChance;
|
||||
|
||||
private boolean canDodge;
|
||||
private boolean canRoll;
|
||||
private boolean canGracefulRoll;
|
||||
|
||||
public AcrobaticsCommand() {
|
||||
super(SkillType.ACROBATICS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
if (skillValue >= 1000) {
|
||||
dodgeChance = "20.00%";
|
||||
rollChance = "100.00%";
|
||||
gracefulRollChance = "100.00%";
|
||||
}
|
||||
else if (skillValue >= 800) {
|
||||
dodgeChance = "20.00%";
|
||||
rollChance = percent.format(skillValue / 1000);
|
||||
gracefulRollChance = "100.00%";
|
||||
}
|
||||
else if (skillValue >= 500) {
|
||||
dodgeChance = percent.format(skillValue / 4000);
|
||||
rollChance = percent.format(skillValue / 1000);
|
||||
gracefulRollChance = "100.00%";
|
||||
}
|
||||
else {
|
||||
dodgeChance = percent.format(skillValue / 4000);
|
||||
rollChance = percent.format(skillValue / 1000);
|
||||
gracefulRollChance = percent.format(skillValue / 500);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canDodge = permInstance.dodge(player);
|
||||
canRoll = permInstance.roll(player);
|
||||
canGracefulRoll = permInstance.gracefulRoll(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canDodge || canGracefulRoll || canRoll;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (canRoll) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canGracefulRoll) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.2"), LocaleLoader.getString("Acrobatics.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canDodge) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.4"), LocaleLoader.getString("Acrobatics.Effect.5") }));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canDodge || canGracefulRoll || canRoll;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canRoll) {
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", new Object[] { rollChance }));
|
||||
}
|
||||
|
||||
if (canGracefulRoll) {
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance }));
|
||||
}
|
||||
|
||||
if (canDodge) {
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.commands.SkillCommand;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class ArcheryCommand extends SkillCommand {
|
||||
private String skillShotBonus;
|
||||
private String dazeChance;
|
||||
private String retrieveChance;
|
||||
|
||||
private boolean canSkillShot;
|
||||
private boolean canDaze;
|
||||
private boolean canRetrieve;
|
||||
|
||||
public ArcheryCommand() {
|
||||
super(SkillType.ARCHERY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
if (skillValue >= 1000) {
|
||||
skillShotBonus = "200.00%";
|
||||
dazeChance = "50.00%";
|
||||
retrieveChance = "100.00%";
|
||||
}
|
||||
else {
|
||||
skillShotBonus = percent.format(((int) skillValue / 50) * 0.1D); //TODO: Not sure if this is the best way to calculate this or not...
|
||||
dazeChance = percent.format(skillValue / 2000);
|
||||
retrieveChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canSkillShot = permInstance.archeryBonus(player);
|
||||
canDaze = permInstance.daze(player);
|
||||
canRetrieve = permInstance.trackArrows(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canSkillShot || canDaze || canRetrieve;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (canSkillShot) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canDaze) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canRetrieve) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5") }));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canSkillShot || canDaze || canRetrieve;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canSkillShot) {
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", new Object[] { skillShotBonus }));
|
||||
}
|
||||
|
||||
if (canDaze) {
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", new Object[] { dazeChance }));
|
||||
}
|
||||
|
||||
if (canRetrieve) {
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.commands.SkillCommand;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.gathering.Fishing;
|
||||
|
||||
public class FishingCommand extends SkillCommand {
|
||||
private int lootTier;
|
||||
private String magicChance;
|
||||
private String shakeChance;
|
||||
|
||||
private boolean canTreasureHunt;
|
||||
private boolean canMagicHunt;
|
||||
private boolean canShake;
|
||||
|
||||
public FishingCommand() {
|
||||
super(SkillType.FISHING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
lootTier = Fishing.getFishingLootTier(profile);
|
||||
magicChance = percent.format((float) lootTier / 15);
|
||||
int dropChance = Fishing.getShakeChance(lootTier);
|
||||
if (player.hasPermission("mcmmo.perks.lucky.fishing")) {
|
||||
dropChance = (int) (dropChance * 1.25);
|
||||
}
|
||||
shakeChance = String.valueOf(dropChance);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canTreasureHunt = permInstance.fishingTreasures(player);
|
||||
canMagicHunt = permInstance.fishingMagic(player);
|
||||
canShake = permInstance.shakeMob(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canTreasureHunt || canMagicHunt || canShake;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canMagicHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canShake) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5") }));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canTreasureHunt || canMagicHunt || canShake;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", new Object[] { lootTier }));
|
||||
}
|
||||
|
||||
if (canMagicHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", new Object[] { magicChance }));
|
||||
}
|
||||
|
||||
if (canShake) {
|
||||
if (skillValue < 150) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Fishing.Ability.Locked.0") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", new Object[] { shakeChance }));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.commands.SkillCommand;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class HerbalismCommand extends SkillCommand {
|
||||
private String greenTerraLength;
|
||||
private String greenThumbChance;
|
||||
private String greenThumbStage;
|
||||
private String farmersDietRank;
|
||||
private String doubleDropChance;
|
||||
|
||||
private boolean canGreenTerra;
|
||||
private boolean canGreenThumbWheat;
|
||||
private boolean canGreenThumbBlocks;
|
||||
private boolean canFarmersDiet;
|
||||
private boolean canDoubleDrop;
|
||||
private boolean doubleDropsDisabled;
|
||||
|
||||
public HerbalismCommand() {
|
||||
super(SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
greenTerraLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||
|
||||
if (skillValue >= 1500) {
|
||||
greenThumbChance = "100.00%";
|
||||
greenThumbStage = "4";
|
||||
farmersDietRank = "5";
|
||||
doubleDropChance = "100.00%";
|
||||
}
|
||||
else if (skillValue >= 1000) {
|
||||
greenThumbChance = percent.format(skillValue / 1500);
|
||||
greenThumbStage = "4";
|
||||
farmersDietRank = "5";
|
||||
doubleDropChance = "100.00%";
|
||||
}
|
||||
else if (skillValue >= 800) {
|
||||
greenThumbChance = percent.format(skillValue / 1500);
|
||||
greenThumbStage = "4";
|
||||
farmersDietRank = "4";
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else if (skillValue >= 600) {
|
||||
greenThumbChance = percent.format(skillValue / 1500);
|
||||
greenThumbStage = "4";
|
||||
farmersDietRank = "3";
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else if (skillValue >= 400) {
|
||||
greenThumbChance = percent.format(skillValue / 1500);
|
||||
greenThumbStage = "3";
|
||||
farmersDietRank = "2";
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else if (skillValue >= 200) {
|
||||
greenThumbChance = percent.format(skillValue / 1500);
|
||||
greenThumbStage = "2";
|
||||
farmersDietRank = "1";
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else {
|
||||
greenThumbChance = percent.format(skillValue / 1500);
|
||||
greenThumbStage = "1";
|
||||
farmersDietRank = "1";
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
canGreenTerra = permInstance.greenTerra(player);
|
||||
canGreenThumbWheat = permInstance.greenThumbWheat(player);
|
||||
canGreenThumbBlocks = permInstance.greenThumbBlocks(player);
|
||||
canFarmersDiet = permInstance.farmersDiet(player);
|
||||
canDoubleDrop = permInstance.herbalismDoubleDrops(player);
|
||||
doubleDropsDisabled = configInstance.herbalismDoubleDropsDisabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (canGreenTerra) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canGreenThumbWheat) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canGreenThumbBlocks) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.4"), LocaleLoader.getString("Herbalism.Effect.5") }));
|
||||
}
|
||||
|
||||
if (canFarmersDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.6"), LocaleLoader.getString("Herbalism.Effect.7") }));
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9") }));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canGreenTerra) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", new Object[] { greenTerraLength }));
|
||||
}
|
||||
|
||||
if (canGreenThumbBlocks || canGreenThumbWheat) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", new Object[] { greenThumbChance }));
|
||||
}
|
||||
|
||||
if (canGreenThumbWheat) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", new Object[] { greenThumbStage }));
|
||||
}
|
||||
|
||||
if (canFarmersDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.FD", new Object[] { farmersDietRank } ));
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", new Object[] { doubleDropChance }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.commands.SkillCommand;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class SwordsCommand extends SkillCommand {
|
||||
private String counterAttackChance;
|
||||
private String bleedLength;
|
||||
private String bleedChance;
|
||||
private String serratedStrikesLength;
|
||||
|
||||
private boolean canCounter;
|
||||
private boolean canSerratedStrike;
|
||||
private boolean canBleed;
|
||||
|
||||
public SwordsCommand() {
|
||||
super(SkillType.SWORDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
serratedStrikesLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||
|
||||
if (skillValue >= 750) {
|
||||
bleedLength = "3";
|
||||
bleedChance = "75.00%";
|
||||
counterAttackChance = "30.00%";
|
||||
}
|
||||
else if (skillValue >= 600) {
|
||||
bleedLength = "2";
|
||||
bleedChance = percent.format(skillValue / 1000);
|
||||
counterAttackChance = "30.00%";
|
||||
}
|
||||
else {
|
||||
bleedLength = "2";
|
||||
bleedChance = percent.format(skillValue / 1000);
|
||||
counterAttackChance = percent.format(skillValue / 2000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canBleed = permInstance.swordsBleed(player);
|
||||
canCounter = permInstance.counterAttack(player);
|
||||
canSerratedStrike = permInstance.serratedStrikes(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canBleed || canCounter || canSerratedStrike;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (canCounter) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.0"), LocaleLoader.getString("Swords.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canSerratedStrike) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.2"), LocaleLoader.getString("Swords.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.4"), LocaleLoader.getString("Swords.Effect.5") }));
|
||||
}
|
||||
|
||||
if (canBleed) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.6"), LocaleLoader.getString("Swords.Effect.7") }));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canBleed || canCounter || canSerratedStrike;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canCounter) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", new Object[] { counterAttackChance }));
|
||||
}
|
||||
|
||||
if (canBleed) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", new Object[] { bleedLength }));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", new Object[] { bleedChance }));
|
||||
}
|
||||
|
||||
if (canSerratedStrike) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", new Object[] { serratedStrikesLength }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.commands.SkillCommand;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class UnarmedCommand extends SkillCommand {
|
||||
private String berserkLength;
|
||||
private String deflectChance;
|
||||
private String disarmChance;
|
||||
private String ironArmBonus;
|
||||
|
||||
private boolean canBerserk;
|
||||
private boolean canDisarm;
|
||||
private boolean canBonusDamage;
|
||||
private boolean canDeflect;
|
||||
|
||||
public UnarmedCommand() {
|
||||
super(SkillType.UNARMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
berserkLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||
|
||||
if (skillValue >= 1000) {
|
||||
disarmChance = "33.33%";
|
||||
deflectChance = "50.00%";
|
||||
ironArmBonus = "8";
|
||||
}
|
||||
else if (skillValue >= 250) {
|
||||
disarmChance = percent.format(skillValue / 3000);
|
||||
deflectChance = percent.format(skillValue / 2000);
|
||||
ironArmBonus = "8";
|
||||
}
|
||||
else {
|
||||
disarmChance = percent.format(skillValue / 3000);
|
||||
deflectChance = percent.format(skillValue / 2000);
|
||||
ironArmBonus = String.valueOf(3 + ((int) skillValue / 50));
|
||||
} }
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canBerserk = permInstance.berserk(player);
|
||||
canBonusDamage = permInstance.unarmedBonus(player);
|
||||
canDeflect = permInstance.deflect(player);
|
||||
canDisarm = permInstance.disarm(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canBerserk || canBonusDamage || canDeflect || canDisarm;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (canBerserk) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canDisarm) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.2"), LocaleLoader.getString("Unarmed.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canBonusDamage) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.4"), LocaleLoader.getString("Unarmed.Effect.5") }));
|
||||
}
|
||||
|
||||
if (canDeflect) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7") }));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canBerserk || canBonusDamage || canDeflect || canDisarm;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canBonusDamage) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", new Object[] {ironArmBonus}) }));
|
||||
}
|
||||
|
||||
if (canDeflect) {
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", new Object[] { deflectChance }));
|
||||
}
|
||||
|
||||
if (canDisarm) {
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", new Object[] { disarmChance }));
|
||||
}
|
||||
|
||||
if (canBerserk) {
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", new Object[] { berserkLength }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.commands.SkillCommand;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class WoodcuttingCommand extends SkillCommand {
|
||||
private String treeFellerLength;
|
||||
private String doubleDropChance;
|
||||
|
||||
private boolean canTreeFell;
|
||||
private boolean canLeafBlow;
|
||||
private boolean canDoubleDrop;
|
||||
private boolean doubleDropsDisabled;
|
||||
|
||||
public WoodcuttingCommand() {
|
||||
super(SkillType.WOODCUTTING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
treeFellerLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||
|
||||
if (skillValue >= 1000) {
|
||||
doubleDropChance = "100.00%";
|
||||
}
|
||||
else {
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
canTreeFell = permInstance.treeFeller(player);
|
||||
canDoubleDrop = permInstance.woodcuttingDoubleDrops(player);
|
||||
canLeafBlow = permInstance.leafBlower(player);
|
||||
doubleDropsDisabled = configInstance.woodcuttingDoubleDropsDisabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return (canDoubleDrop && !doubleDropsDisabled) || canLeafBlow || canTreeFell;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (canTreeFell) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canLeafBlow) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5") }));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return (canDoubleDrop && !doubleDropsDisabled) || canLeafBlow || canTreeFell;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
//TODO: Remove? Basically duplicates the above.
|
||||
if (canLeafBlow) {
|
||||
if (skillValue < 100) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Woodcutting.Ability.Locked.0") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1") }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }));
|
||||
}
|
||||
|
||||
if (canTreeFell) {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }));
|
||||
}
|
||||
}
|
||||
}
|
||||
226
src/main/java/com/gmail/nossr50/config/AdvancedConfig.java
Normal file
226
src/main/java/com/gmail/nossr50/config/AdvancedConfig.java
Normal file
@@ -0,0 +1,226 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
public class AdvancedConfig extends ConfigLoader {
|
||||
private static AdvancedConfig instance;
|
||||
|
||||
private AdvancedConfig() {
|
||||
super("advanced.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static AdvancedConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new AdvancedConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
// TODO Do we need to use this?
|
||||
}
|
||||
/* GENERAL */
|
||||
public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); }
|
||||
|
||||
/* ACROBATICS */
|
||||
public double getDodgeChanceMax() { return config.getDouble("Skills.Acrobatics.Dodge_ChanceMax", 20.0D); }
|
||||
public int getDodgeMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Dodge_MaxBonusLevel", 800); }
|
||||
|
||||
public double getRollChanceMax() { return config.getDouble("Skills.Acrobatics.Roll_ChanceMax", 100.0D); }
|
||||
public int getRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Roll_MaxBonusLevel", 1000); }
|
||||
|
||||
public double getGracefulRollChanceMax() { return config.getDouble("Skills.Acrobatics.GracefulRoll_ChanceMax", 100.0D); }
|
||||
public int getGracefulRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.GracefulRoll_MaxBonusLevel", 500); }
|
||||
|
||||
public int getDodgeXPModifier() { return config.getInt("Skills.Acrobatics.Dodge_XP_Modifier", 120); }
|
||||
public int getRollXPModifier() { return config.getInt("Skills.Acrobatics.Roll_XP_Modifier", 80); }
|
||||
public int getFallXPModifier() { return config.getInt("Skills.Acrobatics.Fall_XP_Modifier", 120); }
|
||||
|
||||
/* ARCHERY */
|
||||
public int getSkillShotIncreaseLevel() { return config.getInt("Skills.Archery.SkillShot_IncreaseLevel", 50); }
|
||||
public double getSkillShotIncreasePercentage() { return config.getDouble("Skills.Archery.SkillShot_IncreasePercentage", 0.1D); }
|
||||
public double getSkillShotBonusMax() { return config.getDouble("Skills.Archery.SkillShot_MaxBonus", 2.0D); }
|
||||
|
||||
public double getDazeBonusMax() { return config.getDouble("Skills.Archery.Daze_MaxChance", 50.0D); }
|
||||
public int getDazeMaxBonusLevel() { return config.getInt("Skills.Archery.Daze_MaxBonusLevel", 1000); }
|
||||
public int getDazeModifier() { return config.getInt("Skills.Archery.Daze_BonusDamage", 4); }
|
||||
|
||||
public double getRetrieveChanceMax() { return config.getDouble("Skills.Archery.Retrieve_MaxBonus", 100.0D); }
|
||||
public int getRetrieveMaxBonusLevel() { return config.getInt("Skills.Archery.Retrieve_MaxBonusLevel", 1000); }
|
||||
|
||||
/* AXES */
|
||||
public int getBonusDamageAxesBonusMax() { return config.getInt("Skills.Axes.DamageIncrease_MaxBonus", 4); }
|
||||
public int getBonusDamageAxesMaxBonusLevel() { return config.getInt("Skills.Axes.DamageIncrease_MaxBonusLevel", 200); }
|
||||
|
||||
public double getAxesCriticalChance() { return config.getDouble("Skills.Axes.AxesCritical_MaxChance", 37.50D); }
|
||||
public int getAxesCriticalMaxBonusLevel() { return config.getInt("Skills.Axes.AxesCritical_MaxBonusLevel", 750); }
|
||||
public double getAxesCriticalPVPModifier() { return config.getDouble("Skills.Axes.AxesCritical_PVP_Modifier", 1.5D); }
|
||||
public double getAxesCriticalPVEModifier() { return config.getDouble("Skills.Axes.AxesCritical_PVE_Modifier", 2.0D); }
|
||||
|
||||
public double getGreaterImpactChance() { return config.getDouble("Skills.Axes.GreaterImpact_Chance", 25.0D); }
|
||||
public double getGreaterImpactModifier() { return config.getDouble("Skills.Axes.GreaterImpact_KnockbackModifier", 1.5); }
|
||||
public int getGreaterImpactBonusDamage() { return config.getInt("Skills.Axes.GreaterImpact_BonusDamage", 2); }
|
||||
|
||||
public int getArmorImpactIncreaseLevel() { return config.getInt("Skills.Axes.ArmorImpact_IncreaseLevel", 50); }
|
||||
public double getArmorImpactMaxDurabilityDamage() { return config.getDouble("Skills.Axes.ArmorImpact_MaxPercentageDurabilityDamage", 20.0D); }
|
||||
|
||||
public int getSkullSplitterModifier() { return config.getInt("Skills.Axes.SkullSplitter_DamagerModifier", 2); }
|
||||
|
||||
/* EXCAVATION */
|
||||
//Nothing to configure, everything is already configurable in config.yml
|
||||
|
||||
/* FISHING */
|
||||
public int getFishingTierLevelsTier1() { return config.getInt("Skills.Fishing.Tier_Levels.Tier1", 0); }
|
||||
public int getFishingTierLevelsTier2() { return config.getInt("Skills.Fishing.Tier_Levels.Tier2", 200); }
|
||||
public int getFishingTierLevelsTier3() { return config.getInt("Skills.Fishing.Tier_Levels.Tier3", 400); }
|
||||
public int getFishingTierLevelsTier4() { return config.getInt("Skills.Fishing.Tier_Levels.Tier4", 600); }
|
||||
public int getFishingTierLevelsTier5() { return config.getInt("Skills.Fishing.Tier_Levels.Tier5", 800); }
|
||||
|
||||
public int getFishingMagicMultiplier() { return config.getInt("Skills.Fishing.MagicHunter_Multiplier", 5); }
|
||||
|
||||
public int getFishermanDietRankChange() { return config.getInt("Skills.Fishing.Fisherman_Diet_RankChange", 200); }
|
||||
|
||||
/* Shake */
|
||||
public int getShakeUnlockLevel() { return config.getInt("Skills.Fishing.Shake_UnlockLevel", 150); }
|
||||
public int getShakeChanceRank1() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_1", 25); }
|
||||
public int getShakeChanceRank2() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_2", 40); }
|
||||
public int getShakeChanceRank3() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_3", 55); }
|
||||
public int getShakeChanceRank4() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_4", 60); }
|
||||
public int getShakeChanceRank5() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_5", 75); }
|
||||
|
||||
/* Vanilla XP Boost */
|
||||
public int getFishingVanillaXPModifierRank1() { return config.getInt("Skills.Fishing.VanillaXPBoost.Rank_1", 1); }
|
||||
public int getFishingVanillaXPModifierRank2() { return config.getInt("Skills.Fishing.VanillaXPBoost.Rank_2", 2); }
|
||||
public int getFishingVanillaXPModifierRank3() { return config.getInt("Skills.Fishing.VanillaXPBoost.Rank_3", 3); }
|
||||
public int getFishingVanillaXPModifierRank4() { return config.getInt("Skills.Fishing.VanillaXPBoost.Rank_4", 4); }
|
||||
public int getFishingVanillaXPModifierRank5() { return config.getInt("Skills.Fishing.VanillaXPBoost.Rank_5", 5); }
|
||||
|
||||
/* HERBALISM */
|
||||
public int getFarmerDietRankChange() { return config.getInt("Skills.Herbalism.Farmer_Diet_RankChange", 200); }
|
||||
|
||||
public int getGreenThumbStageChange() { return config.getInt("Skills.Herbalism.GreenThumb_StageChange", 200); }
|
||||
public double getGreenThumbChanceMax() { return config.getDouble("Skills.Herbalism.GreenThumb_ChanceMax", 100.0D); }
|
||||
public int getGreenThumbMaxLevel() { return config.getInt("Skills.Herbalism.GreenThumb_MaxBonusLevel", 1500); }
|
||||
|
||||
public double getHerbalismDoubleDropsChanceMax() { return config.getDouble("Skills.Herbalism.DoubleDrops_ChanceMax", 100.0D); }
|
||||
public int getHerbalismDoubleDropsMaxLevel() { return config.getInt("Skills.Herbalism.DoubleDrops_MaxBonusLevel", 1000); }
|
||||
|
||||
public double getHylianLuckChanceMax() { return config.getDouble("Skills.Herbalism.HylianLuck_ChanceMax", 10.0D); }
|
||||
public int getHylianLucksMaxLevel() { return config.getInt("Skills.Herbalism.HylianLuck_MaxBonusLevel", 1000); }
|
||||
|
||||
/* MINING */
|
||||
public double getMiningDoubleDropChance() { return config.getDouble("Skills.Mining.DoubleDrops_ChanceMax", 100.0D); }
|
||||
public int getMiningDoubleDropMaxLevel() { return config.getInt("Skills.Mining.DoubleDrops_MaxBonusLevel", 1000); }
|
||||
|
||||
public int getBlastMiningRank1() { return config.getInt("Skills.Mining.BlastMining_Rank1", 125); }
|
||||
public int getBlastMiningRank2() { return config.getInt("Skills.Mining.BlastMining_Rank2", 250); }
|
||||
public int getBlastMiningRank3() { return config.getInt("Skills.Mining.BlastMining_Rank3", 375); }
|
||||
public int getBlastMiningRank4() { return config.getInt("Skills.Mining.BlastMining_Rank4", 500); }
|
||||
public int getBlastMiningRank5() { return config.getInt("Skills.Mining.BlastMining_Rank5", 625); }
|
||||
public int getBlastMiningRank6() { return config.getInt("Skills.Mining.BlastMining_Rank6", 750); }
|
||||
public int getBlastMiningRank7() { return config.getInt("Skills.Mining.BlastMining_Rank7", 875); }
|
||||
public int getBlastMiningRank8() { return config.getInt("Skills.Mining.BlastMining_Rank8", 1000); }
|
||||
|
||||
/* REPAIR */
|
||||
public double getRepairMasteryMaxBonus() { return config.getDouble("Skills.Repair.RepairMastery_MaxBonusPercentage", 200.0D); }
|
||||
public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery_MaxBonusLevel", 1000); }
|
||||
public double getSuperRepairChanceMax() { return config.getDouble("Skills.Repair.SuperRepair_ChanceMax", 100.0D); }
|
||||
public int getSuperRepairMaxLevel() { return config.getInt("Skills.Repair.SuperRepair_MaxBonusLevel", 1000); }
|
||||
|
||||
/* Arcane Forging */
|
||||
public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Skills.Repair.Arcane_Forging.Downgrades.Enabled", true); }
|
||||
public int getArcaneForgingDowngradeChanceRank1() { return config.getInt("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_1", 75); }
|
||||
public int getArcaneForgingDowngradeChanceRank2() { return config.getInt("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_2", 50); }
|
||||
public int getArcaneForgingDowngradeChanceRank3() { return config.getInt("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_3", 25); }
|
||||
public int getArcaneForgingDowngradeChanceRank4() { return config.getInt("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_4", 15); }
|
||||
public boolean getArcaneForgingEnchantLossEnabled() { return config.getBoolean("Skills.Repair.Arcane_Forging.May_Lose_Enchants", true); }
|
||||
public int getArcaneForgingKeepEnchantsChanceRank1() { return config.getInt("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_1", 10); }
|
||||
public int getArcaneForgingKeepEnchantsChanceRank2() { return config.getInt("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_2", 20); }
|
||||
public int getArcaneForgingKeepEnchantsChanceRank3() { return config.getInt("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_3", 30); }
|
||||
public int getArcaneForgingKeepEnchantsChanceRank4() { return config.getInt("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_4", 40); }
|
||||
public int getArcaneForgingRankLevels1() { return config.getInt("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_1", 100); }
|
||||
public int getArcaneForgingRankLevels2() { return config.getInt("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_2", 250); }
|
||||
public int getArcaneForgingRankLevels3() { return config.getInt("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_3", 500); }
|
||||
public int getArcaneForgingRankLevels4() { return config.getInt("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_4", 750); }
|
||||
|
||||
/* SMELTING */
|
||||
public int getBurnModifierMaxLevel() { return config.getInt("Skills.Smelting.FuelEfficiency_MaxBonusLevel", 1000); }
|
||||
public double getBurnTimeMultiplier() { return config.getDouble("Skills.Smelting.FuelEfficiency_Multiplier", 3.0D); }
|
||||
|
||||
public int getSecondSmeltMaxLevel() { return config.getInt("Skills.Smelting.SecondSmelt_MaxBonusLevel", 1000); }
|
||||
public double getSecondSmeltMaxChance() { return config.getDouble("Skills.Smelting.SecondSmelt_MaxBonusChance", 100.0D); }
|
||||
|
||||
public int getFluxMiningUnlockLevel() { return config.getInt("Skills.Smelting.FluxMining_UnlockLevel", 250); }
|
||||
public double getFluxMiningChance() { return config.getDouble("Skills.Smelting.FluxMining_Chance", 33.0D); }
|
||||
|
||||
public int getSmeltingVanillaXPBoostRank1Level() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank1Level", 100); }
|
||||
public int getSmeltingVanillaXPBoostRank2Level() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank2Level", 300); }
|
||||
public int getSmeltingVanillaXPBoostRank3Level() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank3Level", 500); }
|
||||
public int getSmeltingVanillaXPBoostRank4Level() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank4Level", 700); }
|
||||
public int getSmeltingVanillaXPBoostRank5Level() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank5Level", 900); }
|
||||
|
||||
public int getSmeltingVanillaXPBoostRank1Multiplier() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank1Multiplier", 2); }
|
||||
public int getSmeltingVanillaXPBoostRank2Multiplier() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank2Multiplier", 3); }
|
||||
public int getSmeltingVanillaXPBoostRank3Multiplier() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank3Multiplier", 4); }
|
||||
public int getSmeltingVanillaXPBoostRank4Multiplier() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank4Multiplier", 5); }
|
||||
public int getSmeltingVanillaXPBoostRank5Multiplier() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank5Multiplier", 6); }
|
||||
|
||||
/* SWORDS */
|
||||
public double getBleedChanceMax() { return config.getDouble("Skills.Swords.Bleed_ChanceMax", 75.0D); }
|
||||
public int getBleedMaxBonusLevel() { return config.getInt("Skills.Swords.Bleed_MaxBonusLevel", 750); }
|
||||
public int getBleedMaxTicks() { return config.getInt("Skills.Swords.Bleed_MaxTicks", 3); }
|
||||
public int getBleedBaseTicks() { return config.getInt("Skills.Swords.Bleed_BaseTicks", 2); }
|
||||
|
||||
public double getCounterChanceMax() { return config.getDouble("Skills.Swords.Counter_ChanceMax", 30.0D); }
|
||||
public int getCounterMaxBonusLevel() { return config.getInt("Skills.Swords.Counter_MaxBonusLevel", 600); }
|
||||
public int getCounterModifier() { return config.getInt("Skills.Swords.Counter_DamageModifier", 2); }
|
||||
|
||||
public int getSerratedStrikesModifier() { return config.getInt("Skills.Swords.SerratedStrikes_DamageModifier", 4); }
|
||||
public int getSerratedStrikesTicks() { return config.getInt("Skills.Swords.SerratedStrikes_BleedTicks", 5); }
|
||||
|
||||
/* TAMING */
|
||||
public double getGoreChanceMax() { return config.getInt("Skills.Taming.Gore_ChanceMax", 100); }
|
||||
public int getGoreMaxBonusLevel() { return config.getInt("Skills.Taming.Gore_MaxBonusLevel", 1000); }
|
||||
public int getGoreBleedTicks() { return config.getInt("Skills.Taming.Gore_BleedTicks", 2); }
|
||||
public int getGoreModifier() { return config.getInt("Skills.Taming.Gore_Modifier", 2); }
|
||||
|
||||
public int getFastFoodUnlock() { return config.getInt("Skills.Taming.FastFood_UnlockLevel", 50); }
|
||||
public double getFastFoodChance() { return config.getInt("Skills.Taming.FastFood_Chance", 50); }
|
||||
|
||||
public int getEnviromentallyAwareUnlock() { return config.getInt("Skills.Taming.EnvironmentallyAware_UnlockLevel", 100); }
|
||||
|
||||
public int getThickFurUnlock() { return config.getInt("Skills.Taming.ThickFur_UnlockLevel", 250); }
|
||||
public int getThickFurModifier() { return config.getInt("Skills.Taming.ThickFur_Modifier", 2); }
|
||||
|
||||
public int getShockProofUnlock() { return config.getInt("Skills.Taming.ShockProof_UnlockLevel", 500); }
|
||||
public int getShockProofModifier() { return config.getInt("Skills.Taming.ShockProof_Modifier", 6); }
|
||||
|
||||
public int getSharpenedClawsUnlock() { return config.getInt("Skills.Taming.SharpenedClaws_UnlockLevel", 750); }
|
||||
public int getSharpenedClawsBonus() { return config.getInt("Skills.Taming.SharpenedClaws_Bonus", 2); }
|
||||
|
||||
/* UNARMED */
|
||||
public double getDisarmChanceMax() { return config.getDouble("Skills.Unarmed.Disarm_ChanceMax", 33.0D); }
|
||||
public int getDisarmMaxBonusLevel() { return config.getInt("Skills.Unarmed.Disarm_MaxBonusLevel", 1000); }
|
||||
|
||||
public double getDeflectChanceMax() { return config.getDouble("Skills.Unarmed.Deflect_ChanceMax", 50.0D); }
|
||||
public int getDeflectMaxBonusLevel() { return config.getInt("Skills.Unarmed.Deflect_MaxBonusLevel", 1000); }
|
||||
|
||||
public double getIronGripChanceMax() { return config.getDouble("Skills.Unarmed.IronGrip_ChanceMax", 100.0D); }
|
||||
public int getIronGripMaxBonusLevel() { return config.getInt("Skills.Unarmed.IronGrip_MaxBonusLevel", 1000); }
|
||||
|
||||
public int getIronArmMaxBonus() { return config.getInt("Skills.Unarmed.IronArm_BonusMax", 8); }
|
||||
public int getIronArmIncreaseLevel() { return config.getInt("Skills.Unarmed.IronArm_IncreaseLevel", 50); }
|
||||
|
||||
/* WOODCUTTING */
|
||||
public int getLeafBlowUnlockLevel() { return config.getInt("Skills.Woodcutting.LeafBlower_UnlockLevel", 100); }
|
||||
|
||||
public double getWoodcuttingDoubleDropChance() { return config.getDouble("Skills.Woodcutting.DoubleDrops_ChanceMax", 100.0D); }
|
||||
public int getWoodcuttingDoubleDropMaxLevel() { return config.getInt("Skills.Woodcutting.DoubleDrops_MaxBonusLevel", 1000); }
|
||||
|
||||
/* SPOUT STUFF*/
|
||||
public int getSpoutNotificationTier1() { return config.getInt("Spout.Notifications.Tier1", 200); }
|
||||
public int getSpoutNotificationTier2() { return config.getInt("Spout.Notifications.Tier2", 400); }
|
||||
public int getSpoutNotificationTier3() { return config.getInt("Spout.Notifications.Tier3", 600); }
|
||||
public int getSpoutNotificationTier4() { return config.getInt("Spout.Notifications.Tier4", 800); }
|
||||
}
|
||||
@@ -1,17 +1,14 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class Config extends ConfigLoader {
|
||||
private static Config instance;
|
||||
public double xpGainMultiplier = 1;
|
||||
|
||||
private Config() {
|
||||
super("config.yml");
|
||||
xpGainMultiplier = getExperienceGainsGlobalMultiplier();
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@@ -33,25 +30,40 @@ public class Config extends ConfigLoader {
|
||||
/* General Settings */
|
||||
public String getLocale() { return config.getString("General.Locale", "en_us"); }
|
||||
public boolean getMOTDEnabled() { return config.getBoolean("General.MOTD_Enabled", true); }
|
||||
public boolean getDonateMessageEnabled() { return config.getBoolean("Commands.mcmmo.Donate_Message", true); }
|
||||
public int getSaveInterval() { return config.getInt("General.Save_Interval", 10); }
|
||||
public boolean getStatsTrackingEnabled() { return config.getBoolean("General.Stats_Tracking", true); }
|
||||
public boolean getEventCallbackEnabled() { return config.getBoolean("General.Event_Callback", true); }
|
||||
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); }
|
||||
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); }
|
||||
|
||||
/* Database Purging */
|
||||
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
|
||||
public int getOldUsersCutoff() { return config.getInt("Database_Purging.Old_User_Cutoff", 6); }
|
||||
|
||||
/* mySQL */
|
||||
public boolean getUseMySQL() { return config.getBoolean("MySQL.Enabled", false); }
|
||||
public String getMySQLTablePrefix() { return config.getString("MySQL.Database.TablePrefix", "mcmmo_"); }
|
||||
public String getMySQLDatabaseName() { return config.getString("MySQL.Database.Name", "DatabaseName"); }
|
||||
public String getMySQLUserName() { return config.getString("MySQL.Database.User_Name", "UserName"); } //Really should be labeled under MySQL.User_Name instead...
|
||||
public String getMySQLDatabaseName() { return getStringIncludingInts(config, "MySQL.Database.Name"); }
|
||||
public String getMySQLUserName() { return getStringIncludingInts(config, "MySQL.Database.User_Name"); }
|
||||
public int getMySQLServerPort() { return config.getInt("MySQL.Server.Port", 3306); }
|
||||
public String getMySQLServerName() { return config.getString("MySQL.Server.Address", "localhost"); }
|
||||
|
||||
public String getMySQLUserPassword() {
|
||||
if (config.getString("MySQL.Database.User_Password", null) != null) {
|
||||
return config.getString("MySQL.Database.User_Password", null);
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
if (getStringIncludingInts(config, "MySQL.Database.User_Password") != null) {
|
||||
return getStringIncludingInts(config, "MySQL.Database.User_Password");
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String getStringIncludingInts(ConfigurationSection cfg, String key) {
|
||||
String str = cfg.getString(key);
|
||||
if (str == null)
|
||||
str = String.valueOf(cfg.getInt(key));
|
||||
if (str == null)
|
||||
str = "No value set for '" + key + "'";
|
||||
return str;
|
||||
}
|
||||
|
||||
/* Hardcore Mode */
|
||||
@@ -65,31 +77,10 @@ public class Config extends ConfigLoader {
|
||||
public boolean getArmorModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
|
||||
public boolean getBlockModsEnabled() { return config.getBoolean("Mods.Block_Mods_Enabled", false); }
|
||||
|
||||
/* Commands */
|
||||
public boolean getCommandXPLockEnabled() { return config.getBoolean("Commands.xplock.Enabled", true); }
|
||||
public boolean getCommandXPRateEnabled() { return config.getBoolean("Commands.xprate.Enabled", true); }
|
||||
public boolean getCommandMCTopEnabled() { return config.getBoolean("Commands.mctop.Enabled", true); }
|
||||
public boolean getCommandAddXPEnabled() { return config.getBoolean("Commands.addxp.Enabled", true); }
|
||||
public boolean getCommandAddLevelsEnabled() { return config.getBoolean("Commands.addlevels.Enabled", true); }
|
||||
public boolean getCommandMCAbilityEnabled() { return config.getBoolean("Commands.mcability.Enabled", true); }
|
||||
public boolean getCommandMCRefreshEnabled() { return config.getBoolean("Commands.mcrefresh.Enabled", true); }
|
||||
public boolean getCommandmcMMOEnabled() { return config.getBoolean("Commands.mcmmo.Enabled", true); }
|
||||
public boolean getCommandMCCEnabled() { return config.getBoolean("Commands.mcc.Enabled", true); }
|
||||
public boolean getCommandMCGodEnabled() { return config.getBoolean("Commands.mcgod.Enabled", true); }
|
||||
public boolean getCommandMCStatsEnabled() { return config.getBoolean("Commands.mcstats.Enabled", true); }
|
||||
public boolean getCommandSkillResetEnabled() { return config.getBoolean("Commands.skillreset.Enabled", true); }
|
||||
public boolean getCommandMmoeditEnabled() { return config.getBoolean("Commands.mmoedit.Enabled", true); }
|
||||
public boolean getCommandMCRemoveEnabled() { return config.getBoolean("Commands.mcremove.Enable", true); }
|
||||
public boolean getCommandPTPEnabled() { return config.getBoolean("Commands.ptp.Enabled", true); }
|
||||
public boolean getCommandPartyEnabled() { return config.getBoolean("Commands.party.Enabled", true); }
|
||||
public boolean getCommandInspectEnabled() { return config.getBoolean("Commands.inspect.Enabled", true); }
|
||||
public boolean getCommandInviteEnabled() { return config.getBoolean("Commands.invite.Enabled", true); }
|
||||
public boolean getCommandAcceptEnabled() { return config.getBoolean("Commands.accept.Enabled", true); }
|
||||
public boolean getCommandAdminChatAEnabled() { return config.getBoolean("Commands.a.Enabled", true); }
|
||||
public boolean getCommandPartyChatPEnabled() { return config.getBoolean("Commands.p.Enabled", true); }
|
||||
|
||||
/* Party Teleport Settings */
|
||||
public int getPTPCommandCooldown() { return config.getInt("Commands.ptp.Cooldown", 30); }
|
||||
public boolean getDonateMessageEnabled() { return config.getBoolean("Commands.mcmmo.Donate_Message", true); }
|
||||
public int getPTPCommandTimeout() { return config.getInt("Commands.ptp.Request_Timeout", 300); }
|
||||
public boolean getPTPCommandConfirmRequired() { return config.getBoolean("Commands.ptp.Confirm_Required", true); }
|
||||
|
||||
/* Items */
|
||||
public int getChimaeraCost() { return config.getInt("Items.Chimaera_Wing.Feather_Cost", 10); }
|
||||
@@ -142,23 +133,17 @@ public class Config extends ConfigLoader {
|
||||
public boolean getWoodcuttingRequiresTool() { return config.getBoolean("Skills.Woodcutting.Requires_Axe", true); }
|
||||
|
||||
/* Excavation */
|
||||
public int getExcavationBaseXP() { return config.getInt("Experience.Excavation.Base", 40); }
|
||||
public int getExcavationClayXP() { return config.getInt("Experience.Excavation.Clay", 40); }
|
||||
public int getExcavationDirtXP() { return config.getInt("Experience.Excavation.Dirt", 40); }
|
||||
public int getExcavationGrassXP() { return config.getInt("Experience.Excavation.Grass", 40); }
|
||||
public int getExcavationGravelXP() { return config.getInt("Experience.Excavation.Gravel", 40); }
|
||||
public int getExcavationMycelXP() { return config.getInt("Experience.Excavation.Mycel", 40); }
|
||||
public int getExcavationSandXP() { return config.getInt("Experience.Excavation.Sand", 40); }
|
||||
public int getExcavationSoulSandXP() { return config.getInt("Experience.Excavation.SoulSand", 40); }
|
||||
|
||||
/* Fishing */
|
||||
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
|
||||
public boolean getFishingDropsEnabled() { return config.getBoolean("Fishing.Drops_Enabled", true); }
|
||||
public int getFishingTierLevelsTier1() { return config.getInt("Fishing.Tier_Levels.Tier1", 0); }
|
||||
public int getFishingTierLevelsTier2() { return config.getInt("Fishing.Tier_Levels.Tier2", 200); }
|
||||
public int getFishingTierLevelsTier3() { return config.getInt("Fishing.Tier_Levels.Tier3", 400); }
|
||||
public int getFishingTierLevelsTier4() { return config.getInt("Fishing.Tier_Levels.Tier4", 600); }
|
||||
public int getFishingTierLevelsTier5() { return config.getInt("Fishing.Tier_Levels.Tier5", 800); }
|
||||
|
||||
/* Shake */
|
||||
public int getShakeChanceRank1() { return config.getInt("Shake.Chance.Rank_1", 25); }
|
||||
public int getShakeChanceRank2() { return config.getInt("Shake.Chance.Rank_2", 40); }
|
||||
public int getShakeChanceRank3() { return config.getInt("Shake.Chance.Rank_3", 55); }
|
||||
public int getShakeChanceRank4() { return config.getInt("Shake.Chance.Rank_4", 60); }
|
||||
public int getShakeChanceRank5() { return config.getInt("Shake.Chance.Rank_5", 75); }
|
||||
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
|
||||
|
||||
/* Herbalism */
|
||||
public int getHerbalismXPSugarCane() { return config.getInt("Experience.Herbalism.Sugar_Cane", 30); }
|
||||
@@ -197,22 +182,7 @@ public class Config extends ConfigLoader {
|
||||
public boolean getPotatoDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Potato", true); }
|
||||
|
||||
public boolean herbalismDoubleDropsDisabled() {
|
||||
ConfigurationSection section = config.getConfigurationSection("Double_Drops.Herbalism");
|
||||
Set<String> keys = section.getKeys(false);
|
||||
Iterator<String> iterator = keys.iterator();
|
||||
|
||||
boolean disabled = true;
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String key = iterator.next();
|
||||
|
||||
if (config.getBoolean("Double_Drops.Herbalism." + key)) {
|
||||
disabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return disabled;
|
||||
return doubleDropsDisabled("Herbalism");
|
||||
}
|
||||
|
||||
/* Mining */
|
||||
@@ -247,22 +217,7 @@ public class Config extends ConfigLoader {
|
||||
public boolean getEmeraldDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Emerald", true); }
|
||||
|
||||
public boolean miningDoubleDropsDisabled() {
|
||||
ConfigurationSection section = config.getConfigurationSection("Double_Drops.Mining");
|
||||
Set<String> keys = section.getKeys(false);
|
||||
Iterator<String> iterator = keys.iterator();
|
||||
|
||||
boolean disabled = true;
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String key = iterator.next();
|
||||
|
||||
if (config.getBoolean("Double_Drops.Mining." + key)) {
|
||||
disabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return disabled;
|
||||
return doubleDropsDisabled("Mining");
|
||||
}
|
||||
|
||||
public int getDetonatorItemID() { return config.getInt("Skills.Mining.Detonator_ID", 259); }
|
||||
@@ -270,6 +225,20 @@ public class Config extends ConfigLoader {
|
||||
/* Repair */
|
||||
public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); }
|
||||
public int getRepairAnvilId() { return config.getInt("Skills.Repair.Anvil_ID", 42); }
|
||||
public boolean getSalvageEnabled() { return config.getBoolean("Skills.Repair.Salvage_enabled", true); }
|
||||
public int getSalvageAnvilId() { return config.getInt("Skills.Repair.Salvage_Anvil_ID", 41); }
|
||||
public int getSalvageUnlockLevel() { return config.getInt("Skills.Repair.Salvage_UnlockLevel", 600); }
|
||||
public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
|
||||
public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); }
|
||||
|
||||
/* Smelting */
|
||||
public int getSmeltingXPCoal() { return config.getInt("Experience.Smelting.Coal", 10); }
|
||||
public int getSmeltingXPRedstone() { return config.getInt("Experience.Smelting.Redstone", 15); }
|
||||
public int getSmeltingXPIron() { return config.getInt("Experience.Smelting.Iron", 25); }
|
||||
public int getSmeltingXPGold() { return config.getInt("Experience.Smelting.Gold", 35); }
|
||||
public int getSmeltingXPDiamond() { return config.getInt("Experience.Smelting.Diamond", 75); }
|
||||
public int getSmeltingXPLapis() { return config.getInt("Experience.Smelting.Lapis", 40); }
|
||||
public int getSmeltingXPEmerald() { return config.getInt("Experience.Smelting.Emerald", 100); }
|
||||
|
||||
/* Taming */
|
||||
public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); }
|
||||
@@ -289,58 +258,72 @@ public class Config extends ConfigLoader {
|
||||
public boolean getJungleDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Jungle", true); }
|
||||
|
||||
public boolean woodcuttingDoubleDropsDisabled() {
|
||||
ConfigurationSection section = config.getConfigurationSection("Double_Drops.Woodcutting");
|
||||
Set<String> keys = section.getKeys(false);
|
||||
Iterator<String> iterator = keys.iterator();
|
||||
|
||||
boolean disabled = true;
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String key = iterator.next();
|
||||
|
||||
if (config.getBoolean("Double_Drops.Woodcutting." + key)) {
|
||||
disabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return disabled;
|
||||
return doubleDropsDisabled("Woodcutting");
|
||||
}
|
||||
|
||||
/* AFK Leveling */
|
||||
public boolean getAcrobaticsAFKDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
|
||||
public boolean getHerbalismAFKDisabled() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
|
||||
|
||||
/* Arcane Forging */
|
||||
public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Arcane_Forging.Downgrades.Enabled", true); }
|
||||
public int getArcaneForgingDowngradeChanceRank1() { return config.getInt("Arcane_Forging.Downgrades.Chance.Rank_1", 75); }
|
||||
public int getArcaneForgingDowngradeChanceRank2() { return config.getInt("Arcane_Forging.Downgrades.Chance.Rank_2", 50); }
|
||||
public int getArcaneForgingDowngradeChanceRank3() { return config.getInt("Arcane_Forging.Downgrades.Chance.Rank_3", 25); }
|
||||
public int getArcaneForgingDowngradeChanceRank4() { return config.getInt("Arcane_Forging.Downgrades.Chance.Rank_4", 15); }
|
||||
public boolean getArcaneForgingEnchantLossEnabled() { return config.getBoolean("Arcane_Forging.May_Lose_Enchants", true); }
|
||||
public int getArcaneForgingKeepEnchantsChanceRank1() { return config.getInt("Arcane_Forging.Keep_Enchants.Chance.Rank_1", 10); }
|
||||
public int getArcaneForgingKeepEnchantsChanceRank2() { return config.getInt("Arcane_Forging.Keep_Enchants.Chance.Rank_2", 20); }
|
||||
public int getArcaneForgingKeepEnchantsChanceRank3() { return config.getInt("Arcane_Forging.Keep_Enchants.Chance.Rank_3", 30); }
|
||||
public int getArcaneForgingKeepEnchantsChanceRank4() { return config.getInt("Arcane_Forging.Keep_Enchants.Chance.Rank_4", 40); }
|
||||
public int getArcaneForgingRankLevels1() { return config.getInt("Arcane_Forging.Rank_Levels.Rank_1", 100); }
|
||||
public int getArcaneForgingRankLevels2() { return config.getInt("Arcane_Forging.Rank_Levels.Rank_2", 250); }
|
||||
public int getArcaneForgingRankLevels3() { return config.getInt("Arcane_Forging.Rank_Levels.Rank_3", 500); }
|
||||
public int getArcaneForgingRankLevels4() { return config.getInt("Arcane_Forging.Rank_Levels.Rank_4", 750); }
|
||||
/* Dogde Lightning */
|
||||
public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
|
||||
|
||||
/* Level Caps */
|
||||
public int getLevelCapAcrobatics() { return config.getInt("Skills.Acrobatics.Level_Cap", 0); }
|
||||
public int getLevelCapArchery() { return config.getInt("Skills.Archery.Level_Cap", 0); }
|
||||
public int getLevelCapAxes() { return config.getInt("Skills.Axes.Level_Cap", 0); }
|
||||
public int getLevelCapExcavation() { return config.getInt("Skills.Excavation.Level_Cap", 0); }
|
||||
public int getLevelCapFishing() { return config.getInt("Skills.Fishing.Level_Cap", 0); }
|
||||
public int getLevelCapHerbalism() { return config.getInt("Skills.Herbalism.Level_Cap", 0); }
|
||||
public int getLevelCapMining() { return config.getInt("Skills.Mining.Level_Cap", 0); }
|
||||
public int getLevelCapRepair() { return config.getInt("Skills.Repair.Level_Cap", 0); }
|
||||
public int getLevelCapSwords() { return config.getInt("Skills.Swords.Level_Cap", 0); }
|
||||
public int getLevelCapTaming() { return config.getInt("Skills.Taming.Level_Cap", 0); }
|
||||
public int getLevelCapUnarmed() { return config.getInt("Skills.Unarmed.Level_Cap", 0); }
|
||||
public int getLevelCapWoodcutting() { return config.getInt("Skills.Woodcutting.Level_Cap", 0); }
|
||||
public int getPowerLevelCap() { return config.getInt("General.Power_Level_Cap", 0); }
|
||||
public int getLevelCapAcrobatics() {
|
||||
return getLevelCap("Skills.Acrobatics.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapArchery() {
|
||||
return getLevelCap("Skills.Archery.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapAxes() {
|
||||
return getLevelCap("Skills.Axes.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapExcavation() {
|
||||
return getLevelCap("Skills.Excavation.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapFishing() {
|
||||
return getLevelCap("Skills.Fishing.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapHerbalism() {
|
||||
return getLevelCap("Skills.Herbalism.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapMining() {
|
||||
return getLevelCap("Skills.Mining.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapRepair() {
|
||||
return getLevelCap("Skills.Repair.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapSmelting() {
|
||||
return getLevelCap("Skills.Smelting.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapSwords() {
|
||||
return getLevelCap("Skills.Swords.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapTaming() {
|
||||
return getLevelCap("Skills.Taming.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapUnarmed() {
|
||||
return getLevelCap("Skills.Unarmed.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapWoodcutting() {
|
||||
return getLevelCap("Skills.Woodcutting.Level_Cap");
|
||||
}
|
||||
|
||||
public int getPowerLevelCap() {
|
||||
return getLevelCap("General.Power_Level_Cap");
|
||||
}
|
||||
|
||||
/* PVP & PVE Settings */
|
||||
public boolean getAcrobaticsPVP() { return config.getBoolean("Skills.Acrobatics.Enabled_For_PVP", true); }
|
||||
@@ -364,6 +347,7 @@ public class Config extends ConfigLoader {
|
||||
public boolean getExperienceGainsMobspawnersEnabled() { return config.getBoolean("Experience.Gains.Mobspawners.Enabled", false); }
|
||||
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
|
||||
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience.Gains.Multiplier.Global", 1.0); }
|
||||
public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience.Gains.Multiplier.Global", value); }
|
||||
|
||||
/* Combat XP Multipliers */
|
||||
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience.Gains.Multiplier.PVP", 1.0); }
|
||||
@@ -382,6 +366,10 @@ public class Config extends ConfigLoader {
|
||||
public double getMagmaCubeXP() { return config.getDouble("Experience.Combat.Multiplier.Magma_Cube", 2.0); }
|
||||
public double getEnderDragonXP() { return config.getDouble("Experience.Combat.Multiplier.Ender_Dragon", 8.0); }
|
||||
public double getIronGolemXP() { return config.getDouble("Experience.Combat.Multiplier.Iron_Golem", 2.0); }
|
||||
public double getGiantXP() { return config.getDouble("Experience.Combat.Multiplier.Giant", 4.0); }
|
||||
public double getWitherXP() { return config.getDouble("Experience.Combat.Multiplier.Wither", 7.0); }
|
||||
public double getWitherSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Wither_Skeleton", 4.0); }
|
||||
public double getWitchXP() { return config.getDouble("Experience.Combat.Multiplier.Witch", 4.0); }
|
||||
|
||||
/* XP Formula Multiplier */
|
||||
public int getFormulaMultiplierCurve() { return config.getInt("Experience.Formula.Curve_Modifier", 20); }
|
||||
@@ -397,4 +385,31 @@ public class Config extends ConfigLoader {
|
||||
public double getFormulaMultiplierAxes() { return config.getDouble("Experience.Formula.Multiplier.Axes", 1.0); }
|
||||
public double getFormulaMultiplierAcrobatics() { return config.getDouble("Experience.Formula.Multiplier.Acrobatics", 1.0); }
|
||||
public double getFormulaMultiplierFishing() { return config.getDouble("Experience.Formula.Multiplier.Fishing", 1.0); }
|
||||
|
||||
private boolean doubleDropsDisabled(String skillName) {
|
||||
ConfigurationSection section = config.getConfigurationSection("Double_Drops." + skillName);
|
||||
Set<String> keys = section.getKeys(false);
|
||||
|
||||
boolean disabled = true;
|
||||
|
||||
for (String key : keys) {
|
||||
if (config.getBoolean("Double_Drops." + skillName + "." + key)) {
|
||||
disabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return disabled;
|
||||
}
|
||||
|
||||
private int getLevelCap(String configString) {
|
||||
int cap = config.getInt(configString, 0);
|
||||
return ((cap <= 0) ? Integer.MAX_VALUE : cap);
|
||||
}
|
||||
|
||||
/* Party Settings */
|
||||
public boolean getExpShareEnabled() { return config.getBoolean("Party.Sharing.ExpShare_enabled", true); }
|
||||
public double getPartyShareBonus() { return config.getDouble("Party.Sharing.ExpShare_bonus", 1.1); }
|
||||
public boolean getItemShareEnabled() { return config.getBoolean("Party.Sharing.ItemShare_enabled", true); }
|
||||
public double getPartyShareRange() { return config.getDouble("Party.Sharing.Range", 75.0); }
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@ public abstract class ConfigLoader {
|
||||
protected File configFile;
|
||||
protected FileConfiguration config;
|
||||
|
||||
public ConfigLoader(String relativePath, String fileName){
|
||||
public ConfigLoader(String relativePath, String fileName) {
|
||||
this.fileName = fileName;
|
||||
configFile = new File(plugin.getDataFolder(), relativePath + File.separator + fileName);
|
||||
loadFile();
|
||||
}
|
||||
|
||||
public ConfigLoader(String fileName){
|
||||
public ConfigLoader(String fileName) {
|
||||
this.fileName = fileName;
|
||||
configFile = new File(plugin.getDataFolder(), fileName);
|
||||
loadFile();
|
||||
|
||||
@@ -2,7 +2,6 @@ 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.Map.Entry;
|
||||
@@ -11,12 +10,14 @@ import java.util.Set;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.Treasure;
|
||||
|
||||
public class TreasuresConfig extends ConfigLoader{
|
||||
public class TreasuresConfig extends ConfigLoader {
|
||||
private static TreasuresConfig instance;
|
||||
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
|
||||
@@ -25,11 +26,12 @@ public class TreasuresConfig extends ConfigLoader{
|
||||
public List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
|
||||
public List<FishingTreasure> fishingRewardsTier1 = new ArrayList<FishingTreasure>();
|
||||
public List<FishingTreasure> fishingRewardsTier2 = new ArrayList<FishingTreasure>();
|
||||
public List<FishingTreasure> fishingRewardsTier3 = new ArrayList<FishingTreasure>();
|
||||
public List<FishingTreasure> fishingRewardsTier4 = new ArrayList<FishingTreasure>();
|
||||
public List<FishingTreasure> fishingRewardsTier5 = new ArrayList<FishingTreasure>();
|
||||
|
||||
public List<HylianTreasure> hylianFromBushes = new ArrayList<HylianTreasure>();
|
||||
public List<HylianTreasure> hylianFromFlowers = new ArrayList<HylianTreasure>();
|
||||
public List<HylianTreasure> hylianFromPots = new ArrayList<HylianTreasure>();
|
||||
|
||||
public List<FishingTreasure> fishingRewards = new ArrayList<FishingTreasure>();
|
||||
|
||||
private TreasuresConfig() {
|
||||
super("treasures.yml");
|
||||
@@ -49,10 +51,8 @@ public class TreasuresConfig extends ConfigLoader{
|
||||
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();
|
||||
for (String treasureName : treasureConfigSet) {
|
||||
|
||||
// Validate all the things!
|
||||
List<String> reason = new ArrayList<String>();
|
||||
@@ -125,7 +125,7 @@ public class TreasuresConfig extends ConfigLoader{
|
||||
* Drops From & Max Level
|
||||
*/
|
||||
|
||||
ItemStack item = new ItemStack(id, amount, (short) 0, (byte) data);
|
||||
ItemStack item = (new MaterialData(id, (byte) data)).toItemStack(amount);
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
|
||||
if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) {
|
||||
@@ -138,10 +138,6 @@ public class TreasuresConfig extends ConfigLoader{
|
||||
|
||||
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);
|
||||
@@ -149,6 +145,7 @@ public class TreasuresConfig extends ConfigLoader{
|
||||
}
|
||||
else {
|
||||
ExcavationTreasure eTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
|
||||
HylianTreasure hTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Dirt", false)) {
|
||||
eTreasure.setDropsFromDirt();
|
||||
@@ -178,23 +175,36 @@ public class TreasuresConfig extends ConfigLoader{
|
||||
eTreasure.setDropsFromSoulSand();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Bushes", false)) {
|
||||
hTreasure.setDropsFromBushes();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Flowers", false)) {
|
||||
hTreasure.setDropsFromFlowers();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Pots", false)) {
|
||||
hTreasure.setDropsFromPots();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
|
||||
reason.add("Excavation drops cannot also be fishing drops");
|
||||
}
|
||||
|
||||
if (noErrorsInTreasure(reason)) {
|
||||
if (noErrorsInTreasure(reason) && hTreasure.getDropsFrom() == (byte) 0x0) {
|
||||
treasures.put(treasureName, eTreasure);
|
||||
}
|
||||
else if (noErrorsInTreasure(reason) && eTreasure.getDropsFrom() == (byte) 0x0){
|
||||
treasures.put(treasureName, hTreasure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
|
||||
List<String> fishingTreasures = config.getStringList("Fishing.Treasure");
|
||||
// Iterator<String> treasureIterator = treasures.keySet().iterator();
|
||||
Iterator<Entry<String,Treasure>> treasureIterator = treasures.entrySet().iterator();
|
||||
List<String> hylianTreasures = config.getStringList("Hylian_Luck.Treasure");
|
||||
|
||||
while (treasureIterator.hasNext()) {
|
||||
Entry<String,Treasure> nextEntry = treasureIterator.next();
|
||||
for (Entry<String,Treasure> nextEntry : treasures.entrySet()) {
|
||||
String treasureKey = nextEntry.getKey();
|
||||
Treasure treasure = nextEntry.getValue();
|
||||
|
||||
@@ -203,30 +213,26 @@ public class TreasuresConfig extends ConfigLoader{
|
||||
continue;
|
||||
}
|
||||
|
||||
FishingTreasure fTreasure = (FishingTreasure) treasure;
|
||||
int dropLevel = fTreasure.getDropLevel();
|
||||
int maxLevel = fTreasure.getMaxLevel();
|
||||
|
||||
if(dropLevel <= Config.getInstance().getFishingTierLevelsTier1() && maxLevel >= Config.getInstance().getFishingTierLevelsTier1()) {
|
||||
fishingRewardsTier1.add(fTreasure);
|
||||
fishingRewards.add((FishingTreasure) treasure);
|
||||
}
|
||||
else if (treasure instanceof HylianTreasure) {
|
||||
if (!hylianTreasures.contains(treasureKey)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(dropLevel <= Config.getInstance().getFishingTierLevelsTier2() && maxLevel >= Config.getInstance().getFishingTierLevelsTier2()) {
|
||||
fishingRewardsTier2.add(fTreasure);
|
||||
HylianTreasure hTreasure = (HylianTreasure) treasure;
|
||||
|
||||
if (hTreasure.getDropsFromBushes()) {
|
||||
hylianFromBushes.add(hTreasure);
|
||||
}
|
||||
|
||||
if (dropLevel <= Config.getInstance().getFishingTierLevelsTier3() && maxLevel >= Config.getInstance().getFishingTierLevelsTier3()) {
|
||||
fishingRewardsTier3.add(fTreasure);
|
||||
if (hTreasure.getDropsFromFlowers()) {
|
||||
hylianFromFlowers.add(hTreasure);
|
||||
}
|
||||
|
||||
if (dropLevel <= Config.getInstance().getFishingTierLevelsTier4() && maxLevel >= Config.getInstance().getFishingTierLevelsTier4()) {
|
||||
fishingRewardsTier4.add(fTreasure);
|
||||
if (hTreasure.getDropsFromPots()) {
|
||||
hylianFromPots.add(hTreasure);
|
||||
}
|
||||
|
||||
if (dropLevel <= Config.getInstance().getFishingTierLevelsTier5() && maxLevel >= Config.getInstance().getFishingTierLevelsTier5()) {
|
||||
fishingRewardsTier5.add(fTreasure);
|
||||
}
|
||||
|
||||
}
|
||||
else if (treasure instanceof ExcavationTreasure) {
|
||||
if (!excavationTreasures.contains(treasureKey)) {
|
||||
@@ -270,11 +276,10 @@ public class TreasuresConfig extends ConfigLoader{
|
||||
if (issues.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
for (String issue : issues) {
|
||||
plugin.getLogger().warning(issue);
|
||||
}
|
||||
return false;
|
||||
|
||||
for (String issue : issues) {
|
||||
plugin.getLogger().warning(issue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
587
src/main/java/com/gmail/nossr50/database/Database.java
Normal file
587
src/main/java/com/gmail/nossr50/database/Database.java
Normal file
@@ -0,0 +1,587 @@
|
||||
package com.gmail.nossr50.database;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.runnables.SQLReconnect;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.spout.SpoutTools;
|
||||
import com.gmail.nossr50.spout.huds.SpoutHud;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public final class Database {
|
||||
private static String connectionString;
|
||||
|
||||
private static String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
private static Connection connection = null;
|
||||
|
||||
// Scale waiting time by this much per failed attempt
|
||||
private static final double SCALING_FACTOR = 40;
|
||||
|
||||
// Minimum wait in nanoseconds (default 500ms)
|
||||
private static final long MIN_WAIT = 500L*1000000L;
|
||||
|
||||
// Maximum time to wait between reconnects (default 5 minutes)
|
||||
private static final long MAX_WAIT = 5L * 60L * 1000L * 1000000L;
|
||||
|
||||
// How long to wait when checking if connection is valid (default 3 seconds)
|
||||
private static final int VALID_TIMEOUT = 3;
|
||||
|
||||
// When next to try connecting to Database in nanoseconds
|
||||
private static long nextReconnectTimestamp = 0L;
|
||||
|
||||
// How many connection attemtps have failed
|
||||
private static int reconnectAttempt = 0;
|
||||
|
||||
private Database() {}
|
||||
|
||||
/**
|
||||
* Attempt to connect to the mySQL database.
|
||||
*/
|
||||
public static void connect() {
|
||||
Config configInstance = Config.getInstance();
|
||||
connectionString = "jdbc:mysql://" + configInstance.getMySQLServerName() + ":" + configInstance.getMySQLServerPort() + "/" + configInstance.getMySQLDatabaseName();
|
||||
|
||||
try {
|
||||
mcMMO.p.getLogger().info("Attempting connection to MySQL...");
|
||||
|
||||
// Force driver to load if not yet loaded
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
Properties connectionProperties = new Properties();
|
||||
connectionProperties.put("user", configInstance.getMySQLUserName());
|
||||
connectionProperties.put("password", configInstance.getMySQLUserPassword());
|
||||
connectionProperties.put("autoReconnect", "false");
|
||||
connectionProperties.put("maxReconnects", "0");
|
||||
connection = DriverManager.getConnection(connectionString, connectionProperties);
|
||||
|
||||
mcMMO.p.getLogger().info("Connection to MySQL was a success!");
|
||||
} catch (SQLException ex) {
|
||||
connection = null;
|
||||
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
|
||||
mcMMO.p.getLogger().info("Connection to MySQL failed!");
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
connection = null;
|
||||
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
|
||||
mcMMO.p.getLogger().info("MySQL database driver not found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to create the database structure.
|
||||
*/
|
||||
public static void createStructure() {
|
||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "users` ("
|
||||
+ "`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
|
||||
+ "`user` varchar(40) NOT NULL,"
|
||||
+ "`lastlogin` int(32) unsigned NOT NULL,"
|
||||
+ "PRIMARY KEY (`id`),"
|
||||
+ "UNIQUE KEY `user` (`user`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
|
||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "huds` ("
|
||||
+ "`user_id` int(10) unsigned NOT NULL,"
|
||||
+ "`hudtype` varchar(50) NOT NULL DEFAULT 'STANDARD',"
|
||||
+ "PRIMARY KEY (`user_id`),"
|
||||
+ "FOREIGN KEY (`user_id`) REFERENCES `" + tablePrefix + "users` (`id`) "
|
||||
+ "ON DELETE CASCADE) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "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`),"
|
||||
+ "FOREIGN KEY (`user_id`) REFERENCES `" + tablePrefix + "users` (`id`) "
|
||||
+ "ON DELETE CASCADE) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "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`),"
|
||||
+ "FOREIGN KEY (`user_id`) REFERENCES `" + tablePrefix + "users` (`id`) "
|
||||
+ "ON DELETE CASCADE) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "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`),"
|
||||
+ "FOREIGN KEY (`user_id`) REFERENCES `" + tablePrefix + "users` (`id`) "
|
||||
+ "ON DELETE CASCADE) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
|
||||
checkDatabaseStructure(DatabaseUpdate.FISHING);
|
||||
checkDatabaseStructure(DatabaseUpdate.BLAST_MINING);
|
||||
checkDatabaseStructure(DatabaseUpdate.CASCADE_DELETE);
|
||||
checkDatabaseStructure(DatabaseUpdate.INDEX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check database structure for missing values.
|
||||
*
|
||||
* @param update Type of data to check updates for
|
||||
*/
|
||||
private static void checkDatabaseStructure(DatabaseUpdate update) {
|
||||
String sql = null;
|
||||
ResultSet resultSet = null;
|
||||
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
||||
|
||||
switch (update) {
|
||||
case BLAST_MINING:
|
||||
sql = "SELECT * FROM `" + tablePrefix + "cooldowns` ORDER BY `" + tablePrefix + "cooldowns`.`blast_mining` ASC LIMIT 0 , 30";
|
||||
break;
|
||||
|
||||
case CASCADE_DELETE:
|
||||
write("ALTER TABLE `" + tablePrefix + "huds` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
|
||||
write("ALTER TABLE `" + tablePrefix + "experience` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
|
||||
write("ALTER TABLE `" + tablePrefix + "cooldowns` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
|
||||
write("ALTER TABLE `" + tablePrefix + "skills` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
|
||||
|
||||
case FISHING:
|
||||
sql = "SELECT * FROM `" + tablePrefix + "experience` ORDER BY `" + tablePrefix + "experience`.`fishing` ASC LIMIT 0 , 30";
|
||||
break;
|
||||
|
||||
case INDEX:
|
||||
if (read("SHOW INDEX FROM " + tablePrefix + "skills").size() != 13) {
|
||||
mcMMO.p.getLogger().info("Indexing tables, this may take a while on larger databases");
|
||||
write("ALTER TABLE `" + tablePrefix + "skills` ADD INDEX `idx_taming` (`taming`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_mining` (`mining`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_woodcutting` (`woodcutting`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_repair` (`repair`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_unarmed` (`unarmed`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_herbalism` (`herbalism`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_excavation` (`excavation`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_archery` (`archery`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_swords` (`swords`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_axes` (`axes`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_acrobatics` (`acrobatics`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_fishing` (`fishing`) USING BTREE;");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
if (!checkConnected()) return;
|
||||
statement = connection.prepareStatement(sql);
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
while (resultSet.next()) {
|
||||
ArrayList<String> column = new ArrayList<String>();
|
||||
|
||||
for (int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) {
|
||||
column.add(resultSet.getString(i));
|
||||
}
|
||||
|
||||
rows.put(resultSet.getRow(), column);
|
||||
}
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
switch (update) {
|
||||
case BLAST_MINING:
|
||||
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Blast Mining...");
|
||||
write("ALTER TABLE `"+tablePrefix + "cooldowns` ADD `blast_mining` int(32) NOT NULL DEFAULT '0' ;");
|
||||
break;
|
||||
|
||||
case FISHING:
|
||||
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Fishing...");
|
||||
write("ALTER TABLE `"+tablePrefix + "skills` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
|
||||
write("ALTER TABLE `"+tablePrefix + "experience` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} finally {
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
resultSet.close();
|
||||
} catch (SQLException e) {
|
||||
// Ignore the error, we're leaving
|
||||
}
|
||||
}
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
} catch (SQLException e) {
|
||||
// Ignore the error, we're leaving
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to write the SQL query.
|
||||
*
|
||||
* @param sql Query to write.
|
||||
* @return true if the query was successfully written, false otherwise.
|
||||
*/
|
||||
public static boolean write(String sql) {
|
||||
if (checkConnected()) {
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
statement = connection.prepareStatement(sql);
|
||||
statement.executeUpdate();
|
||||
return true;
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
return false;
|
||||
} finally {
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
} catch (SQLException e) {
|
||||
printErrors(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of rows affected by either a DELETE or UPDATE query
|
||||
*
|
||||
* @param sql SQL query to execute
|
||||
* @return the number of rows affected
|
||||
*/
|
||||
public static int update(String sql) {
|
||||
int ret = 0;
|
||||
if (checkConnected()) {
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
statement = connection.prepareStatement(sql);
|
||||
ret = statement.executeUpdate();
|
||||
return ret;
|
||||
} catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
return 0;
|
||||
} finally {
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
} catch (SQLException e) {
|
||||
printErrors(e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 static int getInt(String sql) {
|
||||
ResultSet resultSet;
|
||||
int result = 0;
|
||||
|
||||
if (checkConnected()) {
|
||||
try {
|
||||
PreparedStatement statement = connection.prepareStatement(sql);
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
if (resultSet.next()) {
|
||||
result = resultSet.getInt(1);
|
||||
}
|
||||
else {
|
||||
result = 0;
|
||||
}
|
||||
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check connection status and re-establish if dead or stale.
|
||||
*
|
||||
* If the very first immediate attempt fails, further attempts
|
||||
* will be made in progressively larger intervals up to MAX_WAIT
|
||||
* intervals.
|
||||
*
|
||||
* This allows for MySQL to time out idle connections as needed by
|
||||
* server operator, without affecting McMMO, while still providing
|
||||
* protection against a database outage taking down Bukkit's tick
|
||||
* processing loop due to attemping a database connection each
|
||||
* time McMMO needs the database.
|
||||
*
|
||||
* @return the boolean value for whether or not we are connected
|
||||
*/
|
||||
public static boolean checkConnected() {
|
||||
boolean isClosed = true;
|
||||
boolean isValid = false;
|
||||
boolean exists = (connection != null);
|
||||
|
||||
// If we're waiting for server to recover then leave early
|
||||
if (nextReconnectTimestamp > 0 && nextReconnectTimestamp > System.nanoTime()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (exists) {
|
||||
try {
|
||||
isClosed = connection.isClosed();
|
||||
} catch (SQLException e) {
|
||||
isClosed = true;
|
||||
e.printStackTrace();
|
||||
printErrors(e);
|
||||
}
|
||||
|
||||
if (!isClosed) {
|
||||
try {
|
||||
isValid = connection.isValid(VALID_TIMEOUT);
|
||||
} catch (SQLException e) {
|
||||
// Don't print stack trace because it's valid to lose idle connections
|
||||
// to the server and have to restart them.
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Leave if all ok
|
||||
if (exists && !isClosed && isValid) {
|
||||
// Housekeeping
|
||||
nextReconnectTimestamp = 0;
|
||||
reconnectAttempt = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Cleanup after ourselves for GC and MySQL's sake
|
||||
if (exists && !isClosed) {
|
||||
try {
|
||||
connection.close();
|
||||
} catch (SQLException ex) {
|
||||
// This is a housekeeping exercise, ignore errors
|
||||
}
|
||||
}
|
||||
|
||||
// Try to connect again
|
||||
connect();
|
||||
|
||||
// Leave if connection is good
|
||||
try {
|
||||
if (connection != null && !connection.isClosed()) {
|
||||
// Schedule a database save if we really had an outage
|
||||
if (reconnectAttempt > 1) {
|
||||
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new SQLReconnect(), 5);
|
||||
}
|
||||
nextReconnectTimestamp = 0;
|
||||
reconnectAttempt = 0;
|
||||
return true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// Failed to check isClosed, so presume connection is bad and attempt later
|
||||
e.printStackTrace();
|
||||
printErrors(e);
|
||||
}
|
||||
|
||||
reconnectAttempt++;
|
||||
|
||||
nextReconnectTimestamp = (long)(System.nanoTime() + Math.min(MAX_WAIT, (reconnectAttempt*SCALING_FACTOR*MIN_WAIT)));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read SQL query.
|
||||
*
|
||||
* @param sql SQL query to read
|
||||
* @return the rows in this SQL query
|
||||
*/
|
||||
public static HashMap<Integer, ArrayList<String>> read(String sql) {
|
||||
ResultSet resultSet;
|
||||
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
||||
|
||||
if (checkConnected()) {
|
||||
try {
|
||||
PreparedStatement statement = connection.prepareStatement(sql);
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
while (resultSet.next()) {
|
||||
ArrayList<String> column = new ArrayList<String>();
|
||||
|
||||
for (int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) {
|
||||
column.add(resultSet.getString(i));
|
||||
}
|
||||
|
||||
rows.put(resultSet.getRow(), column);
|
||||
}
|
||||
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
}
|
||||
}
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
public static Map<String, Integer> readSQLRank(String playerName) {
|
||||
ResultSet resultSet;
|
||||
Map<String, Integer> skills = new HashMap<String, Integer>();
|
||||
if (checkConnected()) {
|
||||
try {
|
||||
for (SkillType skillType: SkillType.values()) {
|
||||
if (skillType.isChildSkill()) continue;
|
||||
String sql;
|
||||
if (skillType != SkillType.ALL) {
|
||||
sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillType.name().toLowerCase() + " > 0 AND " + skillType.name().toLowerCase() + " > (SELECT " + skillType.name().toLowerCase() + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "')";
|
||||
}
|
||||
else {
|
||||
sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > 0 AND taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > (SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "')";
|
||||
}
|
||||
PreparedStatement statement = connection.prepareStatement(sql);
|
||||
resultSet = statement.executeQuery();
|
||||
resultSet.next();
|
||||
int rank = resultSet.getInt("rank");
|
||||
if (skillType != SkillType.ALL) {
|
||||
sql = "SELECT user, " + skillType.name().toLowerCase() + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillType.name().toLowerCase() + " > 0 AND " + skillType.name().toLowerCase() + " = (SELECT " + skillType.name().toLowerCase() + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "') ORDER BY user";
|
||||
}
|
||||
else {
|
||||
sql = "SELECT user, taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > 0 AND taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing = (SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "') ORDER BY user";
|
||||
}
|
||||
statement = connection.prepareStatement(sql);
|
||||
resultSet = statement.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
||||
skills.put(skillType.name(), rank + resultSet.getRow());
|
||||
break;
|
||||
}
|
||||
}
|
||||
statement.close();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
}
|
||||
}
|
||||
return skills;
|
||||
}
|
||||
|
||||
public static void purgePowerlessSQL() {
|
||||
mcMMO.p.getLogger().info("Purging powerless users...");
|
||||
HashMap<Integer, ArrayList<String>> usernames = read("SELECT u.user FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u WHERE s.user_id = u.id AND (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0");
|
||||
write("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.id IN (SELECT * FROM (SELECT u.id FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u WHERE s.user_id = u.id AND (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0) AS p)");
|
||||
|
||||
int purgedUsers = 0;
|
||||
for (int i = 1; i <= usernames.size(); i++) {
|
||||
String playerName = usernames.get(i).get(0);
|
||||
|
||||
if (playerName == null || Bukkit.getOfflinePlayer(playerName).isOnline()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
profileCleanup(playerName);
|
||||
purgedUsers++;
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
||||
}
|
||||
|
||||
public static void purgeOldSQL() {
|
||||
mcMMO.p.getLogger().info("Purging old users...");
|
||||
long currentTime = System.currentTimeMillis();
|
||||
long purgeTime = 2630000000L * Config.getInstance().getOldUsersCutoff();
|
||||
HashMap<Integer, ArrayList<String>> usernames = read("SELECT user FROM " + tablePrefix + "users WHERE ((" + currentTime + " - lastlogin*1000) > " + purgeTime + ")");
|
||||
write("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.id IN (SELECT * FROM (SELECT id FROM " + tablePrefix + "users WHERE ((" + currentTime + " - lastlogin*1000) > " + purgeTime + ")) AS p)");
|
||||
|
||||
int purgedUsers = 0;
|
||||
for (int i = 1; i <= usernames.size(); i++) {
|
||||
String playerName = usernames.get(i).get(0);
|
||||
|
||||
if (playerName == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
profileCleanup(playerName);
|
||||
purgedUsers++;
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
||||
}
|
||||
|
||||
private static void printErrors(SQLException ex) {
|
||||
System.out.println("SQLException: " + ex.getMessage());
|
||||
System.out.println("SQLState: " + ex.getSQLState());
|
||||
System.out.println("VendorError: " + ex.getErrorCode());
|
||||
}
|
||||
|
||||
public static void profileCleanup(String playerName) {
|
||||
McMMOPlayer mcmmoPlayer = Users.getPlayer(playerName);
|
||||
|
||||
if (mcmmoPlayer != null) {
|
||||
Player player = mcmmoPlayer.getPlayer();
|
||||
SpoutHud spoutHud = mcmmoPlayer.getProfile().getSpoutHud();
|
||||
|
||||
if (spoutHud != null) {
|
||||
spoutHud.removeWidgets();
|
||||
}
|
||||
|
||||
Users.remove(playerName);
|
||||
|
||||
if (player.isOnline()) {
|
||||
Users.addUser(player);
|
||||
|
||||
if (mcMMO.spoutEnabled) {
|
||||
SpoutTools.reloadSpoutPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.gmail.nossr50.database;
|
||||
|
||||
public enum DatabaseUpdate {
|
||||
FISHING,
|
||||
BLAST_MINING,
|
||||
CASCADE_DELETE,
|
||||
INDEX;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.gmail.nossr50.database.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class McpurgeCommand implements CommandExecutor{
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcremove")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
Database.purgePowerlessSQL();
|
||||
|
||||
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
||||
Database.purgeOldSQL();
|
||||
}
|
||||
}
|
||||
else {
|
||||
//TODO: Make this work for Flatfile data.
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.gmail.nossr50.database.commands;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class McremoveCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String playerName;
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
//String databaseName = Config.getInstance().getMySQLDatabaseName();
|
||||
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"mcremove", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"});
|
||||
String success;
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcremove")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
playerName = args[0];
|
||||
success = LocaleLoader.getString("Commands.mcremove.Success", new Object[] {playerName});
|
||||
break;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* MySQL */
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
int affected = 0;
|
||||
affected = Database.update("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.user = '" + playerName + "'");
|
||||
|
||||
if (affected > 0) {
|
||||
sender.sendMessage(success);
|
||||
} else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (removeFlatFileUser(playerName)) {
|
||||
sender.sendMessage(success);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
}
|
||||
}
|
||||
|
||||
Database.profileCleanup(playerName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean removeFlatFileUser(String playerName) {
|
||||
boolean worked = false;
|
||||
|
||||
BufferedReader in = null;
|
||||
FileWriter out = null;
|
||||
String usersFilePath = mcMMO.getUsersFilePath();
|
||||
|
||||
try {
|
||||
FileReader file = new FileReader(usersFilePath);
|
||||
in = new BufferedReader(file);
|
||||
StringBuilder writer = new StringBuilder();
|
||||
String line = "";
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
|
||||
/* Write out the same file but when we get to the player we want to remove, we skip his line. */
|
||||
if (!line.split(":")[0].equalsIgnoreCase(playerName)) {
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
else {
|
||||
System.out.println("User found, removing...");
|
||||
worked = true;
|
||||
continue; //Skip the player
|
||||
}
|
||||
}
|
||||
|
||||
out = new FileWriter(usersFilePath); //Write out the new file
|
||||
out.write(writer.toString());
|
||||
}
|
||||
catch (Exception e) {
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return worked;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
package com.gmail.nossr50.database.commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -9,31 +8,26 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.runnables.SQLConversionTask;
|
||||
import com.gmail.nossr50.database.runnables.SQLConversionTask;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class MmoupdateCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public MmoupdateCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) {
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mmoupdate")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GRAY + "Starting conversion..."); //TODO: Needs more locale.
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Start"));
|
||||
Users.clearAll();
|
||||
convertToMySQL();
|
||||
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
for (Player x : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
Users.addUser(x);
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Conversion finished!"); //TODO: Needs more locale.
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Finish"));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -46,6 +40,6 @@ public class MmoupdateCommand implements CommandExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getServer().getScheduler().scheduleAsyncDelayedTask(plugin, new SQLConversionTask(plugin), 1);
|
||||
mcMMO.p.getServer().getScheduler().runTaskLaterAsynchronously(mcMMO.p, new SQLConversionTask(), 1);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,19 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
package com.gmail.nossr50.database.runnables;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class SQLConversionTask implements Runnable {
|
||||
private final mcMMO plugin;
|
||||
private String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
|
||||
public SQLConversionTask(mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
String location = mcMMO.getUsersFile();
|
||||
String location = mcMMO.getUsersFilePath();
|
||||
|
||||
try {
|
||||
FileReader file = new FileReader(location);
|
||||
@@ -166,7 +160,7 @@ public class SQLConversionTask implements Runnable {
|
||||
}
|
||||
|
||||
//Check to see if the user is in the DB
|
||||
id = database.getInt("SELECT id FROM "
|
||||
id = Database.getInt("SELECT id FROM "
|
||||
+ tablePrefix
|
||||
+ "users WHERE user = '" + playerName + "'");
|
||||
|
||||
@@ -174,11 +168,11 @@ public class SQLConversionTask implements Runnable {
|
||||
theCount++;
|
||||
|
||||
//Update the skill values
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "users SET lastlogin = " + 0
|
||||
+ " WHERE id = " + id);
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "skills SET "
|
||||
+ " taming = taming+" + Misc.getInt(taming)
|
||||
@@ -194,7 +188,7 @@ public class SQLConversionTask implements Runnable {
|
||||
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
|
||||
+ ", fishing = fishing+" + Misc.getInt(fishing)
|
||||
+ " WHERE user_id = " + id);
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "experience SET "
|
||||
+ " taming = " + Misc.getInt(tamingXP)
|
||||
@@ -215,32 +209,32 @@ public class SQLConversionTask implements Runnable {
|
||||
theCount++;
|
||||
|
||||
//Create the user in the DB
|
||||
database.write("INSERT INTO "
|
||||
Database.write("INSERT INTO "
|
||||
+ tablePrefix
|
||||
+ "users (user, lastlogin) VALUES ('"
|
||||
+ playerName + "',"
|
||||
+ System.currentTimeMillis() / 1000 + ")");
|
||||
id = database.getInt("SELECT id FROM "
|
||||
+ tablePrefix
|
||||
+ "users WHERE user = '"
|
||||
+ playerName + "'");
|
||||
database.write("INSERT INTO "
|
||||
+ System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR + ")");
|
||||
id = Database.getInt("SELECT id FROM "
|
||||
+ tablePrefix
|
||||
+ "users WHERE user = '"
|
||||
+ playerName + "'");
|
||||
Database.write("INSERT INTO "
|
||||
+ tablePrefix
|
||||
+ "skills (user_id) VALUES (" + id + ")");
|
||||
database.write("INSERT INTO "
|
||||
Database.write("INSERT INTO "
|
||||
+ tablePrefix
|
||||
+ "experience (user_id) VALUES (" + id
|
||||
+ ")");
|
||||
//Update the skill values
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "users SET lastlogin = " + 0
|
||||
+ " WHERE id = " + id);
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "users SET party = '" + party
|
||||
+ "' WHERE id = " + id);
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "skills SET "
|
||||
+ " taming = taming+" + Misc.getInt(taming)
|
||||
@@ -256,7 +250,7 @@ public class SQLConversionTask implements Runnable {
|
||||
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
|
||||
+ ", fishing = fishing+" + Misc.getInt(fishing)
|
||||
+ " WHERE user_id = " + id);
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "experience SET "
|
||||
+ " taming = " + Misc.getInt(tamingXP)
|
||||
@@ -275,11 +269,11 @@ public class SQLConversionTask implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("[mcMMO] MySQL Updated from users file, " + theCount + " items added/updated to MySQL DB"); //TODO: Locale
|
||||
System.out.println("[mcMMO] MySQL Updated from users file, " + theCount + " items added/updated to MySQL DB");
|
||||
in.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
plugin.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,19 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
package com.gmail.nossr50.database.runnables;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SQLReconnect implements Runnable {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public SQLReconnect(mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (Database.checkConnected()) {
|
||||
Users.saveAll(); //Save all profiles
|
||||
Users.clearAll(); //Clear the profiles
|
||||
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
Users.addUser(player); //Add in new profiles, forcing them to 'load' again from MySQL
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.gmail.nossr50.database.runnables;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
|
||||
public class UserPurgeTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
Database.purgePowerlessSQL();
|
||||
|
||||
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
||||
Database.purgeOldSQL();
|
||||
}
|
||||
}
|
||||
else {
|
||||
//TODO: Make this work for Flatfile data.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
public enum DatabaseUpdate {
|
||||
FISHING,
|
||||
BLAST_MINING;
|
||||
}
|
||||
@@ -6,18 +6,21 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||
import com.gmail.nossr50.mods.ModChecks;
|
||||
import com.gmail.nossr50.mods.datatypes.CustomTool;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.spout.huds.SpoutHud;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModChecks;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class McMMOPlayer {
|
||||
private Player player;
|
||||
private PlayerProfile profile;
|
||||
|
||||
private Party party;
|
||||
private Party invite;
|
||||
|
||||
@@ -25,7 +28,7 @@ public class McMMOPlayer {
|
||||
String playerName = player.getName();
|
||||
this.player = player;
|
||||
this.profile = new PlayerProfile(playerName, true);
|
||||
this.party = PartyManager.getInstance().getPlayerParty(playerName);
|
||||
this.party = PartyManager.getPlayerParty(playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,6 +40,10 @@ public class McMMOPlayer {
|
||||
int powerLevel = 0;
|
||||
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type.getPermissions(player)) {
|
||||
powerLevel += profile.getSkillLevel(type);
|
||||
}
|
||||
@@ -46,52 +53,25 @@ public class McMMOPlayer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the party XP modifier.
|
||||
* Adds Xp to the player, doesn't calculate for Xp Rate
|
||||
*
|
||||
* @param skillType Type of skill to check
|
||||
* @return the party bonus multiplier
|
||||
* @param skillType The skill to add Xp to
|
||||
* @param xp The amount of Xp to add
|
||||
*/
|
||||
private double calculatePartyXPModifier(SkillType skillType) {
|
||||
double bonusModifier = 0.0;
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
if (party.getLeader().equals(member.getName())) {
|
||||
if (Misc.isNear(player.getLocation(), member.getLocation(), 25.0)) {
|
||||
PlayerProfile partyLeader = Users.getProfile(member);
|
||||
int leaderSkill = partyLeader.getSkillLevel(skillType);
|
||||
int playerSkill = profile.getSkillLevel(skillType);
|
||||
|
||||
if (leaderSkill >= playerSkill) {
|
||||
int difference = leaderSkill - playerSkill;
|
||||
bonusModifier = (difference * 0.75) / 100.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bonusModifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, doesn't calculate for XP Rate
|
||||
*
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newValue The amount of XP to add
|
||||
*/
|
||||
public void addXPOverride(SkillType skillType, int xp) {
|
||||
public void addXpOverride(SkillType skillType, int xp) {
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.equals(SkillType.ALL)) {
|
||||
if (type.equals(SkillType.ALL) || type.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, type, xp));
|
||||
profile.setSkillXPLevel(type, profile.getSkillXpLevel(type) + xp);
|
||||
profile.setSkillXpLevel(type, profile.getSkillXpLevel(type) + xp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
|
||||
profile.setSkillXPLevel(skillType, profile.getSkillXpLevel(skillType) + xp);
|
||||
profile.setSkillXpLevel(skillType, profile.getSkillXpLevel(skillType) + xp);
|
||||
|
||||
SpoutHud spoutHud = profile.getSpoutHud();
|
||||
|
||||
@@ -102,44 +82,40 @@ public class McMMOPlayer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, this ignores skill modifiers.
|
||||
* Adds Xp to the player, this ignores skill modifiers.
|
||||
*
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newValue The amount of XP to add
|
||||
* @param skillType The skill to add Xp to
|
||||
* @param xp The amount of Xp to add
|
||||
*/
|
||||
public void addXPOverrideBonus(SkillType skillType, int xp) {
|
||||
int modifiedXp = (int)Math.floor(xp * Config.getInstance().xpGainMultiplier);
|
||||
addXPOverride(skillType, modifiedXp);
|
||||
public void addXpOverrideBonus(SkillType skillType, int xp) {
|
||||
int modifiedXp = (int) Math.floor(xp * Config.getInstance().getExperienceGainsGlobalMultiplier());
|
||||
addXpOverride(skillType, modifiedXp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, this is affected by skill modifiers and XP Rate and Permissions
|
||||
* Adds experience to the player, this is affected by skill modifiers, rate and permissions
|
||||
*
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newvalue The amount of XP to add
|
||||
* @param skillType The skill to add Xp to
|
||||
* @param xp The amount of Xp to add
|
||||
*/
|
||||
public void addXP(SkillType skillType, int newValue) {
|
||||
if (player.getGameMode().equals(GameMode.CREATIVE)) {
|
||||
public void addXp(SkillType skillType, int xp) {
|
||||
if (player.getGameMode() == GameMode.CREATIVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
double bonusModifier = 0;
|
||||
|
||||
if (inParty()) {
|
||||
bonusModifier = calculatePartyXPModifier(skillType);
|
||||
}
|
||||
|
||||
int xp = (int)Math.floor((newValue / skillType.getXpModifier()) * Config.getInstance().xpGainMultiplier);
|
||||
|
||||
if (bonusModifier > 0) {
|
||||
if (bonusModifier >= 2) {
|
||||
bonusModifier = 2;
|
||||
if (party != null && !ShareHandler.isRunning()) {
|
||||
// Return if the Xp has been shared
|
||||
if (ShareHandler.handleEqualXpShare(xp, this, skillType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double trueBonus = bonusModifier * xp;
|
||||
xp += trueBonus;
|
||||
}
|
||||
|
||||
if ((skillType.getMaxLevel() < profile.getSkillLevel(skillType) + 1) || (Misc.getPowerLevelCap() < getPowerLevel() + 1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
xp = (int) (xp / skillType.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier());
|
||||
|
||||
if (Config.getInstance().getToolModsEnabled()) {
|
||||
ItemStack item = player.getItemInHand();
|
||||
CustomTool tool = ModChecks.getToolFromItemStack(item);
|
||||
@@ -149,30 +125,33 @@ public class McMMOPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
|
||||
xp = xp * 4;
|
||||
// TODO: find a better way to do this, if possible
|
||||
if (Permissions.xpQuadruple(player)) {
|
||||
xp *= 4;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.triple")) {
|
||||
xp = xp * 3;
|
||||
else if (Permissions.xpTriple(player)) {
|
||||
xp *= 3;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.150percentboost")) {
|
||||
xp = (int) (xp * 2.5);
|
||||
else if (Permissions.xpDoubleAndOneHalf(player)) {
|
||||
xp *= 2.5;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.double")) {
|
||||
xp = xp * 2;
|
||||
else if (Permissions.xpDouble(player)) {
|
||||
xp *= 2;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.50percentboost")) {
|
||||
xp = (int) (xp * 1.5);
|
||||
else if (Permissions.xpOneAndOneHalf(player)) {
|
||||
xp *= 1.5;
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
|
||||
profile.setSkillXPLevel(skillType, profile.getSkillXpLevel(skillType) + xp);
|
||||
profile.setSkillXpLevel(skillType, profile.getSkillXpLevel(skillType) + xp);
|
||||
|
||||
SpoutHud spoutHud = profile.getSpoutHud();
|
||||
|
||||
if (spoutHud != null) {
|
||||
spoutHud.setLastGained(skillType);
|
||||
}
|
||||
|
||||
SkillTools.xpCheckSkill(skillType, player, profile);
|
||||
}
|
||||
|
||||
// Players & Profiles
|
||||
@@ -203,9 +182,8 @@ public class McMMOPlayer {
|
||||
if (invite != null) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setParty(Party party) {
|
||||
@@ -220,9 +198,8 @@ public class McMMOPlayer {
|
||||
if (party != null) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removeParty() {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,4 +3,9 @@ package com.gmail.nossr50.datatypes;
|
||||
public class PlayerStat {
|
||||
public String name;
|
||||
public int statVal = 0;
|
||||
|
||||
public PlayerStat(String name, int value) {
|
||||
this.name = name;
|
||||
this.statVal = value;
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Tree {
|
||||
|
||||
private TreeNode root = null;
|
||||
|
||||
/**
|
||||
* 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,50 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TreeNode {
|
||||
TreeNode left = null;
|
||||
TreeNode right = null;
|
||||
PlayerStat ps = new PlayerStat();
|
||||
|
||||
public TreeNode(String p, int in) {
|
||||
ps.statVal = in;
|
||||
ps.name = p;
|
||||
}
|
||||
|
||||
public void add (String p, int in) {
|
||||
if (in >= ps.statVal) {
|
||||
if (left == null) {
|
||||
left = new TreeNode(p, in);
|
||||
}
|
||||
else {
|
||||
left.add(p, in);
|
||||
}
|
||||
}
|
||||
else if(in < ps.statVal) {
|
||||
if (right == null) {
|
||||
right = new TreeNode(p, in);
|
||||
}
|
||||
else {
|
||||
right.add(p, in);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<PlayerStat> inOrder(ArrayList<PlayerStat> a) {
|
||||
//if left node is not null than assign arrayList(a) to left.inOrder()
|
||||
//GOES THROUGH THE ENTIRE LEFT BRANCH AND GRABS THE GREATEST NUMBER
|
||||
|
||||
if (left != null) {
|
||||
a = left.inOrder(a);
|
||||
}
|
||||
|
||||
a.add(ps);
|
||||
|
||||
if (right != null) {
|
||||
a = right.inOrder(a);
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ 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
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.gmail.nossr50.datatypes.treasure;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class HylianTreasure extends Treasure {
|
||||
// bushes | flowers | pots
|
||||
// 00000001 - bushes 1
|
||||
// 00000010 - flowers 2
|
||||
// 00000100 - pots 4
|
||||
private byte dropsFrom = 0x0;
|
||||
|
||||
public HylianTreasure(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 getDropsFromBushes() {
|
||||
return getDropFromMask(1);
|
||||
}
|
||||
|
||||
public boolean getDropsFromFlowers() {
|
||||
return getDropFromMask(2);
|
||||
}
|
||||
|
||||
public boolean getDropsFromPots() {
|
||||
return getDropFromMask(4);
|
||||
}
|
||||
|
||||
private boolean getDropFromMask(int mask) {
|
||||
return ((dropsFrom & mask) > 0) ? true : false;
|
||||
}
|
||||
|
||||
// Setters
|
||||
public void setDropsFromBushes() {
|
||||
setDropFromMask(1);
|
||||
}
|
||||
|
||||
public void setDropsFromFlowers() {
|
||||
setDropFromMask(2);
|
||||
}
|
||||
|
||||
public void setDropsFromPots() {
|
||||
setDropFromMask(4);
|
||||
}
|
||||
|
||||
private void setDropFromMask(int mask) {
|
||||
dropsFrom |= mask;
|
||||
}
|
||||
|
||||
// Un-setters
|
||||
public void unsetDropsFromBushes() {
|
||||
unsetDropFromMask(1);
|
||||
}
|
||||
|
||||
public void unsetDropsFromFlowers() {
|
||||
unsetDropFromMask(2);
|
||||
}
|
||||
|
||||
public void unsetDropsFromPots() {
|
||||
unsetDropFromMask(4);
|
||||
}
|
||||
|
||||
private void unsetDropFromMask(int mask) {
|
||||
dropsFrom &= ~mask;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.gmail.nossr50.events.chat;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Called when a chat is sent to the admin chat channel
|
||||
*/
|
||||
public class McMMOAdminChatEvent extends McMMOChatEvent{
|
||||
|
||||
public McMMOAdminChatEvent(String sender, String message) {
|
||||
super(sender, message);
|
||||
public class McMMOAdminChatEvent extends McMMOChatEvent {
|
||||
public McMMOAdminChatEvent(Plugin plugin, String sender, String displayName, String message) {
|
||||
super(plugin, sender, displayName, message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,17 +3,29 @@ package com.gmail.nossr50.events.chat;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class McMMOChatEvent extends Event implements Cancellable{
|
||||
public class McMMOChatEvent extends Event implements Cancellable {
|
||||
private boolean cancelled;
|
||||
private Plugin plugin;
|
||||
private String sender;
|
||||
private String displayName;
|
||||
private String message;
|
||||
|
||||
public McMMOChatEvent(String sender, String message) {
|
||||
protected McMMOChatEvent(Plugin plugin, String sender, String displayName, String message) {
|
||||
this.plugin = plugin;
|
||||
this.sender = sender;
|
||||
this.displayName = displayName;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The plugin responsible for this event, note this can be null
|
||||
*/
|
||||
public Plugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String name of the player who sent the chat, or "Console"
|
||||
*/
|
||||
@@ -21,6 +33,13 @@ public class McMMOChatEvent extends Event implements Cancellable{
|
||||
return sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String display name of the player who sent the chat, or "Console"
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String message that will be sent
|
||||
*/
|
||||
@@ -28,6 +47,13 @@ public class McMMOChatEvent extends Event implements Cancellable{
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param displayName String display name of the player who sent the chat
|
||||
*/
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message String message to be sent in chat
|
||||
*/
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package com.gmail.nossr50.events.chat;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Called when a chat is sent to a party channel
|
||||
*/
|
||||
public class McMMOPartyChatEvent extends McMMOChatEvent{
|
||||
public class McMMOPartyChatEvent extends McMMOChatEvent {
|
||||
private String party;
|
||||
|
||||
public McMMOPartyChatEvent(String sender, String party, String message) {
|
||||
super(sender, message);
|
||||
public McMMOPartyChatEvent(Plugin plugin, String sender, String displayName, String party, String message) {
|
||||
super(plugin, sender, displayName, message);
|
||||
this.party = party;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,16 +4,16 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
/**
|
||||
* Generic event for mcMMO experience events.
|
||||
*/
|
||||
public class McMMOPlayerExperienceEvent extends PlayerEvent {
|
||||
public abstract class McMMOPlayerExperienceEvent extends PlayerEvent {
|
||||
protected SkillType skill;
|
||||
protected int skillLevel;
|
||||
|
||||
public McMMOPlayerExperienceEvent(Player player, SkillType skill) {
|
||||
protected McMMOPlayerExperienceEvent(Player player, SkillType skill) {
|
||||
super(player);
|
||||
this.skill = skill;
|
||||
this.skillLevel = skill.getSkillLevel(player);
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.gmail.nossr50.events.experience;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
/**
|
||||
* Called when a user levels up in a skill
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.gmail.nossr50.events.experience;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
/**
|
||||
* Called when a player gains XP in a skill
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
* Called when mcMMO breaks a block due to a special ability.
|
||||
*/
|
||||
public class FakeBlockBreakEvent extends BlockBreakEvent {
|
||||
|
||||
public FakeBlockBreakEvent(Block theBlock, Player player) {
|
||||
super(theBlock, player);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
* Called when mcMMO damages a block due to a special ability.
|
||||
*/
|
||||
public class FakeBlockDamageEvent extends BlockDamageEvent {
|
||||
|
||||
public FakeBlockDamageEvent(Player player, Block block, ItemStack itemInHand, boolean instaBreak) {
|
||||
super(player, block, itemInHand, instaBreak);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
* Called when mcMMO applies damage from an entity due to special abilities.
|
||||
*/
|
||||
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent {
|
||||
|
||||
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, int damage) {
|
||||
super(damager, damagee, cause, damage);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
||||
* Called when mcMMO applies damage due to special abilities.
|
||||
*/
|
||||
public class FakeEntityDamageEvent extends EntityDamageEvent {
|
||||
|
||||
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, int damage) {
|
||||
super(damagee, cause, damage);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
* Called when handling extra drops to avoid issues with NoCheat.
|
||||
*/
|
||||
public class FakePlayerAnimationEvent extends PlayerAnimationEvent {
|
||||
|
||||
public FakePlayerAnimationEvent(Player player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
@@ -8,12 +8,11 @@ import org.bukkit.event.player.PlayerEvent;
|
||||
/**
|
||||
* Called when a player attempts to join, leave, or change parties.
|
||||
*/
|
||||
public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable{
|
||||
|
||||
protected String oldParty;
|
||||
protected String newParty;
|
||||
protected EventReason reason;
|
||||
protected boolean cancelled;
|
||||
public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable {
|
||||
private String oldParty;
|
||||
private String newParty;
|
||||
private EventReason reason;
|
||||
private boolean cancelled;
|
||||
|
||||
public McMMOPartyChangeEvent(Player player, String oldParty, String newParty, EventReason reason) {
|
||||
super(player);
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
/**
|
||||
* Called just before a player teleports using the /ptp command.
|
||||
*/
|
||||
public class McMMOPartyTeleportEvent extends PlayerTeleportEvent{
|
||||
public class McMMOPartyTeleportEvent extends PlayerTeleportEvent {
|
||||
private String party;
|
||||
private Player target;
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.gmail.nossr50.events.skills;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
public class McMMOPlayerDisarmEvent extends McMMOPlayerSkillEvent implements Cancellable {
|
||||
private boolean cancelled;
|
||||
private Player defender;
|
||||
|
||||
public McMMOPlayerDisarmEvent(Player defender) {
|
||||
super(defender, SkillType.UNARMED);
|
||||
this.defender = defender;
|
||||
}
|
||||
|
||||
public Player getDefender() {
|
||||
return defender;
|
||||
}
|
||||
|
||||
/** Following are required for Cancellable **/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
/**
|
||||
* Called just before a player repairs an object with mcMMO.
|
||||
|
||||
@@ -4,16 +4,16 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
/**
|
||||
* Generic event for mcMMO skill handling.
|
||||
*/
|
||||
public class McMMOPlayerSkillEvent extends PlayerEvent {
|
||||
public abstract class McMMOPlayerSkillEvent extends PlayerEvent {
|
||||
protected SkillType skill;
|
||||
protected int skillLevel;
|
||||
|
||||
public McMMOPlayerSkillEvent(Player player, SkillType skill) {
|
||||
protected McMMOPlayerSkillEvent(Player player, SkillType skill) {
|
||||
super(player);
|
||||
this.skill = skill;
|
||||
this.skillLevel = skill.getSkillLevel(player);
|
||||
|
||||
@@ -3,43 +3,47 @@ package com.gmail.nossr50.listeners;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
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.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.getspout.spoutapi.sound.SoundEffect;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.ToolType;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
import com.gmail.nossr50.runnables.StickyPistonTracker;
|
||||
import com.gmail.nossr50.skills.gathering.Excavation;
|
||||
import com.gmail.nossr50.skills.gathering.Herbalism;
|
||||
import com.gmail.nossr50.skills.gathering.Mining;
|
||||
import com.gmail.nossr50.skills.gathering.WoodCutting;
|
||||
import com.gmail.nossr50.skills.excavation.Excavation;
|
||||
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||
import com.gmail.nossr50.skills.mining.Mining;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.skills.repair.Salvage;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||
import com.gmail.nossr50.skills.utilities.AbilityType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.skills.utilities.ToolType;
|
||||
import com.gmail.nossr50.skills.woodcutting.Woodcutting;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.ModChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class BlockListener implements Listener {
|
||||
@@ -58,8 +62,7 @@ public class BlockListener implements Listener {
|
||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||
List<Block> blocks = event.getBlocks();
|
||||
BlockFace direction = event.getDirection();
|
||||
// Block that would be air after piston is finished
|
||||
Block futureEmptyBlock = event.getBlock().getRelative(direction);
|
||||
Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished
|
||||
|
||||
for (Block b : blocks) {
|
||||
if (mcMMO.placeStore.isTrue(b)) {
|
||||
@@ -78,81 +81,48 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Monitor BlockPhysics events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
*/
|
||||
// Disabled until a better patch can be applied. This does nothing but flag the wrong block.
|
||||
/*
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||
//TODO: Figure out how to REMOVE metadata from the location the sand/gravel fell from.
|
||||
Material type = event.getChangedType();
|
||||
|
||||
if (type == Material.GRAVEL || type == Material.SAND) {
|
||||
Block fallenBlock = event.getBlock().getRelative(BlockFace.UP);
|
||||
|
||||
if (fallenBlock.getType() == type) {
|
||||
mcMMO.placeStore.setTrue(fallenBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Monitor BlockPistonRetract events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
if (event.isSticky()) {
|
||||
//Needed only because under some circumstances Minecraft doesn't move the block
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StickyPistonTracker(event), 0);
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StickyPistonTracker(event), 2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor BlockPlace events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
Config configInstance = Config.getInstance();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getBlock();
|
||||
Player player = event.getPlayer();
|
||||
int id = block.getTypeId();
|
||||
Material type = block.getType();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
/* Code to prevent issues with placed falling Sand/Gravel not being tracked */
|
||||
if (type.equals(Material.SAND) || type.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);
|
||||
mcMMO.placeStore.setTrue(newLocation);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
|
||||
if (BlockChecks.shouldBeWatched(block)) {
|
||||
if (!((type == Material.SAND || type == Material.GRAVEL) && block.getRelative(BlockFace.DOWN).getType() == Material.AIR)) { //Don't wanna track sand that's gonna fall.
|
||||
mcMMO.placeStore.setTrue(block);
|
||||
}
|
||||
mcMMO.placeStore.setTrue(block);
|
||||
}
|
||||
|
||||
if (id == configInstance.getRepairAnvilId() && configInstance.getRepairAnvilMessagesEnabled()) {
|
||||
Repair.placedAnvilCheck(player, id);
|
||||
if (Repair.anvilMessagesEnabled) {
|
||||
int blockID = block.getTypeId();
|
||||
|
||||
if (blockID == Repair.anvilID) {
|
||||
Repair.placedAnvilCheck(player, blockID);
|
||||
}
|
||||
else if (blockID == Salvage.anvilID) {
|
||||
Salvage.placedAnvilCheck(player, blockID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,214 +138,246 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (profile == null) {
|
||||
if (Misc.isNPCPlayer(player, mcMMOPlayer.getProfile())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getBlock();
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
|
||||
Config configInstance = Config.getInstance();
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
|
||||
/* HERBALISM */
|
||||
if (BlockChecks.canBeGreenTerra(block)) {
|
||||
/* Green Terra */
|
||||
if (profile.getToolPreparationMode(ToolType.HOE) && permInstance.greenTerra(player)) {
|
||||
Skills.abilityCheck(player, SkillType.HERBALISM);
|
||||
if (profile.getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(player)) {
|
||||
SkillTools.abilityCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
/* Triple drops */
|
||||
if (profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||
}
|
||||
/*
|
||||
* We don't check the block store here because herbalism has too many unusual edge cases.
|
||||
* Instead, we check it inside the drops handler.
|
||||
*/
|
||||
if (Permissions.herbalism(player)) {
|
||||
Herbalism.herbalismProcCheck(block, mcMMOPlayer, event, plugin); //Double drops
|
||||
|
||||
if (permInstance.herbalism(player)) {
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||
if (profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
||||
Herbalism.herbalismProcCheck(block, mcMMOPlayer, event, plugin); //Triple drops
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* MINING */
|
||||
else if (BlockChecks.canBeSuperBroken(block) && permInstance.mining(player)) {
|
||||
if (configInstance.getMiningRequiresTool()) {
|
||||
if (ItemChecks.isPickaxe(inHand)) {
|
||||
Mining.miningBlockCheck(player, block);
|
||||
else if (BlockChecks.canBeSuperBroken(block) && Permissions.mining(player) && !mcMMO.placeStore.isTrue(block)) {
|
||||
if (Mining.requiresTool) {
|
||||
if (ItemChecks.isPickaxe(heldItem)) {
|
||||
MiningManager miningManager = new MiningManager(mcMMOPlayer);
|
||||
miningManager.miningBlockCheck(block);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Mining.miningBlockCheck(player, block);
|
||||
MiningManager miningManager = new MiningManager(mcMMOPlayer);
|
||||
miningManager.miningBlockCheck(block);
|
||||
}
|
||||
}
|
||||
|
||||
/* WOOD CUTTING */
|
||||
else if (BlockChecks.isLog(block) && permInstance.woodcutting(player)) {
|
||||
if (configInstance.getWoodcuttingRequiresTool()) {
|
||||
if (ItemChecks.isAxe(inHand)) {
|
||||
WoodCutting.woodcuttingBlockCheck(player, block);
|
||||
}
|
||||
else if (BlockChecks.isLog(block) && Permissions.woodcutting(player) && !mcMMO.placeStore.isTrue(block)) {
|
||||
if (profile.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.treeFeller(player) && ItemChecks.isAxe(heldItem)) {
|
||||
Woodcutting.beginTreeFeller(mcMMOPlayer, block);
|
||||
}
|
||||
else {
|
||||
WoodCutting.woodcuttingBlockCheck(player, block);
|
||||
}
|
||||
|
||||
if (profile.getAbilityMode(AbilityType.TREE_FELLER) && permInstance.treeFeller(player) && ItemChecks.isAxe(inHand)) {
|
||||
WoodCutting.treeFeller(event);
|
||||
if (Config.getInstance().getWoodcuttingRequiresTool()) {
|
||||
if (ItemChecks.isAxe(heldItem)) {
|
||||
Woodcutting.beginWoodcutting(mcMMOPlayer, block);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Woodcutting.beginWoodcutting(mcMMOPlayer, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* EXCAVATION */
|
||||
else if (BlockChecks.canBeGigaDrillBroken(block) && permInstance.excavation(player) && !mcMMO.placeStore.isTrue(block)) {
|
||||
if (configInstance.getExcavationRequiresTool()) {
|
||||
if (ItemChecks.isShovel(inHand)) {
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
else if (BlockChecks.canBeGigaDrillBroken(block) && Permissions.excavation(player) && !mcMMO.placeStore.isTrue(block)) {
|
||||
if (Excavation.requiresTool) {
|
||||
if (ItemChecks.isShovel(heldItem)) {
|
||||
Excavation.excavationProcCheck(block, mcMMOPlayer);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
Excavation.excavationProcCheck(block, mcMMOPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
//Remove metadata when broken
|
||||
if (BlockChecks.shouldBeWatched(block)) {
|
||||
/* Remove metadata from placed watched blocks */
|
||||
if (BlockChecks.shouldBeWatched(block) && mcMMO.placeStore.isTrue(block)) {
|
||||
mcMMO.placeStore.setFalse(block);
|
||||
}
|
||||
}
|
||||
|
||||
//Remove metadata from fallen sand/gravel
|
||||
Material aboveType = block.getRelative(BlockFace.UP).getType();
|
||||
/**
|
||||
* Handle BlockBreak events where the event is modified.
|
||||
*
|
||||
* @param event The event to modify
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockBreakHigher(BlockBreakEvent event) {
|
||||
if (event instanceof FakeBlockBreakEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (aboveType == Material.SAND || aboveType == Material.GRAVEL) {
|
||||
for (int y = 1; block.getY() + y <= block.getWorld().getMaxHeight(); y++) {
|
||||
Block relative = block.getRelative(0, y, 0);
|
||||
Material relativeType = relative.getType();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if ((relativeType == Material.SAND || relativeType == Material.GRAVEL) && mcMMO.placeStore.isTrue(relative)) {
|
||||
mcMMO.placeStore.setFalse(relative);
|
||||
}
|
||||
else if (!BlockChecks.shouldBeWatched(relative) && mcMMO.placeStore.isTrue(relative)){
|
||||
mcMMO.placeStore.setFalse(relative);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getBlock();
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
|
||||
if (Permissions.hylianLuck(player) && ItemChecks.isSword(heldItem)) {
|
||||
Herbalism.hylianLuck(block, player, event);
|
||||
}
|
||||
else if (BlockChecks.canBeFluxMined(block) && ItemChecks.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH) && Permissions.fluxMining(player) && !mcMMO.placeStore.isTrue(block)) {
|
||||
SmeltingManager smeltingManager = new SmeltingManager(Users.getPlayer(player));
|
||||
smeltingManager.fluxMining(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle BlockDamage events where the event is modified.
|
||||
*
|
||||
* @param event The event to modify
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockDamageHigher(BlockDamageEvent event) {
|
||||
if (event instanceof FakeBlockDamageEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (Misc.isNPCPlayer(player, profile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getBlock();
|
||||
|
||||
/*
|
||||
* ABILITY PREPARATION CHECKS
|
||||
*
|
||||
* We check permissions here before processing activation.
|
||||
*/
|
||||
if (BlockChecks.canActivateAbilities(block)) {
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
|
||||
if (profile.getToolPreparationMode(ToolType.HOE) && ItemChecks.isHoe(heldItem) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.canMakeMossy(block)) && Permissions.greenTerra(player)) {
|
||||
SkillTools.abilityCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.AXE) && ItemChecks.isAxe(heldItem) && BlockChecks.isLog(block) && Permissions.treeFeller(player)) {
|
||||
SkillTools.abilityCheck(player, SkillType.WOODCUTTING);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.PICKAXE) && ItemChecks.isPickaxe(heldItem) && BlockChecks.canBeSuperBroken(block) && Permissions.superBreaker(player)) {
|
||||
SkillTools.abilityCheck(player, SkillType.MINING);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.SHOVEL) && ItemChecks.isShovel(heldItem) && BlockChecks.canBeGigaDrillBroken(block) && Permissions.gigaDrillBreaker(player)) {
|
||||
SkillTools.abilityCheck(player, SkillType.EXCAVATION);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockChecks.canBeGigaDrillBroken(block) || block.getType().equals(Material.SNOW)) && Permissions.berserk(player)) {
|
||||
SkillTools.abilityCheck(player, SkillType.UNARMED);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* TREE FELLER SOUNDS
|
||||
*
|
||||
* We don't need to check permissions here because they've already been checked for the ability to even activate.
|
||||
*/
|
||||
if (profile.getAbilityMode(AbilityType.TREE_FELLER) && BlockChecks.isLog(block)) {
|
||||
player.playSound(block.getLocation(), Sound.FIZZ, Misc.FIZZ_VOLUME, Misc.FIZZ_PITCH);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor BlockDamage events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
|
||||
if (event instanceof FakeBlockDamageEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int LEAF_BLOWER_LEVEL = 100;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (profile == null) {
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (Misc.isNPCPlayer(player, profile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
Block block = event.getBlock();
|
||||
Material material = block.getType();
|
||||
|
||||
Config configInstance = Config.getInstance();
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
/*
|
||||
* ABILITY PREPARATION CHECKS
|
||||
*/
|
||||
if (BlockChecks.abilityBlockCheck(block)) {
|
||||
if (profile.getToolPreparationMode(ToolType.HOE) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.makeMossy(block))) {
|
||||
Skills.abilityCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.AXE) && BlockChecks.isLog(block) && permInstance.treeFeller(player)) { //TODO: Why are we checking the permissions here?
|
||||
Skills.abilityCheck(player, SkillType.WOODCUTTING);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.PICKAXE) && BlockChecks.canBeSuperBroken(block)) {
|
||||
Skills.abilityCheck(player, SkillType.MINING);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.SHOVEL) && BlockChecks.canBeGigaDrillBroken(block)) {
|
||||
Skills.abilityCheck(player, SkillType.EXCAVATION);
|
||||
}
|
||||
else if (profile.getToolPreparationMode(ToolType.FISTS) && (BlockChecks.canBeGigaDrillBroken(block) || material.equals(Material.SNOW))) {
|
||||
Skills.abilityCheck(player, SkillType.UNARMED);
|
||||
}
|
||||
}
|
||||
|
||||
/* TREE FELLER SOUNDS */
|
||||
if (mcMMO.spoutEnabled && BlockChecks.isLog(block) && profile.getAbilityMode(AbilityType.TREE_FELLER)) {
|
||||
SpoutSounds.playSoundForPlayer(SoundEffect.FIZZ, player, block.getLocation());
|
||||
}
|
||||
|
||||
/*
|
||||
* ABILITY TRIGGER CHECKS
|
||||
*
|
||||
* We don't need to check permissions here because they've already been checked for the ability to even activate.
|
||||
*/
|
||||
if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && permInstance.greenTerra(player) && BlockChecks.makeMossy(block)) {
|
||||
if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && BlockChecks.canMakeMossy(block)) {
|
||||
Herbalism.greenTerra(player, block);
|
||||
}
|
||||
else if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
|
||||
if (configInstance.getExcavationRequiresTool()) {
|
||||
if (ItemChecks.isShovel(inHand)) {
|
||||
else if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && SkillTools.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
|
||||
if (Excavation.requiresTool) {
|
||||
if (ItemChecks.isShovel(heldItem)) {
|
||||
event.setInstaBreak(true);
|
||||
Excavation.gigaDrillBreaker(player, block);
|
||||
Excavation.gigaDrillBreaker(mcMMOPlayer, block);
|
||||
}
|
||||
}
|
||||
else {
|
||||
event.setInstaBreak(true);
|
||||
Excavation.gigaDrillBreaker(player, block);
|
||||
Excavation.gigaDrillBreaker(mcMMOPlayer, block);
|
||||
}
|
||||
}
|
||||
else if (profile.getAbilityMode(AbilityType.BERSERK) && Skills.triggerCheck(player, block, AbilityType.BERSERK)) {
|
||||
if (inHand.getType().equals(Material.AIR)) {
|
||||
else if (profile.getAbilityMode(AbilityType.BERSERK) && SkillTools.triggerCheck(player, block, AbilityType.BERSERK)) {
|
||||
if (heldItem.getType().equals(Material.AIR)) {
|
||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||
plugin.getServer().getPluginManager().callEvent(armswing);
|
||||
|
||||
event.setInstaBreak(true);
|
||||
}
|
||||
|
||||
if (mcMMO.spoutEnabled) {
|
||||
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
||||
}
|
||||
player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH);
|
||||
}
|
||||
else if (profile.getAbilityMode(AbilityType.SUPER_BREAKER) && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
|
||||
if (configInstance.getMiningRequiresTool()) {
|
||||
if (ItemChecks.isPickaxe(inHand)) {
|
||||
else if (profile.getAbilityMode(AbilityType.SUPER_BREAKER) && SkillTools.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
|
||||
MiningManager miningManager = new MiningManager(mcMMOPlayer);
|
||||
|
||||
if (Mining.requiresTool) {
|
||||
if (ItemChecks.isPickaxe(heldItem)) {
|
||||
event.setInstaBreak(true);
|
||||
Mining.superBreakerBlockCheck(player, block);
|
||||
miningManager.superBreakerBlockCheck(block);
|
||||
}
|
||||
}
|
||||
else {
|
||||
event.setInstaBreak(true);
|
||||
Mining.superBreakerBlockCheck(player, block);
|
||||
miningManager.superBreakerBlockCheck(block);
|
||||
}
|
||||
}
|
||||
else if (profile.getSkillLevel(SkillType.WOODCUTTING) >= LEAF_BLOWER_LEVEL && (material.equals(Material.LEAVES) || (configInstance.getBlockModsEnabled() && ModChecks.isCustomLeafBlock(block)))) {
|
||||
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||
if (configInstance.getWoodcuttingRequiresTool()) {
|
||||
if (ItemChecks.isAxe(inHand)) {
|
||||
else if ((profile.getSkillLevel(SkillType.WOODCUTTING) >= AdvancedConfig.getInstance().getLeafBlowUnlockLevel()) && BlockChecks.isLeaves(block)) {
|
||||
if (SkillTools.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||
if (Config.getInstance().getWoodcuttingRequiresTool()) {
|
||||
if (ItemChecks.isAxe(heldItem)) {
|
||||
event.setInstaBreak(true);
|
||||
WoodCutting.leafBlower(player, block);
|
||||
Woodcutting.beginLeafBlower(player, block);
|
||||
}
|
||||
}
|
||||
else if (!inHand.getType().equals(Material.SHEARS)) {
|
||||
else if (!heldItem.getType().equals(Material.SHEARS)) {
|
||||
event.setInstaBreak(true);
|
||||
WoodCutting.leafBlower(player, block);
|
||||
Woodcutting.beginLeafBlower(player, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
@@ -15,6 +16,7 @@ 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.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
@@ -23,24 +25,24 @@ 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.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.acrobatics.Acrobatics;
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||
import com.gmail.nossr50.skills.archery.Archery;
|
||||
import com.gmail.nossr50.skills.gathering.BlastMining;
|
||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.util.Combat;
|
||||
import com.gmail.nossr50.skills.utilities.CombatTools;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class EntityListener implements Listener {
|
||||
@@ -51,20 +53,45 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor EntityDamageByEntity events.
|
||||
* Monitor EntityChangeBlock events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onEntityChangeBlockEvent(EntityChangeBlockEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (entity instanceof FallingBlock) {
|
||||
Block block = event.getBlock();
|
||||
|
||||
if (mcMMO.placeStore.isTrue(block) && !mcMMO.placeStore.isSpawnedMob(entity)) {
|
||||
mcMMO.placeStore.setFalse(block);
|
||||
mcMMO.placeStore.addSpawnedMob(entity);
|
||||
}
|
||||
else if (mcMMO.placeStore.isSpawnedMob(entity)) {
|
||||
mcMMO.placeStore.setTrue(block);
|
||||
mcMMO.placeStore.removeSpawnedMob(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle EntityDamageByEntity events that involve modifying the event.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
if (event instanceof FakeEntityDamageByEntityEvent) {
|
||||
if (event instanceof FakeEntityDamageByEntityEvent || event.getDamage() <= 0)
|
||||
return;
|
||||
|
||||
Entity defender = event.getEntity();
|
||||
|
||||
if (Misc.isNPCEntity(defender) || defender.isDead()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity attacker = event.getDamager();
|
||||
Entity defender = event.getEntity();
|
||||
|
||||
if(attacker.hasMetadata("NPC") || defender.hasMetadata("NPC")) return; // Check if either players is are Citizens NPCs
|
||||
|
||||
if (attacker instanceof Projectile) {
|
||||
attacker = ((Projectile) attacker).getShooter();
|
||||
@@ -72,7 +99,7 @@ public class EntityListener implements Listener {
|
||||
else if (attacker instanceof Tameable) {
|
||||
AnimalTamer animalTamer = ((Tameable) attacker).getOwner();
|
||||
|
||||
if (animalTamer instanceof Entity) {
|
||||
if (animalTamer != null) {
|
||||
attacker = (Entity) animalTamer;
|
||||
}
|
||||
}
|
||||
@@ -84,11 +111,9 @@ public class EntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (attacker instanceof Player) {
|
||||
if (PartyManager.getInstance().inSameParty(defendingPlayer, (Player) attacker)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (attacker instanceof Player && PartyManager.inSameParty(defendingPlayer, (Player) attacker)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,71 +122,72 @@ public class EntityListener implements Listener {
|
||||
LivingEntity livingDefender = (LivingEntity) defender;
|
||||
|
||||
if (!Misc.isInvincible(livingDefender, event)) {
|
||||
Combat.combatChecks(event);
|
||||
CombatTools.combatChecks(event, attacker, livingDefender);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor EntityDamage events.
|
||||
* Handle EntityDamage events that involve modifying the event.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to modify
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if (event instanceof FakeEntityDamageEvent) {
|
||||
if (event instanceof FakeEntityDamageEvent || event.getDamage() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
DamageCause cause = event.getCause();
|
||||
|
||||
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (!(entity instanceof LivingEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity lEntity = (LivingEntity) entity;
|
||||
DamageCause cause = event.getCause();
|
||||
LivingEntity livingEntity = (LivingEntity) entity;
|
||||
|
||||
if (lEntity instanceof Player) {
|
||||
/* Check for invincibility */
|
||||
if (livingEntity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
|
||||
if (!player.isOnline()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (profile == null) {
|
||||
if (Misc.isNPCPlayer(player, profile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check for invincibility */
|
||||
if (profile.getGodMode()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Misc.isInvincible(player, event)) {
|
||||
if (cause == DamageCause.FALL && !player.isInsideVehicle() && !(player.getItemInHand().getType() == Material.ENDER_PEARL)) {
|
||||
AcrobaticsManager acroManager = new AcrobaticsManager(player);
|
||||
acroManager.rollCheck(event);
|
||||
if (cause == DamageCause.FALL && player.getItemInHand().getType() != Material.ENDER_PEARL && !(Acrobatics.afkLevelingDisabled && player.isInsideVehicle()) && Permissions.roll(player)) {
|
||||
AcrobaticsManager acrobaticsManager = new AcrobaticsManager(mcMMOPlayer);
|
||||
acrobaticsManager.rollCheck(event);
|
||||
}
|
||||
else if (cause == DamageCause.BLOCK_EXPLOSION && Permissions.getInstance().demolitionsExpertise(player)) {
|
||||
BlastMining.demolitionsExpertise(player, event);
|
||||
else if (cause == DamageCause.BLOCK_EXPLOSION && Permissions.demolitionsExpertise(player)) {
|
||||
MiningManager miningManager = new MiningManager(mcMMOPlayer);
|
||||
miningManager.demolitionsExpertise(event);
|
||||
}
|
||||
|
||||
if (event.getDamage() >= 1) {
|
||||
profile.actualizeRecentlyHurt();
|
||||
}
|
||||
}
|
||||
} else if (lEntity instanceof Tameable) {
|
||||
Tameable pet = (Tameable) lEntity;
|
||||
}
|
||||
else if (livingEntity instanceof Tameable) {
|
||||
Tameable pet = (Tameable) livingEntity;
|
||||
AnimalTamer owner = pet.getOwner();
|
||||
|
||||
if ((!Misc.isInvincible(lEntity, event)) && pet.isTamed() && (owner instanceof Player) && pet instanceof Wolf) {
|
||||
TamingManager tamingManager = new TamingManager((Player) owner);
|
||||
if ((!Misc.isInvincible(livingEntity, event)) && pet.isTamed() && owner instanceof Player && pet instanceof Wolf) {
|
||||
TamingManager tamingManager = new TamingManager(Users.getPlayer((Player) owner));
|
||||
tamingManager.preventDamage(event);
|
||||
}
|
||||
}
|
||||
@@ -170,182 +196,142 @@ public class EntityListener implements Listener {
|
||||
/**
|
||||
* Monitor EntityDeath events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
LivingEntity entity = event.getEntity();
|
||||
|
||||
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (Misc.isNPCEntity(entity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
entity.setFireTicks(0);
|
||||
BleedTimer.remove(entity);
|
||||
Archery.arrowRetrievalCheck(entity);
|
||||
mcMMO.placeStore.removeSpawnedMob(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor CreatureSpawn events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
@EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
if (Misc.isSpawnerXPEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
SpawnReason reason = event.getSpawnReason();
|
||||
|
||||
if ((reason.equals(SpawnReason.SPAWNER) || reason.equals(SpawnReason.SPAWNER_EGG)) && !Config.getInstance().getExperienceGainsMobspawnersEnabled()) {
|
||||
event.getEntity().setMetadata("mcmmoFromMobSpawner", new FixedMetadataValue(plugin, true));
|
||||
if (reason.equals(SpawnReason.SPAWNER) || reason.equals(SpawnReason.SPAWNER_EGG)) {
|
||||
mcMMO.placeStore.addSpawnedMob(event.getEntity());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor ExplosionPrime events.
|
||||
* Handle ExplosionPrime events that involve modifying the event.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to modify
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onExplosionPrime(ExplosionPrimeEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
|
||||
if (entity instanceof TNTPrimed) {
|
||||
int id = entity.getEntityId();
|
||||
|
||||
if (plugin.tntIsTracked(id)) {
|
||||
Player player = plugin.getTNTPlayer(id);
|
||||
|
||||
if (Permissions.getInstance().biggerBombs(player)) {
|
||||
BlastMining.biggerBombs(player, event);
|
||||
if (Permissions.biggerBombs(player)) {
|
||||
MiningManager miningManager = new MiningManager(Users.getPlayer(player));
|
||||
miningManager.biggerBombs(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor EntityExplode events.
|
||||
* Handle EntityExplode events that involve modifying the event.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to modify
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEnitityExplode(EntityExplodeEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if(entity == null) return;
|
||||
|
||||
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (entity instanceof TNTPrimed) {
|
||||
int id = entity.getEntityId();
|
||||
|
||||
if (plugin.tntIsTracked(id)) {
|
||||
Player player = plugin.getTNTPlayer(id);
|
||||
BlastMining.dropProcessing(player, event);
|
||||
|
||||
MiningManager miningManager = new MiningManager(Users.getPlayer(player));
|
||||
miningManager.blastMiningDropProcessing(event);
|
||||
|
||||
plugin.removeFromTNTTracker(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor FoodLevelChange events.
|
||||
* Handle FoodLevelChange events that involve modifying the event.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to modify
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.LOW)
|
||||
@EventHandler (priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
int currentFoodLevel = player.getFoodLevel();
|
||||
int newFoodLevel = event.getFoodLevel();
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (!Permissions.getInstance().farmersDiet(player)) {
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (Misc.isNPCPlayer(player, profile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int currentFoodLevel = player.getFoodLevel();
|
||||
int newFoodLevel = event.getFoodLevel();
|
||||
int foodChange = newFoodLevel - currentFoodLevel;
|
||||
|
||||
/*
|
||||
* 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 = profile.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;
|
||||
if (foodChange > 0) {
|
||||
switch (player.getItemInHand().getType()) {
|
||||
case BAKED_POTATO: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
||||
case BREAD: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||
case CARROT_ITEM: /* RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @ 1000 */
|
||||
case GOLDEN_CARROT: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
||||
case MUSHROOM_SOUP: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
case PUMPKIN_PIE: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
Herbalism.farmersDiet(player, Herbalism.farmersDietRankLevel1, event);
|
||||
break;
|
||||
|
||||
case COOKIE:
|
||||
/* COOKIE RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
rankChange = 400;
|
||||
case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
Herbalism.farmersDiet(player, Herbalism.farmersDietRankLevel2, event);
|
||||
break;
|
||||
|
||||
case MELON:
|
||||
/* MELON RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
rankChange = 400;
|
||||
case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||
Fishing.beginFishermansDiet(player, Fishing.fishermansDietRankLevel1, event);
|
||||
break;
|
||||
|
||||
case MUSHROOM_SOUP:
|
||||
/* MUSHROOM SOUP RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
rankChange = 200;
|
||||
case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
Fishing.beginFishermansDiet(player, Fishing.fishermansDietRankLevel2, event);
|
||||
break;
|
||||
|
||||
case CARROT_ITEM:
|
||||
/* CARROT RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @ 1000 */
|
||||
rankChange = 200;
|
||||
break;
|
||||
|
||||
case POTATO_ITEM:
|
||||
/* POTATO RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
rankChange = 400;
|
||||
break;
|
||||
|
||||
case BAKED_POTATO:
|
||||
/* BAKED POTATO RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
||||
rankChange = 200;
|
||||
break;
|
||||
|
||||
case POISONOUS_POTATO:
|
||||
/* POISONOUS POTATO RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
rankChange = 400;
|
||||
break;
|
||||
|
||||
case GOLDEN_CARROT:
|
||||
/* GOLDEN CARROT RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
||||
rankChange = 200;
|
||||
break;
|
||||
|
||||
case PUMPKIN_PIE:
|
||||
/* PUMPKIN PIE 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -355,31 +341,15 @@ public class EntityListener implements Listener {
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
@EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onEntityTame(EntityTameEvent event) {
|
||||
Player player = (Player) event.getOwner();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (Permissions.getInstance().taming(player) && !event.getEntity().hasMetadata("mcmmoSummoned")) {
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
EntityType type = event.getEntityType();
|
||||
int xp = 0;
|
||||
|
||||
switch (type) {
|
||||
case WOLF:
|
||||
xp = Config.getInstance().getTamingXPWolf();
|
||||
break;
|
||||
|
||||
case OCELOT:
|
||||
xp = Config.getInstance().getTamingXPOcelot();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Skills.xpProcessing(player, profile, SkillType.TAMING, xp);
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
TamingManager tamingManager = new TamingManager(Users.getPlayer(player));
|
||||
tamingManager.awardTamingXP(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,26 +6,29 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.util.Hardcore;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class HardcoreListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor PlayerDeath events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||
Player player = event.getEntity(); //Note this returns a Player object for this subevent
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
Player player = event.getEntity();
|
||||
|
||||
if (!Permissions.getInstance().hardcoremodeBypass(player)) {
|
||||
if (player.getKiller() != null && Config.getInstance().getHardcoreVampirismEnabled()) {
|
||||
Hardcore.invokeVampirism(player.getKiller(), player);
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Permissions.hardcoremodeBypass(player)) {
|
||||
Player killer = player.getKiller();
|
||||
|
||||
if (killer != null && Hardcore.vampirismEnabled) {
|
||||
Hardcore.invokeVampirism(killer, player);
|
||||
}
|
||||
|
||||
Hardcore.invokeStatPenalty(player);
|
||||
|
||||
131
src/main/java/com/gmail/nossr50/listeners/InventoryListener.java
Normal file
131
src/main/java/com/gmail/nossr50/listeners/InventoryListener.java
Normal file
@@ -0,0 +1,131 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
||||
import org.bukkit.event.inventory.FurnaceExtractEvent;
|
||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.FurnaceInventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class InventoryListener implements Listener{
|
||||
private final mcMMO plugin;
|
||||
|
||||
public InventoryListener(final mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||
InventoryType inventoryType = event.getInventory().getType();
|
||||
|
||||
if (inventoryType == InventoryType.FURNACE) {
|
||||
FurnaceInventory inventory = (FurnaceInventory) event.getInventory();
|
||||
Furnace furnace = inventory.getHolder();
|
||||
|
||||
if (furnace == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block furnaceBlock = furnace.getBlock();
|
||||
|
||||
if (furnace.getBurnTime() == 0 && !plugin.furnaceIsTracked(furnaceBlock)) {
|
||||
plugin.addToOpenFurnaceTracker(furnaceBlock, event.getPlayer().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
InventoryType inventoryType = event.getInventory().getType();
|
||||
|
||||
if (inventoryType == InventoryType.FURNACE) {
|
||||
FurnaceInventory inventory = (FurnaceInventory) event.getInventory();
|
||||
Furnace furnace = inventory.getHolder();
|
||||
|
||||
if (furnace == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block furnaceBlock = furnace.getBlock();
|
||||
|
||||
if (furnace.getBurnTime() == 0 && plugin.furnaceIsTracked(furnaceBlock)) {
|
||||
plugin.removeFromFurnaceTracker(furnaceBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onFurnaceBurnEvent(FurnaceBurnEvent event) {
|
||||
Block furnaceBlock = event.getBlock();
|
||||
BlockState blockState = furnaceBlock.getState();
|
||||
|
||||
if (blockState instanceof Furnace) {
|
||||
FurnaceInventory inventory = ((Furnace) blockState).getInventory();
|
||||
ItemStack smelting = inventory.getSmelting();
|
||||
|
||||
if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemChecks.isSmeltable(smelting)) {
|
||||
Player player = plugin.getFurnacePlayer(furnaceBlock);
|
||||
|
||||
if (player != null) {
|
||||
SmeltingManager smeltingManager = new SmeltingManager(Users.getPlayer(player));
|
||||
smeltingManager.fuelEfficiency(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) {
|
||||
Block furnaceBlock = event.getBlock();
|
||||
BlockState blockState = furnaceBlock.getState();
|
||||
|
||||
if (blockState instanceof Furnace) {
|
||||
FurnaceInventory inventory = ((Furnace) blockState).getInventory();
|
||||
ItemStack smelting = inventory.getSmelting();
|
||||
|
||||
if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemChecks.isSmeltable(smelting)) {
|
||||
Player player = plugin.getFurnacePlayer(furnaceBlock);
|
||||
|
||||
if (player != null) {
|
||||
SmeltingManager smeltingManager = new SmeltingManager(Users.getPlayer(player));
|
||||
smeltingManager.smeltProcessing(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onFurnaceExtractEvent(FurnaceExtractEvent event) {
|
||||
Block furnaceBlock = event.getBlock();
|
||||
BlockState blockState = furnaceBlock.getState();
|
||||
|
||||
if (blockState instanceof Furnace) {
|
||||
FurnaceInventory inventory = ((Furnace) blockState).getInventory();
|
||||
ItemStack result = inventory.getResult();
|
||||
|
||||
if (plugin.furnaceIsTracked(furnaceBlock) && result != null && ItemChecks.isSmelted(result)) {
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(plugin.getFurnacePlayer(furnaceBlock));
|
||||
|
||||
if (event.getPlayer().equals(mcMMOPlayer.getPlayer())) {
|
||||
SmeltingManager smeltingManager = new SmeltingManager(mcMMOPlayer);
|
||||
smeltingManager.vanillaXPBoost(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@@ -8,39 +7,38 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
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.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.mcMMO;
|
||||
import com.gmail.nossr50.commands.general.XprateCommand;
|
||||
import com.gmail.nossr50.chat.ChatManager;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.gathering.BlastMining;
|
||||
import com.gmail.nossr50.skills.gathering.Fishing;
|
||||
import com.gmail.nossr50.skills.gathering.Herbalism;
|
||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||
import com.gmail.nossr50.skills.mining.BlastMining;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.Salvage;
|
||||
import com.gmail.nossr50.skills.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.Item;
|
||||
import com.gmail.nossr50.util.ChimaeraWing;
|
||||
import com.gmail.nossr50.util.Motd;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
@@ -58,27 +56,20 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerWorldChangeEvent(PlayerChangedWorldEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (profile == null) {
|
||||
if (Misc.isNPCPlayer(player, profile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (profile.getGodMode()) {
|
||||
if (!Permissions.getInstance().mcgod(player)) {
|
||||
profile.toggleGodMode();
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Forbidden"));
|
||||
}
|
||||
if (profile.getGodMode() && !Permissions.mcgod(player)) {
|
||||
profile.toggleGodMode();
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Forbidden"));
|
||||
}
|
||||
|
||||
if (profile.inParty()) {
|
||||
if (!Permissions.getInstance().party(player)) {
|
||||
profile.removeParty();
|
||||
player.sendMessage(LocaleLoader.getString("Party.Forbidden"));
|
||||
}
|
||||
if (profile.inParty() && !Permissions.party(player)) {
|
||||
profile.removeParty();
|
||||
player.sendMessage(LocaleLoader.getString("Party.Forbidden"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,51 +81,27 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerFish(PlayerFishEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (Permissions.getInstance().fishing(player)) {
|
||||
State state = event.getState();
|
||||
|
||||
switch (state) {
|
||||
case CAUGHT_FISH:
|
||||
Fishing.processResults(event);
|
||||
break;
|
||||
|
||||
case CAUGHT_ENTITY:
|
||||
if (!(event.getCaught() instanceof LivingEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Users.getProfile(player).getSkillLevel(SkillType.FISHING) >= 150 && Permissions.getInstance().shakeMob(player)) {
|
||||
Fishing.shakeMob(event);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor PlaterPickupItem events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
||||
|
||||
if(event.getPlayer().hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(event.getPlayer());
|
||||
|
||||
if (profile == null) {
|
||||
if (Misc.isNPCPlayer(player) || !Permissions.fishing(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (profile.getAbilityMode(AbilityType.BERSERK)) {
|
||||
event.setCancelled(true);
|
||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.FISHING);
|
||||
|
||||
switch (event.getState()) {
|
||||
case CAUGHT_FISH:
|
||||
Fishing.beginFishing(Users.getPlayer(player), skillLevel, event);
|
||||
break;
|
||||
|
||||
case CAUGHT_ENTITY:
|
||||
if (skillLevel >= AdvancedConfig.getInstance().getShakeUnlockLevel() && Permissions.shakeMob(player)) {
|
||||
//TODO: Unsafe cast?
|
||||
Fishing.beginShakeMob(player, (LivingEntity) event.getCaught(), skillLevel);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,8 +112,14 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
if(event.getPlayer().hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
Users.addUser(event.getPlayer()).getProfile().actualizeRespawnATS();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
/* We can't use the other check here because a profile hasn't been created yet.*/
|
||||
if (player == null || player.hasMetadata("NPC")) {
|
||||
return;
|
||||
}
|
||||
|
||||
Users.addUser(player).getProfile().actualizeRespawnATS();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,13 +130,13 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* GARBAGE COLLECTION */
|
||||
|
||||
//Bleed it out
|
||||
BleedTimer.bleedOut(player);
|
||||
BleedTimer.bleedOut(player); //Bleed it out
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,55 +147,87 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
//TODO: Locale ALL the things.
|
||||
if (Config.getInstance().getMOTDEnabled() && Permissions.getInstance().motd(player)) {
|
||||
String prefix = ChatColor.GOLD + "[mcMMO] ";
|
||||
String perkPrefix = ChatColor.RED + "[mcMMO Perks] ";
|
||||
|
||||
player.sendMessage(prefix + ChatColor.YELLOW + "Running version " + ChatColor.DARK_AQUA + plugin.getDescription().getVersion()); //TODO: Locale
|
||||
|
||||
if (Config.getInstance().getHardcoreEnabled()) {
|
||||
if (Config.getInstance().getHardcoreVampirismEnabled()) {
|
||||
player.sendMessage(prefix + ChatColor.DARK_RED + "Hardcore & Vampirism enabled.");
|
||||
player.sendMessage(prefix + ChatColor.DARK_AQUA + "Skill Death Penalty: " + ChatColor.DARK_RED + Config.getInstance().getHardcoreDeathStatPenaltyPercentage() + "% " + ChatColor.DARK_AQUA + "Vampirism Stat Leech: " + ChatColor.DARK_RED + Config.getInstance().getHardcoreVampirismStatLeechPercentage() + "%");
|
||||
}
|
||||
else {
|
||||
player.sendMessage(prefix + ChatColor.DARK_RED + "Hardcore enabled.");
|
||||
player.sendMessage(prefix + ChatColor.DARK_AQUA + "Skill Death Penalty: " + ChatColor.DARK_RED + Config.getInstance().getHardcoreDeathStatPenaltyPercentage() + "%");
|
||||
}
|
||||
}
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
|
||||
player.sendMessage(perkPrefix + ChatColor.DARK_AQUA + "Quadruple XP - Receive 4x XP.");
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.triple")) {
|
||||
player.sendMessage(perkPrefix + ChatColor.DARK_AQUA + "Triple XP - Receive 3x XP.");
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.double")) {
|
||||
player.sendMessage(perkPrefix + ChatColor.DARK_AQUA + "Double XP - Receive 2x XP.");
|
||||
}
|
||||
|
||||
player.sendMessage(ChatColor.GOLD+"[mcMMO] " + ChatColor.GREEN + "http://www.mcmmo.info" + ChatColor.YELLOW + " - mcMMO Website & Forums"); //TODO: Locale
|
||||
//player.sendMessage(LocaleLoader.getString("mcMMO.MOTD", new Object[] {plugin.getDescription().getVersion()}));
|
||||
//player.sendMessage(LocaleLoader.getString("mcMMO.Website"));
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//THIS IS VERY BAD WAY TO DO THINGS, NEED BETTER WAY
|
||||
if (XprateCommand.isXpEventRunning()) {
|
||||
player.sendMessage(LocaleLoader.getString("XPRate.Event", new Object[] {Config.getInstance().xpGainMultiplier}));
|
||||
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
|
||||
Motd.displayAll(player);
|
||||
}
|
||||
|
||||
if (plugin.isXPEventEnabled()) {
|
||||
player.sendMessage(LocaleLoader.getString("XPRate.Event", new Object[] {Config.getInstance().getExperienceGainsGlobalMultiplier()}));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor PlayerRespawn events.
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
if(event.getPlayer().hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
PlayerProfile profile = Users.getProfile(event.getPlayer());
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (profile != null) {
|
||||
profile.actualizeRespawnATS();
|
||||
if (Misc.isNPCPlayer(player, profile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
profile.actualizeRespawnATS();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle PlayerInteract events that involve modifying the event.
|
||||
*
|
||||
* @param event The event to modify
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerInteractLowest(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
|
||||
switch (event.getAction()) {
|
||||
case RIGHT_CLICK_BLOCK:
|
||||
int blockID = block.getTypeId();
|
||||
|
||||
/* REPAIR CHECKS */
|
||||
if (blockID == Repair.anvilID && Permissions.repair(player) && mcMMO.repairManager.isRepairable(heldItem)) {
|
||||
mcMMO.repairManager.handleRepair(Users.getPlayer(player), heldItem);
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
}
|
||||
/* SALVAGE CHECKS */
|
||||
else if (blockID == Salvage.anvilID && Permissions.salvage(player) && Salvage.isSalvageable(heldItem)) {
|
||||
Salvage.handleSalvage(player, block.getLocation(), heldItem);
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
}
|
||||
/* BLAST MINING CHECK */
|
||||
else if (player.isSneaking() && Permissions.blastMining(player) && heldItem.getTypeId() == BlastMining.detonatorID) {
|
||||
MiningManager miningManager = new MiningManager(Users.getPlayer(player));
|
||||
miningManager.detonate(event);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RIGHT_CLICK_AIR:
|
||||
/* BLAST MINING CHECK */
|
||||
if (player.isSneaking() && Permissions.blastMining(player) && heldItem.getTypeId() == BlastMining.detonatorID) {
|
||||
MiningManager miningManager = new MiningManager(Users.getPlayer(player));
|
||||
miningManager.detonate(event);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,62 +236,41 @@ public class PlayerListener implements Listener {
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
Action action = event.getAction();
|
||||
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
Material material;
|
||||
ItemStack heldItem = player.getItemInHand();
|
||||
|
||||
/* Fix for NPE on interacting with air */
|
||||
if (block == null) {
|
||||
material = Material.AIR;
|
||||
}
|
||||
else {
|
||||
material = block.getType();
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
switch (event.getAction()) {
|
||||
case RIGHT_CLICK_BLOCK:
|
||||
|
||||
/* REPAIR CHECKS */
|
||||
if (Permissions.getInstance().repair(player) && block.getTypeId() == Config.getInstance().getRepairAnvilId()) {
|
||||
if (mcMMO.repairManager.isRepairable(inHand)) {
|
||||
mcMMO.repairManager.handleRepair(player, inHand);
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
/* ACTIVATION & ITEM CHECKS */
|
||||
if (BlockChecks.canActivateAbilities(block)) {
|
||||
if (SkillTools.abilitiesEnabled) {
|
||||
if (BlockChecks.canActivateHerbalism(block)) {
|
||||
SkillTools.activationCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
/* ACTIVATION CHECKS */
|
||||
if (Config.getInstance().getAbilitiesEnabled() && BlockChecks.abilityBlockCheck(block)) {
|
||||
if (!material.equals(Material.DIRT) && !material.equals(Material.GRASS) && !material.equals(Material.SOIL)) {
|
||||
Skills.activationCheck(player, SkillType.HERBALISM);
|
||||
SkillTools.activationCheck(player, SkillType.AXES);
|
||||
SkillTools.activationCheck(player, SkillType.EXCAVATION);
|
||||
SkillTools.activationCheck(player, SkillType.MINING);
|
||||
SkillTools.activationCheck(player, SkillType.SWORDS);
|
||||
SkillTools.activationCheck(player, SkillType.UNARMED);
|
||||
SkillTools.activationCheck(player, SkillType.WOODCUTTING);
|
||||
}
|
||||
|
||||
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);
|
||||
ChimaeraWing.activationCheck(player);
|
||||
}
|
||||
|
||||
/* GREEN THUMB CHECK */
|
||||
if (inHand.getType().equals(Material.SEEDS) && BlockChecks.makeMossy(block) && Permissions.getInstance().greenThumbBlocks(player)) {
|
||||
Herbalism.greenThumbBlocks(inHand, player, block);
|
||||
}
|
||||
|
||||
/* ITEM CHECKS */
|
||||
if (BlockChecks.abilityBlockCheck(block)) {
|
||||
Item.itemChecks(player);
|
||||
}
|
||||
|
||||
/* BLAST MINING CHECK */
|
||||
if (player.isSneaking() && inHand.getTypeId() == Config.getInstance().getDetonatorItemID() && Permissions.getInstance().blastMining(player)) {
|
||||
BlastMining.detonate(event, player, plugin);
|
||||
if (heldItem.getType() == Material.SEEDS && BlockChecks.canMakeMossy(block) && Permissions.greenThumbBlocks(player)) {
|
||||
Herbalism.greenThumbBlocks(heldItem, player, block);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -294,23 +278,18 @@ public class PlayerListener implements Listener {
|
||||
case RIGHT_CLICK_AIR:
|
||||
|
||||
/* ACTIVATION CHECKS */
|
||||
if (Config.getInstance().getAbilitiesEnabled()) {
|
||||
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);
|
||||
if (SkillTools.abilitiesEnabled) {
|
||||
SkillTools.activationCheck(player, SkillType.AXES);
|
||||
SkillTools.activationCheck(player, SkillType.EXCAVATION);
|
||||
SkillTools.activationCheck(player, SkillType.HERBALISM);
|
||||
SkillTools.activationCheck(player, SkillType.MINING);
|
||||
SkillTools.activationCheck(player, SkillType.SWORDS);
|
||||
SkillTools.activationCheck(player, SkillType.UNARMED);
|
||||
SkillTools.activationCheck(player, SkillType.WOODCUTTING);
|
||||
}
|
||||
|
||||
/* ITEM CHECKS */
|
||||
Item.itemChecks(player);
|
||||
|
||||
/* BLAST MINING CHECK */
|
||||
if (player.isSneaking() && inHand.getTypeId() == Config.getInstance().getDetonatorItemID() && Permissions.getInstance().blastMining(player)) {
|
||||
BlastMining.detonate(event, player, plugin);
|
||||
}
|
||||
ChimaeraWing.activationCheck(player);
|
||||
|
||||
break;
|
||||
|
||||
@@ -319,14 +298,14 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/* CALL OF THE WILD CHECKS */
|
||||
if (player.isSneaking()) {
|
||||
Material type = inHand.getType();
|
||||
Material type = heldItem.getType();
|
||||
|
||||
if (type == Material.RAW_FISH) {
|
||||
TamingManager tamingManager = new TamingManager(player);
|
||||
TamingManager tamingManager = new TamingManager(Users.getPlayer(player));
|
||||
tamingManager.summonOcelot();
|
||||
}
|
||||
else if (type == Material.BONE) {
|
||||
TamingManager tamingManager = new TamingManager(player);
|
||||
TamingManager tamingManager = new TamingManager(Users.getPlayer(player));
|
||||
tamingManager.summonWolf();
|
||||
}
|
||||
}
|
||||
@@ -346,12 +325,9 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (profile == null) {
|
||||
if (Misc.isNPCPlayer(player, profile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -359,70 +335,16 @@ public class PlayerListener implements Listener {
|
||||
Party party = profile.getParty();
|
||||
|
||||
if (party == null) {
|
||||
player.sendMessage("You're not in a party, type /p to leave party chat mode."); //TODO: Use mcLocale
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
return;
|
||||
}
|
||||
|
||||
String partyName = party.getName();
|
||||
String playerName = player.getName();
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(playerName, partyName, event.getMessage());
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String prefix = ChatColor.GREEN + "(" + ChatColor.WHITE + playerName + ChatColor.GREEN + ") ";
|
||||
|
||||
plugin.getLogger().info("[P](" + partyName + ")" + "<" + playerName + "> " + chatEvent.getMessage());
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
member.sendMessage(prefix + chatEvent.getMessage());
|
||||
}
|
||||
|
||||
ChatManager.handlePartyChat(plugin, party, player.getName(), player.getDisplayName(), event.getMessage());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (profile.getAdminChatMode()) {
|
||||
String playerName = player.getName();
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(playerName, event.getMessage());
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String prefix = ChatColor.AQUA + "{" + ChatColor.WHITE + playerName + ChatColor.AQUA + "} ";
|
||||
|
||||
plugin.getLogger().info("[A]<" + playerName + "> " + chatEvent.getMessage());
|
||||
|
||||
for (Player otherPlayer : plugin.getServer().getOnlinePlayers()) {
|
||||
if (Permissions.getInstance().adminChat(otherPlayer) || otherPlayer.isOp()) {
|
||||
otherPlayer.sendMessage(prefix + chatEvent.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
ChatManager.handleAdminChat(plugin, player.getName(), player.getDisplayName(), event.getMessage());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor PlayerCommandPreprocess events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
String message = event.getMessage();
|
||||
String command = message.substring(1).split(" ")[0];
|
||||
String lowerCaseCommand = command.toLowerCase();
|
||||
|
||||
if (plugin.commandIsAliased(lowerCaseCommand)) {
|
||||
//We should find a better way to avoid string replacement where the alias is equals to the command
|
||||
if (command.equals(plugin.getCommandAlias(lowerCaseCommand))) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setMessage(message.replace(command, plugin.getCommandAlias(lowerCaseCommand)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||
* Listener for listening to our own events, only really useful for catching errors
|
||||
*/
|
||||
public class SelfListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor internal XP gain events.
|
||||
*
|
||||
@@ -19,7 +18,7 @@ public class SelfListener implements Listener {
|
||||
public void onPlayerXpGain(McMMOPlayerXpGainEvent event) {
|
||||
int xp = event.getXpGained();
|
||||
|
||||
if(xp < 0) {
|
||||
if (xp < 0) {
|
||||
try {
|
||||
throw new Exception("Gained negative XP!");
|
||||
}
|
||||
|
||||
@@ -3,50 +3,106 @@ package com.gmail.nossr50.listeners;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.event.world.WorldInitEvent;
|
||||
import org.bukkit.event.world.WorldSaveEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
import org.bukkit.World;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.blockstoreconversion.BlockStoreConversionMain;
|
||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.HashChunkManager;
|
||||
import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionMain;
|
||||
|
||||
public class WorldListener implements Listener {
|
||||
ArrayList<BlockStoreConversionMain> converters = new ArrayList<BlockStoreConversionMain>();
|
||||
private ArrayList<BlockStoreConversionMain> converters = new ArrayList<BlockStoreConversionMain>();
|
||||
|
||||
@EventHandler
|
||||
public void onWorldInit(WorldInitEvent event) {
|
||||
File dataDir = new File(event.getWorld().getWorldFolder(), "mcmmo_data");
|
||||
if(!dataDir.exists()) {
|
||||
/**
|
||||
* Monitor StructureGrow events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onStructureGrow(StructureGrowEvent event) {
|
||||
TreeType species = event.getSpecies();
|
||||
|
||||
if (species == TreeType.BROWN_MUSHROOM || species == TreeType.RED_MUSHROOM) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(mcMMO.p == null)
|
||||
return;
|
||||
if (mcMMO.placeStore.isTrue(event.getLocation().getBlock())) {
|
||||
for (BlockState block : event.getBlocks()) {
|
||||
mcMMO.placeStore.setFalse(block.getBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("Converting block storage for " + event.getWorld().getName() + " to a new format.");
|
||||
BlockStoreConversionMain converter = new BlockStoreConversionMain(event.getWorld());
|
||||
/**
|
||||
* Monitor WorldInit events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onWorldInit(WorldInitEvent event) {
|
||||
World world = event.getWorld();
|
||||
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
|
||||
|
||||
if (!dataDir.exists() || mcMMO.p == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("Converting block storage for " + world.getName() + " to a new format.");
|
||||
|
||||
BlockStoreConversionMain converter = new BlockStoreConversionMain(world);
|
||||
converter.run();
|
||||
converters.add(converter);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
/**
|
||||
* Monitor WorldUnload events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onWorldUnload(WorldUnloadEvent event) {
|
||||
mcMMO.placeStore.unloadWorld(event.getWorld());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldSave(WorldSaveEvent event) {
|
||||
mcMMO.placeStore.saveWorld(event.getWorld());
|
||||
/**
|
||||
* Monitor ChunkUnload events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onChunkUnload(ChunkUnloadEvent event) {
|
||||
Chunk chunk = event.getChunk();
|
||||
|
||||
mcMMO.placeStore.chunkUnloaded(chunk.getX(), chunk.getZ(), event.getWorld());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChunkUnload(ChunkUnloadEvent event) {
|
||||
mcMMO.placeStore.chunkUnloaded(event.getChunk().getX(), event.getChunk().getZ(), event.getWorld());
|
||||
/**
|
||||
* Monitor ChunkLoad events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onChunkLoad(ChunkLoadEvent event) {
|
||||
Chunk chunk = event.getChunk();
|
||||
Entity[] entities = chunk.getEntities();
|
||||
|
||||
for (Entity entity : entities) {
|
||||
if (entity instanceof LivingEntity || entity instanceof FallingBlock) {
|
||||
mcMMO.placeStore.loadChunk(chunk.getX(), chunk.getZ(), event.getWorld(), entities);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,12 @@ import org.bukkit.ChatColor;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
|
||||
public class LocaleLoader {
|
||||
public final class LocaleLoader {
|
||||
private static final String BUNDLE_NAME = "com.gmail.nossr50.locale.locale";
|
||||
private static ResourceBundle RESOURCE_BUNDLE = null;
|
||||
|
||||
private LocaleLoader() {};
|
||||
|
||||
public static String getString(String key) {
|
||||
return getString(key, null);
|
||||
}
|
||||
@@ -75,6 +77,12 @@ public class LocaleLoader {
|
||||
input = input.replaceAll("\\Q[[LIGHT_PURPLE]]\\E", ChatColor.LIGHT_PURPLE.toString());
|
||||
input = input.replaceAll("\\Q[[YELLOW]]\\E", ChatColor.YELLOW.toString());
|
||||
input = input.replaceAll("\\Q[[WHITE]]\\E", ChatColor.WHITE.toString());
|
||||
input = input.replaceAll("\\Q[[BOLD]]\\E", ChatColor.BOLD.toString());
|
||||
input = input.replaceAll("\\Q[[UNDERLINE]]\\E", ChatColor.UNDERLINE.toString());
|
||||
input = input.replaceAll("\\Q[[ITALIC]]\\E", ChatColor.ITALIC.toString());
|
||||
input = input.replaceAll("\\Q[[STRIKE]]\\E", ChatColor.STRIKETHROUGH.toString());
|
||||
input = input.replaceAll("\\Q[[MAGIC]]\\E", ChatColor.MAGIC.toString());
|
||||
input = input.replaceAll("\\Q[[RESET]]\\E", ChatColor.RESET.toString());
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
@@ -9,109 +9,101 @@ import java.util.List;
|
||||
import net.shatteredlands.shatt.backup.ZipLibrary;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.World;
|
||||
|
||||
import com.gmail.nossr50.commands.general.AddlevelsCommand;
|
||||
import com.gmail.nossr50.commands.general.AddxpCommand;
|
||||
import com.gmail.nossr50.commands.general.InspectCommand;
|
||||
import com.gmail.nossr50.commands.general.McstatsCommand;
|
||||
import com.gmail.nossr50.commands.general.MmoeditCommand;
|
||||
import com.gmail.nossr50.commands.general.MmoupdateCommand;
|
||||
import com.gmail.nossr50.commands.general.SkillResetCommand;
|
||||
import com.gmail.nossr50.commands.general.XprateCommand;
|
||||
import com.gmail.nossr50.commands.mc.McabilityCommand;
|
||||
import com.gmail.nossr50.commands.mc.MccCommand;
|
||||
import com.gmail.nossr50.commands.mc.McgodCommand;
|
||||
import com.gmail.nossr50.commands.mc.McmmoCommand;
|
||||
import com.gmail.nossr50.commands.mc.McrefreshCommand;
|
||||
import com.gmail.nossr50.commands.mc.McremoveCommand;
|
||||
import com.gmail.nossr50.commands.mc.MctopCommand;
|
||||
import com.gmail.nossr50.commands.party.ACommand;
|
||||
import com.gmail.nossr50.commands.party.AcceptCommand;
|
||||
import com.gmail.nossr50.commands.party.InviteCommand;
|
||||
import com.gmail.nossr50.commands.party.PCommand;
|
||||
import com.gmail.nossr50.commands.party.PartyCommand;
|
||||
import com.gmail.nossr50.commands.party.PtpCommand;
|
||||
import com.gmail.nossr50.commands.skills.AcrobaticsCommand;
|
||||
import com.gmail.nossr50.commands.skills.ArcheryCommand;
|
||||
import com.gmail.nossr50.commands.skills.AxesCommand;
|
||||
import com.gmail.nossr50.commands.skills.ExcavationCommand;
|
||||
import com.gmail.nossr50.commands.skills.FishingCommand;
|
||||
import com.gmail.nossr50.commands.skills.HerbalismCommand;
|
||||
import com.gmail.nossr50.commands.skills.MiningCommand;
|
||||
import com.gmail.nossr50.commands.skills.RepairCommand;
|
||||
import com.gmail.nossr50.commands.skills.SwordsCommand;
|
||||
import com.gmail.nossr50.commands.skills.TamingCommand;
|
||||
import com.gmail.nossr50.commands.skills.UnarmedCommand;
|
||||
import com.gmail.nossr50.commands.skills.WoodcuttingCommand;
|
||||
import com.gmail.nossr50.commands.spout.MchudCommand;
|
||||
import com.gmail.nossr50.commands.spout.XplockCommand;
|
||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
|
||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
|
||||
import com.gmail.nossr50.chat.commands.ACommand;
|
||||
import com.gmail.nossr50.chat.commands.PCommand;
|
||||
import com.gmail.nossr50.commands.CommandRegistrationHelper;
|
||||
import com.gmail.nossr50.commands.admin.AddxpCommand;
|
||||
import com.gmail.nossr50.commands.admin.McgodCommand;
|
||||
import com.gmail.nossr50.commands.admin.McrefreshCommand;
|
||||
import com.gmail.nossr50.commands.admin.MmoeditCommand;
|
||||
import com.gmail.nossr50.commands.admin.SkillResetCommand;
|
||||
import com.gmail.nossr50.commands.admin.XprateCommand;
|
||||
import com.gmail.nossr50.commands.player.InspectCommand;
|
||||
import com.gmail.nossr50.commands.player.McabilityCommand;
|
||||
import com.gmail.nossr50.commands.player.MccCommand;
|
||||
import com.gmail.nossr50.commands.player.McmmoCommand;
|
||||
import com.gmail.nossr50.commands.player.McrankCommand;
|
||||
import com.gmail.nossr50.commands.player.McstatsCommand;
|
||||
import com.gmail.nossr50.commands.player.MctopCommand;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.HiddenConfig;
|
||||
import com.gmail.nossr50.config.TreasuresConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomToolsConfig;
|
||||
import com.gmail.nossr50.config.repair.RepairConfigManager;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.database.commands.McpurgeCommand;
|
||||
import com.gmail.nossr50.database.commands.McremoveCommand;
|
||||
import com.gmail.nossr50.database.commands.MmoupdateCommand;
|
||||
import com.gmail.nossr50.database.runnables.UserPurgeTask;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.listeners.BlockListener;
|
||||
import com.gmail.nossr50.listeners.EntityListener;
|
||||
import com.gmail.nossr50.listeners.HardcoreListener;
|
||||
import com.gmail.nossr50.listeners.InventoryListener;
|
||||
import com.gmail.nossr50.listeners.PlayerListener;
|
||||
import com.gmail.nossr50.listeners.WorldListener;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mods.config.CustomArmorConfig;
|
||||
import com.gmail.nossr50.mods.config.CustomBlocksConfig;
|
||||
import com.gmail.nossr50.mods.config.CustomToolsConfig;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.runnables.ChunkletUnloader;
|
||||
import com.gmail.nossr50.party.commands.PartyCommand;
|
||||
import com.gmail.nossr50.party.commands.PtpCommand;
|
||||
import com.gmail.nossr50.runnables.MobStoreCleaner;
|
||||
import com.gmail.nossr50.runnables.SaveTimer;
|
||||
import com.gmail.nossr50.runnables.SkillMonitor;
|
||||
import com.gmail.nossr50.runnables.SpoutStart;
|
||||
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||
import com.gmail.nossr50.skills.repair.RepairManagerFactory;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.skills.repair.config.RepairConfigManager;
|
||||
import com.gmail.nossr50.skills.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.runnables.SkillMonitor;
|
||||
import com.gmail.nossr50.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.spout.SpoutTools;
|
||||
import com.gmail.nossr50.spout.commands.MchudCommand;
|
||||
import com.gmail.nossr50.spout.commands.XplockCommand;
|
||||
import com.gmail.nossr50.util.Anniversary;
|
||||
import com.gmail.nossr50.util.Leaderboard;
|
||||
import com.gmail.nossr50.util.Metrics;
|
||||
import com.gmail.nossr50.util.Metrics.Graph;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
|
||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
|
||||
|
||||
|
||||
public class mcMMO extends JavaPlugin {
|
||||
|
||||
private final PlayerListener playerListener = new PlayerListener(this);
|
||||
private final BlockListener blockListener = new BlockListener(this);
|
||||
private final EntityListener entityListener = new EntityListener(this);
|
||||
private final InventoryListener inventoryListener = new InventoryListener(this);
|
||||
private final WorldListener worldListener = new WorldListener();
|
||||
private final HardcoreListener hardcoreListener = new HardcoreListener();
|
||||
|
||||
private HashMap<String, String> aliasMap = new HashMap<String, String>(); //Alias - Command
|
||||
private HashMap<Integer, String> tntTracker = new HashMap<Integer, String>();
|
||||
private HashMap<Block, String> furnaceTracker = new HashMap<Block, String>();
|
||||
|
||||
private static Database database;
|
||||
public static mcMMO p;
|
||||
|
||||
public static ChunkManager placeStore;
|
||||
public static RepairManager repairManager;
|
||||
|
||||
/* Jar Stuff */
|
||||
// Jar Stuff
|
||||
public static File mcmmo;
|
||||
|
||||
//File Paths
|
||||
// File Paths
|
||||
private static String mainDirectory;
|
||||
private static String flatFileDirectory;
|
||||
private static String usersFile;
|
||||
private static String leaderboardDirectory;
|
||||
private static String modDirectory;
|
||||
|
||||
//Spout Check
|
||||
public static boolean spoutEnabled;
|
||||
// Spout Check
|
||||
public static boolean spoutEnabled = false;
|
||||
|
||||
// XP Event Check
|
||||
private boolean xpEventEnabled = false;
|
||||
|
||||
/**
|
||||
* Things to be run when the plugin is enabled.
|
||||
@@ -121,10 +113,23 @@ public class mcMMO extends JavaPlugin {
|
||||
p = this;
|
||||
setupFilePaths();
|
||||
|
||||
//Force the loading of config files
|
||||
// Check for Spout
|
||||
if (getServer().getPluginManager().isPluginEnabled("Spout")) {
|
||||
spoutEnabled = true;
|
||||
|
||||
SpoutConfig.getInstance();
|
||||
SpoutTools.setupSpoutConfigs();
|
||||
SpoutTools.registerCustomEvent();
|
||||
SpoutTools.preCacheFiles();
|
||||
SpoutTools.reloadSpoutPlayers(); // Handle spout players after a /reload
|
||||
}
|
||||
|
||||
// Force the loading of config files
|
||||
Config configInstance = Config.getInstance();
|
||||
TreasuresConfig.getInstance();
|
||||
HiddenConfig.getInstance();
|
||||
AdvancedConfig.getInstance();
|
||||
PartyManager.loadParties();
|
||||
|
||||
List<Repairable> repairables = new ArrayList<Repairable>();
|
||||
|
||||
@@ -140,22 +145,28 @@ public class mcMMO extends JavaPlugin {
|
||||
CustomBlocksConfig.getInstance();
|
||||
}
|
||||
|
||||
//Load repair configs, make manager, and register them at this time
|
||||
// Load repair configs, make manager, and register them at this time
|
||||
RepairConfigManager rManager = new RepairConfigManager(this);
|
||||
repairables.addAll(rManager.getLoadedRepairables());
|
||||
repairManager = RepairManagerFactory.getRepairManager(repairables.size());
|
||||
repairManager.registerRepairables(repairables);
|
||||
|
||||
// Check if Repair Anvil and Salvage Anvil have different itemID's
|
||||
if (configInstance.getSalvageAnvilId() == configInstance.getRepairAnvilId()) {
|
||||
getLogger().warning("Can't use the same itemID for Repair/Salvage Anvils!");
|
||||
}
|
||||
|
||||
if (!configInstance.getUseMySQL()) {
|
||||
Users.loadUsers();
|
||||
}
|
||||
|
||||
PluginManager pluginManager = getServer().getPluginManager();
|
||||
|
||||
//Register events
|
||||
// Register events
|
||||
pluginManager.registerEvents(playerListener, this);
|
||||
pluginManager.registerEvents(blockListener, this);
|
||||
pluginManager.registerEvents(entityListener, this);
|
||||
pluginManager.registerEvents(inventoryListener, this);
|
||||
pluginManager.registerEvents(worldListener, this);
|
||||
|
||||
if (configInstance.getHardcoreEnabled()) {
|
||||
@@ -164,40 +175,46 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
PluginDescriptionFile pdfFile = getDescription();
|
||||
|
||||
//Setup the leaderboards
|
||||
// Setup the leader boards
|
||||
if (configInstance.getUseMySQL()) {
|
||||
database = new Database(this);
|
||||
database.createStructure();
|
||||
// TODO: Why do we have to check for a connection that hasn't be made yet?
|
||||
Database.checkConnected();
|
||||
Database.createStructure();
|
||||
}
|
||||
else {
|
||||
Leaderboard.makeLeaderboards();
|
||||
Leaderboard.updateLeaderboards();
|
||||
}
|
||||
|
||||
for (Player player : getServer().getOnlinePlayers()) {
|
||||
Users.addUser(player); //In case of reload add all users back into PlayerProfile
|
||||
Users.addUser(player); // In case of reload add all users back into PlayerProfile
|
||||
}
|
||||
|
||||
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
|
||||
getLogger().info("Version " + pdfFile.getVersion() + " is enabled!");
|
||||
|
||||
BukkitScheduler scheduler = getServer().getScheduler();
|
||||
|
||||
//Schedule Spout Activation 1 second after start-up
|
||||
scheduler.scheduleSyncDelayedTask(this, new SpoutStart(this), 20);
|
||||
//Periodic save timer (Saves every 10 minutes by default)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(this), 0, configInstance.getSaveInterval() * 1200);
|
||||
//Regen & Cooldown timer (Runs every second)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new SkillMonitor(this), 0, 20);
|
||||
//Bleed timer (Runs every two seconds)
|
||||
// Periodic save timer (Saves every 10 minutes by default)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(), 0, configInstance.getSaveInterval() * 1200);
|
||||
// Regen & Cooldown timer (Runs every second)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new SkillMonitor(), 0, 20);
|
||||
// Bleed timer (Runs every two seconds)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new BleedTimer(), 0, 40);
|
||||
//Chunklet unloader (Runs every 20 seconds by default)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new ChunkletUnloader(), 0, ChunkletUnloader.RUN_INTERVAL * 20);
|
||||
|
||||
// Old & Powerless User remover
|
||||
int purgeInterval = Config.getInstance().getPurgeInterval();
|
||||
|
||||
if (purgeInterval == 0) {
|
||||
scheduler.scheduleSyncDelayedTask(this, new UserPurgeTask(), 40); // Start 2 seconds after startup.
|
||||
}
|
||||
else if (purgeInterval > 0) {
|
||||
scheduler.scheduleSyncRepeatingTask(this, new UserPurgeTask(), 0, purgeInterval * 60L * 60L * 20L);
|
||||
}
|
||||
|
||||
registerCommands();
|
||||
|
||||
if (configInstance.getStatsTrackingEnabled()) {
|
||||
try {
|
||||
Metrics metrics = new Metrics(this);
|
||||
|
||||
Graph graph = metrics.createGraph("Percentage of servers using timings");
|
||||
|
||||
if (pluginManager.useTimings()) {
|
||||
@@ -224,8 +241,10 @@ public class mcMMO extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
// Get our ChunkletManager
|
||||
placeStore = ChunkManagerFactory.getChunkManager();
|
||||
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
|
||||
|
||||
new MobStoreCleaner(); // Automatically starts and stores itself
|
||||
Anniversary.createAnniversaryFile(); // Create Anniversary files
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,7 +255,6 @@ public class mcMMO extends JavaPlugin {
|
||||
mainDirectory = getDataFolder().getPath() + File.separator;
|
||||
flatFileDirectory = mainDirectory + "FlatFileStuff" + File.separator;
|
||||
usersFile = flatFileDirectory + "mcmmo.users";
|
||||
leaderboardDirectory = flatFileDirectory + "Leaderboards" + File.separator;
|
||||
modDirectory = mainDirectory + "ModConfigs" + File.separator;
|
||||
}
|
||||
|
||||
@@ -282,13 +300,13 @@ public class mcMMO extends JavaPlugin {
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Users.saveAll(); //Make sure to save player information if the server shuts down
|
||||
PartyManager.getInstance().saveParties();
|
||||
getServer().getScheduler().cancelTasks(this); //This removes our tasks
|
||||
placeStore.saveAll(); //Save our metadata
|
||||
placeStore.cleanUp(); //Cleanup empty metadata stores
|
||||
Users.saveAll(); // Make sure to save player information if the server shuts down
|
||||
PartyManager.saveParties();
|
||||
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
||||
placeStore.saveAll(); // Save our metadata
|
||||
placeStore.cleanUp(); // Cleanup empty metadata stores
|
||||
|
||||
//Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
|
||||
// Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
|
||||
try {
|
||||
ZipLibrary.mcMMObackup();
|
||||
}
|
||||
@@ -296,158 +314,49 @@ public class mcMMO extends JavaPlugin {
|
||||
getLogger().severe(e.toString());
|
||||
}
|
||||
|
||||
System.out.println("mcMMO was disabled."); //How informative!
|
||||
Anniversary.saveAnniversaryFiles();
|
||||
getLogger().info("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(LocaleLoader.getString("Acrobatics.SkillName").toLowerCase(), "acrobatics");
|
||||
aliasMap.put(LocaleLoader.getString("Archery.SkillName").toLowerCase(), "archery");
|
||||
aliasMap.put(LocaleLoader.getString("Axes.SkillName").toLowerCase(), "axes");
|
||||
aliasMap.put(LocaleLoader.getString("Excavation.SkillName").toLowerCase(), "excavation");
|
||||
aliasMap.put(LocaleLoader.getString("Fishing.SkillName").toLowerCase(), "fishing");
|
||||
aliasMap.put(LocaleLoader.getString("Herbalism.SkillName").toLowerCase(), "herbalism");
|
||||
aliasMap.put(LocaleLoader.getString("Mining.SkillName").toLowerCase(), "mining");
|
||||
aliasMap.put(LocaleLoader.getString("Repair.SkillName").toLowerCase(), "repair");
|
||||
aliasMap.put(LocaleLoader.getString("Swords.SkillName").toLowerCase(), "swords");
|
||||
aliasMap.put(LocaleLoader.getString("Taming.SkillName").toLowerCase(), "taming");
|
||||
aliasMap.put(LocaleLoader.getString("Unarmed.SkillName").toLowerCase(), "unarmed");
|
||||
aliasMap.put(LocaleLoader.getString("Woodcutting.SkillName").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());
|
||||
|
||||
CommandRegistrationHelper.registerSkillCommands();
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
//mc* commands
|
||||
if (configInstance.getCommandMCRemoveEnabled()) {
|
||||
getCommand("mcremove").setExecutor(new McremoveCommand(this));
|
||||
}
|
||||
// mc* commands
|
||||
getCommand("mcpurge").setExecutor(new McpurgeCommand());
|
||||
getCommand("mcremove").setExecutor(new McremoveCommand());
|
||||
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());
|
||||
getCommand("mctop").setExecutor(new MctopCommand());
|
||||
getCommand("mcrank").setExecutor(new McrankCommand());
|
||||
getCommand("mcstats").setExecutor(new McstatsCommand());
|
||||
|
||||
if (configInstance.getCommandMCAbilityEnabled()) {
|
||||
getCommand("mcability").setExecutor(new McabilityCommand());
|
||||
}
|
||||
// Party commands
|
||||
getCommand("a").setExecutor(new ACommand());
|
||||
getCommand("party").setExecutor(new PartyCommand());
|
||||
getCommand("p").setExecutor(new PCommand(this));
|
||||
getCommand("ptp").setExecutor(new PtpCommand(this));
|
||||
|
||||
if (configInstance.getCommandMCCEnabled()) {
|
||||
getCommand("mcc").setExecutor(new MccCommand());
|
||||
}
|
||||
|
||||
if (configInstance.getCommandMCGodEnabled()) {
|
||||
getCommand("mcgod").setExecutor(new McgodCommand());
|
||||
}
|
||||
|
||||
if (configInstance.getCommandmcMMOEnabled()) {
|
||||
getCommand("mcmmo").setExecutor(new McmmoCommand());
|
||||
}
|
||||
|
||||
if (configInstance.getCommandMCRefreshEnabled()) {
|
||||
getCommand("mcrefresh").setExecutor(new McrefreshCommand(this));
|
||||
}
|
||||
|
||||
if (configInstance.getCommandMCTopEnabled()) {
|
||||
getCommand("mctop").setExecutor(new MctopCommand());
|
||||
}
|
||||
|
||||
if (configInstance.getCommandMCStatsEnabled()) {
|
||||
getCommand("mcstats").setExecutor(new McstatsCommand());
|
||||
}
|
||||
|
||||
if (configInstance.getCommandSkillResetEnabled()) {
|
||||
getCommand("skillreset").setExecutor(new SkillResetCommand());
|
||||
}
|
||||
|
||||
//Party commands
|
||||
if (configInstance.getCommandAcceptEnabled()) {
|
||||
getCommand("accept").setExecutor(new AcceptCommand(this));
|
||||
}
|
||||
|
||||
if (configInstance.getCommandAdminChatAEnabled()) {
|
||||
getCommand("a").setExecutor(new ACommand(this));
|
||||
}
|
||||
|
||||
if (configInstance.getCommandInviteEnabled()) {
|
||||
getCommand("invite").setExecutor(new InviteCommand(this));
|
||||
}
|
||||
|
||||
if (configInstance.getCommandPartyEnabled()) {
|
||||
getCommand("party").setExecutor(new PartyCommand(this));
|
||||
}
|
||||
|
||||
if (configInstance.getCommandPartyChatPEnabled()) {
|
||||
getCommand("p").setExecutor(new PCommand(this));
|
||||
}
|
||||
|
||||
if (configInstance.getCommandPTPEnabled()) {
|
||||
getCommand("ptp").setExecutor(new PtpCommand(this));
|
||||
}
|
||||
|
||||
//Other commands
|
||||
if (configInstance.getCommandAddXPEnabled()) {
|
||||
getCommand("addxp").setExecutor(new AddxpCommand(this));
|
||||
}
|
||||
|
||||
if (configInstance.getCommandAddLevelsEnabled()) {
|
||||
getCommand("addlevels").setExecutor(new AddlevelsCommand(this));
|
||||
}
|
||||
|
||||
if (configInstance.getCommandMmoeditEnabled()) {
|
||||
getCommand("mmoedit").setExecutor(new MmoeditCommand());
|
||||
}
|
||||
|
||||
if (configInstance.getCommandInspectEnabled()) {
|
||||
getCommand("inspect").setExecutor(new InspectCommand());
|
||||
}
|
||||
|
||||
if (configInstance.getCommandXPRateEnabled()) {
|
||||
getCommand("xprate").setExecutor(new XprateCommand(this));
|
||||
}
|
||||
|
||||
getCommand("mmoupdate").setExecutor(new MmoupdateCommand(this));
|
||||
|
||||
//Spout commands
|
||||
if (configInstance.getCommandXPLockEnabled()) {
|
||||
getCommand("xplock").setExecutor(new XplockCommand());
|
||||
}
|
||||
// Other commands
|
||||
getCommand("addxp").setExecutor(new AddxpCommand());
|
||||
CommandRegistrationHelper.registerAddlevelsCommand();
|
||||
getCommand("mmoedit").setExecutor(new MmoeditCommand());
|
||||
getCommand("inspect").setExecutor(new InspectCommand());
|
||||
getCommand("xprate").setExecutor(new XprateCommand());
|
||||
getCommand("mmoupdate").setExecutor(new MmoupdateCommand());
|
||||
getCommand("skillreset").setExecutor(new SkillResetCommand());
|
||||
|
||||
// Spout commands
|
||||
getCommand("xplock").setExecutor(new XplockCommand());
|
||||
getCommand("mchud").setExecutor(new MchudCommand());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the alias map contains the given key.
|
||||
*
|
||||
* @param command The command to check
|
||||
* @return true if the command is in the map, false otherwise
|
||||
*/
|
||||
public boolean commandIsAliased(String command) {
|
||||
return aliasMap.containsKey(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the alias of a given command.
|
||||
*
|
||||
* @param command The command to retrieve the alias of
|
||||
* @return the alias of the command
|
||||
*/
|
||||
public String getCommandAlias(String command) {
|
||||
return aliasMap.get(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a set of values to the TNT tracker.
|
||||
*
|
||||
@@ -487,6 +396,22 @@ public class mcMMO extends JavaPlugin {
|
||||
tntTracker.remove(tntID);
|
||||
}
|
||||
|
||||
public void addToOpenFurnaceTracker(Block furnace, String playerName) {
|
||||
furnaceTracker.put(furnace, playerName);
|
||||
}
|
||||
|
||||
public boolean furnaceIsTracked(Block furnace) {
|
||||
return furnaceTracker.containsKey(furnace);
|
||||
}
|
||||
|
||||
public void removeFromFurnaceTracker(Block furnace) {
|
||||
furnaceTracker.remove(furnace);
|
||||
}
|
||||
|
||||
public Player getFurnacePlayer(Block furnace) {
|
||||
return getServer().getPlayer(furnaceTracker.get(furnace));
|
||||
}
|
||||
|
||||
public static String getMainDirectory() {
|
||||
return mainDirectory;
|
||||
}
|
||||
@@ -495,20 +420,20 @@ public class mcMMO extends JavaPlugin {
|
||||
return flatFileDirectory;
|
||||
}
|
||||
|
||||
public static String getUsersFile() {
|
||||
public static String getUsersFilePath() {
|
||||
return usersFile;
|
||||
}
|
||||
|
||||
public static String getLeaderboardDirectory() {
|
||||
return leaderboardDirectory;
|
||||
}
|
||||
|
||||
public static String getModDirectory() {
|
||||
return modDirectory;
|
||||
}
|
||||
|
||||
public static Database getPlayerDatabase() {
|
||||
return database;
|
||||
public boolean isXPEventEnabled() {
|
||||
return xpEventEnabled;
|
||||
}
|
||||
|
||||
public void setXPEventEnabled(boolean enabled) {
|
||||
this.xpEventEnabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
172
src/main/java/com/gmail/nossr50/mods/ModChecks.java
Normal file
172
src/main/java/com/gmail/nossr50/mods/ModChecks.java
Normal file
@@ -0,0 +1,172 @@
|
||||
package com.gmail.nossr50.mods;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.mods.config.CustomArmorConfig;
|
||||
import com.gmail.nossr50.mods.config.CustomBlocksConfig;
|
||||
import com.gmail.nossr50.mods.config.CustomToolsConfig;
|
||||
import com.gmail.nossr50.mods.datatypes.CustomBlock;
|
||||
import com.gmail.nossr50.mods.datatypes.CustomItem;
|
||||
import com.gmail.nossr50.mods.datatypes.CustomTool;
|
||||
|
||||
public final class ModChecks {
|
||||
private static Config configInstance = Config.getInstance();
|
||||
private static boolean customToolsEnabled = configInstance.getToolModsEnabled();
|
||||
private static boolean customArmorEnabled = configInstance.getArmorModsEnabled();
|
||||
private static boolean customBlocksEnabled = configInstance.getBlockModsEnabled();
|
||||
|
||||
private ModChecks() {}
|
||||
|
||||
/**
|
||||
* Get the custom armor associated with an item.
|
||||
*
|
||||
* @param item The item to check
|
||||
* @return the armor if it exists, null otherwise
|
||||
*/
|
||||
public static CustomItem getArmorFromItemStack(ItemStack item) {
|
||||
return CustomArmorConfig.getInstance().customArmor.get(item.getTypeId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the custom tool associated with an item.
|
||||
*
|
||||
* @param item The item to check
|
||||
* @return the tool if it exists, null otherwise
|
||||
*/
|
||||
public static CustomTool getToolFromItemStack(ItemStack item) {
|
||||
return CustomToolsConfig.getInstance().customTools.get(item.getTypeId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the custom block associated with an block.
|
||||
*
|
||||
* @param block The block to check
|
||||
* @return the block if it exists, null otherwise
|
||||
*/
|
||||
public static CustomBlock getCustomBlock(Block block) {
|
||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||
|
||||
if (!CustomBlocksConfig.getInstance().customItems.contains(item)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is a custom block.
|
||||
*
|
||||
* @param block The block to check
|
||||
* @return true if the block is custom, false otherwise
|
||||
*/
|
||||
public static boolean isCustomMiningBlock(Block block) {
|
||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||
|
||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customMiningBlocks.contains(item)) {
|
||||
for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is a leaf block.
|
||||
*
|
||||
* @param block The block to check
|
||||
* @return true if the block represents leaves, false otherwise
|
||||
*/
|
||||
public static boolean isCustomLeafBlock(Block block) {
|
||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||
|
||||
if (CustomBlocksConfig.getInstance().customLeaves.contains(item)) {
|
||||
for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is a log block.
|
||||
*
|
||||
* @param block The block to check
|
||||
* @return true if the block represents a log, false otherwise
|
||||
*/
|
||||
public static boolean isCustomLogBlock(Block block) {
|
||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||
|
||||
if (CustomBlocksConfig.getInstance().customLogs.contains(item)) {
|
||||
for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a custom block is an ore block.
|
||||
*
|
||||
* @param block The block to check
|
||||
* @return true if the block represents an ore, false otherwise
|
||||
*/
|
||||
public static boolean isCustomOreBlock(Block block) {
|
||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||
|
||||
if (CustomBlocksConfig.getInstance().customOres.contains(item)) {
|
||||
for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) {
|
||||
if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is a custom tool.
|
||||
*
|
||||
* @param item Item to check
|
||||
* @return true if the item is a custom tool, false otherwise
|
||||
*/
|
||||
public static boolean isCustomTool(ItemStack item) {
|
||||
if (customToolsEnabled && CustomToolsConfig.getInstance().customTools.containsKey(item.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an item is custom armor.
|
||||
*
|
||||
* @param item Item to check
|
||||
* @return true if the item is custom armor, false otherwise
|
||||
*/
|
||||
public static boolean isCustomArmor(ItemStack item) {
|
||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customArmor.containsKey(item.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
package com.gmail.nossr50.mods.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
||||
import com.gmail.nossr50.mods.datatypes.CustomItem;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
|
||||
@@ -50,15 +49,12 @@ public class CustomArmorConfig extends ConfigLoader{
|
||||
private void loadArmor(String armorType, List<Integer> idList) {
|
||||
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
|
||||
|
||||
if(armorSection == null)
|
||||
if (armorSection == null)
|
||||
return;
|
||||
|
||||
Set<String> armorConfigSet = armorSection.getKeys(false);
|
||||
Iterator<String> iterator = armorConfigSet.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String armorName = iterator.next();
|
||||
|
||||
for (String armorName : armorConfigSet) {
|
||||
int id = config.getInt(armorType + "." + armorName + ".ID", 0);
|
||||
boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable");
|
||||
int repairID = config.getInt(armorType + "." + armorName + ".Repair_Material_ID", 0);
|
||||
@@ -92,7 +88,7 @@ public class CustomArmorConfig extends ConfigLoader{
|
||||
}
|
||||
|
||||
public List<Repairable> getLoadedRepairables() {
|
||||
if(repairables == null) return new ArrayList<Repairable>();
|
||||
if (repairables == null) return new ArrayList<Repairable>();
|
||||
return repairables;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
package com.gmail.nossr50.mods.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import com.gmail.nossr50.mods.datatypes.CustomBlock;
|
||||
|
||||
public class CustomBlocksConfig extends ConfigLoader {
|
||||
private static CustomBlocksConfig instance;
|
||||
@@ -49,15 +49,12 @@ public class CustomBlocksConfig extends ConfigLoader {
|
||||
private void loadBlocks(String skillType, List<ItemStack> blockList) {
|
||||
ConfigurationSection skillSection = config.getConfigurationSection(skillType);
|
||||
|
||||
if(skillSection == null)
|
||||
if (skillSection == null)
|
||||
return;
|
||||
|
||||
Set<String> skillConfigSet = skillSection.getKeys(false);
|
||||
Iterator<String> iterator = skillConfigSet.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String blockName = iterator.next();
|
||||
|
||||
for (String blockName : skillConfigSet) {
|
||||
int id = config.getInt(skillType + "." + blockName + ".ID", 0);
|
||||
byte data = (byte) config.getInt(skillType + "." + blockName + ".Data_Value", 0);
|
||||
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain", 0);
|
||||
@@ -78,7 +75,8 @@ public class CustomBlocksConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
if (skillType.equals("Ability_Blocks")) {
|
||||
blockItem = new ItemStack(id, 1, (short) 0, data);
|
||||
blockItem = (new MaterialData(id, data)).toItemStack(1);
|
||||
|
||||
blockList.add(blockItem);
|
||||
continue;
|
||||
}
|
||||
@@ -89,14 +87,14 @@ public class CustomBlocksConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
if (dropItem) {
|
||||
itemDrop = new ItemStack(dropID, 1, (short) 0, dropData);
|
||||
itemDrop = (new MaterialData(dropID, dropData)).toItemStack(1);
|
||||
}
|
||||
else {
|
||||
itemDrop = new ItemStack(id, 1, (short) 0, data);
|
||||
itemDrop = (new MaterialData(id, data)).toItemStack(1);
|
||||
}
|
||||
|
||||
block = new CustomBlock(minimumDropAmount, maxiumDropAmount, itemDrop, tier, xp, data, id);
|
||||
blockItem = new ItemStack(id, 1, (short) 0, data);
|
||||
blockItem = (new MaterialData(id, data)).toItemStack(1);
|
||||
|
||||
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
||||
customOres.add(blockItem);
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
package com.gmail.nossr50.mods.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
import com.gmail.nossr50.mods.datatypes.CustomTool;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
|
||||
@@ -54,15 +53,12 @@ public class CustomToolsConfig extends ConfigLoader {
|
||||
private void loadTool(String toolType, List<Integer> idList) {
|
||||
ConfigurationSection toolSection = config.getConfigurationSection(toolType);
|
||||
|
||||
if(toolSection == null)
|
||||
if (toolSection == null)
|
||||
return;
|
||||
|
||||
Set<String> toolConfigSet = toolSection.getKeys(false);
|
||||
Iterator<String> iterator = toolConfigSet.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String toolName = iterator.next();
|
||||
|
||||
for (String toolName : toolConfigSet) {
|
||||
int id = config.getInt(toolType + "." + toolName + ".ID", 0);
|
||||
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);
|
||||
boolean abilityEnabled = config.getBoolean(toolType + "." + toolName + ".Ability_Enabled", true);
|
||||
@@ -99,7 +95,7 @@ public class CustomToolsConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
public List<Repairable> getLoadedRepairables() {
|
||||
if(repairables == null) return new ArrayList<Repairable>();
|
||||
if (repairables == null) return new ArrayList<Repairable>();
|
||||
return repairables;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.datatypes.mods;
|
||||
package com.gmail.nossr50.mods.datatypes;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.datatypes.mods;
|
||||
package com.gmail.nossr50.mods.datatypes;
|
||||
|
||||
public class CustomItem {
|
||||
protected int itemID;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user