mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 09:43:00 +01:00
Compare commits
585 Commits
1.3.14
...
1.4.00-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72a2e24c98 | ||
|
|
593975a255 | ||
|
|
b16cc87ffb | ||
|
|
c5e8b90d71 | ||
|
|
88a6326f87 | ||
|
|
0603ea0fc4 | ||
|
|
c4aedd5323 | ||
|
|
6eb125c913 | ||
|
|
704f7374d2 | ||
|
|
009396cad9 | ||
|
|
a38b7ca9fa | ||
|
|
c5daaffeb1 | ||
|
|
83debde0a1 | ||
|
|
9c2ab19404 | ||
|
|
ef1a777180 | ||
|
|
77014b03ef | ||
|
|
9143051d9f | ||
|
|
f496ecf7b1 | ||
|
|
fc3afc4340 | ||
|
|
fd138eb0b5 | ||
|
|
6d5835849f | ||
|
|
800ebf5b64 | ||
|
|
9df149c489 | ||
|
|
efcf80899e | ||
|
|
c1b12c027a | ||
|
|
476ea80c4e | ||
|
|
bf4d70e8be | ||
|
|
284002bf8b | ||
|
|
b92b9c6507 | ||
|
|
a8cfcf31ab | ||
|
|
d14821e385 | ||
|
|
5e8b036481 | ||
|
|
27ba4ff800 | ||
|
|
c80bb45cad | ||
|
|
dedcf0469b | ||
|
|
9ec6a6d1aa | ||
|
|
1ce01d2043 | ||
|
|
0701169a7e | ||
|
|
2d0cf6413e | ||
|
|
4cf658b629 | ||
|
|
8d21883c20 | ||
|
|
fca0847929 | ||
|
|
1d19dab71d | ||
|
|
49fe98ac57 | ||
|
|
bc9e946618 | ||
|
|
3d3a1abf7b | ||
|
|
1ef1d53fd9 | ||
|
|
0419dca385 | ||
|
|
11bd473f55 | ||
|
|
5947ad5004 | ||
|
|
894218cac9 | ||
|
|
4ce06de18a | ||
|
|
6c4ea34811 | ||
|
|
34736836cc | ||
|
|
9c09c168f8 | ||
|
|
c61e710341 | ||
|
|
63753b8197 | ||
|
|
20f436c646 | ||
|
|
092b9096e6 | ||
|
|
caa1b0d14c | ||
|
|
d39ff036c7 | ||
|
|
6702256b4c | ||
|
|
110fbe9478 | ||
|
|
128c24c8f6 | ||
|
|
6cc2497182 | ||
|
|
615288e635 | ||
|
|
1b814b937b | ||
|
|
01e26f321d | ||
|
|
e8319aee81 | ||
|
|
ca5bf0bd09 | ||
|
|
88b05cd5aa | ||
|
|
132fcb8c74 | ||
|
|
1492fa473f | ||
|
|
9bd33ab3df | ||
|
|
7d826a0cdb | ||
|
|
ec6fc30f47 | ||
|
|
25a54ea802 | ||
|
|
dda9c82940 | ||
|
|
55b88f0274 | ||
|
|
f4da69a205 | ||
|
|
3a919f3e4c | ||
|
|
6cfd124804 | ||
|
|
0879e1f326 | ||
|
|
8312570825 | ||
|
|
7110e6ec3d | ||
|
|
1455a9b3a4 | ||
|
|
2ad73e9b2c | ||
|
|
b1db0d037d | ||
|
|
776821a988 | ||
|
|
1380e64c0b | ||
|
|
0319e2cbff | ||
|
|
7350fdb99c | ||
|
|
25061e7f71 | ||
|
|
0cd8d2b333 | ||
|
|
28dca6e66f | ||
|
|
491a70ad82 | ||
|
|
aa0acf767b | ||
|
|
e37f5e765e | ||
|
|
fe1cf40bbb | ||
|
|
9be6a7cf3b | ||
|
|
0684b1d425 | ||
|
|
12a2107601 | ||
|
|
163b3d19f9 | ||
|
|
15113ba7e4 | ||
|
|
5e9f01ac57 | ||
|
|
ec718f04d7 | ||
|
|
bb96c00cb9 | ||
|
|
697cfeea64 | ||
|
|
0528139c2c | ||
|
|
cbe68e7879 | ||
|
|
074a798213 | ||
|
|
e9b016903b | ||
|
|
8f4d5442b1 | ||
|
|
2160eef1af | ||
|
|
b66c5d7023 | ||
|
|
b21d5bdcc4 | ||
|
|
574770c289 | ||
|
|
adda85a660 | ||
|
|
92473cc56d | ||
|
|
d7e74b9fe0 | ||
|
|
9db2d50676 | ||
|
|
048a979375 | ||
|
|
761fb3b811 | ||
|
|
505d6e258f | ||
|
|
9f22382506 | ||
|
|
f486492c37 | ||
|
|
6f1ddee0ac | ||
|
|
2fac0170e7 | ||
|
|
56056797bc | ||
|
|
bbc2091b77 | ||
|
|
51493fab48 | ||
|
|
5d693c5d8f | ||
|
|
8cd9942be6 | ||
|
|
b2575c9b8f | ||
|
|
a60a6355d2 | ||
|
|
6acfba1315 | ||
|
|
ab731302e0 | ||
|
|
5a48d5c5f8 | ||
|
|
e92c6b8f26 | ||
|
|
200ac53078 | ||
|
|
288907cfd4 | ||
|
|
c822be4a53 | ||
|
|
70f588cce1 | ||
|
|
e5c7e81b08 | ||
|
|
45ebc2b89b | ||
|
|
76523d2988 | ||
|
|
98a64a0948 | ||
|
|
2d6fb72b9d | ||
|
|
e66ff53ca4 | ||
|
|
e8ac3c812f | ||
|
|
a597a7d281 | ||
|
|
1c0e392552 | ||
|
|
59a52a73bb | ||
|
|
0aeff40aaa | ||
|
|
bcd8906315 | ||
|
|
de9249e523 | ||
|
|
5160f5c380 | ||
|
|
5da51e78cc | ||
|
|
2be57414ad | ||
|
|
c2293396be | ||
|
|
cdbc19570d | ||
|
|
ccedd23342 | ||
|
|
46b5746dcc | ||
|
|
97dafc45fa | ||
|
|
adf62fd332 | ||
|
|
98bb865062 | ||
|
|
d50123085f | ||
|
|
b628b9eb4d | ||
|
|
317a39177b | ||
|
|
73924543df | ||
|
|
457754b6f1 | ||
|
|
c659f8a9a9 | ||
|
|
74df4a4fb6 | ||
|
|
b60d9032be | ||
|
|
a2cbfa2668 | ||
|
|
340c47eebd | ||
|
|
ae5f39253e | ||
|
|
3df5f529eb | ||
|
|
0fae8be816 | ||
|
|
f97e9bd19f | ||
|
|
400d551295 | ||
|
|
4957366beb | ||
|
|
27e4a2c290 | ||
|
|
a424d36e96 | ||
|
|
9c0518f251 | ||
|
|
794071efb8 | ||
|
|
787c4e5b73 | ||
|
|
33d3cd0522 | ||
|
|
e14f8ad93c | ||
|
|
7a357634c7 | ||
|
|
ef5f72f56c | ||
|
|
ae3a95dd34 | ||
|
|
6d9db06305 | ||
|
|
35f243a6e6 | ||
|
|
ea25558ac9 | ||
|
|
1f09cb29f0 | ||
|
|
9e4b06e0b6 | ||
|
|
114858505c | ||
|
|
3da062c4cc | ||
|
|
291393d45d | ||
|
|
3cc5cd4a04 | ||
|
|
70ba4a0f3d | ||
|
|
9de6b4724a | ||
|
|
79b96c380d | ||
|
|
3ccf79cff5 | ||
|
|
02bccf6dc1 | ||
|
|
e397de99df | ||
|
|
911f036723 | ||
|
|
af1288b6f8 | ||
|
|
366940fc14 | ||
|
|
4f45431dd3 | ||
|
|
6c266a8926 | ||
|
|
c3f83302c5 | ||
|
|
57063246fb | ||
|
|
29f47d5ca7 | ||
|
|
e0180881e2 | ||
|
|
7c579a1040 | ||
|
|
59219e3f33 | ||
|
|
b67a308a34 | ||
|
|
d5550c8fd1 | ||
|
|
d0ca2b9d4b | ||
|
|
84fb7eec36 | ||
|
|
c04b5dc4d6 | ||
|
|
4b4fb7fd39 | ||
|
|
215bd0f4a2 | ||
|
|
a13d28a6ec | ||
|
|
bcdd235b9f | ||
|
|
6be0714872 | ||
|
|
7e70c4001b | ||
|
|
9326921e2a | ||
|
|
7a0f8ea2dd | ||
|
|
2799bab206 | ||
|
|
ba4d0451ff | ||
|
|
40773ee6f6 | ||
|
|
cd190eebc9 | ||
|
|
c13593def1 | ||
|
|
bbfbe1e72c | ||
|
|
bb88812668 | ||
|
|
94a9230525 | ||
|
|
c7a0841c2e | ||
|
|
b843970033 | ||
|
|
4931ff6e4a | ||
|
|
b9ef701ff1 | ||
|
|
c07364f775 | ||
|
|
64d3430455 | ||
|
|
7e4188e776 | ||
|
|
3f6c07ba6a | ||
|
|
419937f62e | ||
|
|
ab92aa3ffa | ||
|
|
2d9dc92f83 | ||
|
|
0f214496f2 | ||
|
|
9103914bc9 | ||
|
|
aad14169fb | ||
|
|
3550c25b7d | ||
|
|
2764368089 | ||
|
|
e46dcb69da | ||
|
|
ef7aeb752e | ||
|
|
81ba0404b2 | ||
|
|
9af470536b | ||
|
|
5349b46122 | ||
|
|
0de7e22408 | ||
|
|
03f96daba3 | ||
|
|
f6aca88b36 | ||
|
|
ea32cb9e12 | ||
|
|
1c328e7ac7 | ||
|
|
89eef2ce07 | ||
|
|
433c99e239 | ||
|
|
e2faeac505 | ||
|
|
263cb2823c | ||
|
|
5769c8dea9 | ||
|
|
3cff8aba16 | ||
|
|
e5e19f77b9 | ||
|
|
4d93f3271d | ||
|
|
0683745dd2 | ||
|
|
49ef013152 | ||
|
|
3153bbc973 | ||
|
|
717a258430 | ||
|
|
bb945a765c | ||
|
|
6d486401b5 | ||
|
|
07df5edc86 | ||
|
|
ae5ab13533 | ||
|
|
fc40f545fe | ||
|
|
37e01f992d | ||
|
|
b497853e8a | ||
|
|
85dc6e51d2 | ||
|
|
6d5ce1357e | ||
|
|
ac1d556895 | ||
|
|
4aceadd777 | ||
|
|
49de6614c0 | ||
|
|
cc50428646 | ||
|
|
b60bdc9b17 | ||
|
|
35cdcb62b7 | ||
|
|
458f7f5f5b | ||
|
|
284bab397a | ||
|
|
5f306447a0 | ||
|
|
44b862c0bb | ||
|
|
74c367c069 | ||
|
|
c3db026fd9 | ||
|
|
958095d11b | ||
|
|
b21dc8631a | ||
|
|
03354ed1cb | ||
|
|
1a63fc7638 | ||
|
|
6498c711ba | ||
|
|
57c8c94db7 | ||
|
|
15f212c384 | ||
|
|
dee384c8b9 | ||
|
|
93ffd950e9 | ||
|
|
b01d80b1f4 | ||
|
|
84d01362f9 | ||
|
|
939586ce1a | ||
|
|
2888fdff9e | ||
|
|
b048cc1e55 | ||
|
|
3c94074533 | ||
|
|
2de8962887 | ||
|
|
e37e913f6a | ||
|
|
51305118fa | ||
|
|
52bd48cde7 | ||
|
|
ecf32da760 | ||
|
|
1dbe56b026 | ||
|
|
f51bdad6b4 | ||
|
|
97d47c19b7 | ||
|
|
a1ab6f286b | ||
|
|
6d871c9bdb | ||
|
|
12faebca27 | ||
|
|
c231a68bb2 | ||
|
|
bd3db4a425 | ||
|
|
5801981147 | ||
|
|
727cb029a6 | ||
|
|
dd0933c584 | ||
|
|
e92b57c50c | ||
|
|
2e3c1d53f5 | ||
|
|
a67e0c1433 | ||
|
|
a42a1f4a9f | ||
|
|
8f17ec96f0 | ||
|
|
b11e28c880 | ||
|
|
a16d5b62cf | ||
|
|
e9425625e2 | ||
|
|
12324017d7 | ||
|
|
8aabe1c148 | ||
|
|
76ff0374ce | ||
|
|
09373c45f3 | ||
|
|
d0a5454333 | ||
|
|
9ea693d3ce | ||
|
|
ebca9fc2da | ||
|
|
c43e8f8f19 | ||
|
|
b6b03369f7 | ||
|
|
0b6e854520 | ||
|
|
55b17e7d2b | ||
|
|
c15fdae32e | ||
|
|
0fe232e1f5 | ||
|
|
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 |
@@ -7,9 +7,94 @@ 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 an automatic party kick when a party member has been offline for 7 days (default)
|
||||
+ Added a permission to allow friendly fire in parties, both attacker and defender must have it for friendly fire to occur
|
||||
+ 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, when more party members are near the share bonus increases.
|
||||
+ Added vanilla XP boost for Fishing - includes permissions, config options, etc
|
||||
+ Added particle effect for bleeding
|
||||
+ Added methods to check if a player is in party or admin chat to the ChatAPI
|
||||
+ Added /mcpurge functionality for Flatfile users
|
||||
+ Added basic support for Mo' Creatures (and other entity mods) - specify mob info in entities.yml
|
||||
+ Added Shears, Buckets, Fishing Rods, Flint & Steel, Carrot Sticks, and Bows to the list of items that can be Salvaged
|
||||
+ Added the "wait" music disc to the default fishing treasures
|
||||
+ Added "Chinese (Taiwan)" localization files (zh_TW)
|
||||
+ Added '/hardcore' and '/vampirism' commands for toggling these modes on or off.
|
||||
+ Added Block Cracker to Unarmed's Berserk, turn smooth brick into cracked smooth brick
|
||||
+ Added config option to disable automatic zip backups.
|
||||
= Fixed Green Thumb on wheat not working properly at rank 4
|
||||
= Fixed Green Thumb and Green Terra consuming twice the amount of seed needed
|
||||
= Fixed Green Terra not also checking Green Thumb permissions
|
||||
= Fixed bug where splash potions could raise a player's unarmed level
|
||||
= Fixed bug where fired arrows could raise skill levels other than Archery
|
||||
= Fixed /ptp telporting the target to the player, rather than the other way around.
|
||||
= Fixed Impact reducing the durability of non-armor equipped blocks
|
||||
= Fixed Impact reducing improperly the durability of armors (as a consequence it is now more effective)
|
||||
= Fixed multiple commands 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 a bug which made it impossible to join other players' parties
|
||||
= 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 /party kick not working on offline players
|
||||
= Fixed a bug where party join messages weren't displayed
|
||||
= Fixed a bug where a new party leader wasn't appointed, after the previous party leader left
|
||||
= Fixed a bug where Disarm and Deflect had wrong values
|
||||
= Fixed Magic Hunter (Fishing ability) favoring certain enchants
|
||||
! Config files are now backed up even when running in SQL mode
|
||||
! Changed /p and /a to use /partychat and /adminchat as the default command name. The use of /p, /pc, /a, and /ac is still supported.
|
||||
! 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 Tree Feller to work on huge mushrooms
|
||||
! 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
|
||||
! Changed backup task to include ALL config files
|
||||
! Deprecated most functions in ExperienceAPI, replaced them with identical versions that use a String for the SkillName rather than the SkillType enum values
|
||||
! Changed Super Breaker & Giga Drill Breaker to be an enchantment-based boost, rather than an instabreak.
|
||||
! Changed locales to fall back on English when translated strings cannot be found.
|
||||
- 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.
|
||||
- Removed /mcc command. Replaced with /mcmmo [?|help|commands]
|
||||
|
||||
Version 1.3.14
|
||||
+ Added new Hylian Luck skill to Herbalism.
|
||||
= Fixed a memory leak involving mob tracking
|
||||
= Fixed a memory leak involving mob tracking
|
||||
- Removed extra durability loss from Leaf Blower
|
||||
|
||||
Version 1.3.13
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
**The RPG lovers mod**
|
||||
|
||||
=== Dev builds
|
||||
http://nuclearw.com:8080/job/mcMMO/ Download the latest dev build of mcMMO here.
|
||||
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.
|
||||
@@ -25,4 +25,4 @@ Required Libraries:
|
||||
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.
|
||||
|
||||
77
pom.xml
77
pom.xml
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>1.3.14</version>
|
||||
<version>1.4.00-beta3</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<issueManagement>
|
||||
@@ -19,6 +19,7 @@
|
||||
<directory>${basedir}/src/main/resources/</directory>
|
||||
<includes>
|
||||
<include>*.yml</include>
|
||||
<include>.jenkins</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
@@ -54,12 +55,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>
|
||||
@@ -91,6 +92,32 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>1.5</version>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.turt2live.metrics:MetricsExtension</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.turt2live.metrics</pattern>
|
||||
<shadedPattern>com.gmail.nossr50.util.mcstats</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<extensions>
|
||||
<extension>
|
||||
@@ -106,7 +133,7 @@
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>fail</checksumPolicy>
|
||||
</snapshots>
|
||||
</snapshots>
|
||||
<id>bukkit-repo</id>
|
||||
<url>http://repo.bukkit.org/content/groups/public/</url>
|
||||
</repository>
|
||||
@@ -115,9 +142,18 @@
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>fail</checksumPolicy>
|
||||
</snapshots>
|
||||
<id>spout-repo</id>
|
||||
<url>http://nexus.spout.org/content/groups/public/</url>
|
||||
</snapshots>
|
||||
<id>spout-repo</id>
|
||||
<url>http://nexus.spout.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>fail</checksumPolicy>
|
||||
</snapshots>
|
||||
<id>Plugin MetricsExtension</id>
|
||||
<url>http://repo.turt2live.com</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
@@ -135,12 +171,19 @@
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<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>
|
||||
<dependency>
|
||||
<groupId>com.turt2live.metrics</groupId>
|
||||
<artifactId>MetricsExtension</artifactId>
|
||||
<version>0.0.2-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
|
||||
@@ -2,42 +2,46 @@ package com.gmail.nossr50.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
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);
|
||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.BERSERK);
|
||||
}
|
||||
|
||||
public static boolean gigaDrillBreakerEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.GIGA_DRILL_BREAKER);
|
||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.GIGA_DRILL_BREAKER);
|
||||
}
|
||||
|
||||
public static boolean greenTerraEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.GREEN_TERRA);
|
||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.GREEN_TERRA);
|
||||
}
|
||||
|
||||
public static boolean serratedStrikesEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.SERRATED_STRIKES);
|
||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.SERRATED_STRIKES);
|
||||
}
|
||||
|
||||
public static boolean skullSplitterEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.SKULL_SPLIITER);
|
||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.SKULL_SPLIITER);
|
||||
}
|
||||
|
||||
public static boolean superBreakerEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.SUPER_BREAKER);
|
||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.SUPER_BREAKER);
|
||||
}
|
||||
|
||||
public static boolean treeFellerEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.TREE_FELLER);
|
||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.TREE_FELLER);
|
||||
}
|
||||
|
||||
public static boolean isAnyAbilityEnabled(Player player) {
|
||||
PlayerProfile profile = Users.getPlayer(player).getProfile();
|
||||
|
||||
for (AbilityType ability : AbilityType.values()) {
|
||||
if (Users.getProfile(player).getAbilityMode(ability)) {
|
||||
if (profile.getAbilityMode(ability)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
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.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.chat.ChatManager;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public final class ChatAPI {
|
||||
|
||||
private ChatAPI() {}
|
||||
|
||||
/**
|
||||
@@ -18,27 +15,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;
|
||||
}
|
||||
|
||||
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(LocaleLoader.getString("Commands.Party.Chat.Prefix", new Object[] {chatEvent.getSender()} ) + chatEvent.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
sendPartyChat(null, party, sender, sender, message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,22 +60,80 @@ 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);
|
||||
sendAdminChat(null, sender, sender, message);
|
||||
}
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Check if a player is currently talking in party chat.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return true if the player is using party chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingPartyChat(Player player) {
|
||||
return Users.getPlayer(player).getPartyChatMode();
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("[A]<" + chatEvent.getSender() + "> " + chatEvent.getMessage());
|
||||
/**
|
||||
* Check if a player is currently talking in party chat.
|
||||
*
|
||||
* @param playerName The name of the player to check
|
||||
* @return true if the player is using party chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingPartyChat(String playerName) {
|
||||
return Users.getPlayer(playerName).getPartyChatMode();
|
||||
}
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
if (Permissions.adminChat(player) || player.isOp())
|
||||
player.sendMessage(LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {chatEvent.getSender()} ) + chatEvent.getMessage());
|
||||
}
|
||||
/**
|
||||
* Check if a player is currently talking in admin chat.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return true if the player is using admin chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingAdminChat(Player player) {
|
||||
return Users.getPlayer(player).getAdminChatMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player is currently talking in admin chat.
|
||||
*
|
||||
* @param playerName The name of the player to check
|
||||
* @return true if the player is using admin chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingAdminChat(String playerName) {
|
||||
return Users.getPlayer(playerName).getAdminChatMode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ 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.config.Config;
|
||||
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() {}
|
||||
|
||||
/**
|
||||
@@ -15,32 +15,30 @@ public final class ExperienceAPI {
|
||||
*
|
||||
* @param player The player to check
|
||||
* @param skillType The skill to check
|
||||
* @deprecated Calling this function is no longer needed and should be avoided
|
||||
*/
|
||||
@Deprecated
|
||||
private static void checkXP(Player player, SkillType skillType) {
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
Skills.xpCheckAll(player, Users.getProfile(player));
|
||||
}
|
||||
else {
|
||||
Skills.xpCheckSkill(skillType, player, Users.getProfile(player));
|
||||
}
|
||||
SkillTools.xpCheckSkill(skillType, player, Users.getProfile(player));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, doesn't calculate for XP Rate or other modifiers.
|
||||
* Adds raw XP to the player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
* @deprecated Use {@link #addRawXP(Player, String, int)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static void addRawXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getPlayer(player).addXPOverride(skillType, XP);
|
||||
checkXP(player, skillType);
|
||||
Users.getPlayer(player).applyXpGain(skillType, XP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, calculates for XP Rate but not skill modifiers.
|
||||
* Adds raw XP to the player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
@@ -48,13 +46,27 @@ public final class ExperienceAPI {
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*/
|
||||
public static void addRawXP(Player player, String skillType, int XP) {
|
||||
Users.getPlayer(player).applyXpGain(SkillType.getSkill(skillType), XP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, calculates for XP Rate only.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
* @deprecated Use {@link #addMultipliedXP(Player, String, int)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static void addMultipliedXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getPlayer(player).addXPOverrideBonus(skillType, XP);
|
||||
checkXP(player, skillType);
|
||||
Users.getPlayer(player).applyXpGain(skillType, (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, calculates for XP Rate and skill modifiers.
|
||||
* Adds XP to the player, calculates for XP Rate only.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
@@ -62,9 +74,51 @@ public final class ExperienceAPI {
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*/
|
||||
public static void addMultipliedXP(Player player, String skillType, int XP) {
|
||||
Users.getPlayer(player).applyXpGain(SkillType.getSkill(skillType), (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, calculates for XP Rate, skill modifiers and perks. May be shared with the party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
* @deprecated Use {@link #addXP(Player, String, int)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static void addXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getPlayer(player).addXP(skillType, XP);
|
||||
checkXP(player, skillType);
|
||||
Users.getPlayer(player).beginXpGain(skillType, XP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, calculates for XP Rate, skill modifiers and perks. May be shared with the party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*/
|
||||
public static void addXP(Player player, String skillType, int XP) {
|
||||
Users.getPlayer(player).beginXpGain(SkillType.getSkill(skillType), XP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of XP a player has in a specific skill.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
* @return the amount of XP in a given skill
|
||||
* @deprecated Use {@link #getXP(Player, String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static int getXP(Player player, SkillType skillType) {
|
||||
return Users.getPlayer(player).getProfile().getSkillXpLevel(skillType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,8 +130,23 @@ public final class ExperienceAPI {
|
||||
* @param skillType The skill to get XP for
|
||||
* @return the amount of XP in a given skill
|
||||
*/
|
||||
public static int getXP(Player player, SkillType skillType) {
|
||||
return Users.getProfile(player).getSkillXpLevel(skillType);
|
||||
public static int getXP(Player player, String skillType) {
|
||||
return Users.getPlayer(player).getProfile().getSkillXpLevel(SkillType.getSkill(skillType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of XP left before leveling up.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get the XP amount for
|
||||
* @param skillType The skill to get the XP amount for
|
||||
* @return the amount of XP left before leveling up a specifc skill
|
||||
* @deprecated Use {@link #getXPToNextLevel(Player, String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static int getXPToNextLevel(Player player, SkillType skillType) {
|
||||
return Users.getPlayer(player).getProfile().getXpToLevel(skillType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,8 +158,8 @@ public final class ExperienceAPI {
|
||||
* @param skillType The skill to get the XP amount for
|
||||
* @return the amount of XP left before leveling up a specifc skill
|
||||
*/
|
||||
public static int getXPToNextLevel(Player player, SkillType skillType) {
|
||||
return Users.getProfile(player).getXpToLevel(skillType);
|
||||
public static int getXPToNextLevel(Player player, String skillType) {
|
||||
return Users.getPlayer(player).getProfile().getXpToLevel(SkillType.getSkill(skillType));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,7 +170,8 @@ public final class ExperienceAPI {
|
||||
* @param player The player to add levels to
|
||||
* @param skillType Type of skill to add levels to
|
||||
* @param levels Number of levels to add
|
||||
* @param notify True if this should fire a level up notification, false otherwise.
|
||||
* @param notify Unused argument
|
||||
* @deprecated Use addLevel(Player, SKillType, int) instead
|
||||
*/
|
||||
public static void addLevel(Player player, SkillType skillType, int levels, boolean notify) {
|
||||
Users.getProfile(player).addLevels(skillType, levels);
|
||||
@@ -111,6 +181,49 @@ public final class ExperienceAPI {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add levels to a skill.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add levels to
|
||||
* @param skillType Type of skill to add levels to
|
||||
* @param levels Number of levels to add
|
||||
* @deprecated Use {@link #addLevel(Player, String, int)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static void addLevel(Player player, SkillType skillType, int levels) {
|
||||
Users.getPlayer(player).getProfile().addLevels(skillType, levels);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add levels to a skill.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add levels to
|
||||
* @param skillType Type of skill to add levels to
|
||||
* @param levels Number of levels to add
|
||||
*/
|
||||
public static void addLevel(Player player, String skillType, int levels) {
|
||||
Users.getPlayer(player).getProfile().addLevels(SkillType.getSkill(skillType), levels);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the level a player has in a specific skill.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get the level for
|
||||
* @param skillType The skill to get the level for
|
||||
* @return the level of a given skill
|
||||
* @deprecated Use {@link #getLevel(Player, String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static int getLevel(Player player, SkillType skillType) {
|
||||
return Users.getPlayer(player).getProfile().getSkillLevel(skillType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the level a player has in a specific skill.
|
||||
* </br>
|
||||
@@ -120,8 +233,8 @@ public final class ExperienceAPI {
|
||||
* @param skillType The skill to get the level for
|
||||
* @return the level of a given skill
|
||||
*/
|
||||
public static int getLevel(Player player, SkillType skillType) {
|
||||
return Users.getProfile(player).getSkillLevel(skillType);
|
||||
public static int getLevel(Player player, String skillType) {
|
||||
return Users.getPlayer(player).getProfile().getSkillLevel(SkillType.getSkill(skillType));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,9 +257,39 @@ public final class ExperienceAPI {
|
||||
* @param player The player to set the level of
|
||||
* @param skillType The skill to set the level for
|
||||
* @param skillLevel The value to set the level to
|
||||
* @deprecated Use {@link #setLevel(Player, String, int)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setLevel(Player player, SkillType skillType, int skillLevel) {
|
||||
Users.getProfile(player).modifySkill(skillType, skillLevel);
|
||||
Users.getPlayer(player).getProfile().modifySkill(skillType, skillLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the level of a player in a specific skill type.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to set the level of
|
||||
* @param skillType The skill to set the level for
|
||||
* @param skillLevel The value to set the level to
|
||||
*/
|
||||
public static void setLevel(Player player, String skillType, int skillLevel) {
|
||||
Users.getPlayer(player).getProfile().modifySkill(SkillType.getSkill(skillType), skillLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XP of a player in a specific skill type.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to set the XP of
|
||||
* @param skillType The skill to set the XP for
|
||||
* @param newValue The value to set the XP to
|
||||
* @deprecated Use {@link #setXP(Player, String, int)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setXP(Player player, SkillType skillType, int newValue) {
|
||||
Users.getPlayer(player).getProfile().setSkillXpLevel(skillType, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,8 +301,23 @@ public final class ExperienceAPI {
|
||||
* @param skillType The skill to set the XP for
|
||||
* @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);
|
||||
public static void setXP(Player player, String skillType, int newValue) {
|
||||
Users.getPlayer(player).getProfile().setSkillXpLevel(SkillType.getSkill(skillType), newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes XP from a player in a specific skill type.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to change the XP of
|
||||
* @param skillType The skill to change the XP for
|
||||
* @param xp The amount of XP to remove
|
||||
* @deprecated Use {@link #removeXP(Player, String, int)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static void removeXP(Player player, SkillType skillType, int xp) {
|
||||
Users.getPlayer(player).getProfile().removeXp(skillType, xp);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,7 +329,7 @@ public final class ExperienceAPI {
|
||||
* @param skillType The skill to change the XP for
|
||||
* @param xp The amount of XP to remove
|
||||
*/
|
||||
public static void removeXP(Player player, SkillType skillType, int xp) {
|
||||
Users.getProfile(player).removeXP(skillType, xp);
|
||||
public static void removeXP(Player player, String skillType, int xp) {
|
||||
Users.getPlayer(player).getProfile().removeXp(SkillType.getSkill(skillType), xp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.party.Party;
|
||||
@@ -9,7 +11,6 @@ import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public final class PartyAPI {
|
||||
|
||||
private PartyAPI() {}
|
||||
|
||||
/**
|
||||
@@ -21,7 +22,7 @@ public final class PartyAPI {
|
||||
* @return the name of the player's party
|
||||
*/
|
||||
public static String getPartyName(Player player) {
|
||||
return Users.getProfile(player).getParty().getName();
|
||||
return Users.getPlayer(player).getParty().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,7 +34,7 @@ public final class PartyAPI {
|
||||
* @return true if the player is in a party, false otherwise
|
||||
*/
|
||||
public static boolean inParty(Player player) {
|
||||
return Users.getProfile(player).inParty();
|
||||
return Users.getPlayer(player).inParty();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,7 +47,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 +58,7 @@ public final class PartyAPI {
|
||||
* @return the list of parties.
|
||||
*/
|
||||
public static List<Party> getParties() {
|
||||
return PartyManager.getInstance().getParties();
|
||||
return PartyManager.getParties();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,16 +70,15 @@ public final class PartyAPI {
|
||||
* @param partyName The party to add the player to
|
||||
*/
|
||||
public static void addToParty(Player player, String partyName) {
|
||||
Party party = PartyManager.getInstance().getParty(partyName);
|
||||
String playerName = player.getName();
|
||||
Party party = PartyManager.getParty(partyName);
|
||||
|
||||
if (party == null) {
|
||||
party = new Party();
|
||||
party.setName(partyName);
|
||||
party.setLeader(playerName);
|
||||
party.setLeader(player.getName());
|
||||
}
|
||||
|
||||
PartyManager.getInstance().addToParty(playerName, Users.getProfile(player), party);
|
||||
PartyManager.addToParty(player, Users.getPlayer(player), party);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,7 +89,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, Users.getPlayer(player).getParty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,7 +101,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +113,27 @@ 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));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all players in this player's party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return all the players in the player's party
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<String> getAllMembers(Player player) {
|
||||
List<String> memberNames = new ArrayList<String>();
|
||||
|
||||
for (OfflinePlayer member : PartyManager.getAllMembers(player)) {
|
||||
memberNames.add(member.getName());
|
||||
}
|
||||
|
||||
return memberNames;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,8 +144,8 @@ public final class PartyAPI {
|
||||
* @param player The player to check
|
||||
* @return all the players in the player's party
|
||||
*/
|
||||
public static List<String> getAllMembers(Player player) {
|
||||
return PartyManager.getInstance().getAllMembers(player);
|
||||
public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) {
|
||||
return PartyManager.getAllMembers(player);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +157,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,6 +169,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;
|
||||
|
||||
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();
|
||||
|
||||
mcMMO.p.getServer().broadcast(LocaleLoader.getString("Commands.AdminChat.Prefix", displayName) + adminMessage, "mcmmo.chat.adminchat");
|
||||
mcMMO.p.getLogger().info("[A]<" + ChatColor.stripColor(displayName) + "> " + adminMessage);
|
||||
}
|
||||
|
||||
public static void handleAdminChat(Plugin plugin, String senderName, String message) {
|
||||
handleAdminChat(plugin, senderName, senderName, message);
|
||||
}
|
||||
|
||||
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", displayName) + partyMessage);
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("[P](" + partyName + ")" + "<" + ChatColor.stripColor(displayName) + "> " + partyMessage);
|
||||
}
|
||||
|
||||
public static void handlePartyChat(Plugin plugin, Party party, String senderName, String message) {
|
||||
handlePartyChat(plugin, party, senderName, senderName, message);
|
||||
}
|
||||
}
|
||||
70
src/main/java/com/gmail/nossr50/chat/ChatMode.java
Normal file
70
src/main/java/com/gmail/nossr50/chat/ChatMode.java
Normal file
@@ -0,0 +1,70 @@
|
||||
package com.gmail.nossr50.chat;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public enum ChatMode {
|
||||
ADMIN(LocaleLoader.getString("Commands.AdminChat.On"), LocaleLoader.getString("Commands.AdminChat.Off")),
|
||||
PARTY(LocaleLoader.getString("Commands.Party.Chat.On"), LocaleLoader.getString("Commands.Party.Chat.Off"));
|
||||
|
||||
private String enabledMessage;
|
||||
private String disabledMessage;
|
||||
|
||||
private ChatMode (String enabledMessage, String disabledMessage) {
|
||||
this.enabledMessage = enabledMessage;
|
||||
this.disabledMessage = disabledMessage;
|
||||
}
|
||||
|
||||
public boolean isEnabled(McMMOPlayer mcMMOPlayer) {
|
||||
switch (this) {
|
||||
case ADMIN:
|
||||
return mcMMOPlayer.getAdminChatMode();
|
||||
|
||||
case PARTY:
|
||||
return mcMMOPlayer.getPartyChatMode();
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void disable(McMMOPlayer mcMMOPlayer) {
|
||||
switch (this) {
|
||||
case ADMIN:
|
||||
mcMMOPlayer.setAdminChat(false);
|
||||
return;
|
||||
|
||||
case PARTY:
|
||||
mcMMOPlayer.setPartyChat(false);
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void enable(McMMOPlayer mcMMOPlayer) {
|
||||
switch (this) {
|
||||
case ADMIN:
|
||||
mcMMOPlayer.setAdminChat(true);
|
||||
mcMMOPlayer.setPartyChat(false);
|
||||
return;
|
||||
|
||||
case PARTY:
|
||||
mcMMOPlayer.setPartyChat(true);
|
||||
mcMMOPlayer.setAdminChat(false);
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public String getEnabledMessage() {
|
||||
return enabledMessage;
|
||||
}
|
||||
|
||||
public String getDisabledMessage() {
|
||||
return disabledMessage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.gmail.nossr50.chat.commands;
|
||||
|
||||
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.chat.ChatMode;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class AdminChatCommand extends ChatCommand {
|
||||
public AdminChatCommand() {
|
||||
super(ChatMode.ADMIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleChatSending(CommandSender sender, String[] args) {
|
||||
String message = buildChatMessage(args, 0);
|
||||
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
ChatManager.handleAdminChat(mcMMO.p, player.getName(), player.getDisplayName(), message);
|
||||
}
|
||||
else {
|
||||
ChatManager.handleAdminChat(mcMMO.p, LocaleLoader.getString("Commands.Chat.Console"), message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
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.chat.ChatMode;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public abstract class ChatCommand implements CommandExecutor {
|
||||
protected McMMOPlayer mcMMOPlayer;
|
||||
protected ChatMode chatMode;
|
||||
|
||||
public ChatCommand (ChatMode chatMode) {
|
||||
this.chatMode = chatMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mcMMOPlayer = Users.getPlayer((Player) sender);
|
||||
|
||||
if (chatMode.isEnabled(mcMMOPlayer)) {
|
||||
disableChatMode(sender);
|
||||
}
|
||||
else {
|
||||
enableChatMode(sender);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("on")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
enableChatMode(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("off")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
disableChatMode(sender);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
handleChatSending(sender, args);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void enableChatMode(CommandSender sender) {
|
||||
chatMode.enable(mcMMOPlayer);
|
||||
sender.sendMessage(chatMode.getEnabledMessage());
|
||||
}
|
||||
|
||||
private void disableChatMode(CommandSender sender) {
|
||||
chatMode.disable(mcMMOPlayer);
|
||||
sender.sendMessage(chatMode.getDisabledMessage());
|
||||
}
|
||||
|
||||
protected String buildChatMessage(String[] args, int index) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(args[index]);
|
||||
|
||||
for (int i = index + 1; i < args.length; i++) {
|
||||
builder.append(" ");
|
||||
builder.append(args[i]);
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
protected abstract void handleChatSending(CommandSender sender, String[] args);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.gmail.nossr50.chat.commands;
|
||||
|
||||
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.chat.ChatMode;
|
||||
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 PartyChatCommand extends ChatCommand {
|
||||
public PartyChatCommand() {
|
||||
super(ChatMode.PARTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleChatSending(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
Party party = Users.getPlayer(player).getParty();
|
||||
|
||||
if (party == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
return;
|
||||
}
|
||||
|
||||
ChatManager.handlePartyChat(mcMMO.p, party, player.getName(), player.getDisplayName(), buildChatMessage(args, 0));
|
||||
}
|
||||
else {
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Specify"));
|
||||
return;
|
||||
}
|
||||
|
||||
Party party = PartyManager.getParty(args[0]);
|
||||
|
||||
if (party == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
|
||||
return;
|
||||
}
|
||||
|
||||
ChatManager.handlePartyChat(mcMMO.p, party, LocaleLoader.getString("Commands.Chat.Console"), buildChatMessage(args, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,33 +4,12 @@ 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.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
public class CommandHelper {
|
||||
|
||||
/**
|
||||
* Checks for command permissions.
|
||||
*
|
||||
* @param sender The command sender
|
||||
* @param permission The permission to check
|
||||
* @return true if the sender is a player without permissions, false otherwise
|
||||
*/
|
||||
public static boolean noCommandPermissions(CommandSender sender, String permission) {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (!Permissions.hasPermission(player, permission)) {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public final class CommandHelper {
|
||||
private CommandHelper() {}
|
||||
|
||||
public static boolean noConsoleUsage(CommandSender sender) {
|
||||
if (!(sender instanceof Player)) {
|
||||
@@ -45,116 +24,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.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 (inspect.hasPermission("mcmmo.skills.excavation")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION)));
|
||||
}
|
||||
|
||||
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 (inspect.hasPermission("mcmmo.skills.fishing")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING)));
|
||||
}
|
||||
|
||||
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 (inspect.hasPermission("mcmmo.skills.fishing")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM)));
|
||||
}
|
||||
|
||||
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 (inspect.hasPermission("mcmmo.skills.mining")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING)));
|
||||
}
|
||||
|
||||
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) }));
|
||||
if (inspect.hasPermission("mcmmo.skills.woodcutting")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", 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.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 (inspect.hasPermission("mcmmo.skills.axes")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES)));
|
||||
}
|
||||
|
||||
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 (inspect.hasPermission("mcmmo.skills.archery")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY)));
|
||||
}
|
||||
|
||||
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 (inspect.hasPermission("mcmmo.skills.swords")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS)));
|
||||
}
|
||||
|
||||
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 (inspect.hasPermission("mcmmo.skills.taming")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING)));
|
||||
}
|
||||
|
||||
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) }));
|
||||
if (inspect.hasPermission("mcmmo.skills.unarmed")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", 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.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 (inspect.hasPermission("mcmmo.skills.acrobatics")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS)));
|
||||
}
|
||||
|
||||
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) }));
|
||||
if (inspect.hasPermission("mcmmo.skills.repair")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", 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,361 @@
|
||||
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.chat.commands.AdminChatCommand;
|
||||
import com.gmail.nossr50.chat.commands.PartyChatCommand;
|
||||
import com.gmail.nossr50.commands.admin.AddlevelsCommand;
|
||||
import com.gmail.nossr50.commands.admin.AddxpCommand;
|
||||
import com.gmail.nossr50.commands.admin.HardcoreCommand;
|
||||
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.VampirismCommand;
|
||||
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.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.Config;
|
||||
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.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.commands.PartyCommand;
|
||||
import com.gmail.nossr50.party.commands.PtpCommand;
|
||||
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.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingCommand;
|
||||
import com.gmail.nossr50.spout.commands.MchudCommand;
|
||||
import com.gmail.nossr50.spout.commands.XplockCommand;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public final class CommandRegistrationHelper {
|
||||
private CommandRegistrationHelper() {};
|
||||
private static String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission");
|
||||
|
||||
public static void registerSkillCommands() {
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
String commandName = skill.toString().toLowerCase();
|
||||
String localizedName = SkillTools.getSkillName(skill);
|
||||
|
||||
PluginCommand command;
|
||||
|
||||
command = mcMMO.p.getCommand(commandName);
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.Skill", StringUtils.getCapitalized(localizedName)));
|
||||
command.setPermission("mcmmo.commands." + commandName);
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", localizedName));
|
||||
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.2", localizedName, "?", "[" + LocaleLoader.getString("Commands.Usage.Page") + "]"));
|
||||
|
||||
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;mcmmo.commands.addlevels.others");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.3", "addlevels", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">"));
|
||||
command.setExecutor(new AddlevelsCommand());
|
||||
}
|
||||
|
||||
public static void registerAddxpCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("addxp");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.addxp"));
|
||||
command.setPermission("mcmmo.commands.addxp;mcmmo.commands.addxp.others");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.3", "addxp", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.XP") + ">"));
|
||||
command.setExecutor(new AddxpCommand());
|
||||
}
|
||||
|
||||
public static void registerMcgodCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mcgod");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcgod"));
|
||||
command.setPermission("mcmmo.commands.mcgod;mcmmo.commands.mcgod.others");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcgod", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"));
|
||||
command.setExecutor(new McgodCommand());
|
||||
}
|
||||
|
||||
public static void registerMcrefreshCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mcrefresh");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcrefresh"));
|
||||
command.setPermission("mcmmo.commands.mcrefresh;mcmmo.commands.mcrefresh.others");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcrefresh", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"));
|
||||
command.setExecutor(new McrefreshCommand());
|
||||
}
|
||||
|
||||
public static void registerMmoeditCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mmoedit");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mmoedit"));
|
||||
command.setPermission("mcmmo.commands.mmoedit;mcmmo.commands.mmoedit.others");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.3", "mmoedit", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">"));
|
||||
command.setExecutor(new MmoeditCommand());
|
||||
}
|
||||
|
||||
public static void registerSkillresetCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("skillreset");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.skillreset"));
|
||||
command.setPermission("mcmmo.commands.skillreset;mcmmo.commands.skillreset.others"); // Only need the main ones, not the individual skill ones
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.2", "skillreset", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">"));
|
||||
command.setExecutor(new SkillresetCommand());
|
||||
}
|
||||
|
||||
public static void registerXprateCommand() {
|
||||
List<String> aliasList = new ArrayList<String>();
|
||||
aliasList.add("mcxprate");
|
||||
|
||||
PluginCommand command = mcMMO.p.getCommand("xprate");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.xprate"));
|
||||
command.setPermission("mcmmo.commands.xprate;mcmmo.commands.xprate.reset;mcmmo.commands.xprate.set");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.2", "xprate", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">", "<true|false>"));
|
||||
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "xprate", "reset"));
|
||||
command.setAliases(aliasList);
|
||||
command.setExecutor(new XprateCommand());
|
||||
}
|
||||
|
||||
public static void registerInspectCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("inspect");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.inspect"));
|
||||
command.setPermission("mcmmo.commands.inspect;mcmmo.commands.inspect.far;mcmmo.commands.inspect.offline");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "inspect", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
command.setExecutor(new InspectCommand());
|
||||
}
|
||||
|
||||
public static void registerMcabilityCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mcability");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcability"));
|
||||
command.setPermission("mcmmo.commands.mcability;mcmmo.commands.mcability.others");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcability", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"));
|
||||
command.setExecutor(new McabilityCommand());
|
||||
}
|
||||
|
||||
public static void registerMcmmoCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mcmmo");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcmmo"));
|
||||
command.setPermission("mcmmo.commands.mcmmo;mcmmo.commands.mcmmo.help");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcmmo"));
|
||||
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "mcmmo", "help"));
|
||||
command.setExecutor(new McmmoCommand());
|
||||
}
|
||||
|
||||
public static void registerMcrankCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mcrank");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcrank"));
|
||||
command.setPermission("mcmmo.commands.mcrank;mcmmo.commands.mcrank.others;mcmmo.commands.mcrank.others.far;mcmmo.commands.mcrank.others.offline");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcrank", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"));
|
||||
command.setExecutor(new McrankCommand());
|
||||
}
|
||||
|
||||
public static void registerMcstatsCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mcstats");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcstats"));
|
||||
command.setPermission("mcmmo.commands.mcstats");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcstats"));
|
||||
command.setExecutor(new McstatsCommand());
|
||||
}
|
||||
|
||||
public static void registerMctopCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mctop");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mctop"));
|
||||
command.setPermission("mcmmo.commands.mctop"); // Only need the main one, not the individual skill ones
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.2", "mctop", "[" + LocaleLoader.getString("Commands.Usage.Skill") + "]", "[" + LocaleLoader.getString("Commands.Usage.Page") + "]"));
|
||||
command.setExecutor(new MctopCommand());
|
||||
}
|
||||
|
||||
public static void registerMcpurgeCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mcpurge");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcpurge", Config.getInstance().getOldUsersCutoff()));
|
||||
command.setPermission("mcmmo.commands.mcpurge");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcpurge"));
|
||||
command.setExecutor(new McpurgeCommand());
|
||||
}
|
||||
|
||||
public static void registerMcremoveCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mcremove");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcremove"));
|
||||
command.setPermission("mcmmo.commands.mcremove");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcremove", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
command.setExecutor(new McremoveCommand());
|
||||
}
|
||||
|
||||
public static void registerMmoupdateCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mmoupdate");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mmoupdate"));
|
||||
command.setPermission("mcmmo.commands.mmoupdate");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mmoupdate"));
|
||||
command.setExecutor(new MmoupdateCommand());
|
||||
}
|
||||
|
||||
public static void registerAdminChatCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("adminchat");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.adminchat"));
|
||||
command.setPermission("mcmmo.chat.adminchat");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "adminchat"));
|
||||
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "adminchat", "<on|off>"));
|
||||
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "adminchat", "<" + LocaleLoader.getString("Commands.Usage.Message") + ">"));
|
||||
command.setExecutor(new AdminChatCommand());
|
||||
}
|
||||
|
||||
public static void registerPartyChatCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("partychat");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.partychat"));
|
||||
command.setPermission("mcmmo.chat.partychat;mcmmo.commands.party");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "partychat"));
|
||||
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "partychat", "<on|off>"));
|
||||
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "partychat", "<" + LocaleLoader.getString("Commands.Usage.Message") + ">"));
|
||||
command.setExecutor(new PartyChatCommand());
|
||||
}
|
||||
|
||||
public static void registerMchudCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mchud");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mchud"));
|
||||
command.setPermission("mcmmo.commands.mchud");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mchud", "<DISABLED | STANDARD | SMALL | RETRO>"));
|
||||
command.setExecutor(new MchudCommand());
|
||||
}
|
||||
|
||||
public static void registerXplockCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("xplock");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.xplock"));
|
||||
command.setPermission("mcmmo.commands.xplock");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "xplock"));
|
||||
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "xplock", "<on|off>"));
|
||||
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "xplock", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">"));
|
||||
command.setExecutor(new XplockCommand());
|
||||
}
|
||||
|
||||
public static void registerPartyCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("party");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.party"));
|
||||
command.setPermission("mcmmo.commands.party;mcmmo.commands.party.accept;mcmmo.commands.party.create;mcmmo.commands.party.disband;" +
|
||||
"mcmmo.commands.party.expshare;mcmmo.commands.party.invite;mcmmo.commands.party.itemshare;mcmmo.commands.party.join;" +
|
||||
"mcmmo.commands.party.kick;mcmmo.commands.party.lock;mcmmo.commands.party.owner;mcmmo.commands.party.password;" +
|
||||
"mcmmo.commands.party.quit;mcmmo.commands.party.rename;mcmmo.commands.party.unlock");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setExecutor(new PartyCommand());
|
||||
}
|
||||
|
||||
public static void registerPtpCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("ptp");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.ptp"));
|
||||
command.setPermission("mcmmo.commands.ptp;mcmmo.commands.ptp.accept;mcmmo.commands.ptp.acceptall;mcmmo.commands.ptp.toggle");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "ptp", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "ptp", "<toggle|accept|acceptall>"));
|
||||
command.setExecutor(new PtpCommand());
|
||||
}
|
||||
|
||||
public static void registerHardcoreCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("hardcore");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.hardcore"));
|
||||
command.setPermission("mcmmo.commands.hardcore;mcmmo.commands.hardcore.toggle;mcmmo.commands.hardcore.modify");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "hardcore", "[on|off]"));
|
||||
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "hardcore", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">"));
|
||||
command.setExecutor(new HardcoreCommand());
|
||||
}
|
||||
|
||||
public static void registerVampirismCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("vampirism");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.vampirism"));
|
||||
command.setPermission("mcmmo.commands.vampirism;mcmmo.commands.vampirism.toggle;mcmmo.commands.vampirism.modify");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "vampirism", "[on|off]"));
|
||||
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "vampirism", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">"));
|
||||
command.setExecutor(new VampirismCommand());
|
||||
}
|
||||
}
|
||||
@@ -1,88 +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.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%");
|
||||
|
||||
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,153 @@
|
||||
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.StringUtils;
|
||||
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;
|
||||
boolean allSkills = false;
|
||||
SkillType skill = null;
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (!sender.hasPermission("mcmmo.commands.addlevels")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("all")) {
|
||||
allSkills = true;
|
||||
}
|
||||
else if (!SkillTools.isSkill(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!StringUtils.isInt(args[1])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
levels = Integer.parseInt(args[1]);
|
||||
profile = Users.getPlayer((Player) sender).getProfile();
|
||||
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
profile.addLevels(skillType, levels);
|
||||
}
|
||||
}
|
||||
else {
|
||||
skill = SkillType.getSkill(args[0]);
|
||||
profile.addLevels(skill, levels);
|
||||
}
|
||||
|
||||
if (allSkills) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, SkillTools.getSkillName(skill)));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
if (!sender.hasPermission("mcmmo.commands.addlevels.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
allSkills = true;
|
||||
}
|
||||
else if (!SkillTools.isSkill(args[1])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!StringUtils.isInt(args[2])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
levels = Integer.parseInt(args[2]);
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
profile.addLevels(skillType, levels);
|
||||
}
|
||||
}
|
||||
else {
|
||||
skill = SkillType.getSkill(args[1]);
|
||||
profile.addLevels(skill, levels);
|
||||
}
|
||||
|
||||
profile.save(); // Since this is a temporary profile, we save it here.
|
||||
}
|
||||
else {
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
profile.addLevels(skillType, levels);
|
||||
}
|
||||
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels));
|
||||
}
|
||||
else {
|
||||
skill = SkillType.getSkill(args[1]);
|
||||
profile.addLevels(skill, levels);
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, SkillTools.getSkillName(skill)));
|
||||
}
|
||||
}
|
||||
|
||||
if (allSkills) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillTools.getSkillName(skill), args[0]));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
150
src/main/java/com/gmail/nossr50/commands/admin/AddxpCommand.java
Normal file
150
src/main/java/com/gmail/nossr50/commands/admin/AddxpCommand.java
Normal file
@@ -0,0 +1,150 @@
|
||||
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.StringUtils;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class AddxpCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
int xp;
|
||||
McMMOPlayer mcMMOPlayer;
|
||||
PlayerProfile profile;
|
||||
boolean allSkills = false;
|
||||
SkillType skill = null;
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (!sender.hasPermission("mcmmo.commands.addxp")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("all")) {
|
||||
allSkills = true;
|
||||
}
|
||||
else if (!SkillTools.isSkill(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!StringUtils.isInt(args[1])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
xp = Integer.parseInt(args[1]);
|
||||
mcMMOPlayer = Users.getPlayer((Player) sender);
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mcMMOPlayer.applyXpGain(skillType, xp);
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp));
|
||||
}
|
||||
else {
|
||||
skill = SkillType.getSkill(args[0]);
|
||||
|
||||
mcMMOPlayer.applyXpGain(skill, xp);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, SkillTools.getSkillName(skill)));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
if (!sender.hasPermission("mcmmo.commands.addxp.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
allSkills = true;
|
||||
}
|
||||
else if (!SkillTools.isSkill(args[1])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!StringUtils.isInt(args[2])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
xp = Integer.parseInt(args[2]);
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// TODO: Currently the offline player doesn't level up automatically
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
profile.setSkillXpLevel(skillType, xp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
skill = SkillType.getSkill(args[1]);
|
||||
profile.setSkillXpLevel(skill, xp);
|
||||
}
|
||||
|
||||
profile.save(); // Since this is a temporary profile, we save it here.
|
||||
}
|
||||
else {
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mcMMOPlayer.applyXpGain(skillType, xp);
|
||||
}
|
||||
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp));
|
||||
}
|
||||
else {
|
||||
skill = SkillType.getSkill(args[1]);
|
||||
mcMMOPlayer.applyXpGain(skill, xp);
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, SkillTools.getSkillName(skill)));
|
||||
}
|
||||
}
|
||||
|
||||
if (allSkills) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillTools.getSkillName(skill), args[0]));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
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.StringUtils;
|
||||
|
||||
public class HardcoreCommand implements CommandExecutor{
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!sender.hasPermission("mcmmo.commands.hardcore.toggle")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getHardcoreEnabled()) {
|
||||
disableHardcore();
|
||||
}
|
||||
else {
|
||||
enableHardcore();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enabled")) {
|
||||
if (!sender.hasPermission("mcmmo.commands.hardcore.toggle")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
enableHardcore();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disabled")) {
|
||||
if (!sender.hasPermission("mcmmo.commands.hardcore.toggle")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
disableHardcore();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!StringUtils.isDouble(args[0])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.hardcore.modify")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
double newPercent = Double.parseDouble(args[0]);
|
||||
|
||||
Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercent);
|
||||
sender.sendMessage(LocaleLoader.getString("Hardcore.PercentageChanged", percent.format(newPercent / 100D)));
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void disableHardcore() {
|
||||
Config.getInstance().setHardcoreEnabled(false);
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Disabled"));
|
||||
}
|
||||
|
||||
private void enableHardcore() {
|
||||
Config.getInstance().setHardcoreEnabled(true);
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Enabled"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
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.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 (!sender.hasPermission("mcmmo.commands.mcgod")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
profile = Users.getPlayer((Player) sender).getProfile();
|
||||
|
||||
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 (!sender.hasPermission("mcmmo.commands.mcgod.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||
return true;
|
||||
}
|
||||
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (!player.isOnline()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
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.util.Users;
|
||||
|
||||
public class McrefreshCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!sender.hasPermission("mcmmo.commands.mcrefresh")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
profile = Users.getPlayer(sender.getName()).getProfile();
|
||||
|
||||
profile.setRecentlyHurt(0);
|
||||
profile.resetCooldowns();
|
||||
profile.resetToolPrepMode();
|
||||
profile.resetAbilityMode();
|
||||
SkillTools.handleAbilitySpeedDecrease((Player) sender); //Remove enchants left over
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (!sender.hasPermission("mcmmo.commands.mcrefresh.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||
return true;
|
||||
}
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (!player.isOnline()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||
return true;
|
||||
}
|
||||
|
||||
profile.setRecentlyHurt(0);
|
||||
profile.resetCooldowns();
|
||||
profile.resetToolPrepMode();
|
||||
profile.resetAbilityMode();
|
||||
SkillTools.handleAbilitySpeedDecrease(player); //Remove enchants left over
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", args[0]));
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
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.StringUtils;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class MmoeditCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
int newValue;
|
||||
boolean allSkills = false;
|
||||
SkillType skill = null;
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (!sender.hasPermission("mcmmo.commands.mmoedit")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("all")) {
|
||||
allSkills = true;
|
||||
}
|
||||
else if (!SkillTools.isSkill(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!StringUtils.isInt(args[1])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
newValue = Integer.parseInt(args[1]);
|
||||
profile = Users.getPlayer((Player) sender).getProfile();
|
||||
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
profile.modifySkill(skillType, newValue);
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue));
|
||||
}
|
||||
else {
|
||||
skill = SkillType.getSkill(args[0]);
|
||||
profile.modifySkill(skill, newValue);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", SkillTools.getSkillName(skill), newValue));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
if (!sender.hasPermission("mcmmo.commands.mmoedit.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
allSkills = true;
|
||||
}
|
||||
else if (!SkillTools.isSkill(args[1])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!StringUtils.isInt(args[2])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
newValue = Integer.parseInt(args[2]);
|
||||
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;
|
||||
}
|
||||
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
profile.modifySkill(skillType, newValue);
|
||||
}
|
||||
}
|
||||
else {
|
||||
skill = SkillType.getSkill(args[1]);
|
||||
profile.modifySkill(skill, newValue);
|
||||
}
|
||||
|
||||
profile.save(); // Since this is a temporary profile, we save it here.
|
||||
}
|
||||
else {
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
profile.modifySkill(skillType, newValue);
|
||||
}
|
||||
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue));
|
||||
}
|
||||
else {
|
||||
skill = SkillType.getSkill(args[1]);
|
||||
profile.modifySkill(skill, newValue);
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", SkillTools.getSkillName(skill), newValue));
|
||||
}
|
||||
}
|
||||
|
||||
if (allSkills) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", SkillTools.getSkillName(skill), args[0]));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
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.Users;
|
||||
|
||||
public class SkillresetCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
boolean allSkills = false;
|
||||
SkillType skill = null;
|
||||
String skillName = "";
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (!sender.hasPermission("mcmmo.commands.skillreset")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("all")) {
|
||||
allSkills = true;
|
||||
}
|
||||
else if (!SkillTools.isSkill(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
profile = Users.getPlayer((Player) sender).getProfile();
|
||||
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.skillreset." + skillType.toString().toLowerCase())) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
profile.modifySkill(skillType, 0);
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
|
||||
}
|
||||
else {
|
||||
skill = SkillType.getSkill(args[0]);
|
||||
skillName = SkillTools.getSkillName(skill);
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.skillreset." + skill.toString().toLowerCase())) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
profile.modifySkill(skill, 0);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skillName));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (!sender.hasPermission("mcmmo.commands.skillreset.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
allSkills = true;
|
||||
}
|
||||
else if (!SkillTools.isSkill(args[1])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!allSkills) {
|
||||
skill = SkillType.getSkill(args[1]);
|
||||
skillName = SkillTools.getSkillName(skill);
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.skillreset.others." + skill.toString().toLowerCase())) {
|
||||
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;
|
||||
}
|
||||
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.skillreset.others." + skillType.toString().toLowerCase())) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
profile.modifySkill(skillType, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
profile.modifySkill(skill, 0);
|
||||
}
|
||||
|
||||
profile.save(); // Since this is a temporary profile, we save it here.
|
||||
}
|
||||
else {
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.skillreset.others." + skillType.toString().toLowerCase())) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
profile.modifySkill(skillType, 0);
|
||||
}
|
||||
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.All"));
|
||||
}
|
||||
else {
|
||||
profile.modifySkill(skill, 0);
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.Single", skillName));
|
||||
}
|
||||
}
|
||||
|
||||
if (allSkills) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", skillName, args[0]));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
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.StringUtils;
|
||||
|
||||
public class VampirismCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!Config.getInstance().getHardcoreEnabled()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Hardcore.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!sender.hasPermission("mcmmo.commands.vampirism.toggle")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getHardcoreVampirismEnabled()) {
|
||||
disableVampirism();
|
||||
}
|
||||
else {
|
||||
enableVampirism();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enabled")) {
|
||||
if (!sender.hasPermission("mcmmo.commands.vampirism.toggle")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
enableVampirism();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disabled")) {
|
||||
if (!sender.hasPermission("mcmmo.commands.vampirism.toggle")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
disableVampirism();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!StringUtils.isDouble(args[0])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.vampirism.modify")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
double newPercent = Double.parseDouble(args[0]);
|
||||
|
||||
Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercent);
|
||||
sender.sendMessage(LocaleLoader.getString("Vampirism.PercentageChanged", percent.format(newPercent / 100D)));
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void disableVampirism() {
|
||||
Config.getInstance().setHardcoreVampirismEnabled(false);
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Disabled"));
|
||||
}
|
||||
|
||||
private void enableVampirism() {
|
||||
Config.getInstance().setHardcoreVampirismEnabled(true);
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Enabled"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
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.StringUtils;
|
||||
|
||||
public class XprateCommand implements CommandExecutor {
|
||||
private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (!args[0].equalsIgnoreCase("reset")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.xprate.reset")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mcMMO.p.isXPEventEnabled()) {
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.over"));
|
||||
mcMMO.p.toggleXpEventEnabled();
|
||||
}
|
||||
|
||||
Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (!StringUtils.isInt(args[0])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.xprate.set")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!args[1].equalsIgnoreCase("true") && !args[1].equalsIgnoreCase("false")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mcMMO.p.setXPEventEnabled(Boolean.valueOf(args[1]));
|
||||
int newXpRate = Integer.parseInt(args[0]);
|
||||
Config.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
|
||||
|
||||
if (mcMMO.p.isXPEventEnabled()) {
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.0"));
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.1", newXpRate));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", newXpRate));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
|
||||
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 usage = LocaleLoader.getString("Commands.Usage.3", new Object[] {"addlevels", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">" });
|
||||
|
||||
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)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
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]);
|
||||
|
||||
Users.getProfile(modifiedPlayer).addLevels(skill, levels);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", new Object[] {playerName}));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", new Object[] {Misc.getCapitalized(skill.toString()), playerName}));
|
||||
}
|
||||
|
||||
if (modifiedPlayer.isOnline()) {
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
((Player) modifiedPlayer).sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", new Object[] {levels}));
|
||||
}
|
||||
else {
|
||||
((Player) modifiedPlayer).sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", new Object[] {levels, Misc.getCapitalized(skill.toString())}));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,132 +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.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.util.Misc;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
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 usage = LocaleLoader.getString("Commands.Usage.3", new Object[] {"addxp", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.XP") + ">" });
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (sender instanceof Player) {
|
||||
if (!Skills.isSkill(args[1])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Misc.isInt(args[1])) {
|
||||
modifiedPlayer = (Player) sender;
|
||||
xp = Integer.valueOf(args[1]);
|
||||
skill = Skills.getSkillType(args[0]);
|
||||
|
||||
PlayerProfile profile = Users.getProfile(modifiedPlayer);
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(modifiedPlayer);
|
||||
mcMMOPlayer.addXPOverride(skill, xp);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", new Object[] {xp}));
|
||||
}
|
||||
else {
|
||||
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", new Object[] {xp, Misc.getCapitalized(skill.toString())}));
|
||||
}
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
Skills.xpCheckAll(modifiedPlayer, profile);
|
||||
}
|
||||
else {
|
||||
Skills.xpCheckSkill(skill, modifiedPlayer, profile);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
modifiedPlayer = plugin.getServer().getPlayer(args[0]);
|
||||
String playerName = modifiedPlayer.getName();
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(modifiedPlayer);
|
||||
PlayerProfile 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])) {
|
||||
xp = Integer.valueOf(args[2]);
|
||||
skill = Skills.getSkillType(args[1]);
|
||||
|
||||
mcMMOPlayer.addXPOverride(skill, xp);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", new Object[] {playerName}));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", new Object[] {Misc.getCapitalized(skill.toString()), playerName}));
|
||||
}
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", new Object[] {xp}));
|
||||
Skills.xpCheckAll(modifiedPlayer, profile);
|
||||
}
|
||||
else {
|
||||
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", new Object[] {xp, Misc.getCapitalized(skill.toString())}));
|
||||
Skills.xpCheckSkill(skill, modifiedPlayer, profile);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,86 +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 = 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 && !sender.isOp() && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !Permissions.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;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && !sender.isOp() && !Permissions.inspectOfflineBypass((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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,117 +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.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class MmoeditCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
int newValue;
|
||||
SkillType skill;
|
||||
String skillName;
|
||||
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") + ">" });
|
||||
|
||||
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])) {
|
||||
Player player = (Player) sender;
|
||||
newValue = Integer.valueOf(args[1]);
|
||||
skill = Skills.getSkillType(args[0]);
|
||||
profile = Users.getProfile(player);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
}
|
||||
else {
|
||||
skillName = Misc.getCapitalized(skill.toString());
|
||||
}
|
||||
|
||||
profile.modifySkill(skill, newValue);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", new Object[] {skillName, newValue}));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
if (!Misc.isInt(args[2])) {
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
|
||||
skill = Skills.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]);
|
||||
|
||||
if (mcmmoPlayer != null) {
|
||||
profile = mcmmoPlayer.getProfile();
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
profile.modifySkill(skill, newValue);
|
||||
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.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
profile.modifySkill(skill, newValue);
|
||||
profile.save();
|
||||
}
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,51 +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.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.SQLConversionTask;
|
||||
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")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Start"));
|
||||
Users.clearAll();
|
||||
convertToMySQL();
|
||||
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
Users.addUser(x);
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Finish"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert FlatFile data to MySQL data.
|
||||
*/
|
||||
private void convertToMySQL() {
|
||||
if (!Config.getInstance().getUseMySQL()) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new SQLConversionTask(plugin), 1);
|
||||
}
|
||||
}
|
||||
@@ -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 == 0 || (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,97 +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.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String usage1 = LocaleLoader.getString("Commands.xprate.proper.0");
|
||||
String usage2 = LocaleLoader.getString("Commands.xprate.proper.1");
|
||||
String usage3 = LocaleLoader.getString("Commands.xprate.proper.2");
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("reset")) {
|
||||
if (xpEvent) {
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
x.sendMessage(LocaleLoader.getString("Commands.xprate.over"));
|
||||
}
|
||||
|
||||
xpEvent = !xpEvent;
|
||||
Config.getInstance().xpGainMultiplier = oldRate;
|
||||
}
|
||||
else {
|
||||
Config.getInstance().xpGainMultiplier = oldRate;
|
||||
}
|
||||
}
|
||||
else if (Misc.isInt(args[0])) {
|
||||
sender.sendMessage(usage3);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage2);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (Misc.isInt(args[0])) {
|
||||
oldRate = Config.getInstance().xpGainMultiplier;
|
||||
|
||||
if (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")) {
|
||||
xpEvent = Boolean.valueOf(args[1]);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage3);
|
||||
}
|
||||
|
||||
Config.getInstance().xpGainMultiplier = Misc.getInt(args[0]);
|
||||
|
||||
if (xpEvent) {
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
x.sendMessage(LocaleLoader.getString("Commands.xprate.started.0"));
|
||||
x.sendMessage(LocaleLoader.getString("Commands.xprate.started.1", new Object[] {Config.getInstance().xpGainMultiplier}));
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", new Object[] {Config.getInstance().xpGainMultiplier}));
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage1);
|
||||
sender.sendMessage(usage2);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage1);
|
||||
sender.sendMessage(usage2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isXpEventRunning() {
|
||||
return xpEvent;
|
||||
}
|
||||
}
|
||||
@@ -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,76 +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.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)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.mcc.Header"));
|
||||
|
||||
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"));
|
||||
|
||||
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"));
|
||||
|
||||
if (Permissions.partyTeleport(player)) {
|
||||
player.sendMessage("/ptp " + LocaleLoader.getString("Commands.Party.Teleport"));
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Other"));
|
||||
player.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
|
||||
player.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards"));
|
||||
|
||||
if (Config.getInstance().getCommandSkillResetEnabled() && Permissions.skillReset(player)) {
|
||||
player.sendMessage("/skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
|
||||
}
|
||||
|
||||
if (Permissions.mcAbility(player)) {
|
||||
player.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
|
||||
}
|
||||
|
||||
if (Permissions.adminChat(player)) {
|
||||
player.sendMessage("/a " + LocaleLoader.getString("Commands.AdminToggle"));
|
||||
}
|
||||
|
||||
if (Permissions.inspect(player)) {
|
||||
player.sendMessage("/inspect " + LocaleLoader.getString("Commands.Inspect"));
|
||||
}
|
||||
|
||||
if (Permissions.mmoedit(player)) {
|
||||
player.sendMessage("/mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
|
||||
}
|
||||
|
||||
if (Permissions.mcgod(player)) {
|
||||
player.sendMessage("/mcgod " + LocaleLoader.getString("Commands.mcgod"));
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.SkillInfo"));
|
||||
player.sendMessage("/mcmmo " + LocaleLoader.getString("Commands.ModDescription"));
|
||||
|
||||
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,38 +0,0 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
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
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String description = LocaleLoader.getString("mcMMO.Description");
|
||||
String[] mcSplit = description.split(",");
|
||||
sender.sendMessage(mcSplit);
|
||||
|
||||
if (Config.getInstance().getDonateMessageEnabled()) {
|
||||
if (mcMMO.spoutEnabled && sender instanceof SpoutPlayer) {
|
||||
SpoutPlayer spoutPlayer = (SpoutPlayer) sender;
|
||||
|
||||
spoutPlayer.sendNotification(LocaleLoader.getString("Spout.Donate"), ChatColor.GREEN + "gjmcferrin@gmail.com", Material.DIAMOND);
|
||||
}
|
||||
|
||||
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 anniversary = new Anniversary();
|
||||
anniversary.anniversaryCheck(sender);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
|
||||
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.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
|
||||
public class McpurgeCommand implements CommandExecutor{
|
||||
private Database database = mcMMO.getPlayerDatabase();
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
|
||||
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.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.McRankAsync;
|
||||
import com.gmail.nossr50.util.Leaderboard;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
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.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[] {Skills.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[] {Skills.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));
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
|
||||
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 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 = LocaleLoader.getString("Commands.Usage.1", new Object[] {"mcrefresh", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"});
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcrefresh")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
profile = Users.getProfile(player);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
player = plugin.getServer().getOfflinePlayer(args[0]);
|
||||
profile = Users.getProfile(player);
|
||||
String playerName = player.getName();
|
||||
|
||||
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("Commands.mcrefresh.Success", new Object[] {playerName}));
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
|
||||
profile.setRecentlyHurt(0);
|
||||
profile.resetCooldowns();
|
||||
profile.resetToolPrepMode();
|
||||
profile.resetAbilityMode();
|
||||
|
||||
if (player.isOnline()) {
|
||||
((Player) player).sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,129 +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.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.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
|
||||
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 = 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()) {
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
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;
|
||||
|
||||
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,175 +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.datatypes.SkillType;
|
||||
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 = 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 (Skills.isSkill(args[0])) {
|
||||
flatfileDisplay(1, args[0].toUpperCase(), sender);
|
||||
}
|
||||
else if (Skills.isLocalizedSkill(args[0])) {
|
||||
flatfileDisplay(1, Skills.translateLocalizedSkill(args[0]).toUpperCase(), sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (Misc.isInt(args[1])) {
|
||||
if (Skills.isSkill(args[0])) {
|
||||
flatfileDisplay(Integer.valueOf(args[1]), args[0].toUpperCase(), sender);
|
||||
}
|
||||
else if (Skills.isLocalizedSkill(args[0])) {
|
||||
flatfileDisplay(Integer.valueOf(args[1]), Skills.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 (Skills.isSkill(args[0])) {
|
||||
sqlDisplay(1, args[0].toLowerCase(), sender);
|
||||
}
|
||||
else if (Skills.isLocalizedSkill(args[0])) {
|
||||
sqlDisplay(1, Skills.translateLocalizedSkill(args[0]).toLowerCase(), sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (Misc.isInt(args[1])) {
|
||||
if (Skills.isSkill(args[0])) {
|
||||
sqlDisplay(Integer.valueOf(args[1]), args[0].toLowerCase(), sender);
|
||||
}
|
||||
else if (Skills.isLocalizedSkill(args[0])) {
|
||||
sqlDisplay(Integer.valueOf(args[1]), Skills.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();
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
|
||||
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,111 +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.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 = 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:
|
||||
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 = LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {player.getName()} );
|
||||
|
||||
plugin.getLogger().info("[A]<" + player.getName() + "> " + message);
|
||||
|
||||
for (Player otherPlayer : plugin.getServer().getOnlinePlayers()) {
|
||||
if (Permissions.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 = LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {LocaleLoader.getString("Commands.Chat.Console")} );
|
||||
|
||||
plugin.getLogger().info("[A]<*Console*> " + message);
|
||||
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
if (Permissions.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,71 +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.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 = LocaleLoader.getString("Commands.Usage.1", new Object[] {"invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"});
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
||||
return true;
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,134 +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.chat.McMMOPartyChatEvent;
|
||||
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 PCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public PCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
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;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (sender instanceof Player) {
|
||||
profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (profile.getAdminChatMode()) {
|
||||
profile.toggleAdminChat();
|
||||
}
|
||||
|
||||
profile.togglePartyChat();
|
||||
|
||||
if (profile.getPartyChatMode()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.Chat.On"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Off"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
Party party = Users.getProfile(player).getParty();
|
||||
|
||||
if (party == null) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
return true;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), party.getName(), message);
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
message = chatEvent.getMessage();
|
||||
String prefix = LocaleLoader.getString("Commands.Party.Chat.Prefix", new Object[] {player.getName()} );
|
||||
|
||||
plugin.getLogger().info("[P](" + party.getName() + ")" + "<" + player.getName() + "> " + message);
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
member.sendMessage(prefix + message);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!PartyManager.getInstance().isParty(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
|
||||
return true;
|
||||
}
|
||||
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(args[1]);
|
||||
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
buffer.append(" ");
|
||||
buffer.append(args[i]);
|
||||
}
|
||||
|
||||
String message = buffer.toString();
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent("Console", args[0], message);
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
message = chatEvent.getMessage();
|
||||
String prefix = LocaleLoader.getString("Commands.Party.Chat.Prefix", new Object[] {LocaleLoader.getString("Commands.Chat.Console")} );
|
||||
|
||||
plugin.getLogger().info("[P](" + args[0] + ")" + "<*Console*> " + message);
|
||||
|
||||
for (Player member : PartyManager.getInstance().getOnlineMembers(args[0])) {
|
||||
member.sendMessage(prefix + message);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,261 +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(LocaleLoader.getString("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 {
|
||||
Party newParty = partyManagerInstance.getParty(args[0]);
|
||||
|
||||
// Check to see if the party exists, and if it does, can the player join it?
|
||||
if (newParty != null && !partyManagerInstance.checkJoinability(player, newParty, null)) {
|
||||
return true; // End before any event is fired.
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
partyManagerInstance.setPartyLeader(args[1], party);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Party newParty = partyManagerInstance.getParty(args[0]);
|
||||
|
||||
// Check to see if the party exists, and if it does, can the player join it?
|
||||
if (newParty != null && !partyManagerInstance.checkJoinability(player, newParty, args[1])) {
|
||||
return true; // End before any event is fired.
|
||||
}
|
||||
|
||||
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 {
|
||||
Party newParty = partyManagerInstance.getParty(args[0]);
|
||||
|
||||
// Check to see if the party exists, and if it does, can the player join it?
|
||||
if (newParty != null && !partyManagerInstance.checkJoinability(player, newParty, args[1])) {
|
||||
return true; // End before any event is fired.
|
||||
}
|
||||
|
||||
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.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.Misc;
|
||||
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 = LocaleLoader.getString("Commands.Usage.1", new Object[] {"ptp", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"});
|
||||
|
||||
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() * Misc.TIME_CONVERSION_FACTOR) > 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(LocaleLoader.getString("Party.Teleport.Self"));
|
||||
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,90 @@
|
||||
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.Users;
|
||||
|
||||
public class InspectCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (!sender.hasPermission("mcmmo.commands.inspect")) {
|
||||
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); //Temporary Profile
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && !sender.hasPermission("mcmmo.commands.inspect.offline")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", args[0]));
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION)));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING)));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM)));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING)));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", 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", LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES)));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY)));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS)));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING)));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", 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", LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS)));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR)));
|
||||
}
|
||||
else {
|
||||
Player target = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (sender instanceof Player) {
|
||||
Player inspector = (Player) sender;
|
||||
|
||||
if (!Misc.isNear(inspector.getLocation(), target.getLocation(), 5.0) && !inspector.hasPermission("mcmmo.commands.inspect.far")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
|
||||
CommandHelper.printGatheringSkills(target, profile, sender);
|
||||
CommandHelper.printCombatSkills(target, profile, sender);
|
||||
CommandHelper.printMiscSkills(target, profile, sender);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
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.datatypes.McMMOPlayer;
|
||||
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;
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!sender.hasPermission("mcmmo.commands.mcability")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
profile = Users.getPlayer((Player) sender).getProfile();
|
||||
|
||||
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 (!sender.hasPermission("mcmmo.commands.mcability.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (!player.isOnline()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (profile.getAbilityUse()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
||||
}
|
||||
|
||||
profile.toggleAbilityUse();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class McmmoCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
String description = LocaleLoader.getString("mcMMO.Description");
|
||||
String[] mcSplit = description.split(",");
|
||||
sender.sendMessage(mcSplit);
|
||||
|
||||
if (Config.getInstance().getDonateMessageEnabled()) {
|
||||
if (mcMMO.spoutEnabled && sender instanceof SpoutPlayer) {
|
||||
SpoutPlayer spoutPlayer = (SpoutPlayer) sender;
|
||||
spoutPlayer.sendNotification(LocaleLoader.getString("Spout.Donate"), ChatColor.GREEN + "gjmcferrin@gmail.com", Material.DIAMOND);
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
|
||||
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("commands")) {
|
||||
if (!sender.hasPermission("mcmmo.commands.mcmmo.help")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcc.Header"));
|
||||
displayPartyCommands(sender);
|
||||
displayOtherCommands(sender);
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void displayPartyCommands(CommandSender sender) {
|
||||
if (sender.hasPermission("mcmmo.commands.party")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.Commands"));
|
||||
sender.sendMessage("/party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1"));
|
||||
sender.sendMessage("/party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2"));
|
||||
sender.sendMessage("/party quit " + LocaleLoader.getString("Commands.Party.Quit"));
|
||||
|
||||
if (sender.hasPermission("mcmmo.chat.party")) {
|
||||
sender.sendMessage("/party chat " + LocaleLoader.getString("Commands.Party.Toggle"));
|
||||
}
|
||||
|
||||
sender.sendMessage("/party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite"));
|
||||
sender.sendMessage("/party accept " + LocaleLoader.getString("Commands.Party.Accept"));
|
||||
|
||||
if (sender.hasPermission("mcmmo.commands.ptp")) {
|
||||
sender.sendMessage("/party teleport " + LocaleLoader.getString("Commands.Party.Teleport"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void displayOtherCommands(CommandSender sender) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Other"));
|
||||
sender.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
|
||||
sender.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards"));
|
||||
|
||||
if (sender.hasPermission("mcmmo.commands.skillreset")) {
|
||||
sender.sendMessage("/skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
|
||||
}
|
||||
|
||||
if (sender.hasPermission("mcmmo.commands.mcability")) {
|
||||
sender.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
|
||||
}
|
||||
|
||||
if (sender.hasPermission("mcmmo.chat.admin")) {
|
||||
sender.sendMessage("/adminchat " + LocaleLoader.getString("Commands.AdminToggle"));
|
||||
}
|
||||
|
||||
if (sender.hasPermission("mcmmo.commands.inspect")) {
|
||||
sender.sendMessage("/inspect " + LocaleLoader.getString("Commands.Inspect"));
|
||||
}
|
||||
|
||||
if (sender.hasPermission("mcmmo.commands.mmoedit")) {
|
||||
sender.sendMessage("/mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
|
||||
}
|
||||
|
||||
if (sender.hasPermission("mcmmo.commands.mcgod")) {
|
||||
sender.sendMessage("/mcgod " + LocaleLoader.getString("Commands.mcgod"));
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.SkillInfo"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
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.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.Leaderboard;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
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.Misc;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McrankCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!sender.hasPermission("mcmmo.commands.mcrank")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
sqlDisplay(sender, sender.getName());
|
||||
}
|
||||
else {
|
||||
Leaderboard.updateLeaderboards(); // Make sure the information is up to date
|
||||
flatfileDisplay(sender, sender.getName());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (!sender.hasPermission("mcmmo.commands.mcrank.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
if (mcMMOPlayer == null) {
|
||||
PlayerProfile profile = new PlayerProfile(args[0], false); //Temporary Profile
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && !!sender.hasPermission("mcmmo.commands.mcrank.others.offline")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Player target = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !sender.hasPermission("mcmmo.commands.mcrank.others.far")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
sqlDisplay(sender, args[0]);
|
||||
}
|
||||
else {
|
||||
Leaderboard.updateLeaderboards(); // Make sure the information is up to date
|
||||
flatfileDisplay(sender, args[0]);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void flatfileDisplay(CommandSender sender, String playerName) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
|
||||
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
int[] rankInts = Leaderboard.getPlayerRank(playerName, skillType);
|
||||
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rankInts[1] == 0) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.getSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.getSkillName(skillType), rankInts[0]));
|
||||
}
|
||||
}
|
||||
|
||||
// Show the powerlevel ranking
|
||||
int[] rankInts = Leaderboard.getPlayerRank(playerName);
|
||||
|
||||
if (rankInts[1] == 0) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", rankInts[0]));
|
||||
}
|
||||
}
|
||||
|
||||
private void sqlDisplay(CommandSender sender, String playerName) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new McRankAsync(playerName, sender));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
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.McMMOPlayer;
|
||||
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;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
|
||||
PlayerProfile profile = mcMMOPlayer.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 != Integer.MAX_VALUE) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", mcMMOPlayer.getPowerLevel(), powerLevelCap));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
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.database.Leaderboard;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.McTopAsync;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class MctopCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
boolean useMySQL = Config.getInstance().getUseMySQL();
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
display(1, "ALL", sender, useMySQL, command);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (StringUtils.isInt(args[0])) {
|
||||
display(Integer.parseInt(args[0]), "ALL", sender, useMySQL, command);
|
||||
}
|
||||
else if (SkillTools.isSkill(args[0])) {
|
||||
display(1, SkillType.getSkill(args[0]).toString(), sender, useMySQL, command);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (!StringUtils.isInt(args[1])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (SkillTools.isSkill(args[0])) {
|
||||
display(Integer.parseInt(args[1]), SkillType.getSkill(args[0]).toString(), sender, useMySQL, command);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void display(int page, String skill, CommandSender sender, boolean sql, Command command) {
|
||||
if (sql) {
|
||||
if (skill.equalsIgnoreCase("all")) {
|
||||
sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender, command);
|
||||
}
|
||||
else {
|
||||
sqlDisplay(page, skill, sender, command);
|
||||
}
|
||||
}
|
||||
else {
|
||||
flatfileDisplay(page, skill, sender, command);
|
||||
}
|
||||
}
|
||||
|
||||
private void flatfileDisplay(int page, String skill, CommandSender sender, Command command) {
|
||||
if (!skill.equalsIgnoreCase("all") && !sender.hasPermission("mcmmo.commands.mctop." + skill.toLowerCase())) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
Leaderboard.updateLeaderboards(); //Make sure we have the latest information
|
||||
|
||||
String[] info = Leaderboard.retrieveInfo(skill, page);
|
||||
|
||||
if (skill.equalsIgnoreCase("all")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.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, Command command) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new McTopAsync(page, query, sender, command));
|
||||
}
|
||||
}
|
||||
@@ -1,116 +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;
|
||||
import com.gmail.nossr50.skills.acrobatics.Acrobatics;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class AcrobaticsCommand extends SkillCommand {
|
||||
private String dodgeChance;
|
||||
private String dodgeChanceLucky;
|
||||
private String rollChance;
|
||||
private String rollChanceLucky;
|
||||
private String gracefulRollChance;
|
||||
private String gracefulRollChanceLucky;
|
||||
|
||||
private boolean canDodge;
|
||||
private boolean canRoll;
|
||||
private boolean canGracefulRoll;
|
||||
private boolean lucky;
|
||||
|
||||
public AcrobaticsCommand() {
|
||||
super(SkillType.ACROBATICS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
float dodgeChanceF;
|
||||
float rollChanceF;
|
||||
float gracefulRollChanceF;
|
||||
|
||||
// DODGE
|
||||
if (skillValue >= Acrobatics.dodgeMaxBonusLevel) dodgeChanceF = (float) Acrobatics.dodgeMaxChance;
|
||||
else dodgeChanceF = (float) ((Acrobatics.dodgeMaxChance / Acrobatics.dodgeMaxBonusLevel) * skillValue);
|
||||
dodgeChance = percent.format(dodgeChanceF / 100D);
|
||||
if (dodgeChanceF * 1.3333D >= 100D) dodgeChanceLucky = percent.format(1D);
|
||||
else dodgeChanceLucky = percent.format(dodgeChanceF * 1.3333D / 100D);
|
||||
|
||||
// ROLL
|
||||
if (skillValue >= Acrobatics.rollMaxBonusLevel) rollChanceF = (float) Acrobatics.rollMaxChance;
|
||||
else rollChanceF = (float) ((Acrobatics.rollMaxChance / Acrobatics.rollMaxBonusLevel) * skillValue);
|
||||
rollChance = percent.format(rollChanceF / 100D);
|
||||
if (rollChanceF * 1.3333D >= 100D) rollChanceLucky = percent.format(1D);
|
||||
else rollChanceLucky = percent.format(rollChanceF * 1.3333D / 100D);
|
||||
|
||||
// GRACEFULROLL
|
||||
if (skillValue >= Acrobatics.gracefulRollMaxBonusLevel) gracefulRollChanceF = (float) Acrobatics.gracefulRollMaxChance;
|
||||
else gracefulRollChanceF = (float) ((Acrobatics.gracefulRollMaxChance / Acrobatics.gracefulRollMaxBonusLevel) * skillValue);
|
||||
gracefulRollChance = percent.format(gracefulRollChanceF / 100D);
|
||||
if (gracefulRollChanceF * 1.3333D >= 100D) gracefulRollChanceLucky = percent.format(1D);
|
||||
else gracefulRollChanceLucky = percent.format(gracefulRollChanceF * 1.3333D / 100D);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canDodge = Permissions.dodge(player);
|
||||
canRoll = Permissions.roll(player);
|
||||
canGracefulRoll = Permissions.gracefulRoll(player);
|
||||
lucky = Permissions.luckyAcrobatics(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canDodge || canGracefulRoll || canRoll;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (lucky) {
|
||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.ACROBATICS) }) }));
|
||||
}
|
||||
|
||||
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) {
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", new Object[] { rollChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { rollChanceLucky }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", new Object[] { rollChance }));
|
||||
}
|
||||
|
||||
if (canGracefulRoll) {
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { gracefulRollChanceLucky }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance }));
|
||||
}
|
||||
|
||||
if (canDodge) {
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { dodgeChanceLucky }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,109 +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;
|
||||
import com.gmail.nossr50.skills.archery.Archery;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class ArcheryCommand extends SkillCommand {
|
||||
private String skillShotBonus;
|
||||
private String dazeChance;
|
||||
private String dazeChanceLucky;
|
||||
private String retrieveChance;
|
||||
private String retrieveChanceLucky;
|
||||
|
||||
private boolean canSkillShot;
|
||||
private boolean canDaze;
|
||||
private boolean canRetrieve;
|
||||
private boolean lucky;
|
||||
|
||||
public ArcheryCommand() {
|
||||
super(SkillType.ARCHERY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
float dazeChanceF;
|
||||
float retrieveChanceF;
|
||||
|
||||
// SkillShot
|
||||
double bonus = (int)((double) skillValue / (double) Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage;
|
||||
if (bonus > Archery.skillShotMaxBonusPercentage) skillShotBonus = percent.format(Archery.skillShotMaxBonusPercentage);
|
||||
else skillShotBonus = percent.format(bonus);
|
||||
|
||||
// Daze
|
||||
if (skillValue >= Archery.dazeMaxBonusLevel) dazeChanceF = (float) Archery.dazeMaxBonus;
|
||||
else dazeChanceF = (float) (( Archery.dazeMaxBonus / Archery.dazeMaxBonusLevel) * skillValue);
|
||||
dazeChance = percent.format(dazeChanceF / 100D);
|
||||
if (dazeChanceF * 1.3333D >= 100D) dazeChanceLucky = percent.format(1D);
|
||||
else dazeChanceLucky = percent.format(dazeChanceF * 1.3333D / 100D);
|
||||
|
||||
// Retrieve
|
||||
if (skillValue >= Archery.retrieveMaxBonusLevel) retrieveChanceF = (float) Archery.retrieveMaxChance;
|
||||
else retrieveChanceF = (float) ((Archery.retrieveMaxChance / Archery.retrieveMaxBonusLevel) * skillValue);
|
||||
retrieveChance = percent.format(retrieveChanceF / 100D);
|
||||
if (retrieveChanceF * 1.3333D >= 100D) retrieveChanceLucky = percent.format(1D);
|
||||
else retrieveChanceLucky = percent.format(retrieveChanceF * 1.3333D / 100D);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canSkillShot = Permissions.archeryBonus(player);
|
||||
canDaze = Permissions.daze(player);
|
||||
canRetrieve = Permissions.trackArrows(player);
|
||||
lucky = Permissions.luckyArchery(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canSkillShot || canDaze || canRetrieve;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (lucky) {
|
||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.ARCHERY) }) }));
|
||||
}
|
||||
|
||||
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) {
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", new Object[] { dazeChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { dazeChanceLucky }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", new Object[] { dazeChance }));
|
||||
}
|
||||
|
||||
if (canRetrieve) {
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { retrieveChanceLucky }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,148 +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;
|
||||
import com.gmail.nossr50.skills.axes.Axes;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class AxesCommand extends SkillCommand {
|
||||
private String critChance;
|
||||
private String critChanceLucky;
|
||||
private String bonusDamage;
|
||||
private String impactDamage;
|
||||
private String greaterImpactDamage;
|
||||
private String skullSplitterLength;
|
||||
private String skullSplitterLengthEndurance;
|
||||
|
||||
private boolean canSkullSplitter;
|
||||
private boolean canCritical;
|
||||
private boolean canBonusDamage;
|
||||
private boolean canImpact;
|
||||
private boolean canGreaterImpact;
|
||||
private boolean lucky;
|
||||
private boolean endurance;
|
||||
|
||||
public AxesCommand() {
|
||||
super(SkillType.AXES);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
float critChanceF;
|
||||
int skillCheck = Misc.skillCheck((int) skillValue, Axes.criticalHitMaxBonusLevel);
|
||||
|
||||
//Armor Impact
|
||||
impactDamage = String.valueOf(1 + ((double) skillValue / (double) Axes.impactIncreaseLevel));
|
||||
//Skull Splitter
|
||||
int length = 2 + (int) ((double) skillValue / (double) Misc.abilityLengthIncreaseLevel);
|
||||
skullSplitterLength = String.valueOf(length);
|
||||
|
||||
if (Permissions.activationTwelve(player)) {
|
||||
length = length + 12;
|
||||
}
|
||||
else if (Permissions.activationEight(player)) {
|
||||
length = length + 8;
|
||||
}
|
||||
else if (Permissions.activationFour(player)) {
|
||||
length = length + 4;
|
||||
}
|
||||
int maxLength = SkillType.AXES.getAbility().getMaxTicks();
|
||||
if (maxLength != 0 && length > maxLength) {
|
||||
length = maxLength;
|
||||
}
|
||||
skullSplitterLengthEndurance = String.valueOf(length);
|
||||
|
||||
//Greater Impact
|
||||
greaterImpactDamage = String.valueOf(Axes.greaterImpactBonusDamage);
|
||||
//Critical Strikes
|
||||
if (skillValue >= Axes.criticalHitMaxBonusLevel) critChanceF = (float) Axes.criticalHitMaxChance;
|
||||
else critChanceF = (float) ((Axes.criticalHitMaxChance / Axes.criticalHitMaxBonusLevel) * skillCheck);
|
||||
critChance = percent.format(critChanceF / 100D);
|
||||
if (critChanceF * 1.3333D >= 100D) critChanceLucky = percent.format(1D);
|
||||
else critChanceLucky = percent.format(critChanceF * 1.3333D / 100D);
|
||||
//Axe Mastery
|
||||
if (skillValue >= Axes.bonusDamageMaxBonusLevel) bonusDamage = String.valueOf(Axes.bonusDamageMaxBonus);
|
||||
else bonusDamage = String.valueOf(skillValue / ((double) Axes.bonusDamageMaxBonusLevel / (double) Axes.bonusDamageMaxBonus));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canSkullSplitter = Permissions.skullSplitter(player);
|
||||
canCritical = Permissions.criticalHit(player);
|
||||
canBonusDamage = Permissions.axeBonus(player);
|
||||
canImpact = Permissions.impact(player);
|
||||
canGreaterImpact = Permissions.greaterImpact(player);
|
||||
lucky = Permissions.luckyAxes(player);
|
||||
endurance = Permissions.activationTwelve(player) || Permissions.activationEight(player) || Permissions.activationFour(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (lucky) {
|
||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.AXES) }) }));
|
||||
}
|
||||
|
||||
if (canSkullSplitter) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.0"), LocaleLoader.getString("Axes.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canCritical) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.2"), LocaleLoader.getString("Axes.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canBonusDamage) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.4"), LocaleLoader.getString("Axes.Effect.5") }));
|
||||
}
|
||||
|
||||
if (canImpact) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.6"), LocaleLoader.getString("Axes.Effect.7") }));
|
||||
}
|
||||
|
||||
if (canGreaterImpact) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.8"), LocaleLoader.getString("Axes.Effect.9") }));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canBonusDamage) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", new Object[] {bonusDamage}) }));
|
||||
}
|
||||
|
||||
if (canImpact) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", new Object[] {impactDamage}) }));
|
||||
}
|
||||
|
||||
if (canGreaterImpact) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", new Object[] {greaterImpactDamage}) }));
|
||||
}
|
||||
|
||||
if (canCritical) {
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", new Object[] { critChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { critChanceLucky }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", new Object[] { critChance }));
|
||||
}
|
||||
|
||||
if (canSkullSplitter) {
|
||||
if (endurance)
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", new Object[] { skullSplitterLength }) + LocaleLoader.getString("Perks.activationtime.bonus", new Object[] { skullSplitterLengthEndurance }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", new Object[] { skullSplitterLength }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.commands.SkillCommand;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class ExcavationCommand extends SkillCommand {
|
||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
private String gigaDrillBreakerLength;
|
||||
private String gigaDrillBreakerLengthEndurance;
|
||||
|
||||
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
|
||||
|
||||
private boolean canGigaDrill;
|
||||
private boolean canTreasureHunt;
|
||||
private boolean lucky;
|
||||
private boolean endurance;
|
||||
|
||||
public ExcavationCommand() {
|
||||
super(SkillType.EXCAVATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
int length = 2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel);
|
||||
gigaDrillBreakerLength = String.valueOf(length);
|
||||
|
||||
if (Permissions.activationTwelve(player)) {
|
||||
length = length + 12;
|
||||
}
|
||||
else if (Permissions.activationEight(player)) {
|
||||
length = length + 8;
|
||||
}
|
||||
else if (Permissions.activationFour(player)) {
|
||||
length = length + 4;
|
||||
}
|
||||
int maxLength = SkillType.EXCAVATION.getAbility().getMaxTicks();
|
||||
if (maxLength != 0 && length > maxLength) {
|
||||
length = maxLength;
|
||||
}
|
||||
gigaDrillBreakerLengthEndurance = String.valueOf(length);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canGigaDrill = Permissions.gigaDrillBreaker(player);
|
||||
canTreasureHunt = Permissions.excavationTreasures(player);
|
||||
lucky = Permissions.luckyExcavation(player);
|
||||
endurance = Permissions.activationTwelve(player) || Permissions.activationEight(player) || Permissions.activationFour(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canGigaDrill || canTreasureHunt;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (lucky) {
|
||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.EXCAVATION) }) }));
|
||||
}
|
||||
|
||||
if (canGigaDrill) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Excavation.Effect.0"), LocaleLoader.getString("Excavation.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3") }));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canGigaDrill;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canGigaDrill) {
|
||||
if (endurance)
|
||||
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", new Object[] { gigaDrillBreakerLength }) + LocaleLoader.getString("Perks.activationtime.bonus", new Object[] { gigaDrillBreakerLengthEndurance }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", new Object[] { gigaDrillBreakerLength }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.commands.SkillCommand;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.gathering.Fishing;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class FishingCommand extends SkillCommand {
|
||||
|
||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
|
||||
private int lootTier;
|
||||
private String magicChance;
|
||||
private String magicChanceLucky;
|
||||
private String chanceRaining;
|
||||
private int shakeUnlockLevel;
|
||||
private String shakeChance;
|
||||
private String shakeChanceLucky;
|
||||
private String fishermansDietRank;
|
||||
|
||||
private int magicHunterMultiplier = advancedConfig.getFishingMagicMultiplier();
|
||||
private int fishermansDietRankChange = advancedConfig.getFarmerDietRankChange();
|
||||
private int fishermansDietRankMaxLevel = fishermansDietRankChange * 5;
|
||||
|
||||
private boolean canTreasureHunt;
|
||||
private boolean canMagicHunt;
|
||||
private boolean canShake;
|
||||
private boolean canFishermansDiet;
|
||||
private boolean lucky;
|
||||
private boolean raining;
|
||||
|
||||
public FishingCommand() {
|
||||
super(SkillType.FISHING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
raining = player.getWorld().hasStorm();
|
||||
chanceRaining = "";
|
||||
//Treasure Hunter
|
||||
lootTier = Fishing.getFishingLootTier(profile);
|
||||
double magicChanceD = lootTier * magicHunterMultiplier;
|
||||
if (raining) {
|
||||
chanceRaining = LocaleLoader.getString("Fishing.Chance.Raining");
|
||||
magicChanceD = magicChanceD * 1.1D;
|
||||
}
|
||||
magicChance = percent.format(magicChanceD / 100D);
|
||||
if (magicChanceD * 1.3333D >= 100D) magicChanceLucky = percent.format(1D);
|
||||
else magicChanceLucky = percent.format(magicChanceD * 1.3333D / 100D);
|
||||
|
||||
//Shake
|
||||
int dropChance = Fishing.getShakeChance(lootTier);
|
||||
shakeChance = percent.format(dropChance / 100D);
|
||||
if (dropChance * 1.3333D >= 100D) shakeChanceLucky = percent.format(1D);
|
||||
else shakeChanceLucky = percent.format(dropChance * 1.3333D / 100D);
|
||||
shakeUnlockLevel = advancedConfig.getShakeUnlockLevel();
|
||||
|
||||
//Fishermans Diet
|
||||
if (skillValue >= fishermansDietRankMaxLevel) fishermansDietRank = "5";
|
||||
else fishermansDietRank = String.valueOf((int) ((double) skillValue / (double) fishermansDietRankChange));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canTreasureHunt = Permissions.fishingTreasures(player);
|
||||
canMagicHunt = Permissions.fishingMagic(player);
|
||||
canShake = Permissions.shakeMob(player);
|
||||
canFishermansDiet = Permissions.fishermansDiet(player);
|
||||
lucky = Permissions.luckyFishing(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canTreasureHunt || canMagicHunt || canShake;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (lucky) {
|
||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.FISHING) }) }));
|
||||
}
|
||||
|
||||
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") }));
|
||||
}
|
||||
|
||||
if (canFishermansDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7") }));
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", new Object[] { magicChance}) + chanceRaining + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { magicChanceLucky }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", new Object[] { magicChance}) + chanceRaining);
|
||||
}
|
||||
|
||||
if (canShake) {
|
||||
if (skillValue < advancedConfig.getShakeUnlockLevel()) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Fishing.Ability.Locked.0", new Object[] { shakeUnlockLevel }) }));
|
||||
}
|
||||
else {
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", new Object[] { shakeChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { shakeChanceLucky }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", new Object[] { shakeChance }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canFishermansDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", new Object[] { fishermansDietRank }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,191 +0,0 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.commands.SkillCommand;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class HerbalismCommand extends SkillCommand {
|
||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
|
||||
private String greenTerraLength;
|
||||
private String greenTerraLengthEndurance;
|
||||
private String greenThumbChance;
|
||||
private String greenThumbChanceLucky;
|
||||
private String greenThumbStage;
|
||||
private String farmersDietRank;
|
||||
private String doubleDropChance;
|
||||
private String doubleDropChanceLucky;
|
||||
private String hylianLuckChance;
|
||||
private String hylianLuckChanceLucky;
|
||||
|
||||
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
|
||||
private int farmersDietRankChange = advancedConfig.getFarmerDietRankChange();
|
||||
private int farmersDietMaxLevel = farmersDietRankChange * 5;
|
||||
private int greenThumbStageChange = advancedConfig.getGreenThumbStageChange();
|
||||
private int greenThumbStageMaxLevel = greenThumbStageChange * 4;
|
||||
private double greenThumbMaxBonus = advancedConfig.getGreenThumbChanceMax();
|
||||
private int greenThumbMaxLevel = advancedConfig.getGreenThumbMaxLevel();
|
||||
private double doubleDropsMaxBonus = advancedConfig.getHerbalismDoubleDropsChanceMax();
|
||||
private int doubleDropsMaxLevel = advancedConfig.getHerbalismDoubleDropsMaxLevel();
|
||||
|
||||
private boolean hasHylianLuck;
|
||||
private boolean canGreenTerra;
|
||||
private boolean canGreenThumbWheat;
|
||||
private boolean canGreenThumbBlocks;
|
||||
private boolean canFarmersDiet;
|
||||
private boolean canDoubleDrop;
|
||||
private boolean doubleDropsDisabled;
|
||||
private boolean lucky;
|
||||
private boolean endurance;
|
||||
|
||||
public HerbalismCommand() {
|
||||
super(SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
float greenThumbChanceF;
|
||||
float doubleDropChanceF;
|
||||
float hylianLuckChanceF;
|
||||
|
||||
int length = 2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel);
|
||||
greenTerraLength = String.valueOf(length);
|
||||
|
||||
if (Permissions.activationTwelve(player)) {
|
||||
length = length + 12;
|
||||
}
|
||||
else if (Permissions.activationEight(player)) {
|
||||
length = length + 8;
|
||||
}
|
||||
else if (Permissions.activationFour(player)) {
|
||||
length = length + 4;
|
||||
}
|
||||
int maxLength = SkillType.HERBALISM.getAbility().getMaxTicks();
|
||||
if (maxLength != 0 && length > maxLength) {
|
||||
length = maxLength;
|
||||
}
|
||||
greenTerraLengthEndurance = String.valueOf(length);
|
||||
//FARMERS DIET
|
||||
if (skillValue >= farmersDietMaxLevel) farmersDietRank = "5";
|
||||
else farmersDietRank = String.valueOf((int) ((double) skillValue / (double) farmersDietRankChange));
|
||||
//GREEN THUMB
|
||||
if (skillValue >= greenThumbStageMaxLevel) greenThumbStage = "4";
|
||||
else greenThumbStage = String.valueOf((int) ((double) skillValue / (double) greenThumbStageChange));
|
||||
|
||||
if (skillValue >= greenThumbMaxLevel) greenThumbChanceF = (float) (greenThumbMaxBonus);
|
||||
else greenThumbChanceF = (float) ((greenThumbMaxBonus / greenThumbMaxLevel) * skillValue);
|
||||
greenThumbChance = percent.format(greenThumbChanceF / 100D);
|
||||
if (greenThumbChanceF * 1.3333D >= 100D) greenThumbChanceLucky = percent.format(1D);
|
||||
else greenThumbChanceLucky = percent.format(greenThumbChanceF * 1.3333D / 100D);
|
||||
//DOUBLE DROPS
|
||||
if (skillValue >= doubleDropsMaxLevel) doubleDropChanceF = (float) (doubleDropsMaxBonus);
|
||||
else doubleDropChanceF = (float) ((doubleDropsMaxBonus / doubleDropsMaxLevel) * skillValue);
|
||||
doubleDropChance = percent.format(doubleDropChanceF / 100D);
|
||||
if (doubleDropChanceF * 1.3333D >= 100D) doubleDropChanceLucky = percent.format(1D);
|
||||
else doubleDropChanceLucky = percent.format(doubleDropChanceF * 1.3333D / 100D);
|
||||
//HYLIAN LUCK
|
||||
hylianLuckChanceF = (skillValue / 100);
|
||||
hylianLuckChance = percent.format(hylianLuckChanceF / 100D);
|
||||
if (hylianLuckChanceF * 1.3333D >= 100D) hylianLuckChanceLucky = percent.format(1D);
|
||||
else hylianLuckChanceLucky = percent.format(hylianLuckChanceF * 1.3333D / 100D);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
hasHylianLuck = Permissions.hylianLuck(player);
|
||||
canGreenTerra = Permissions.greenTerra(player);
|
||||
canGreenThumbWheat = Permissions.greenThumbWheat(player);
|
||||
canGreenThumbBlocks = Permissions.greenThumbBlocks(player);
|
||||
canFarmersDiet = Permissions.farmersDiet(player);
|
||||
canDoubleDrop = Permissions.herbalismDoubleDrops(player);
|
||||
doubleDropsDisabled = configInstance.herbalismDoubleDropsDisabled();
|
||||
lucky = Permissions.luckyHerbalism(player);
|
||||
endurance = Permissions.activationTwelve(player) || Permissions.activationEight(player) || Permissions.activationFour(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (lucky) {
|
||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.HERBALISM) }) }));
|
||||
}
|
||||
|
||||
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 (hasHylianLuck) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.10"), LocaleLoader.getString("Herbalism.Effect.11") }));
|
||||
}
|
||||
|
||||
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) {
|
||||
if (endurance)
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", new Object[] { greenTerraLength }) + LocaleLoader.getString("Perks.activationtime.bonus", new Object[] { greenTerraLengthEndurance }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", new Object[] { greenTerraLength }));
|
||||
}
|
||||
|
||||
if (canGreenThumbBlocks || canGreenThumbWheat) {
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", new Object[] { greenThumbChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { greenThumbChanceLucky }));
|
||||
else
|
||||
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 (hasHylianLuck) {
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", new Object[] { hylianLuckChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { hylianLuckChanceLucky }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", new Object[] { hylianLuckChance }));
|
||||
}
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", new Object[] { doubleDropChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { doubleDropChanceLucky }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", new Object[] { doubleDropChance }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,219 +0,0 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.commands.SkillCommand;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
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.Skills;
|
||||
|
||||
public class MiningCommand extends SkillCommand {
|
||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
private String doubleDropChance;
|
||||
private String doubleDropChanceLucky;
|
||||
private String superBreakerLength;
|
||||
private String superBreakerLengthEndurance;
|
||||
private String blastMiningRank;
|
||||
private String blastRadiusIncrease;
|
||||
private String blastDamageDecrease;
|
||||
|
||||
private int blastMiningRank1 = advancedConfig.getBlastMiningRank1();
|
||||
private int blastMiningRank2 = advancedConfig.getBlastMiningRank2();
|
||||
private int blastMiningRank3 = advancedConfig.getBlastMiningRank3();
|
||||
private int blastMiningRank4 = advancedConfig.getBlastMiningRank4();
|
||||
private int blastMiningRank5 = advancedConfig.getBlastMiningRank5();
|
||||
private int blastMiningRank6 = advancedConfig.getBlastMiningRank6();
|
||||
private int blastMiningRank7 = advancedConfig.getBlastMiningRank7();
|
||||
private int blastMiningRank8 = advancedConfig.getBlastMiningRank8();
|
||||
|
||||
private double doubleDropsMaxBonus = advancedConfig.getMiningDoubleDropChance();
|
||||
private int doubleDropsMaxLevel = advancedConfig.getMiningDoubleDropMaxLevel();
|
||||
public int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
|
||||
|
||||
private boolean canSuperBreaker;
|
||||
private boolean canDoubleDrop;
|
||||
private boolean canBlast;
|
||||
private boolean canBiggerBombs;
|
||||
private boolean canDemoExpert;
|
||||
private boolean doubleDropsDisabled;
|
||||
private boolean lucky;
|
||||
private boolean endurance;
|
||||
|
||||
public MiningCommand() {
|
||||
super(SkillType.MINING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
float doubleDropChanceF;
|
||||
//Super Breaker
|
||||
int length = 2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel);
|
||||
superBreakerLength = String.valueOf(length);
|
||||
|
||||
if (Permissions.activationTwelve(player)) {
|
||||
length = length + 12;
|
||||
}
|
||||
else if (Permissions.activationEight(player)) {
|
||||
length = length + 8;
|
||||
}
|
||||
else if (Permissions.activationFour(player)) {
|
||||
length = length + 4;
|
||||
}
|
||||
int maxLength = SkillType.MINING.getAbility().getMaxTicks();
|
||||
if (maxLength != 0 && length > maxLength) {
|
||||
length = maxLength;
|
||||
}
|
||||
superBreakerLengthEndurance = String.valueOf(length);
|
||||
//Double Drops
|
||||
if (skillValue >= doubleDropsMaxLevel) doubleDropChanceF = (float) (doubleDropsMaxBonus);
|
||||
else doubleDropChanceF = (float) ((doubleDropsMaxBonus / doubleDropsMaxLevel) * skillValue);
|
||||
doubleDropChance = percent.format(doubleDropChanceF / 100D);
|
||||
if (doubleDropChanceF * 1.3333D >= 100D) doubleDropChanceLucky = percent.format(1D);
|
||||
else doubleDropChanceLucky = percent.format(doubleDropChanceF * 1.3333D / 100D);
|
||||
|
||||
//Blast Mining
|
||||
if (skillValue >= blastMiningRank8) {
|
||||
blastMiningRank = "8";
|
||||
blastDamageDecrease = "100.00%";
|
||||
blastRadiusIncrease = "4";
|
||||
}
|
||||
else if (skillValue >= blastMiningRank7) {
|
||||
blastMiningRank = "7";
|
||||
blastDamageDecrease = "50.00%";
|
||||
blastRadiusIncrease = "3";
|
||||
}
|
||||
else if (skillValue >= blastMiningRank6) {
|
||||
blastMiningRank = "6";
|
||||
blastDamageDecrease = "50.00%";
|
||||
blastRadiusIncrease = "3";
|
||||
}
|
||||
else if (skillValue >= blastMiningRank5) {
|
||||
blastMiningRank = "5";
|
||||
blastDamageDecrease = "25.00%";
|
||||
blastRadiusIncrease = "2";
|
||||
}
|
||||
else if (skillValue >= blastMiningRank4) {
|
||||
blastMiningRank = "4";
|
||||
blastDamageDecrease = "25.00%";
|
||||
blastRadiusIncrease = "2";
|
||||
}
|
||||
else if (skillValue >= blastMiningRank3) {
|
||||
blastMiningRank = "3";
|
||||
blastDamageDecrease = "0.00%";
|
||||
blastRadiusIncrease = "1";
|
||||
}
|
||||
else if (skillValue >= blastMiningRank2) {
|
||||
blastMiningRank = "2";
|
||||
blastDamageDecrease = "0.00%";
|
||||
blastRadiusIncrease = "1";
|
||||
}
|
||||
else if (skillValue >= blastMiningRank1) {
|
||||
blastMiningRank = "1";
|
||||
blastDamageDecrease = "0.00%";
|
||||
blastRadiusIncrease = "0";
|
||||
}
|
||||
else {
|
||||
blastMiningRank = "0";
|
||||
blastDamageDecrease = "0.00%";
|
||||
blastRadiusIncrease = "0";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
canBiggerBombs = Permissions.biggerBombs(player);
|
||||
canBlast = Permissions.blastMining(player);
|
||||
canDemoExpert = Permissions.demolitionsExpertise(player);
|
||||
canDoubleDrop = Permissions.miningDoubleDrops(player);
|
||||
canSuperBreaker = Permissions.superBreaker(player);
|
||||
doubleDropsDisabled = configInstance.miningDoubleDropsDisabled();
|
||||
lucky = Permissions.luckyMining(player);
|
||||
endurance = Permissions.activationTwelve(player) || Permissions.activationEight(player) || Permissions.activationFour(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled) || canSuperBreaker;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (lucky) {
|
||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.MINING) }) }));
|
||||
}
|
||||
|
||||
if (canSuperBreaker) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.0"), LocaleLoader.getString("Mining.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.2"), LocaleLoader.getString("Mining.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canBlast) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.4"), LocaleLoader.getString("Mining.Effect.5") }));
|
||||
}
|
||||
|
||||
if (canBiggerBombs) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.6"), LocaleLoader.getString("Mining.Effect.7") }));
|
||||
}
|
||||
|
||||
if (canDemoExpert) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.8"), LocaleLoader.getString("Mining.Effect.9") }));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled) || canSuperBreaker;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", new Object[] { doubleDropChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { doubleDropChanceLucky }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", new Object[] { doubleDropChance }));
|
||||
}
|
||||
|
||||
if (canSuperBreaker) {
|
||||
if (endurance)
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", new Object[] { superBreakerLength }) + LocaleLoader.getString("Perks.activationtime.bonus", new Object[] { superBreakerLengthEndurance }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", new Object[] { superBreakerLength }));
|
||||
}
|
||||
|
||||
if (canBlast) {
|
||||
if (skillValue < blastMiningRank1) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.0", new Object[] { blastMiningRank1 }) }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", new Object[] { blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect." + (Misc.getInt(blastMiningRank) - 1)) }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canBiggerBombs) {
|
||||
if (skillValue < blastMiningRank2) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.1", new Object[] { blastMiningRank2 }) }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Radius.Increase", new Object[] { blastRadiusIncrease }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canDemoExpert) {
|
||||
if (skillValue < blastMiningRank4) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.2", new Object[] { blastMiningRank4 }) }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Effect.Decrease", new Object[] { blastDamageDecrease }));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.commands.SkillCommand;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class SwordsCommand extends SkillCommand {
|
||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
|
||||
private String counterAttackChance;
|
||||
private String counterAttackChanceLucky;
|
||||
private String bleedLength;
|
||||
private String bleedChance;
|
||||
private String bleedChanceLucky;
|
||||
private String serratedStrikesLength;
|
||||
private String serratedStrikesLengthEndurance;
|
||||
|
||||
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
|
||||
private float bleedChanceMax = advancedConfig.getBleedChanceMax();
|
||||
private float bleedMaxLevel = advancedConfig.getBleedMaxBonusLevel();
|
||||
private int bleedMaxTicks = advancedConfig.getBleedMaxTicks();
|
||||
private int bleedBaseTicks = advancedConfig.getBleedBaseTicks();
|
||||
private float counterChanceMax = advancedConfig.getCounterChanceMax();
|
||||
private float counterMaxLevel = advancedConfig.getCounterMaxBonusLevel();
|
||||
|
||||
private boolean canCounter;
|
||||
private boolean canSerratedStrike;
|
||||
private boolean canBleed;
|
||||
private boolean lucky;
|
||||
private boolean endurance;
|
||||
|
||||
public SwordsCommand() {
|
||||
super(SkillType.SWORDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
float bleedChanceF;
|
||||
float counterAttackChanceF;
|
||||
//Serrated Strikes
|
||||
int length = 2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel);
|
||||
serratedStrikesLength = String.valueOf(length);
|
||||
|
||||
if (Permissions.activationTwelve(player)) {
|
||||
length = length + 12;
|
||||
}
|
||||
else if (Permissions.activationEight(player)) {
|
||||
length = length + 8;
|
||||
}
|
||||
else if (Permissions.activationFour(player)) {
|
||||
length = length + 4;
|
||||
}
|
||||
int maxLength = SkillType.SWORDS.getAbility().getMaxTicks();
|
||||
if (maxLength != 0 && length > maxLength) {
|
||||
length = maxLength;
|
||||
}
|
||||
serratedStrikesLengthEndurance = String.valueOf(length);
|
||||
|
||||
//Bleed
|
||||
if (skillValue >= bleedMaxLevel) bleedLength = String.valueOf(bleedMaxTicks);
|
||||
else bleedLength = String.valueOf(bleedBaseTicks);
|
||||
|
||||
if (skillValue >= bleedMaxLevel) bleedChanceF = bleedChanceMax;
|
||||
else bleedChanceF = (float) (((double) bleedChanceMax / (double) bleedMaxLevel) * skillValue);
|
||||
bleedChance = percent.format(bleedChanceF / 100D);
|
||||
if (bleedChanceF * 1.3333D >= 100D) bleedChanceLucky = percent.format(1D);
|
||||
else bleedChanceLucky = percent.format(bleedChanceF * 1.3333D / 100D);
|
||||
|
||||
//Counter Attack
|
||||
if (skillValue >= counterMaxLevel) counterAttackChanceF = counterChanceMax;
|
||||
else counterAttackChanceF = (float) (((double) counterChanceMax / (double) counterMaxLevel) * skillValue);
|
||||
counterAttackChance = percent.format(counterAttackChanceF / 100D);
|
||||
if (counterAttackChanceF * 1.3333D >= 100D) counterAttackChanceLucky = percent.format(1D);
|
||||
else counterAttackChanceLucky = percent.format(counterAttackChanceF * 1.3333D / 100D);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canBleed = Permissions.swordsBleed(player);
|
||||
canCounter = Permissions.counterAttack(player);
|
||||
canSerratedStrike = Permissions.serratedStrikes(player);
|
||||
lucky = Permissions.luckySwords(player);
|
||||
endurance = Permissions.activationTwelve(player) || Permissions.activationEight(player) || Permissions.activationFour(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canBleed || canCounter || canSerratedStrike;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (lucky) {
|
||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.SWORDS) }) }));
|
||||
}
|
||||
|
||||
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) {
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", new Object[] { counterAttackChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { counterAttackChanceLucky }));
|
||||
else
|
||||
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"));
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", new Object[] { bleedChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { bleedChanceLucky }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", new Object[] { bleedChance }));
|
||||
}
|
||||
|
||||
if (canSerratedStrike) {
|
||||
if (endurance)
|
||||
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", new Object[] { serratedStrikesLength }) + LocaleLoader.getString("Perks.activationtime.bonus", new Object[] { serratedStrikesLengthEndurance }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", new Object[] { serratedStrikesLength }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,170 +0,0 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.commands.SkillCommand;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class TamingCommand extends SkillCommand {
|
||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
private String goreChance;
|
||||
private String goreChanceLucky;
|
||||
|
||||
private float goreChanceMax = advancedConfig.getGoreChanceMax();
|
||||
private float goreMaxLevel = advancedConfig.getGoreMaxBonusLevel();
|
||||
private int fastFoodUnlock = advancedConfig.getFastFoodUnlock();
|
||||
private float fastFoodChance = advancedConfig.getFastFoodChance();
|
||||
private int enviromentallyAwareUnlock = advancedConfig.getEnviromentallyAwareUnlock();
|
||||
private int thickFurUnlock = advancedConfig.getThickFurUnlock();
|
||||
private int shockProofUnlock = advancedConfig.getShockProofUnlock();
|
||||
private int sharpenedClawUnlock = advancedConfig.getSharpenedClawsUnlock();
|
||||
|
||||
private boolean canBeastLore;
|
||||
private boolean canGore;
|
||||
private boolean canSharpenedClaws;
|
||||
private boolean canEnvironmentallyAware;
|
||||
private boolean canThickFur;
|
||||
private boolean canShockProof;
|
||||
private boolean canCallWild;
|
||||
private boolean canFastFood;
|
||||
private boolean lucky;
|
||||
|
||||
public TamingCommand() {
|
||||
super(SkillType.TAMING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
float goreChanceF;
|
||||
if (skillValue >= goreMaxLevel) goreChanceF = (goreChanceMax);
|
||||
else goreChanceF = (float) (((double) goreChanceMax / (double) goreMaxLevel) * skillValue);
|
||||
goreChance = percent.format(goreChanceF / 100D);
|
||||
if (goreChanceF * 1.3333D >= 100D) goreChanceLucky = percent.format(1D);
|
||||
else goreChanceLucky = percent.format(goreChanceF * 1.3333D / 100D);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canBeastLore = Permissions.beastLore(player);
|
||||
canCallWild = Permissions.callOfTheWild(player);
|
||||
canEnvironmentallyAware = Permissions.environmentallyAware(player);
|
||||
canFastFood = Permissions.fastFoodService(player);
|
||||
canGore = Permissions.gore(player);
|
||||
canSharpenedClaws = Permissions.sharpenedClaws(player);
|
||||
canShockProof = Permissions.shockProof(player);
|
||||
canThickFur = Permissions.thickFur(player);
|
||||
lucky = Permissions.luckyTaming(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canBeastLore || canCallWild || canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (lucky) {
|
||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.TAMING) }) }));
|
||||
}
|
||||
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
if (canBeastLore) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canGore) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.2"), LocaleLoader.getString("Taming.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canSharpenedClaws) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.4"), LocaleLoader.getString("Taming.Effect.5") }));
|
||||
}
|
||||
|
||||
if (canEnvironmentallyAware) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.6"), LocaleLoader.getString("Taming.Effect.7") }));
|
||||
}
|
||||
|
||||
if (canThickFur) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.8"), LocaleLoader.getString("Taming.Effect.9") }));
|
||||
}
|
||||
|
||||
if (canShockProof) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.10"), LocaleLoader.getString("Taming.Effect.11") }));
|
||||
}
|
||||
|
||||
if (canFastFood) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17") }));
|
||||
}
|
||||
|
||||
if (canCallWild) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13") }));
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", new Object[] { configInstance.getTamingCOTWOcelotCost() }));
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Effect.15", new Object[] { configInstance.getTamingCOTWWolfCost() }));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canFastFood) {
|
||||
if (skillValue < fastFoodUnlock) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.4", new Object[] { fastFoodUnlock } ) }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9", new Object[] { fastFoodChance } ) }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canEnvironmentallyAware) {
|
||||
if (skillValue < enviromentallyAwareUnlock) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.0", new Object[] { enviromentallyAwareUnlock } ) }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1") }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canThickFur) {
|
||||
if (skillValue < thickFurUnlock) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.1", new Object[] { thickFurUnlock } ) }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3") }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canShockProof) {
|
||||
if (skillValue < shockProofUnlock) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.2", new Object[] { shockProofUnlock } ) }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5") }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canSharpenedClaws) {
|
||||
if (skillValue < sharpenedClawUnlock) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.3", new Object[] { sharpenedClawUnlock } ) }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7") }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canGore) {
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", new Object[] { goreChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { goreChanceLucky }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", new Object[] { goreChance }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.commands.SkillCommand;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class UnarmedCommand extends SkillCommand {
|
||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
private String berserkLength;
|
||||
private String berserkLengthEndurance;
|
||||
private String deflectChance;
|
||||
private String deflectChanceLucky;
|
||||
private String disarmChance;
|
||||
private String disarmChanceLucky;
|
||||
private String ironArmBonus;
|
||||
|
||||
private float disarmChanceMax = advancedConfig.getDisarmChanceMax();
|
||||
private float disarmMaxLevel = advancedConfig.getDisarmMaxBonusLevel();
|
||||
private float deflectChanceMax = advancedConfig.getDeflectChanceMax();
|
||||
private float deflectMaxLevel = advancedConfig.getDeflectMaxBonusLevel();
|
||||
private float ironArmMaxBonus = advancedConfig.getIronArmBonus();
|
||||
private int ironArmIncreaseLevel = advancedConfig.getIronArmIncreaseLevel();
|
||||
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
|
||||
|
||||
private boolean canBerserk;
|
||||
private boolean canDisarm;
|
||||
private boolean canBonusDamage;
|
||||
private boolean canDeflect;
|
||||
private boolean lucky;
|
||||
private boolean endurance;
|
||||
|
||||
public UnarmedCommand() {
|
||||
super(SkillType.UNARMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
float disarmChanceF;
|
||||
float deflectChanceF;
|
||||
//Berserk
|
||||
int length = 2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel);
|
||||
berserkLength = String.valueOf(length);
|
||||
|
||||
if (Permissions.activationTwelve(player)) {
|
||||
length = length + 12;
|
||||
}
|
||||
else if (Permissions.activationEight(player)) {
|
||||
length = length + 8;
|
||||
}
|
||||
else if (Permissions.activationFour(player)) {
|
||||
length = length + 4;
|
||||
}
|
||||
int maxLength = SkillType.UNARMED.getAbility().getMaxTicks();
|
||||
if (maxLength != 0 && length > maxLength) {
|
||||
length = maxLength;
|
||||
}
|
||||
berserkLengthEndurance = String.valueOf(length);
|
||||
|
||||
//Disarm
|
||||
if (skillValue >= disarmMaxLevel) disarmChanceF = disarmChanceMax;
|
||||
else disarmChanceF = (float) (((double) disarmChanceMax / (double) disarmMaxLevel) * skillValue);
|
||||
disarmChance = percent.format(disarmChanceF / 100D);
|
||||
if (disarmChanceF * 1.3333D >= 100D) disarmChanceLucky = percent.format(1D);
|
||||
else disarmChanceLucky = percent.format(disarmChanceF * 1.3333D / 100D);
|
||||
|
||||
//Deflect
|
||||
if (skillValue >= deflectMaxLevel) deflectChanceF = deflectChanceMax;
|
||||
else deflectChanceF = (float) (((double) deflectChanceMax / (double) deflectMaxLevel) * skillValue);
|
||||
deflectChance = percent.format(deflectChanceF / 100D);
|
||||
if (deflectChanceF * 1.3333D >= 100D) deflectChanceLucky = percent.format(1D);
|
||||
else deflectChanceLucky = percent.format(deflectChanceF * 1.3333D / 100D);
|
||||
|
||||
//Iron Arm
|
||||
if (skillValue >= 250) ironArmBonus = String.valueOf(ironArmMaxBonus);
|
||||
else ironArmBonus = String.valueOf(3 + ((double) skillValue / (double) ironArmIncreaseLevel));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canBerserk = Permissions.berserk(player);
|
||||
canBonusDamage = Permissions.unarmedBonus(player);
|
||||
canDeflect = Permissions.deflect(player);
|
||||
canDisarm = Permissions.disarm(player);
|
||||
lucky = Permissions.luckyUnarmed(player);
|
||||
endurance = Permissions.activationTwelve(player) || Permissions.activationEight(player) || Permissions.activationFour(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canBerserk || canBonusDamage || canDeflect || canDisarm;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (lucky) {
|
||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.UNARMED) }) }));
|
||||
}
|
||||
|
||||
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) {
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", new Object[] { deflectChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { deflectChanceLucky }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", new Object[] { deflectChance }));
|
||||
}
|
||||
|
||||
if (canDisarm) {
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", new Object[] { disarmChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { disarmChanceLucky }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", new Object[] { disarmChance }));
|
||||
}
|
||||
|
||||
if (canBerserk) {
|
||||
if (endurance)
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", new Object[] { berserkLength }) + LocaleLoader.getString("Perks.activationtime.bonus", new Object[] { berserkLengthEndurance }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", new Object[] { berserkLength }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.commands.SkillCommand;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class WoodcuttingCommand extends SkillCommand {
|
||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
private String treeFellerLength;
|
||||
private String treeFellerLengthEndurance;
|
||||
private String doubleDropChance;
|
||||
private String doubleDropChanceLucky;
|
||||
|
||||
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
|
||||
private double doubleDropsMaxBonus = advancedConfig.getWoodcuttingDoubleDropChance();
|
||||
private int doubleDropsMaxLevel = advancedConfig.getWoodcuttingDoubleDropMaxLevel();
|
||||
private int leafBlowUnlock = advancedConfig.getLeafBlowUnlockLevel();
|
||||
|
||||
private boolean canTreeFell;
|
||||
private boolean canLeafBlow;
|
||||
private boolean canDoubleDrop;
|
||||
private boolean doubleDropsDisabled;
|
||||
private boolean lucky;
|
||||
private boolean endurance;
|
||||
|
||||
public WoodcuttingCommand() {
|
||||
super(SkillType.WOODCUTTING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
float doubleDropChanceF;
|
||||
|
||||
//Tree Feller
|
||||
int length = 2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel);
|
||||
treeFellerLength = String.valueOf(length);
|
||||
|
||||
if (Permissions.activationTwelve(player)) {
|
||||
length = length + 12;
|
||||
}
|
||||
else if (Permissions.activationEight(player)) {
|
||||
length = length + 8;
|
||||
}
|
||||
else if (Permissions.activationFour(player)) {
|
||||
length = length + 4;
|
||||
}
|
||||
int maxLength = SkillType.WOODCUTTING.getAbility().getMaxTicks();
|
||||
if (maxLength != 0 && length > maxLength) {
|
||||
length = maxLength;
|
||||
}
|
||||
treeFellerLengthEndurance = String.valueOf(length);
|
||||
|
||||
//Double Drops
|
||||
if (skillValue >= doubleDropsMaxLevel) doubleDropChanceF = (float) (doubleDropsMaxBonus);
|
||||
else doubleDropChanceF = (float) ((doubleDropsMaxBonus / doubleDropsMaxLevel) * skillValue);
|
||||
doubleDropChance = percent.format(doubleDropChanceF / 100D);
|
||||
if (doubleDropChanceF * 1.3333D >= 100D) doubleDropChanceLucky = percent.format(1D);
|
||||
else doubleDropChanceLucky = percent.format(doubleDropChanceF * 1.3333D / 100D);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
canTreeFell = Permissions.treeFeller(player);
|
||||
canDoubleDrop = Permissions.woodcuttingDoubleDrops(player);
|
||||
canLeafBlow = Permissions.leafBlower(player);
|
||||
doubleDropsDisabled = configInstance.woodcuttingDoubleDropsDisabled();
|
||||
lucky = Permissions.luckyWoodcutting(player);
|
||||
endurance = Permissions.activationTwelve(player) || Permissions.activationEight(player) || Permissions.activationFour(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return (canDoubleDrop && !doubleDropsDisabled) || canLeafBlow || canTreeFell;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (lucky) {
|
||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.WOODCUTTING) }) }));
|
||||
}
|
||||
|
||||
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 < leafBlowUnlock) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Woodcutting.Ability.Locked.0", new Object[] { leafBlowUnlock }) }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1") }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
if (lucky)
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { doubleDropChanceLucky }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }));
|
||||
}
|
||||
|
||||
if (canTreeFell) {
|
||||
if (endurance)
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }) + LocaleLoader.getString("Perks.activationtime.bonus", new Object[] { treeFellerLengthEndurance }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.gmail.nossr50.commands.spout;
|
||||
|
||||
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.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.HudType;
|
||||
import com.gmail.nossr50.datatypes.SpoutHud;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class MchudCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"mchud", "<DISABLED | STANDARD | SMALL | RETRO>"});
|
||||
String invalid = LocaleLoader.getString("Commands.mchud.Invalid");
|
||||
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mcMMO.spoutEnabled || !SpoutConfig.getInstance().getXPBarEnabled()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
SpoutHud spoutHud = playerProfile.getSpoutHud();
|
||||
|
||||
if (spoutHud == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
for (HudType hudType : HudType.values()) {
|
||||
if (hudType.toString().equalsIgnoreCase(args[0])) {
|
||||
playerProfile.setHudType(hudType);
|
||||
spoutHud.initializeXpBar();
|
||||
spoutHud.updateXpBar();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMessage(invalid);
|
||||
return true;
|
||||
|
||||
default:
|
||||
player.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
package com.gmail.nossr50.commands.spout;
|
||||
|
||||
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.config.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.SpoutHud;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
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 XplockCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"xplock", "[skill]"});
|
||||
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mcMMO.spoutEnabled || !SpoutConfig.getInstance().getXPBarEnabled() || !Config.getInstance().getCommandXPLockEnabled()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
SpoutHud spoutHud = playerProfile.getSpoutHud();
|
||||
|
||||
if (spoutHud == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (spoutHud.getXpBarLocked()) {
|
||||
spoutHud.toggleXpBarLocked();
|
||||
player.sendMessage(LocaleLoader.getString("Commands.xplock.unlocked"));
|
||||
return true;
|
||||
}
|
||||
|
||||
SkillType lastGained = spoutHud.getLastGained();
|
||||
|
||||
if (lastGained != null) {
|
||||
spoutHud.toggleXpBarLocked();
|
||||
spoutHud.setSkillLock(lastGained);
|
||||
player.sendMessage(LocaleLoader.getString("Commands.xplock.locked", new Object[] { Misc.getCapitalized(lastGained.toString()) }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (Skills.isSkill(args[0])) {
|
||||
if (Permissions.hasPermission(player, "mcmmo.skills." + args[0].toLowerCase())) {
|
||||
spoutHud.setXpBarLocked(true);
|
||||
spoutHud.setSkillLock(Skills.getSkillType(args[0]));
|
||||
spoutHud.updateXpBar();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.xplock.locked", new Object[] { Misc.getCapitalized(args[0]) }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
player.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,12 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
super("advanced.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static AdvancedConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new AdvancedConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -77,6 +79,8 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
|
||||
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); }
|
||||
@@ -85,18 +89,28 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
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.Food_RankChange", 200); }
|
||||
public int getFarmerDietRankChange() { return config.getInt("Skills.Herbalism.Farmer_Diet_RankChange", 200); }
|
||||
|
||||
public int getGreenThumbStageChange() { return config.getInt("Skills.Herbalism.GreenThumb_StageChange", 200); }
|
||||
public int getGreenThumbChanceMax() { return config.getInt("Skills.Herbalism.GreenThumb_ChanceMax", 100); }
|
||||
public double getGreenThumbChanceMax() { return config.getDouble("Skills.Herbalism.GreenThumb_ChanceMax", 100.0D); }
|
||||
public int getGreenThumbMaxLevel() { return config.getInt("Skills.Herbalism.GreenThumb_MaxBonusLevel", 1500); }
|
||||
|
||||
public int getHerbalismDoubleDropsChanceMax() { return config.getInt("Skills.Herbalism.DoubleDrops_ChanceMax", 100); }
|
||||
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 int getMiningDoubleDropChance() { return config.getInt("Skills.Mining.DoubleDrops_ChanceMax", 100); }
|
||||
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); }
|
||||
@@ -109,9 +123,9 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
public int getBlastMiningRank8() { return config.getInt("Skills.Mining.BlastMining_Rank8", 1000); }
|
||||
|
||||
/* REPAIR */
|
||||
public int getRepairMasteryMaxBonus() { return config.getInt("Skills.Repair.RepairMastery_MaxBonusPercentage", 200); }
|
||||
public double getRepairMasteryMaxBonus() { return config.getDouble("Skills.Repair.RepairMastery_MaxBonusPercentage", 200.0D); }
|
||||
public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery_MaxBonusLevel", 1000); }
|
||||
public int getSuperRepairChanceMax() { return config.getInt("Skills.Repair.SuperRepair_ChanceMax", 100); }
|
||||
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 */
|
||||
@@ -130,13 +144,35 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
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 int getBleedChanceMax() { return config.getInt("Skills.Swords.Bleed_ChanceMax", 75); }
|
||||
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 int getCounterChanceMax() { return config.getInt("Skills.Swords.Counter_ChanceMax", 30); }
|
||||
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); }
|
||||
|
||||
@@ -144,13 +180,13 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
public int getSerratedStrikesTicks() { return config.getInt("Skills.Swords.SerratedStrikes_BleedTicks", 5); }
|
||||
|
||||
/* TAMING */
|
||||
public int getGoreChanceMax() { return config.getInt("Skills.Taming.Gore_ChanceMax", 100); }
|
||||
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 int getFastFoodChance() { return config.getInt("Skills.Taming.FastFood_Chance", 50); }
|
||||
public double getFastFoodChance() { return config.getInt("Skills.Taming.FastFood_Chance", 50); }
|
||||
|
||||
public int getEnviromentallyAwareUnlock() { return config.getInt("Skills.Taming.EnvironmentallyAware_UnlockLevel", 100); }
|
||||
|
||||
@@ -164,18 +200,22 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
public int getSharpenedClawsBonus() { return config.getInt("Skills.Taming.SharpenedClaws_Bonus", 2); }
|
||||
|
||||
/* UNARMED */
|
||||
public int getDisarmChanceMax() { return config.getInt("Skills.Unarmed.Disarm_ChanceMax", 33); }
|
||||
public double getDisarmChanceMax() { return config.getDouble("Skills.Unarmed.Disarm_ChanceMax", 33.0D); }
|
||||
public int getDisarmMaxBonusLevel() { return config.getInt("Skills.Unarmed.Disarm_MaxBonusLevel", 1000); }
|
||||
public int getDeflectChanceMax() { return config.getInt("Skills.Unarmed.Deflect_ChanceMax", 50); }
|
||||
|
||||
public double getDeflectChanceMax() { return config.getDouble("Skills.Unarmed.Deflect_ChanceMax", 50.0D); }
|
||||
public int getDeflectMaxBonusLevel() { return config.getInt("Skills.Unarmed.Deflect_MaxBonusLevel", 1000); }
|
||||
public int getIronGripChanceMax() { return config.getInt("Skills.Unarmed.IronGrip_ChanceMax", 100); }
|
||||
|
||||
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 getIronArmBonus() { return config.getInt("Skills.Unarmed.IronArm_BonusMax", 8); }
|
||||
|
||||
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 int getWoodcuttingDoubleDropChance() { return config.getInt("Skills.Woodcutting.DoubleDrops_ChanceMax", 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*/
|
||||
|
||||
@@ -4,13 +4,13 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class Config extends ConfigLoader {
|
||||
private static Config instance;
|
||||
public double xpGainMultiplier = 1;
|
||||
|
||||
private Config() {
|
||||
super("config.yml");
|
||||
xpGainMultiplier = getExperienceGainsGlobalMultiplier();
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@@ -32,9 +32,13 @@ 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 getBackupsEnabled() { return config.getBoolean("General.Generate_Backups", 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); }
|
||||
@@ -57,58 +61,54 @@ public class Config extends ConfigLoader {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
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 */
|
||||
public boolean getHardcoreEnabled() { return config.getBoolean("Hardcore.Enabled", false); }
|
||||
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss_Penalty_Percentage", 75); }
|
||||
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism_Stat_Leech_Percentage", 5); }
|
||||
public void setHardcoreEnabled(boolean enabled) { config.set("Hardcore.Enabled", enabled); }
|
||||
|
||||
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss_Penalty_Percentage", 75.0); }
|
||||
public void setHardcoreDeathStatPenaltyPercentage(double value) { config.set("Hardcore.Death_Stat_Loss_Penalty_Percentage", value); }
|
||||
|
||||
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism_Stat_Leech_Percentage", 5.0); }
|
||||
public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism_Stat_Leech_Percentage", value); }
|
||||
|
||||
public boolean getHardcoreVampirismEnabled() { return config.getBoolean("Hardcore.Vampirism", false); }
|
||||
public void setHardcoreVampirismEnabled(boolean enabled) { config.set("Hardcore.Vampirism", enabled); }
|
||||
|
||||
/* SMP Mods */
|
||||
public boolean getToolModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
|
||||
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 getCommandMCRankEnabled() { return config.getBoolean("Commands.mcrank.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 getCommandMCPurgeEnabled() { return config.getBoolean("Commands.mcpurge.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); }
|
||||
|
||||
public int getPTPCommandCooldown() { return config.getInt("Commands.ptp.Cooldown", 30); }
|
||||
public boolean getDonateMessageEnabled() { return config.getBoolean("Commands.mcmmo.Donate_Message", true); }
|
||||
public boolean getEntityModsEnabled() { return config.getBoolean("Mods.Entity_Mods_Enabled", false); }
|
||||
|
||||
/* Items */
|
||||
public int getChimaeraCost() { return config.getInt("Items.Chimaera_Wing.Feather_Cost", 10); }
|
||||
public int getChimaeraItemId() { return config.getInt("Items.Chimaera_Wing.Item_ID", 288); }
|
||||
public boolean getChimaeraEnabled() { return config.getBoolean("Items.Chimaera_Wing.Enabled", true); }
|
||||
|
||||
/* PARTY SETTINGS */
|
||||
public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); }
|
||||
public int getAutoPartyKickTime() { return config.getInt("Party.Old_Party_Member_Cutoff", 7); }
|
||||
public boolean getExpShareEnabled() { return config.getBoolean("Party.Sharing.ExpShare_enabled", true); }
|
||||
public double getPartyShareBonusBase() { return config.getDouble("Party.Sharing.ExpShare_bonus_base", 1.1); }
|
||||
public double getPartyShareBonusIncrease() { return config.getDouble("Party.Sharing.ExpShare_bonus_increase", 0.05); }
|
||||
public double getPartyShareBonusCap() { return config.getDouble("Party.Sharing.ExpShare_bonus_cap", 1.5); }
|
||||
public boolean getItemShareEnabled() { return config.getBoolean("Party.Sharing.ItemShare_enabled", true); }
|
||||
public double getPartyShareRange() { return config.getDouble("Party.Sharing.Range", 75.0); }
|
||||
|
||||
/* Party Teleport Settings */
|
||||
public int getPTPCommandCooldown() { return config.getInt("Commands.ptp.Cooldown", 30); }
|
||||
public int getPTPCommandTimeout() { return config.getInt("Commands.ptp.Request_Timeout", 300); }
|
||||
public boolean getPTPCommandConfirmRequired() { return config.getBoolean("Commands.ptp.Confirm_Required", true); }
|
||||
public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); }
|
||||
|
||||
/*
|
||||
* ABILITY SETTINGS
|
||||
*/
|
||||
@@ -155,7 +155,13 @@ 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); }
|
||||
@@ -247,6 +253,18 @@ public class Config extends ConfigLoader {
|
||||
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); }
|
||||
|
||||
/* Unarmed */
|
||||
public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); }
|
||||
|
||||
/* Taming */
|
||||
public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); }
|
||||
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
|
||||
@@ -258,6 +276,9 @@ public class Config extends ConfigLoader {
|
||||
public int getWoodcuttingXPBirch() { return config.getInt("Experience.Woodcutting.Birch", 90); }
|
||||
public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); }
|
||||
public int getWoodcuttingXPJungle() { return config.getInt("Experience.Woodcutting.Jungle", 100); }
|
||||
public int getWoodcuttingXPHugeBrownMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Brown", 70); }
|
||||
public int getWoodcuttingXPHugeRedMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Red", 70); }
|
||||
|
||||
|
||||
public boolean getOakDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Oak", true); }
|
||||
public boolean getBirchDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Birch", true); }
|
||||
@@ -273,7 +294,7 @@ public class Config extends ConfigLoader {
|
||||
public boolean getHerbalismAFKDisabled() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
|
||||
|
||||
/* Dogde Lightning */
|
||||
public boolean getDodgeLightningDisabled() {return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
|
||||
public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
|
||||
|
||||
/* Level Caps */
|
||||
public int getLevelCapAcrobatics() {
|
||||
@@ -308,6 +329,10 @@ public class Config extends ConfigLoader {
|
||||
return getLevelCap("Skills.Repair.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapSmelting() {
|
||||
return getLevelCap("Skills.Smelting.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapSwords() {
|
||||
return getLevelCap("Skills.Swords.Level_Cap");
|
||||
}
|
||||
@@ -350,6 +375,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); }
|
||||
@@ -361,7 +387,7 @@ public class Config extends ConfigLoader {
|
||||
public double getSlimeXP() { return config.getDouble("Experience.Combat.Multiplier.Slime", 2.0); }
|
||||
public double getZombieXP() { return config.getDouble("Experience.Combat.Multiplier.Zombie", 2.0); }
|
||||
public double getPigZombieXP() { return config.getDouble("Experience.Combat.Multiplier.Pig_Zombie", 3.0); }
|
||||
public double getEndermanXP() { return config.getDouble("Experience.Combat.Multiplier.Enderman", 2.0); }
|
||||
public double getEndermanXP() { return config.getDouble("Experience.Combat.Multiplier.Enderman", 1.0); }
|
||||
public double getCaveSpiderXP() { return config.getDouble("Experience.Combat.Multiplier.Cave_Spider", 3.0); }
|
||||
public double getSilverfishXP() { return config.getDouble("Experience.Combat.Multiplier.Silverfish", 3.0); }
|
||||
public double getBlazeXP() { return config.getDouble("Experience.Combat.Multiplier.Blaze", 3.0); }
|
||||
@@ -390,6 +416,12 @@ public class Config extends ConfigLoader {
|
||||
|
||||
private boolean doubleDropsDisabled(String skillName) {
|
||||
ConfigurationSection section = config.getConfigurationSection("Double_Drops." + skillName);
|
||||
|
||||
if (section == null) {
|
||||
mcMMO.p.getLogger().warning("The configuration files are outdated!"); //TODO Locale and more descriptive message!
|
||||
return false;
|
||||
}
|
||||
|
||||
Set<String> keys = section.getKeys(false);
|
||||
|
||||
boolean disabled = true;
|
||||
|
||||
@@ -59,7 +59,7 @@ public abstract class ConfigLoader {
|
||||
}
|
||||
}
|
||||
else {
|
||||
plugin.getLogger().severe("Missing ressource file: '" + fileName + "' please notify the plugin authors");
|
||||
plugin.getLogger().severe("Missing resource file: '" + fileName + "' please notify the plugin authors");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,10 @@ 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,6 +26,11 @@ 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<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() {
|
||||
@@ -132,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);
|
||||
@@ -143,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();
|
||||
@@ -172,18 +175,34 @@ 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");
|
||||
List<String> hylianTreasures = config.getStringList("Hylian_Luck.Treasure");
|
||||
|
||||
for (Entry<String,Treasure> nextEntry : treasures.entrySet()) {
|
||||
String treasureKey = nextEntry.getKey();
|
||||
@@ -196,6 +215,25 @@ public class TreasuresConfig extends ConfigLoader{
|
||||
|
||||
fishingRewards.add((FishingTreasure) treasure);
|
||||
}
|
||||
else if (treasure instanceof HylianTreasure) {
|
||||
if (!hylianTreasures.contains(treasureKey)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
HylianTreasure hTreasure = (HylianTreasure) treasure;
|
||||
|
||||
if (hTreasure.getDropsFromBushes()) {
|
||||
hylianFromBushes.add(hTreasure);
|
||||
}
|
||||
|
||||
if (hTreasure.getDropsFromFlowers()) {
|
||||
hylianFromFlowers.add(hTreasure);
|
||||
}
|
||||
|
||||
if (hTreasure.getDropsFromPots()) {
|
||||
hylianFromPots.add(hTreasure);
|
||||
}
|
||||
}
|
||||
else if (treasure instanceof ExcavationTreasure) {
|
||||
if (!excavationTreasures.contains(treasureKey)) {
|
||||
continue;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.util;
|
||||
package com.gmail.nossr50.database;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
@@ -15,21 +15,18 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.DatabaseUpdate;
|
||||
import com.gmail.nossr50.database.runnables.SQLReconnect;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.SpoutHud;
|
||||
import com.gmail.nossr50.runnables.SQLReconnect;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
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 class Database {
|
||||
|
||||
private static Config configInstance = Config.getInstance();
|
||||
public final class Database {
|
||||
private static String connectionString;
|
||||
|
||||
private static String tablePrefix = configInstance.getMySQLTablePrefix();
|
||||
private static String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
private static Connection connection = null;
|
||||
private static mcMMO plugin = null;
|
||||
|
||||
// Scale waiting time by this much per failed attempt
|
||||
private static final double SCALING_FACTOR = 40;
|
||||
@@ -49,16 +46,15 @@ public class Database {
|
||||
// How many connection attemtps have failed
|
||||
private static int reconnectAttempt = 0;
|
||||
|
||||
public Database(mcMMO instance) {
|
||||
plugin = instance;
|
||||
checkConnected(); //Connect to MySQL
|
||||
}
|
||||
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...");
|
||||
|
||||
@@ -74,17 +70,21 @@ public class Database {
|
||||
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!");
|
||||
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!");
|
||||
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
|
||||
mcMMO.p.getLogger().info("MySQL database driver not found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to create the database structure.
|
||||
*/
|
||||
public void createStructure() {
|
||||
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,"
|
||||
@@ -156,9 +156,9 @@ public class Database {
|
||||
/**
|
||||
* Check database structure for missing values.
|
||||
*
|
||||
* @param update Type of data to check updates for
|
||||
* @param update Type of data to check updates for
|
||||
*/
|
||||
public void checkDatabaseStructure(DatabaseUpdate update) {
|
||||
private static void checkDatabaseStructure(DatabaseUpdate update) {
|
||||
String sql = null;
|
||||
ResultSet resultSet = null;
|
||||
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
||||
@@ -173,14 +173,15 @@ public class Database {
|
||||
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;");
|
||||
break;
|
||||
|
||||
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) {
|
||||
plugin.getLogger().info("Indexing tables, this may take a while on larger databases");
|
||||
if (read("SHOW INDEX FROM " + tablePrefix + "skills").size() != 13 && checkConnected()) {
|
||||
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, "
|
||||
@@ -195,7 +196,7 @@ public class Database {
|
||||
+ "ADD INDEX `idx_fishing` (`fishing`) USING BTREE;");
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -256,7 +257,7 @@ public class Database {
|
||||
* @param sql Query to write.
|
||||
* @return true if the query was successfully written, false otherwise.
|
||||
*/
|
||||
public boolean write(String sql) {
|
||||
public static boolean write(String sql) {
|
||||
if (checkConnected()) {
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
@@ -288,7 +289,7 @@ public class Database {
|
||||
* @param sql SQL query to execute
|
||||
* @return the number of rows affected
|
||||
*/
|
||||
public int update(String sql) {
|
||||
public static int update(String sql) {
|
||||
int ret = 0;
|
||||
if (checkConnected()) {
|
||||
PreparedStatement statement = null;
|
||||
@@ -320,7 +321,7 @@ public class Database {
|
||||
* @param sql SQL query to execute
|
||||
* @return the value in the first row / first field
|
||||
*/
|
||||
public int getInt(String sql) {
|
||||
public static int getInt(String sql) {
|
||||
ResultSet resultSet;
|
||||
int result = 0;
|
||||
|
||||
@@ -416,7 +417,7 @@ public class Database {
|
||||
if (connection != null && !connection.isClosed()) {
|
||||
// Schedule a database save if we really had an outage
|
||||
if (reconnectAttempt > 1) {
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new SQLReconnect(plugin), 5);
|
||||
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new SQLReconnect(), 5);
|
||||
}
|
||||
nextReconnectTimestamp = 0;
|
||||
reconnectAttempt = 0;
|
||||
@@ -441,7 +442,7 @@ public class Database {
|
||||
* @param sql SQL query to read
|
||||
* @return the rows in this SQL query
|
||||
*/
|
||||
public HashMap<Integer, ArrayList<String>> read(String sql) {
|
||||
public static HashMap<Integer, ArrayList<String>> read(String sql) {
|
||||
ResultSet resultSet;
|
||||
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
||||
|
||||
@@ -469,50 +470,75 @@ public class Database {
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
public Map<String, Integer> readSQLRank(String playerName) {
|
||||
|
||||
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()) {
|
||||
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 + "')";
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String 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 + "')";
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
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";
|
||||
|
||||
statement = connection.prepareStatement(sql);
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
while (resultSet.next()) {
|
||||
if(resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
||||
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
||||
skills.put(skillType.name(), rank + resultSet.getRow());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
statement.close();
|
||||
}
|
||||
|
||||
|
||||
String 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");
|
||||
|
||||
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("ALL", rank + resultSet.getRow());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
}
|
||||
}
|
||||
|
||||
return skills;
|
||||
}
|
||||
|
||||
public void purgePowerlessSQL() {
|
||||
plugin.getLogger().info("Purging powerless users...");
|
||||
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)");
|
||||
|
||||
@@ -528,11 +554,11 @@ public class Database {
|
||||
purgedUsers++;
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
||||
mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
||||
}
|
||||
|
||||
public void purgeOldSQL() {
|
||||
plugin.getLogger().info("Purging old users...");
|
||||
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 + ")");
|
||||
@@ -550,13 +576,13 @@ public class Database {
|
||||
purgedUsers++;
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
||||
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());
|
||||
mcMMO.p.getLogger().severe("SQLException: " + ex.getMessage());
|
||||
mcMMO.p.getLogger().severe("SQLState: " + ex.getSQLState());
|
||||
mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode());
|
||||
}
|
||||
|
||||
public static void profileCleanup(String playerName) {
|
||||
@@ -576,7 +602,7 @@ public class Database {
|
||||
Users.addUser(player);
|
||||
|
||||
if (mcMMO.spoutEnabled) {
|
||||
SpoutStuff.reloadSpoutPlayer(player);
|
||||
SpoutTools.reloadSpoutPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
package com.gmail.nossr50.database;
|
||||
|
||||
public enum DatabaseUpdate {
|
||||
FISHING,
|
||||
BLAST_MINING,
|
||||
CASCADE_DELETE,
|
||||
CASCADE_DELETE,
|
||||
INDEX;
|
||||
}
|
||||
401
src/main/java/com/gmail/nossr50/database/Leaderboard.java
Normal file
401
src/main/java/com/gmail/nossr50/database/Leaderboard.java
Normal file
@@ -0,0 +1,401 @@
|
||||
package com.gmail.nossr50.database;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public final class Leaderboard {
|
||||
private static HashMap<SkillType, List<PlayerStat>> playerStatHash = new HashMap<SkillType, List<PlayerStat>>();
|
||||
private static List<PlayerStat> powerLevels = new ArrayList<PlayerStat>();
|
||||
private static long lastUpdate = 0;
|
||||
|
||||
private Leaderboard() {}
|
||||
|
||||
/**
|
||||
* Update the leader boards.
|
||||
*/
|
||||
public static void updateLeaderboards() {
|
||||
if(System.currentTimeMillis() < lastUpdate + 600000) {
|
||||
return; //Only update FFS leaderboards every 10 minutes.. this puts a lot of strain on the server (depending on the size of the database) and should not be done frequently
|
||||
}
|
||||
|
||||
lastUpdate = System.currentTimeMillis(); //Log when the last update was run
|
||||
|
||||
//Initialize lists
|
||||
List<PlayerStat> mining, woodcutting, herbalism, excavation, acrobatics, repair, swords, axes, archery, unarmed, taming, fishing;
|
||||
|
||||
mining = new ArrayList<PlayerStat>();
|
||||
woodcutting = new ArrayList<PlayerStat>();
|
||||
herbalism = new ArrayList<PlayerStat>();
|
||||
excavation = new ArrayList<PlayerStat>();
|
||||
acrobatics = new ArrayList<PlayerStat>();
|
||||
repair = new ArrayList<PlayerStat>();
|
||||
swords = new ArrayList<PlayerStat>();
|
||||
axes = new ArrayList<PlayerStat>();
|
||||
archery = new ArrayList<PlayerStat>();
|
||||
unarmed = new ArrayList<PlayerStat>();
|
||||
taming = new ArrayList<PlayerStat>();
|
||||
fishing = new ArrayList<PlayerStat>();
|
||||
powerLevels = new ArrayList<PlayerStat>();
|
||||
|
||||
//Read from the FlatFile database and fill our arrays with information
|
||||
try {
|
||||
FileReader file = new FileReader(mcMMO.getUsersFilePath());
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
String line = "";
|
||||
ArrayList<String> players = new ArrayList<String>();
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
String[] character = line.split(":");
|
||||
|
||||
String p = character[0];
|
||||
int powerLevel = 0;
|
||||
|
||||
//Prevent the same player from being added multiple times (I'd like to note that this shouldn't happen...)
|
||||
if (players.contains(p)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
players.add(p);
|
||||
|
||||
if (character.length > 1 && StringUtils.isInt(character[1])) {
|
||||
mining.add(new PlayerStat(p, Integer.parseInt(character[1])));
|
||||
powerLevel += Integer.parseInt(character[1]);
|
||||
}
|
||||
|
||||
if (character.length > 5 && StringUtils.isInt(character[5])) {
|
||||
woodcutting.add(new PlayerStat(p, Integer.parseInt(character[5])));
|
||||
powerLevel += Integer.parseInt(character[5]);
|
||||
}
|
||||
|
||||
if (character.length > 7 && StringUtils.isInt(character[7])) {
|
||||
repair.add(new PlayerStat(p, Integer.parseInt(character[7])));
|
||||
powerLevel += Integer.parseInt(character[7]);
|
||||
}
|
||||
|
||||
if (character.length > 8 && StringUtils.isInt(character[8])) {
|
||||
unarmed.add(new PlayerStat(p, Integer.parseInt(character[8])));
|
||||
powerLevel += Integer.parseInt(character[8]);
|
||||
}
|
||||
|
||||
if (character.length > 9 && StringUtils.isInt(character[9])) {
|
||||
herbalism.add(new PlayerStat(p, Integer.parseInt(character[9])));
|
||||
powerLevel += Integer.parseInt(character[9]);
|
||||
}
|
||||
|
||||
if (character.length > 10 && StringUtils.isInt(character[10])) {
|
||||
excavation.add(new PlayerStat(p, Integer.parseInt(character[10])));
|
||||
powerLevel += Integer.parseInt(character[10]);
|
||||
}
|
||||
|
||||
if (character.length > 11 && StringUtils.isInt(character[11])) {
|
||||
archery.add(new PlayerStat(p, Integer.parseInt(character[11])));
|
||||
powerLevel += Integer.parseInt(character[11]);
|
||||
}
|
||||
|
||||
if (character.length > 12 && StringUtils.isInt(character[12])) {
|
||||
swords.add(new PlayerStat(p, Integer.parseInt(character[12])));
|
||||
powerLevel += Integer.parseInt(character[12]);
|
||||
}
|
||||
|
||||
if (character.length > 13 && StringUtils.isInt(character[13])) {
|
||||
axes.add(new PlayerStat(p, Integer.parseInt(character[13])));
|
||||
powerLevel += Integer.parseInt(character[13]);
|
||||
}
|
||||
|
||||
if (character.length > 14 && StringUtils.isInt(character[14])) {
|
||||
acrobatics.add(new PlayerStat(p, Integer.parseInt(character[14])));
|
||||
powerLevel += Integer.parseInt(character[14]);
|
||||
}
|
||||
|
||||
if (character.length > 24 && StringUtils.isInt(character[24])) {
|
||||
taming.add(new PlayerStat(p, Integer.parseInt(character[24])));
|
||||
powerLevel += Integer.parseInt(character[24]);
|
||||
}
|
||||
|
||||
if (character.length > 34 && StringUtils.isInt(character[34])) {
|
||||
fishing.add(new PlayerStat(p, Integer.parseInt(character[34])));
|
||||
powerLevel += Integer.parseInt(character[34]);
|
||||
}
|
||||
|
||||
powerLevels.add(new PlayerStat(p, powerLevel));
|
||||
}
|
||||
in.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
mcMMO.p.getLogger().severe(("Exception while reading " + mcMMO.getUsersFilePath() + " (Are you sure you formatted it correctly?)" + e.toString()));
|
||||
}
|
||||
|
||||
SkillComparator c = new SkillComparator();
|
||||
Collections.sort(mining, c);
|
||||
Collections.sort(woodcutting, c);
|
||||
Collections.sort(repair, c);
|
||||
Collections.sort(unarmed, c);
|
||||
Collections.sort(herbalism, c);
|
||||
Collections.sort(excavation, c);
|
||||
Collections.sort(archery, c);
|
||||
Collections.sort(swords, c);
|
||||
Collections.sort(axes, c);
|
||||
Collections.sort(acrobatics, c);
|
||||
Collections.sort(taming, c);
|
||||
Collections.sort(fishing, c);
|
||||
Collections.sort(powerLevels, c);
|
||||
|
||||
playerStatHash.put(SkillType.MINING, mining);
|
||||
playerStatHash.put(SkillType.WOODCUTTING, woodcutting);
|
||||
playerStatHash.put(SkillType.REPAIR, repair);
|
||||
playerStatHash.put(SkillType.UNARMED, unarmed);
|
||||
playerStatHash.put(SkillType.HERBALISM, herbalism);
|
||||
playerStatHash.put(SkillType.EXCAVATION, excavation);
|
||||
playerStatHash.put(SkillType.ARCHERY, archery);
|
||||
playerStatHash.put(SkillType.SWORDS, swords);
|
||||
playerStatHash.put(SkillType.AXES, axes);
|
||||
playerStatHash.put(SkillType.ACROBATICS, acrobatics);
|
||||
playerStatHash.put(SkillType.TAMING, taming);
|
||||
playerStatHash.put(SkillType.FISHING, fishing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve leaderboard info.
|
||||
*
|
||||
* @param skillType Skill to retrieve info on.
|
||||
* @param pageNumber Which page in the leaderboards to retrieve
|
||||
* @return the requested leaderboard information
|
||||
*/
|
||||
public static String[] retrieveInfo(String skillType, int pageNumber) {
|
||||
String[] info = new String[10];
|
||||
List<PlayerStat> statsList;
|
||||
|
||||
if (skillType.equalsIgnoreCase("all")) {
|
||||
statsList = powerLevels;
|
||||
}
|
||||
else {
|
||||
statsList = playerStatHash.get(SkillType.getSkill(skillType));
|
||||
}
|
||||
|
||||
int destination;
|
||||
|
||||
// How many lines to skip through
|
||||
if (pageNumber == 1) {
|
||||
destination = 0;
|
||||
}
|
||||
else {
|
||||
destination = (pageNumber * 10) - 9;
|
||||
}
|
||||
|
||||
int currentPos = 0;
|
||||
|
||||
for (PlayerStat ps : statsList) {
|
||||
if (currentPos == 10) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (destination > 1) {
|
||||
destination--;
|
||||
continue;
|
||||
}
|
||||
|
||||
info[currentPos] = ps.name + ":" + ps.statVal;
|
||||
currentPos++;
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
public static int[] getPlayerRank(String playerName) {
|
||||
int currentPos = 1;
|
||||
|
||||
if (powerLevels != null) {
|
||||
for (PlayerStat stat : powerLevels) {
|
||||
if (stat.name.equalsIgnoreCase(playerName)) {
|
||||
return new int[] {currentPos, stat.statVal};
|
||||
}
|
||||
|
||||
currentPos++;
|
||||
continue;
|
||||
}
|
||||
return new int[] {0, 0};
|
||||
}
|
||||
|
||||
return new int[] {0, 0};
|
||||
}
|
||||
|
||||
public static int[] getPlayerRank(String playerName, SkillType skillType) {
|
||||
int currentPos = 1;
|
||||
List<PlayerStat> statsList = playerStatHash.get(skillType);
|
||||
|
||||
if (statsList != null) {
|
||||
for (PlayerStat stat : statsList) {
|
||||
if (stat.name.equalsIgnoreCase(playerName)) {
|
||||
return new int[] {currentPos, stat.statVal};
|
||||
}
|
||||
|
||||
currentPos++;
|
||||
continue;
|
||||
}
|
||||
return new int[] {0, 0};
|
||||
}
|
||||
|
||||
return new int[] {0, 0};
|
||||
}
|
||||
|
||||
private static class SkillComparator implements Comparator<PlayerStat> {
|
||||
@Override
|
||||
public int compare(PlayerStat o1, PlayerStat o2) {
|
||||
return (o2.statVal - o1.statVal);
|
||||
}
|
||||
}
|
||||
|
||||
public static 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 {
|
||||
mcMMO.p.getLogger().info("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;
|
||||
}
|
||||
|
||||
|
||||
public static void purgePowerlessFlatfile() {
|
||||
mcMMO.p.getLogger().info("Purging powerless users...");
|
||||
|
||||
int purgedUsers = 0;
|
||||
for (PlayerStat stat : powerLevels) {
|
||||
if (stat.statVal == 0 && removeFlatFileUser(stat.name) && !Bukkit.getOfflinePlayer(stat.name).isOnline()) {
|
||||
purgedUsers++;
|
||||
}
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
||||
}
|
||||
|
||||
public static void purgeOldFlatfile() {
|
||||
mcMMO.p.getLogger().info("Purging old users...");
|
||||
int purgedUsers = removeOldFlatfileUsers();
|
||||
mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
||||
}
|
||||
|
||||
private static int removeOldFlatfileUsers() {
|
||||
int removedPlayers = 0;
|
||||
long currentTime = System.currentTimeMillis();
|
||||
long purgeTime = 2630000000L * Config.getInstance().getOldUsersCutoff();
|
||||
|
||||
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. */
|
||||
String[] splitLine = line.split(":");
|
||||
|
||||
if (splitLine.length > 37) {
|
||||
if (currentTime - (StringUtils.getLong(line.split(":")[37]) * 1000) <= purgeTime) {
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
else {
|
||||
mcMMO.p.getLogger().info("User found, removing...");
|
||||
removedPlayers++;
|
||||
continue; //Skip the player
|
||||
}
|
||||
}
|
||||
else {
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
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 removedPlayers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
package com.gmail.nossr50.database;
|
||||
|
||||
public class PlayerStat {
|
||||
public String name;
|
||||
public int statVal = 0;
|
||||
|
||||
public PlayerStat() {};
|
||||
|
||||
public PlayerStat(String name, int value) {
|
||||
this.name = name;
|
||||
this.statVal = value;
|
||||
@@ -0,0 +1,39 @@
|
||||
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.config.Config;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.database.Leaderboard;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class McpurgeCommand implements CommandExecutor{
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
Database.purgePowerlessSQL();
|
||||
|
||||
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
||||
Database.purgeOldSQL();
|
||||
}
|
||||
}
|
||||
else {
|
||||
Leaderboard.purgePowerlessFlatfile();
|
||||
|
||||
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
||||
Leaderboard.purgeOldFlatfile();
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success"));
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
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.config.Config;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.database.Leaderboard;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class McremoveCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
/* MySQL */
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
|
||||
if (Database.update("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.user = '" + args[0] + "'") != 0) {
|
||||
Database.profileCleanup(args[0]);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0]));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (Leaderboard.removeFlatFileUser(args[0])) {
|
||||
Database.profileCleanup(args[0]);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0]));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.gmail.nossr50.database.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.config.Config;
|
||||
import com.gmail.nossr50.database.runnables.SQLConversionTask;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class MmoupdateCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Start"));
|
||||
Users.clearAll();
|
||||
convertToMySQL();
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
Users.addUser(player);
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Finish"));
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert FlatFile data to MySQL data.
|
||||
*/
|
||||
private void convertToMySQL() {
|
||||
if (!Config.getInstance().getUseMySQL()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getScheduler().runTaskLaterAsynchronously(mcMMO.p, new SQLConversionTask(), 1);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,20 @@
|
||||
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;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
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 +161,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,112 +169,112 @@ 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)
|
||||
+ ", mining = mining+" + Misc.getInt(mining)
|
||||
+ ", repair = repair+" + Misc.getInt(repair)
|
||||
+ ", woodcutting = woodcutting+" + Misc.getInt(woodcutting)
|
||||
+ ", unarmed = unarmed+" + Misc.getInt(unarmed)
|
||||
+ ", herbalism = herbalism+" + Misc.getInt(herbalism)
|
||||
+ ", excavation = excavation+" + Misc.getInt(excavation)
|
||||
+ ", archery = archery+" + Misc.getInt(archery)
|
||||
+ ", swords = swords+" + Misc.getInt(swords)
|
||||
+ ", axes = axes+" + Misc.getInt(axes)
|
||||
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
|
||||
+ ", fishing = fishing+" + Misc.getInt(fishing)
|
||||
+ " taming = taming+" + StringUtils.getInt(taming)
|
||||
+ ", mining = mining+" + StringUtils.getInt(mining)
|
||||
+ ", repair = repair+" + StringUtils.getInt(repair)
|
||||
+ ", woodcutting = woodcutting+" + StringUtils.getInt(woodcutting)
|
||||
+ ", unarmed = unarmed+" + StringUtils.getInt(unarmed)
|
||||
+ ", herbalism = herbalism+" + StringUtils.getInt(herbalism)
|
||||
+ ", excavation = excavation+" + StringUtils.getInt(excavation)
|
||||
+ ", archery = archery+" + StringUtils.getInt(archery)
|
||||
+ ", swords = swords+" + StringUtils.getInt(swords)
|
||||
+ ", axes = axes+" + StringUtils.getInt(axes)
|
||||
+ ", acrobatics = acrobatics+" + StringUtils.getInt(acrobatics)
|
||||
+ ", fishing = fishing+" + StringUtils.getInt(fishing)
|
||||
+ " WHERE user_id = " + id);
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "experience SET "
|
||||
+ " taming = " + Misc.getInt(tamingXP)
|
||||
+ ", mining = " + Misc.getInt(miningXP)
|
||||
+ ", repair = " + Misc.getInt(repairXP)
|
||||
+ ", woodcutting = " + Misc.getInt(woodCuttingXP)
|
||||
+ ", unarmed = " + Misc.getInt(unarmedXP)
|
||||
+ ", herbalism = " + Misc.getInt(herbalismXP)
|
||||
+ ", excavation = " + Misc.getInt(excavationXP)
|
||||
+ ", archery = " + Misc.getInt(archeryXP)
|
||||
+ ", swords = " + Misc.getInt(swordsXP)
|
||||
+ ", axes = " + Misc.getInt(axesXP)
|
||||
+ ", acrobatics = " + Misc.getInt(acrobaticsXP)
|
||||
+ ", fishing = " + Misc.getInt(fishingXP)
|
||||
+ " taming = " + StringUtils.getInt(tamingXP)
|
||||
+ ", mining = " + StringUtils.getInt(miningXP)
|
||||
+ ", repair = " + StringUtils.getInt(repairXP)
|
||||
+ ", woodcutting = " + StringUtils.getInt(woodCuttingXP)
|
||||
+ ", unarmed = " + StringUtils.getInt(unarmedXP)
|
||||
+ ", herbalism = " + StringUtils.getInt(herbalismXP)
|
||||
+ ", excavation = " + StringUtils.getInt(excavationXP)
|
||||
+ ", archery = " + StringUtils.getInt(archeryXP)
|
||||
+ ", swords = " + StringUtils.getInt(swordsXP)
|
||||
+ ", axes = " + StringUtils.getInt(axesXP)
|
||||
+ ", acrobatics = " + StringUtils.getInt(acrobaticsXP)
|
||||
+ ", fishing = " + StringUtils.getInt(fishingXP)
|
||||
+ " WHERE user_id = " + id);
|
||||
}
|
||||
else {
|
||||
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 "
|
||||
+ System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR + ")");
|
||||
id = Database.getInt("SELECT id FROM "
|
||||
+ tablePrefix
|
||||
+ "users WHERE user = '"
|
||||
+ playerName + "'");
|
||||
database.write("INSERT INTO "
|
||||
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)
|
||||
+ ", mining = mining+" + Misc.getInt(mining)
|
||||
+ ", repair = repair+" + Misc.getInt(repair)
|
||||
+ ", woodcutting = woodcutting+" + Misc.getInt(woodcutting)
|
||||
+ ", unarmed = unarmed+" + Misc.getInt(unarmed)
|
||||
+ ", herbalism = herbalism+" + Misc.getInt(herbalism)
|
||||
+ ", excavation = excavation+" + Misc.getInt(excavation)
|
||||
+ ", archery = archery+" + Misc.getInt(archery)
|
||||
+ ", swords = swords+" + Misc.getInt(swords)
|
||||
+ ", axes = axes+" + Misc.getInt(axes)
|
||||
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
|
||||
+ ", fishing = fishing+" + Misc.getInt(fishing)
|
||||
+ " taming = taming+" + StringUtils.getInt(taming)
|
||||
+ ", mining = mining+" + StringUtils.getInt(mining)
|
||||
+ ", repair = repair+" + StringUtils.getInt(repair)
|
||||
+ ", woodcutting = woodcutting+" + StringUtils.getInt(woodcutting)
|
||||
+ ", unarmed = unarmed+" + StringUtils.getInt(unarmed)
|
||||
+ ", herbalism = herbalism+" + StringUtils.getInt(herbalism)
|
||||
+ ", excavation = excavation+" + StringUtils.getInt(excavation)
|
||||
+ ", archery = archery+" + StringUtils.getInt(archery)
|
||||
+ ", swords = swords+" + StringUtils.getInt(swords)
|
||||
+ ", axes = axes+" + StringUtils.getInt(axes)
|
||||
+ ", acrobatics = acrobatics+" + StringUtils.getInt(acrobatics)
|
||||
+ ", fishing = fishing+" + StringUtils.getInt(fishing)
|
||||
+ " WHERE user_id = " + id);
|
||||
database.write("UPDATE "
|
||||
Database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "experience SET "
|
||||
+ " taming = " + Misc.getInt(tamingXP)
|
||||
+ ", mining = " + Misc.getInt(miningXP)
|
||||
+ ", repair = " + Misc.getInt(repairXP)
|
||||
+ ", woodcutting = " + Misc.getInt(woodCuttingXP)
|
||||
+ ", unarmed = " + Misc.getInt(unarmedXP)
|
||||
+ ", herbalism = " + Misc.getInt(herbalismXP)
|
||||
+ ", excavation = " + Misc.getInt(excavationXP)
|
||||
+ ", archery = " + Misc.getInt(archeryXP)
|
||||
+ ", swords = " + Misc.getInt(swordsXP)
|
||||
+ ", axes = " + Misc.getInt(axesXP)
|
||||
+ ", acrobatics = " + Misc.getInt(acrobaticsXP)
|
||||
+ ", fishing = " + Misc.getInt(fishingXP)
|
||||
+ " taming = " + StringUtils.getInt(tamingXP)
|
||||
+ ", mining = " + StringUtils.getInt(miningXP)
|
||||
+ ", repair = " + StringUtils.getInt(repairXP)
|
||||
+ ", woodcutting = " + StringUtils.getInt(woodCuttingXP)
|
||||
+ ", unarmed = " + StringUtils.getInt(unarmedXP)
|
||||
+ ", herbalism = " + StringUtils.getInt(herbalismXP)
|
||||
+ ", excavation = " + StringUtils.getInt(excavationXP)
|
||||
+ ", archery = " + StringUtils.getInt(archeryXP)
|
||||
+ ", swords = " + StringUtils.getInt(swordsXP)
|
||||
+ ", axes = " + StringUtils.getInt(axesXP)
|
||||
+ ", acrobatics = " + StringUtils.getInt(acrobaticsXP)
|
||||
+ ", fishing = " + StringUtils.getInt(fishingXP)
|
||||
+ " WHERE user_id = " + id);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("[mcMMO] MySQL Updated from users file, " + theCount + " items added/updated to MySQL DB");
|
||||
mcMMO.p.getLogger().info("[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,25 @@
|
||||
package com.gmail.nossr50.database.runnables;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.database.Leaderboard;
|
||||
|
||||
public class UserPurgeTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
Database.purgePowerlessSQL();
|
||||
|
||||
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
||||
Database.purgeOldSQL();
|
||||
}
|
||||
}
|
||||
else {
|
||||
Leaderboard.purgePowerlessFlatfile();
|
||||
|
||||
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
||||
Leaderboard.purgeOldFlatfile();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,27 +6,34 @@ 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.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McMMOPlayer {
|
||||
private Player player;
|
||||
private PlayerProfile profile;
|
||||
|
||||
private Party party;
|
||||
private Party invite;
|
||||
private Player ptpRequest;
|
||||
private boolean ptpEnabled = true;
|
||||
private boolean ptpConfirmRequired = Config.getInstance().getPTPCommandConfirmRequired();
|
||||
private long ptpTimeout;
|
||||
private boolean partyChatMode;
|
||||
private boolean adminChatMode;
|
||||
|
||||
public McMMOPlayer (Player player) {
|
||||
String playerName = player.getName();
|
||||
this.player = player;
|
||||
this.profile = new PlayerProfile(playerName, true);
|
||||
this.party = PartyManager.getInstance().getPlayerParty(playerName);
|
||||
this.party = PartyManager.getPlayerParty(playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,7 +45,11 @@ public class McMMOPlayer {
|
||||
int powerLevel = 0;
|
||||
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.getPermissions(player)) {
|
||||
if (type.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (player.hasPermission("mcmmo.skills." + type.toString().toLowerCase())) {
|
||||
powerLevel += profile.getSkillLevel(type);
|
||||
}
|
||||
}
|
||||
@@ -47,138 +58,106 @@ public class McMMOPlayer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the party XP modifier.
|
||||
* Begins an experience gain. The amount will be affected by skill modifiers, global rate, perks, and may be shared with the party
|
||||
*
|
||||
* @param skillType Type of skill to check
|
||||
* @return the party bonus multiplier
|
||||
* @param skillType Skill being used
|
||||
* @param xp Experience amount to process
|
||||
*/
|
||||
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) {
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.equals(SkillType.ALL)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, 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);
|
||||
|
||||
SpoutHud spoutHud = profile.getSpoutHud();
|
||||
|
||||
if (spoutHud != null) {
|
||||
spoutHud.setLastGained(skillType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public void addXPOverrideBonus(SkillType skillType, int xp) {
|
||||
int modifiedXp = (int)Math.floor(xp * Config.getInstance().xpGainMultiplier);
|
||||
addXPOverride(skillType, modifiedXp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, this is affected by skill modifiers and XP Rate and Permissions
|
||||
*
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newvalue The amount of XP to add
|
||||
*/
|
||||
public void addXP(SkillType skillType, int newValue) {
|
||||
if (player == null)
|
||||
return;
|
||||
else if (player.getGameMode() == null)
|
||||
return;
|
||||
|
||||
if (player.getGameMode().equals(GameMode.CREATIVE)) {
|
||||
public void beginXpGain(SkillType skillType, int xp) {
|
||||
// Return if the experience has been shared
|
||||
if (party != null && ShareHandler.handleXpShare(xp, this, skillType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double bonusModifier = 0;
|
||||
beginUnsharedXpGain(skillType, xp);
|
||||
}
|
||||
|
||||
if (inParty()) {
|
||||
bonusModifier = calculatePartyXPModifier(skillType);
|
||||
/**
|
||||
* Begins an experience gain. The amount will be affected by skill modifiers, global rate and perks
|
||||
*
|
||||
* @param skillType Skill being used
|
||||
* @param xp Experience amount to process
|
||||
*/
|
||||
public void beginUnsharedXpGain(SkillType skillType, int xp) {
|
||||
xp = modifyXpGain(skillType, xp);
|
||||
|
||||
if (xp == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int xp = (int)Math.floor((newValue / skillType.getXpModifier()) * Config.getInstance().xpGainMultiplier);
|
||||
applyXpGain(skillType, xp);
|
||||
}
|
||||
|
||||
if (bonusModifier > 0) {
|
||||
if (bonusModifier >= 2) {
|
||||
bonusModifier = 2;
|
||||
}
|
||||
/**
|
||||
* Applies an experience gain
|
||||
*
|
||||
* @param skillType Skill being used
|
||||
* @param xp Experience amount to add
|
||||
*/
|
||||
public void applyXpGain(SkillType skillType, int xp) {
|
||||
McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skillType, xp);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
double trueBonus = bonusModifier * xp;
|
||||
xp += trueBonus;
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getToolModsEnabled()) {
|
||||
ItemStack item = player.getItemInHand();
|
||||
CustomTool tool = ModChecks.getToolFromItemStack(item);
|
||||
|
||||
if (tool != null) {
|
||||
xp = (int) (xp * tool.getXpMultiplier());
|
||||
}
|
||||
}
|
||||
|
||||
if (Permissions.xpQuadruple(player)) {
|
||||
xp = xp * 4;
|
||||
}
|
||||
else if (Permissions.xpTriple(player)) {
|
||||
xp = xp * 3;
|
||||
}
|
||||
else if (Permissions.xpDoubleAndOneHalf(player)) {
|
||||
xp = (int) (xp * 2.5);
|
||||
}
|
||||
else if (Permissions.xpDouble(player)) {
|
||||
xp = xp * 2;
|
||||
}
|
||||
else if (Permissions.xpOneAndOneHalf(player)) {
|
||||
xp = (int) (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) + event.getXpGained());
|
||||
|
||||
SpoutHud spoutHud = profile.getSpoutHud();
|
||||
|
||||
if (spoutHud != null) {
|
||||
spoutHud.setLastGained(skillType);
|
||||
}
|
||||
|
||||
SkillTools.xpCheckSkill(skillType, player, profile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies an experience gain using skill modifiers, global rate and perks
|
||||
*
|
||||
* @param skillType Skill being used
|
||||
* @param xp Experience amount to process
|
||||
* @return Modified experience
|
||||
*/
|
||||
private int modifyXpGain(SkillType skillType, int xp) {
|
||||
if (player.getGameMode() == GameMode.CREATIVE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((skillType.getMaxLevel() < profile.getSkillLevel(skillType) + 1) || (Misc.getPowerLevelCap() < getPowerLevel() + 1)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
xp = (int) (xp / skillType.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier());
|
||||
|
||||
if (Config.getInstance().getToolModsEnabled()) {
|
||||
ItemStack item = player.getItemInHand();
|
||||
CustomTool tool = ModChecks.getToolFromItemStack(item);
|
||||
|
||||
if (tool != null) {
|
||||
xp *= tool.getXpMultiplier();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Too many permission checks here, is there no way to avoid that?
|
||||
if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
|
||||
xp *= 4;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.triple")) {
|
||||
xp *= 3;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.150percentboost")) {
|
||||
xp *= 2.5;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.150percentboost")) {
|
||||
xp *= 2;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.50percentboost")) {
|
||||
xp *= 1.5;
|
||||
}
|
||||
|
||||
return xp;
|
||||
}
|
||||
|
||||
// Players & Profiles
|
||||
@@ -197,11 +176,11 @@ public class McMMOPlayer {
|
||||
|
||||
// Party Stuff
|
||||
|
||||
public void setInvite(Party invite) {
|
||||
public void setPartyInvite(Party invite) {
|
||||
this.invite = invite;
|
||||
}
|
||||
|
||||
public Party getInvite() {
|
||||
public Party getPartyInvite() {
|
||||
return invite;
|
||||
}
|
||||
|
||||
@@ -233,7 +212,71 @@ public class McMMOPlayer {
|
||||
party = null;
|
||||
}
|
||||
|
||||
public void removeInvite() {
|
||||
public void removePartyInvite() {
|
||||
invite = null;
|
||||
}
|
||||
|
||||
public boolean getPtpEnabled() {
|
||||
return ptpEnabled;
|
||||
}
|
||||
|
||||
public void togglePtpUse() {
|
||||
ptpEnabled = !ptpEnabled;
|
||||
}
|
||||
|
||||
public Player getPtpRequest() {
|
||||
return ptpRequest;
|
||||
}
|
||||
|
||||
public void setPtpRequest(Player ptpRequest) {
|
||||
this.ptpRequest = ptpRequest;
|
||||
}
|
||||
|
||||
public boolean hasPtpRequest() {
|
||||
return (ptpRequest != null) ? true : false;
|
||||
}
|
||||
|
||||
public void removePtpRequest() {
|
||||
ptpRequest = null;
|
||||
}
|
||||
|
||||
public boolean getPtpConfirmRequired() {
|
||||
return ptpConfirmRequired;
|
||||
}
|
||||
|
||||
public void togglePtpConfirmRequired() {
|
||||
ptpConfirmRequired = !ptpConfirmRequired;
|
||||
}
|
||||
|
||||
public long getPtpTimeout() {
|
||||
return ptpTimeout;
|
||||
}
|
||||
|
||||
public void actualizePtpTimeout() {
|
||||
ptpTimeout = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
public boolean getAdminChatMode() {
|
||||
return adminChatMode;
|
||||
}
|
||||
|
||||
public void setAdminChat(boolean enabled) {
|
||||
adminChatMode = enabled;
|
||||
}
|
||||
|
||||
public void toggleAdminChat() {
|
||||
adminChatMode = !adminChatMode;
|
||||
}
|
||||
|
||||
public boolean getPartyChatMode() {
|
||||
return partyChatMode;
|
||||
}
|
||||
|
||||
public void setPartyChat(boolean enabled) {
|
||||
partyChatMode = enabled;
|
||||
}
|
||||
|
||||
public void togglePartyChat() {
|
||||
partyChatMode = !partyChatMode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,63 +9,65 @@ import java.util.HashMap;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.SpoutConfig;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.skills.utilities.AbilityType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.skills.utilities.ToolType;
|
||||
import com.gmail.nossr50.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.spout.huds.HudType;
|
||||
import com.gmail.nossr50.spout.huds.SpoutHud;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class PlayerProfile {
|
||||
|
||||
private String playerName;
|
||||
|
||||
/* HUD */
|
||||
// HUD
|
||||
private SpoutHud spoutHud;
|
||||
private HudType hudType = SpoutConfig.getInstance().defaultHudType;
|
||||
private HudType hudType;
|
||||
|
||||
/* Party Stuff */
|
||||
private Party party;
|
||||
private Party invite;
|
||||
|
||||
/* Toggles */
|
||||
// Toggles
|
||||
private boolean loaded;
|
||||
|
||||
private boolean placedAnvil;
|
||||
private boolean placedSalvageAnvil;
|
||||
private boolean partyChatMode, adminChatMode;
|
||||
private boolean godMode;
|
||||
private boolean greenTerraMode, treeFellerMode, superBreakerMode, gigaDrillBreakerMode, serratedStrikesMode, skullSplitterMode, berserkMode;
|
||||
private boolean greenTerraInformed = true, berserkInformed = true, skullSplitterInformed = true, gigaDrillBreakerInformed = true,
|
||||
superBreakerInformed = true, blastMiningInformed = true, serratedStrikesInformed = true, treeFellerInformed = true;
|
||||
superBreakerInformed = true, blastMiningInformed = true, serratedStrikesInformed = true, treeFellerInformed = true;
|
||||
private boolean hoePreparationMode, shovelPreparationMode, swordsPreparationMode, fistsPreparationMode,
|
||||
pickaxePreparationMode, axePreparationMode;
|
||||
private boolean abilityUse = true;
|
||||
|
||||
/* Timestamps */
|
||||
// Timestamps
|
||||
private long recentlyHurt;
|
||||
private int respawnATS;
|
||||
private long lastSave = 0L;
|
||||
|
||||
/* mySQL STUFF */
|
||||
// mySQL STUFF
|
||||
private int userId;
|
||||
|
||||
private HashMap<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); //Skills and Levels
|
||||
HashMap<SkillType, Integer> skillsXp = new HashMap<SkillType, Integer>(); //Skills and XP
|
||||
HashMap<SkillType, Integer> skillsXp = new HashMap<SkillType, Integer>(); //Skills and Xp
|
||||
HashMap<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>();
|
||||
HashMap<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
|
||||
|
||||
private final static String location = mcMMO.getUsersFile();
|
||||
private final static String location = mcMMO.getUsersFilePath();
|
||||
|
||||
public PlayerProfile(String playerName, boolean addNew) {
|
||||
this.playerName = playerName;
|
||||
party = PartyManager.getInstance().getPlayerParty(playerName);
|
||||
|
||||
if (mcMMO.spoutEnabled) {
|
||||
hudType = SpoutConfig.getInstance().defaultHudType;
|
||||
}
|
||||
else {
|
||||
hudType = HudType.DISABLED;
|
||||
}
|
||||
|
||||
for (AbilityType abilityType : AbilityType.values()) {
|
||||
skillsDATS.put(abilityType, 0);
|
||||
}
|
||||
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType != SkillType.ALL) {
|
||||
if (!skillType.isChildSkill()) {
|
||||
skills.put(skillType, 0);
|
||||
skillsXp.put(skillType, 0);
|
||||
}
|
||||
@@ -88,19 +90,18 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
public boolean loadMySQL() {
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
|
||||
userId = database.getInt("SELECT id FROM " + tablePrefix + "users WHERE user = '" + playerName + "'");
|
||||
userId = Database.getInt("SELECT id FROM " + tablePrefix + "users WHERE user = '" + playerName + "'");
|
||||
|
||||
if (userId == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HashMap<Integer, ArrayList<String>> huds = database.read("SELECT hudtype FROM " + tablePrefix + "huds WHERE user_id = " + userId);
|
||||
HashMap<Integer, ArrayList<String>> huds = Database.read("SELECT hudtype FROM " + tablePrefix + "huds WHERE user_id = " + userId);
|
||||
|
||||
if (huds.get(1) == null) {
|
||||
database.write("INSERT INTO " + tablePrefix + "huds (user_id) VALUES (" + userId + ")");
|
||||
Database.write("INSERT INTO " + tablePrefix + "huds (user_id) VALUES (" + userId + ")");
|
||||
}
|
||||
else {
|
||||
for (HudType type : HudType.values()) {
|
||||
@@ -114,11 +115,11 @@ public class PlayerProfile {
|
||||
* I'm still learning MySQL, this is a fix for adding a new table
|
||||
* its not pretty but it works
|
||||
*/
|
||||
HashMap<Integer, ArrayList<String>> cooldowns = database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM " + tablePrefix + "cooldowns WHERE user_id = " + userId);
|
||||
HashMap<Integer, ArrayList<String>> cooldowns = Database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM " + tablePrefix + "cooldowns WHERE user_id = " + userId);
|
||||
ArrayList<String> cooldownValues = cooldowns.get(1);
|
||||
|
||||
if (cooldownValues == null) {
|
||||
database.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")");
|
||||
Database.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")");
|
||||
mcMMO.p.getLogger().warning(playerName + "does not exist in the cooldown table. Their cooldowns will be reset.");
|
||||
}
|
||||
else {
|
||||
@@ -132,11 +133,11 @@ public class PlayerProfile {
|
||||
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(cooldownValues.get(7)));
|
||||
}
|
||||
|
||||
HashMap<Integer, ArrayList<String>> stats = database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "skills WHERE user_id = " + userId);
|
||||
HashMap<Integer, ArrayList<String>> stats = Database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "skills WHERE user_id = " + userId);
|
||||
ArrayList<String> statValues = stats.get(1);
|
||||
|
||||
if (statValues == null) {
|
||||
database.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")");
|
||||
Database.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")");
|
||||
mcMMO.p.getLogger().warning(playerName + "does not exist in the skills table. Their stats will be reset.");
|
||||
}
|
||||
else {
|
||||
@@ -154,11 +155,11 @@ public class PlayerProfile {
|
||||
skills.put(SkillType.FISHING, Integer.valueOf(statValues.get(11)));
|
||||
}
|
||||
|
||||
HashMap<Integer, ArrayList<String>> experience = database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "experience WHERE user_id = " + userId);
|
||||
HashMap<Integer, ArrayList<String>> experience = Database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "experience WHERE user_id = " + userId);
|
||||
ArrayList<String> experienceValues = experience.get(1);
|
||||
|
||||
if (experienceValues == null) {
|
||||
database.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")");
|
||||
Database.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")");
|
||||
mcMMO.p.getLogger().warning(playerName + "does not exist in the experience table. Their experience will be reset.");
|
||||
}
|
||||
else {
|
||||
@@ -181,74 +182,73 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
public void addMySQLPlayer() {
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
|
||||
database.write("INSERT INTO " + tablePrefix + "users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 + ")");
|
||||
userId = database.getInt("SELECT id FROM "+tablePrefix + "users WHERE user = '" + playerName + "'");
|
||||
database.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")");
|
||||
database.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")");
|
||||
database.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")");
|
||||
Database.write("INSERT INTO " + tablePrefix + "users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR + ")");
|
||||
userId = Database.getInt("SELECT id FROM "+tablePrefix + "users WHERE user = '" + playerName + "'");
|
||||
Database.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")");
|
||||
Database.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")");
|
||||
Database.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")");
|
||||
}
|
||||
|
||||
public boolean load() {
|
||||
try {
|
||||
//Open the user file
|
||||
// Open the user file
|
||||
FileReader file = new FileReader(location);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
String line = "";
|
||||
String line;
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
//Find if the line contains the player we want.
|
||||
// Find if the line contains the player we want.
|
||||
String[] character = line.split(":");
|
||||
|
||||
if (!character[0].equals(playerName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (character.length > 1 && Misc.isInt(character[1]))
|
||||
if (character.length > 1 && StringUtils.isInt(character[1]))
|
||||
skills.put(SkillType.MINING, Integer.valueOf(character[1]));
|
||||
if (character.length > 4 && Misc.isInt(character[4]))
|
||||
if (character.length > 4 && StringUtils.isInt(character[4]))
|
||||
skillsXp.put(SkillType.MINING, Integer.valueOf(character[4]));
|
||||
if (character.length > 5 && Misc.isInt(character[5]))
|
||||
if (character.length > 5 && StringUtils.isInt(character[5]))
|
||||
skills.put(SkillType.WOODCUTTING, Integer.valueOf(character[5]));
|
||||
if (character.length > 6 && Misc.isInt(character[6]))
|
||||
if (character.length > 6 && StringUtils.isInt(character[6]))
|
||||
skillsXp.put(SkillType.WOODCUTTING, Integer.valueOf(character[6]));
|
||||
if (character.length > 7 && Misc.isInt(character[7]))
|
||||
if (character.length > 7 && StringUtils.isInt(character[7]))
|
||||
skills.put(SkillType.REPAIR, Integer.valueOf(character[7]));
|
||||
if (character.length > 8 && Misc.isInt(character[8]))
|
||||
if (character.length > 8 && StringUtils.isInt(character[8]))
|
||||
skills.put(SkillType.UNARMED, Integer.valueOf(character[8]));
|
||||
if (character.length > 9 && Misc.isInt(character[9]))
|
||||
if (character.length > 9 && StringUtils.isInt(character[9]))
|
||||
skills.put(SkillType.HERBALISM, Integer.valueOf(character[9]));
|
||||
if (character.length > 10 && Misc.isInt(character[10]))
|
||||
if (character.length > 10 && StringUtils.isInt(character[10]))
|
||||
skills.put(SkillType.EXCAVATION, Integer.valueOf(character[10]));
|
||||
if (character.length > 11 && Misc.isInt(character[11]))
|
||||
if (character.length > 11 && StringUtils.isInt(character[11]))
|
||||
skills.put(SkillType.ARCHERY, Integer.valueOf(character[11]));
|
||||
if (character.length > 12 && Misc.isInt(character[12]))
|
||||
if (character.length > 12 && StringUtils.isInt(character[12]))
|
||||
skills.put(SkillType.SWORDS, Integer.valueOf(character[12]));
|
||||
if (character.length > 13 && Misc.isInt(character[13]))
|
||||
if (character.length > 13 && StringUtils.isInt(character[13]))
|
||||
skills.put(SkillType.AXES, Integer.valueOf(character[13]));
|
||||
if (character.length > 14 && Misc.isInt(character[14]))
|
||||
if (character.length > 14 && StringUtils.isInt(character[14]))
|
||||
skills.put(SkillType.ACROBATICS, Integer.valueOf(character[14]));
|
||||
if (character.length > 15 && Misc.isInt(character[15]))
|
||||
if (character.length > 15 && StringUtils.isInt(character[15]))
|
||||
skillsXp.put(SkillType.REPAIR, Integer.valueOf(character[15]));
|
||||
if (character.length > 16 && Misc.isInt(character[16]))
|
||||
if (character.length > 16 && StringUtils.isInt(character[16]))
|
||||
skillsXp.put(SkillType.UNARMED, Integer.valueOf(character[16]));
|
||||
if (character.length > 17 && Misc.isInt(character[17]))
|
||||
if (character.length > 17 && StringUtils.isInt(character[17]))
|
||||
skillsXp.put(SkillType.HERBALISM, Integer.valueOf(character[17]));
|
||||
if (character.length > 18 && Misc.isInt(character[18]))
|
||||
if (character.length > 18 && StringUtils.isInt(character[18]))
|
||||
skillsXp.put(SkillType.EXCAVATION, Integer.valueOf(character[18]));
|
||||
if (character.length > 19 && Misc.isInt(character[19]))
|
||||
if (character.length > 19 && StringUtils.isInt(character[19]))
|
||||
skillsXp.put(SkillType.ARCHERY, Integer.valueOf(character[19]));
|
||||
if (character.length > 20 && Misc.isInt(character[20]))
|
||||
if (character.length > 20 && StringUtils.isInt(character[20]))
|
||||
skillsXp.put(SkillType.SWORDS, Integer.valueOf(character[20]));
|
||||
if (character.length > 21 && Misc.isInt(character[21]))
|
||||
if (character.length > 21 && StringUtils.isInt(character[21]))
|
||||
skillsXp.put(SkillType.AXES, Integer.valueOf(character[21]));
|
||||
if (character.length > 22 && Misc.isInt(character[22]))
|
||||
if (character.length > 22 && StringUtils.isInt(character[22]))
|
||||
skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(character[22]));
|
||||
if (character.length > 24 && Misc.isInt(character[24]))
|
||||
if (character.length > 24 && StringUtils.isInt(character[24]))
|
||||
skills.put(SkillType.TAMING, Integer.valueOf(character[24]));
|
||||
if (character.length > 25 && Misc.isInt(character[25]))
|
||||
if (character.length > 25 && StringUtils.isInt(character[25]))
|
||||
skillsXp.put(SkillType.TAMING, Integer.valueOf(character[25]));
|
||||
if (character.length > 26)
|
||||
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(character[26]));
|
||||
@@ -292,22 +292,15 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
public void save() {
|
||||
save(true);
|
||||
}
|
||||
|
||||
public void save(boolean override) {
|
||||
Long timestamp = System.currentTimeMillis();
|
||||
if (timestamp < (lastSave + ((long) Config.getInstance().getSaveInterval() * 60000)) && !override)
|
||||
return;
|
||||
|
||||
// if we are using mysql save to database
|
||||
// If we are using mysql save to database
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
|
||||
database.write("UPDATE " + tablePrefix + "huds SET hudtype = '" + hudType.toString() + "' WHERE user_id = " + userId);
|
||||
database.write("UPDATE " + tablePrefix + "users SET lastlogin = " + ((int) (timestamp / 1000L)) + " WHERE id = " + userId);
|
||||
database.write("UPDATE " + tablePrefix + "cooldowns SET "
|
||||
Database.write("UPDATE " + tablePrefix + "huds SET hudtype = '" + hudType.toString() + "' WHERE user_id = " + userId);
|
||||
Database.write("UPDATE " + tablePrefix + "users SET lastlogin = " + ((int) (timestamp / Misc.TIME_CONVERSION_FACTOR)) + " WHERE id = " + userId);
|
||||
Database.write("UPDATE " + tablePrefix + "cooldowns SET "
|
||||
+ " mining = " + skillsDATS.get(AbilityType.SUPER_BREAKER)
|
||||
+ ", woodcutting = " + skillsDATS.get(AbilityType.TREE_FELLER)
|
||||
+ ", unarmed = " + skillsDATS.get(AbilityType.BERSERK)
|
||||
@@ -317,7 +310,7 @@ public class PlayerProfile {
|
||||
+ ", axes = " + skillsDATS.get(AbilityType.SKULL_SPLIITER)
|
||||
+ ", blast_mining = " + skillsDATS.get(AbilityType.BLAST_MINING)
|
||||
+ " WHERE user_id = " + userId);
|
||||
database.write("UPDATE " + tablePrefix + "skills SET "
|
||||
Database.write("UPDATE " + tablePrefix + "skills SET "
|
||||
+ " taming = " + skills.get(SkillType.TAMING)
|
||||
+ ", mining = " + skills.get(SkillType.MINING)
|
||||
+ ", repair = " + skills.get(SkillType.REPAIR)
|
||||
@@ -331,7 +324,7 @@ public class PlayerProfile {
|
||||
+ ", acrobatics = " + skills.get(SkillType.ACROBATICS)
|
||||
+ ", fishing = " + skills.get(SkillType.FISHING)
|
||||
+ " WHERE user_id = " + userId);
|
||||
database.write("UPDATE " + tablePrefix + "experience SET "
|
||||
Database.write("UPDATE " + tablePrefix + "experience SET "
|
||||
+ " taming = " + skillsXp.get(SkillType.TAMING)
|
||||
+ ", mining = " + skillsXp.get(SkillType.MINING)
|
||||
+ ", repair = " + skillsXp.get(SkillType.REPAIR)
|
||||
@@ -347,68 +340,69 @@ public class PlayerProfile {
|
||||
+ " WHERE user_id = " + userId);
|
||||
}
|
||||
else {
|
||||
// otherwise save to flatfile
|
||||
// Otherwise save to flatfile
|
||||
try {
|
||||
//Open the file
|
||||
// Open the file
|
||||
FileReader file = new FileReader(location);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
StringBuilder writer = new StringBuilder();
|
||||
String line = "";
|
||||
String line;
|
||||
|
||||
//While not at the end of the file
|
||||
// While not at the end of the file
|
||||
while ((line = in.readLine()) != null) {
|
||||
//Read the line in and copy it to the output it's not the player
|
||||
//we want to edit
|
||||
// Read the line in and copy it to the output it's not the player
|
||||
// we want to edit
|
||||
if (!line.split(":")[0].equals(playerName)) {
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
else {
|
||||
//Otherwise write the new player information
|
||||
writer.append(playerName + ":");
|
||||
writer.append(skills.get(SkillType.MINING) + ":");
|
||||
writer.append("" + ":");
|
||||
writer.append("" + ":");
|
||||
writer.append(skillsXp.get(SkillType.MINING) + ":");
|
||||
writer.append(skills.get(SkillType.WOODCUTTING) + ":");
|
||||
writer.append(skillsXp.get(SkillType.WOODCUTTING) + ":");
|
||||
writer.append(skills.get(SkillType.REPAIR) + ":");
|
||||
writer.append(skills.get(SkillType.UNARMED) + ":");
|
||||
writer.append(skills.get(SkillType.HERBALISM) + ":");
|
||||
writer.append(skills.get(SkillType.EXCAVATION) + ":");
|
||||
writer.append(skills.get(SkillType.ARCHERY) + ":");
|
||||
writer.append(skills.get(SkillType.SWORDS) + ":");
|
||||
writer.append(skills.get(SkillType.AXES) + ":");
|
||||
writer.append(skills.get(SkillType.ACROBATICS) + ":");
|
||||
writer.append(skillsXp.get(SkillType.REPAIR) + ":");
|
||||
writer.append(skillsXp.get(SkillType.UNARMED) + ":");
|
||||
writer.append(skillsXp.get(SkillType.HERBALISM) + ":");
|
||||
writer.append(skillsXp.get(SkillType.EXCAVATION) + ":");
|
||||
writer.append(skillsXp.get(SkillType.ARCHERY) + ":");
|
||||
writer.append(skillsXp.get(SkillType.SWORDS) + ":");
|
||||
writer.append(skillsXp.get(SkillType.AXES) + ":");
|
||||
writer.append(skillsXp.get(SkillType.ACROBATICS) + ":");
|
||||
writer.append("" + ":");
|
||||
writer.append(skills.get(SkillType.TAMING) + ":");
|
||||
writer.append(skillsXp.get(SkillType.TAMING) + ":");
|
||||
//Need to store the DATS of abilities nao
|
||||
//Berserk, Gigadrillbreaker, Tree Feller, Green Terra, Serrated Strikes, Skull Splitter, Super Breaker
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.BERSERK)) + ":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER)) + ":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.TREE_FELLER)) + ":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.GREEN_TERRA)) + ":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.SERRATED_STRIKES)) + ":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.SKULL_SPLIITER)) + ":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.SUPER_BREAKER)) + ":");
|
||||
writer.append(hudType.toString() + ":");
|
||||
writer.append(skills.get(SkillType.FISHING) + ":");
|
||||
writer.append(skillsXp.get(SkillType.FISHING) + ":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.BLAST_MINING)) + ":");
|
||||
// Otherwise write the new player information
|
||||
writer.append(playerName).append(":");
|
||||
writer.append(skills.get(SkillType.MINING)).append(":");
|
||||
writer.append(":");
|
||||
writer.append(":");
|
||||
writer.append(skillsXp.get(SkillType.MINING)).append(":");
|
||||
writer.append(skills.get(SkillType.WOODCUTTING)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.WOODCUTTING)).append(":");
|
||||
writer.append(skills.get(SkillType.REPAIR)).append(":");
|
||||
writer.append(skills.get(SkillType.UNARMED)).append(":");
|
||||
writer.append(skills.get(SkillType.HERBALISM)).append(":");
|
||||
writer.append(skills.get(SkillType.EXCAVATION)).append(":");
|
||||
writer.append(skills.get(SkillType.ARCHERY)).append(":");
|
||||
writer.append(skills.get(SkillType.SWORDS)).append(":");
|
||||
writer.append(skills.get(SkillType.AXES)).append(":");
|
||||
writer.append(skills.get(SkillType.ACROBATICS)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.REPAIR)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.UNARMED)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.HERBALISM)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.EXCAVATION)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.ARCHERY)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.SWORDS)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.AXES)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.ACROBATICS)).append(":");
|
||||
writer.append(":");
|
||||
writer.append(skills.get(SkillType.TAMING)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.TAMING)).append(":");
|
||||
// Need to store the DATS of abilities nao
|
||||
// Berserk, Gigadrillbreaker, Tree Feller, Green Terra, Serrated Strikes, Skull Splitter, Super Breaker
|
||||
writer.append(skillsDATS.get(AbilityType.BERSERK)).append(":");
|
||||
writer.append(skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER)).append(":");
|
||||
writer.append(skillsDATS.get(AbilityType.TREE_FELLER)).append(":");
|
||||
writer.append(skillsDATS.get(AbilityType.GREEN_TERRA)).append(":");
|
||||
writer.append(skillsDATS.get(AbilityType.SERRATED_STRIKES)).append(":");
|
||||
writer.append(skillsDATS.get(AbilityType.SKULL_SPLIITER)).append(":");
|
||||
writer.append(skillsDATS.get(AbilityType.SUPER_BREAKER)).append(":");
|
||||
writer.append(hudType.toString()).append(":");
|
||||
writer.append(skills.get(SkillType.FISHING)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.FISHING)).append(":");
|
||||
writer.append(skillsDATS.get(AbilityType.BLAST_MINING)).append(":");
|
||||
writer.append(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR).append(":");
|
||||
writer.append("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
in.close();
|
||||
//Write the new file
|
||||
// Write the new file
|
||||
FileWriter out = new FileWriter(location);
|
||||
out.write(writer.toString());
|
||||
out.close();
|
||||
@@ -417,55 +411,55 @@ public class PlayerProfile {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
lastSave = timestamp;
|
||||
}
|
||||
|
||||
public void addPlayer() {
|
||||
try {
|
||||
//Open the file to write the player
|
||||
// Open the file to write the player
|
||||
FileWriter file = new FileWriter(location, true);
|
||||
BufferedWriter out = new BufferedWriter(file);
|
||||
|
||||
//Add the player to the end
|
||||
out.append(playerName + ":");
|
||||
out.append(0 + ":"); //mining
|
||||
out.append("" + ":");
|
||||
out.append("" + ":");
|
||||
out.append(0 + ":"); //XP
|
||||
out.append(0 + ":"); //woodcutting
|
||||
out.append(0 + ":"); //woodCuttingXP
|
||||
out.append(0 + ":"); //repair
|
||||
out.append(0 + ":"); //unarmed
|
||||
out.append(0 + ":"); //herbalism
|
||||
out.append(0 + ":"); //excavation
|
||||
out.append(0 + ":"); //archery
|
||||
out.append(0 + ":"); //swords
|
||||
out.append(0 + ":"); //axes
|
||||
out.append(0 + ":"); //acrobatics
|
||||
out.append(0 + ":"); //repairXP
|
||||
out.append(0 + ":"); //unarmedXP
|
||||
out.append(0 + ":"); //herbalismXP
|
||||
out.append(0 + ":"); //excavationXP
|
||||
out.append(0 + ":"); //archeryXP
|
||||
out.append(0 + ":"); //swordsXP
|
||||
out.append(0 + ":"); //axesXP
|
||||
out.append(0 + ":"); //acrobaticsXP
|
||||
out.append("" + ":");
|
||||
out.append(0 + ":"); //taming
|
||||
out.append(0 + ":"); //tamingXP
|
||||
out.append(0 + ":"); //DATS
|
||||
out.append(0 + ":"); //DATS
|
||||
out.append(0 + ":"); //DATS
|
||||
out.append(0 + ":"); //DATS
|
||||
out.append(0 + ":"); //DATS
|
||||
out.append(0 + ":"); //DATS
|
||||
out.append(0 + ":"); //DATS
|
||||
out.append(SpoutConfig.getInstance().defaultHudType.toString() + ":");//HUD
|
||||
out.append(0 + ":"); //Fishing
|
||||
out.append(0 +":"); //FishingXP
|
||||
out.append(0 + ":"); //Blast Mining
|
||||
// Add the player to the end
|
||||
out.append(playerName).append(":");
|
||||
out.append("0:"); // mining
|
||||
out.append(":");
|
||||
out.append(":");
|
||||
out.append("0:"); // Xp
|
||||
out.append("0:"); // woodcutting
|
||||
out.append("0:"); // woodCuttingXp
|
||||
out.append("0:"); // repair
|
||||
out.append("0:"); // unarmed
|
||||
out.append("0:"); // herbalism
|
||||
out.append("0:"); // excavation
|
||||
out.append("0:"); // archery
|
||||
out.append("0:"); // swords
|
||||
out.append("0:"); // axes
|
||||
out.append("0:"); // acrobatics
|
||||
out.append("0:"); // repairXp
|
||||
out.append("0:"); // unarmedXp
|
||||
out.append("0:"); // herbalismXp
|
||||
out.append("0:"); // excavationXp
|
||||
out.append("0:"); // archeryXp
|
||||
out.append("0:"); // swordsXp
|
||||
out.append("0:"); // axesXp
|
||||
out.append("0:"); // acrobaticsXp
|
||||
out.append(":");
|
||||
out.append("0:"); // taming
|
||||
out.append("0:"); // tamingXp
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append(hudType.toString()).append(":"); // HUD
|
||||
out.append("0:"); // Fishing
|
||||
out.append("0:"); // FishingXp
|
||||
out.append("0:"); // Blast Mining
|
||||
out.append(String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)).append(":"); //LastLogin
|
||||
|
||||
//Add more in the same format as the line above
|
||||
// Add more in the same format as the line above
|
||||
|
||||
out.newLine();
|
||||
out.close();
|
||||
@@ -540,26 +534,6 @@ public class PlayerProfile {
|
||||
this.hudType = hudType;
|
||||
}
|
||||
|
||||
/*
|
||||
* Chat Stuff
|
||||
*/
|
||||
|
||||
public boolean getAdminChatMode() {
|
||||
return adminChatMode;
|
||||
}
|
||||
|
||||
public void toggleAdminChat() {
|
||||
adminChatMode = !adminChatMode;
|
||||
}
|
||||
|
||||
public boolean getPartyChatMode() {
|
||||
return partyChatMode;
|
||||
}
|
||||
|
||||
public void togglePartyChat() {
|
||||
partyChatMode = !partyChatMode;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tools
|
||||
*/
|
||||
@@ -658,7 +632,7 @@ public class PlayerProfile {
|
||||
* @param ATS the ATS of the tool
|
||||
*/
|
||||
public void setToolPreparationATS(ToolType tool, long ATS) {
|
||||
int startTime = (int) (ATS / 1000);
|
||||
int startTime = (int) (ATS / Misc.TIME_CONVERSION_FACTOR);
|
||||
toolATS.put(tool, startTime);
|
||||
}
|
||||
|
||||
@@ -853,7 +827,7 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
public void actualizeRecentlyHurt() {
|
||||
respawnATS = (int) (System.currentTimeMillis() / 1000);
|
||||
respawnATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -899,161 +873,55 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
public void actualizeRespawnATS() {
|
||||
respawnATS = (int) (System.currentTimeMillis() / 1000);
|
||||
respawnATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
/*
|
||||
* XP Functions
|
||||
* Xp Functions
|
||||
*/
|
||||
|
||||
public int getSkillLevel(SkillType skillType) {
|
||||
if (skillType.isChildSkill()) {
|
||||
return getChildSkillLevel(skillType);
|
||||
}
|
||||
|
||||
return skills.get(skillType);
|
||||
}
|
||||
|
||||
public int getChildSkillLevel(SkillType skillType) {
|
||||
switch (skillType) {
|
||||
case SMELTING:
|
||||
return ((getSkillLevel(SkillType.MINING) / 4) + (getSkillLevel(SkillType.REPAIR) / 4)); //TODO: Make this cleaner somehow
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int getSkillXpLevel(SkillType skillType) {
|
||||
return skillsXp.get(skillType);
|
||||
}
|
||||
|
||||
public void setSkillXPLevel(SkillType skillType, int newValue) {
|
||||
public void setSkillXpLevel(SkillType skillType, int newValue) {
|
||||
skillsXp.put(skillType, newValue);
|
||||
save(false);
|
||||
}
|
||||
|
||||
public void skillUp(SkillType skillType, int newValue) {
|
||||
skills.put(skillType, skills.get(skillType) + newValue);
|
||||
save(false);
|
||||
}
|
||||
|
||||
public void resetSkill(SkillType skillType)
|
||||
{
|
||||
//do a single skilltype
|
||||
if (skillType != SkillType.ALL)
|
||||
skills.put(skillType, 0);
|
||||
else //do them all
|
||||
{
|
||||
for (SkillType skill : SkillType.values()) //iterate over all items in the enumeration
|
||||
{
|
||||
if (skill != SkillType.ALL) // skip the "all" value
|
||||
skills.put(skill, 0);
|
||||
}
|
||||
}
|
||||
save(false);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 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 newValue) {
|
||||
// if (skillType.equals(SkillType.ALL)) {
|
||||
// for (SkillType x : SkillType.values()) {
|
||||
// if (x.equals(SkillType.ALL)) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, x, newValue));
|
||||
// skillsXp.put(x, skillsXp.get(x) + newValue);
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, newValue));
|
||||
// skillsXp.put(skillType, skillsXp.get(skillType) + newValue);
|
||||
// spoutHud.setLastGained(skillType);
|
||||
// }
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * 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
|
||||
// */
|
||||
// public void addXPOverrideBonus(SkillType skillType, int newValue) {
|
||||
// int xp = newValue * Config.getInstance().xpGainMultiplier;
|
||||
// addXPOverride(skillType, xp);
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Adds XP to the player, this is affected by skill modifiers and XP Rate and Permissions
|
||||
// *
|
||||
// * @param skillType The skill to add XP to
|
||||
// * @param newvalue The amount of XP to add
|
||||
// */
|
||||
// public void addXP(SkillType skillType, int newValue) {
|
||||
// if (player.getGameMode().equals(GameMode.CREATIVE)) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// double bonusModifier = 0;
|
||||
//
|
||||
// if (inParty()) {
|
||||
// bonusModifier = partyModifier(skillType);
|
||||
// }
|
||||
//
|
||||
// int xp = (int) (newValue / skillType.getXpModifier()) * Config.getInstance().xpGainMultiplier;
|
||||
//
|
||||
// if (bonusModifier > 0) {
|
||||
// if (bonusModifier >= 2) {
|
||||
// bonusModifier = 2;
|
||||
// }
|
||||
//
|
||||
// double trueBonus = bonusModifier * xp;
|
||||
// xp += trueBonus;
|
||||
// }
|
||||
//
|
||||
// if (Config.getInstance().getToolModsEnabled()) {
|
||||
// ItemStack item = player.getItemInHand();
|
||||
// CustomTool tool = ModChecks.getToolFromItemStack(item);
|
||||
//
|
||||
// if (tool != null) {
|
||||
// xp = (int) (xp * tool.getXpMultiplier());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //TODO: Can we make this so we do perks by doing "mcmmo.perks.xp.[multiplier]" ?
|
||||
// if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
|
||||
// xp = xp * 4;
|
||||
// }
|
||||
// else if (player.hasPermission("mcmmo.perks.xp.triple")) {
|
||||
// xp = xp * 3;
|
||||
// }
|
||||
// else if (player.hasPermission("mcmmo.perks.xp.150percentboost")) {
|
||||
// xp = (int) (xp * 2.5);
|
||||
// }
|
||||
// else if (player.hasPermission("mcmmo.perks.xp.double")) {
|
||||
// xp = xp * 2;
|
||||
// }
|
||||
// else if (player.hasPermission("mcmmo.perks.xp.50percentboost")) {
|
||||
// xp = (int) (xp * 1.5);
|
||||
// }
|
||||
//
|
||||
// mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
|
||||
// skillsXp.put(skillType, skillsXp.get(skillType) + xp);
|
||||
// spoutHud.setLastGained(skillType);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Remove XP from a skill.
|
||||
* Remove Xp from a skill.
|
||||
*
|
||||
* @param skillType Type of skill to modify
|
||||
* @param xp Amount of xp to remove
|
||||
*/
|
||||
public void removeXP(SkillType skillType, int xp) {
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
continue;
|
||||
}
|
||||
public void removeXp(SkillType skillType, int xp) {
|
||||
if (skillType.isChildSkill()) {
|
||||
return;
|
||||
}
|
||||
|
||||
skillsXp.put(skill, skillsXp.get(skill) - xp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
skillsXp.put(skillType, skillsXp.get(skillType) - xp);
|
||||
}
|
||||
save(false);
|
||||
skillsXp.put(skillType, skillsXp.get(skillType) - xp);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1063,21 +931,12 @@ public class PlayerProfile {
|
||||
* @param newValue New level value for the skill
|
||||
*/
|
||||
public void modifySkill(SkillType skillType, int newValue) {
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
continue;
|
||||
}
|
||||
if (skillType.isChildSkill()) {
|
||||
return;
|
||||
}
|
||||
|
||||
skills.put(skill, newValue);
|
||||
skillsXp.put(skill, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
skills.put(skillType, newValue);
|
||||
skillsXp.put(skillType, 0);
|
||||
}
|
||||
save(false);
|
||||
skills.put(skillType, newValue);
|
||||
skillsXp.put(skillType, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1087,120 +946,21 @@ public class PlayerProfile {
|
||||
* @param levels Number of levels to add
|
||||
*/
|
||||
public void addLevels(SkillType skillType, int levels) {
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
continue;
|
||||
}
|
||||
if (skillType.isChildSkill()) {
|
||||
return;
|
||||
}
|
||||
|
||||
skills.put(skill, skills.get(skill) + levels);
|
||||
skillsXp.put(skill, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
skills.put(skillType, skills.get(skillType) + levels);
|
||||
skillsXp.put(skillType, 0);
|
||||
}
|
||||
save(false);
|
||||
skills.put(skillType, skills.get(skillType) + levels);
|
||||
skillsXp.put(skillType, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of XP remaining before the next level.
|
||||
* Get the amount of Xp remaining before the next level.
|
||||
*
|
||||
* @param skillType Type of skill to check
|
||||
* @return the XP remaining until next level
|
||||
* @return the Xp remaining until next level
|
||||
*/
|
||||
public int getXpToLevel(SkillType skillType) {
|
||||
return 1020 + (skills.get(skillType) * Config.getInstance().getFormulaMultiplierCurve());
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Gets the power level of a player.
|
||||
// *
|
||||
// * @return the power level of the player
|
||||
// */
|
||||
// public int getPowerLevel() {
|
||||
// int powerLevel = 0;
|
||||
//
|
||||
// for (SkillType type : SkillType.values()) {
|
||||
// if (type.getPermissions(player)) {
|
||||
// powerLevel += getSkillLevel(type);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return powerLevel;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Calculate the party XP modifier.
|
||||
// *
|
||||
// * @param skillType Type of skill to check
|
||||
// * @return the party bonus multiplier
|
||||
// */
|
||||
// private double partyModifier(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 = getSkillLevel(skillType);
|
||||
//
|
||||
// if (leaderSkill >= playerSkill) {
|
||||
// int difference = leaderSkill - playerSkill;
|
||||
// bonusModifier = (difference * 0.75) / 100.0;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return bonusModifier;
|
||||
// }
|
||||
|
||||
/*
|
||||
* Party Stuff
|
||||
*/
|
||||
|
||||
public void setInvite(Party invite) {
|
||||
this.invite = invite;
|
||||
}
|
||||
|
||||
public Party getInvite() {
|
||||
return invite;
|
||||
}
|
||||
|
||||
public boolean hasPartyInvite() {
|
||||
if (invite != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setParty(Party party) {
|
||||
this.party = party;
|
||||
save(false);
|
||||
}
|
||||
|
||||
public Party getParty() {
|
||||
return party;
|
||||
}
|
||||
|
||||
public boolean inParty() {
|
||||
if (party != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removeParty() {
|
||||
party = null;
|
||||
save(false);
|
||||
}
|
||||
|
||||
public void removeInvite() {
|
||||
invite = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 abstract 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
package com.gmail.nossr50.events.experience;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
/**
|
||||
* Generic event for mcMMO experience events.
|
||||
*/
|
||||
public class McMMOPlayerExperienceEvent extends PlayerEvent {
|
||||
public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements Cancellable {
|
||||
private boolean cancelled;
|
||||
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);
|
||||
this.skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(skill);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,4 +47,15 @@ public class McMMOPlayerExperienceEvent extends PlayerEvent {
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/** Following are required for Cancellable **/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -12,7 +12,12 @@ public class McMMOPlayerLevelUpEvent extends McMMOPlayerExperienceEvent {
|
||||
|
||||
public McMMOPlayerLevelUpEvent(Player player, SkillType skill) {
|
||||
super(player, skill);
|
||||
this.levelsGained = 1; // Always 1 for now as we call in the loop where the levelups are calculated, could change later!
|
||||
this.levelsGained = 1;
|
||||
}
|
||||
|
||||
public McMMOPlayerLevelUpEvent(Player player, SkillType skill, int levelsGained) {
|
||||
super(player, skill);
|
||||
this.levelsGained = levelsGained;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -21,4 +26,11 @@ public class McMMOPlayerLevelUpEvent extends McMMOPlayerExperienceEvent {
|
||||
public int getLevelsGained() {
|
||||
return levelsGained;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param levelsGained int number of levels gained in this event
|
||||
*/
|
||||
public void setLevelsGained(int levelsGained) {
|
||||
this.levelsGained = levelsGained;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -21,4 +21,11 @@ public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent {
|
||||
public int getXpGained() {
|
||||
return xpGained;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param xpGained int amount of experience gained in this event
|
||||
*/
|
||||
public void setXpGained(int xpGained) {
|
||||
this.xpGained = xpGained;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user