mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 17:53:00 +01:00
Compare commits
502 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb1eabc3fa | ||
|
|
b30002948c | ||
|
|
42a1fdf2df | ||
|
|
ca9ce1ba1b | ||
|
|
ac1c420cb5 | ||
|
|
05a9e85529 | ||
|
|
ca6ed76e8f | ||
|
|
3d04da39e3 | ||
|
|
127908f104 | ||
|
|
686bcd5308 | ||
|
|
07c66378c0 | ||
|
|
4e7107c8a8 | ||
|
|
3c2d658b37 | ||
|
|
f0b2cc1bab | ||
|
|
d038cbf357 | ||
|
|
c3ea632cb9 | ||
|
|
a31d50924d | ||
|
|
c567e2714a | ||
|
|
a2e342b4fc | ||
|
|
4469637f27 | ||
|
|
f4ecbe7f65 | ||
|
|
dbaab4efe1 | ||
|
|
8c178869b7 | ||
|
|
3c7bcb990e | ||
|
|
f7a5678814 | ||
|
|
646bb32965 | ||
|
|
dce7d8fdd3 | ||
|
|
6dd17312f4 | ||
|
|
9c64f40ea1 | ||
|
|
da6b461408 | ||
|
|
77dce75108 | ||
|
|
37308917d1 | ||
|
|
21d2229572 | ||
|
|
7d372af51e | ||
|
|
a3e0753076 | ||
|
|
a728d1f9c8 | ||
|
|
b893e86f3c | ||
|
|
63cf6e9b3a | ||
|
|
67738d811e | ||
|
|
4d77f6d04d | ||
|
|
3702495038 | ||
|
|
ede08ce5ac | ||
|
|
5571e0bc0c | ||
|
|
73bb73c8ca | ||
|
|
54011fdeb7 | ||
|
|
5b8811bd09 | ||
|
|
c460eec0ab | ||
|
|
bc6233541a | ||
|
|
18aef9d526 | ||
|
|
ccc6fd30f8 | ||
|
|
1ba498c443 | ||
|
|
64f31f2b5a | ||
|
|
b94085c5f4 | ||
|
|
62b90ad552 | ||
|
|
d6d1e0ffed | ||
|
|
ccd103cd88 | ||
|
|
0606f16a11 | ||
|
|
c9e3ea005b | ||
|
|
f009f5803f | ||
|
|
3f8268d848 | ||
|
|
cefec723d0 | ||
|
|
124aa72fd9 | ||
|
|
dbc7277ba9 | ||
|
|
24d8769b5b | ||
|
|
4aecb9756e | ||
|
|
51ca29ab9f | ||
|
|
c6e5264b7b | ||
|
|
73203ce869 | ||
|
|
b80a29ca04 | ||
|
|
5ee440d9a5 | ||
|
|
cda3675dc5 | ||
|
|
caf9c07ba3 | ||
|
|
96e70aa4d2 | ||
|
|
9f1b77a007 | ||
|
|
946b5bb006 | ||
|
|
bebcc40987 | ||
|
|
d6d7f5099f | ||
|
|
bdcc2f644b | ||
|
|
c3ba54a0ce | ||
|
|
1443e2f6b8 | ||
|
|
7799acec05 | ||
|
|
1bbc1f28aa | ||
|
|
8257fd8e7c | ||
|
|
bc58aff362 | ||
|
|
1073954550 | ||
|
|
c3d7a4e3de | ||
|
|
92ae92c116 | ||
|
|
3c10be6d1a | ||
|
|
f18a9bdcc7 | ||
|
|
87f59cd3eb | ||
|
|
819b6fcacb | ||
|
|
246961887e | ||
|
|
54e21333a3 | ||
|
|
c45beec59d | ||
|
|
c88ada489a | ||
|
|
189f23f407 | ||
|
|
9789143c6d | ||
|
|
f4dd7ff483 | ||
|
|
50e05c6320 | ||
|
|
9ba5360bfc | ||
|
|
565ef693ce | ||
|
|
0c1a8eff85 | ||
|
|
32e9de6e9a | ||
|
|
533955a9c7 | ||
|
|
2faa0356a5 | ||
|
|
ee2a5c199a | ||
|
|
bdcc522897 | ||
|
|
71b20bdeaa | ||
|
|
0e85b4776a | ||
|
|
24d2c1bc7a | ||
|
|
1610e932c6 | ||
|
|
31d7bb2332 | ||
|
|
3d9c03c0c8 | ||
|
|
dd94343d92 | ||
|
|
4b93dede33 | ||
|
|
61205989cc | ||
|
|
2559ea61d8 | ||
|
|
eae665c1c5 | ||
|
|
d73521e0a0 | ||
|
|
e8deb0384a | ||
|
|
881f2c023e | ||
|
|
5057a8a7a3 | ||
|
|
b8e9269488 | ||
|
|
76afd5a7ca | ||
|
|
dc48d467f5 | ||
|
|
0b0390620e | ||
|
|
24eb34c182 | ||
|
|
1a5bd1b6a2 | ||
|
|
ab7b6ce460 | ||
|
|
c4cd677021 | ||
|
|
6b84d39dda | ||
|
|
e61342177d | ||
|
|
d51fa92b46 | ||
|
|
3e20dc7de6 | ||
|
|
dce1d7ba39 | ||
|
|
adffea1d52 | ||
|
|
20b73dcc84 | ||
|
|
b331fa353b | ||
|
|
9fe14609af | ||
|
|
f6973b8907 | ||
|
|
8738036f6f | ||
|
|
fce02dc0e5 | ||
|
|
2bef0e833f | ||
|
|
9040a2a2e3 | ||
|
|
4407ed0a6f | ||
|
|
09721518b0 | ||
|
|
8ad6337dde | ||
|
|
271740d2ac | ||
|
|
48dd537257 | ||
|
|
77b4aaa50d | ||
|
|
1014316581 | ||
|
|
739cd83155 | ||
|
|
df08bc4da0 | ||
|
|
55e832d4f6 | ||
|
|
032472dcb3 | ||
|
|
68bf93d1ac | ||
|
|
ba133f94fc | ||
|
|
064c16f4d7 | ||
|
|
5a394ee744 | ||
|
|
3bc2f5dc55 | ||
|
|
6f63818e5f | ||
|
|
a5d7bee939 | ||
|
|
9d396162f1 | ||
|
|
4a0d9a96ab | ||
|
|
9f65e5a9ab | ||
|
|
c71f4e438b | ||
|
|
14d13eb4c7 | ||
|
|
29c629eb22 | ||
|
|
050b794b42 | ||
|
|
89b5f8c275 | ||
|
|
f589197321 | ||
|
|
09575a68f0 | ||
|
|
c1b838e356 | ||
|
|
8ed2696315 | ||
|
|
ab138bdba2 | ||
|
|
5ba9fb78fd | ||
|
|
2d47447375 | ||
|
|
d9eaede4c2 | ||
|
|
c6db11a10b | ||
|
|
2225e542ad | ||
|
|
975e13d45f | ||
|
|
534a165c45 | ||
|
|
5cff6ed67b | ||
|
|
3448733834 | ||
|
|
c382c95d24 | ||
|
|
0034226fa7 | ||
|
|
5f067a6bb5 | ||
|
|
6ab1996440 | ||
|
|
5bff6d63f2 | ||
|
|
5fe227b874 | ||
|
|
cbaf2f8370 | ||
|
|
393ac886e2 | ||
|
|
c9082083d1 | ||
|
|
5d0d89e74d | ||
|
|
e9c3583fd8 | ||
|
|
81eadc1418 | ||
|
|
dfff0efc0b | ||
|
|
3732db2226 | ||
|
|
e9ccdcfbbe | ||
|
|
01345a5dc4 | ||
|
|
90c8e57ed7 | ||
|
|
d644b4c331 | ||
|
|
2f15c71412 | ||
|
|
0a44a74f59 | ||
|
|
f876fe8d25 | ||
|
|
290032646f | ||
|
|
e5d2ed4bb2 | ||
|
|
e9ea0e0389 | ||
|
|
35565bb021 | ||
|
|
56aff1d191 | ||
|
|
b8be1d1866 | ||
|
|
1d7d2cd52e | ||
|
|
71446a12af | ||
|
|
ca6cafaebd | ||
|
|
c97be335ee | ||
|
|
fd1227b87e | ||
|
|
7ef72c501e | ||
|
|
f7ee96aa99 | ||
|
|
b84478898d | ||
|
|
6afe0e8a34 | ||
|
|
6e4f4b5c8d | ||
|
|
f86fe4a138 | ||
|
|
63c663b8c1 | ||
|
|
a1296596fa | ||
|
|
1cca4de9e5 | ||
|
|
7ada587df3 | ||
|
|
1e58c32a5f | ||
|
|
2a27048174 | ||
|
|
2b291954cf | ||
|
|
8f8bfc62ca | ||
|
|
38d4d448a9 | ||
|
|
d5d11ca4bd | ||
|
|
e3e400f376 | ||
|
|
6637758ad0 | ||
|
|
41e9bd3cb5 | ||
|
|
c2d1909379 | ||
|
|
77688f297f | ||
|
|
714f665cc7 | ||
|
|
ec138d5741 | ||
|
|
560e5aa19a | ||
|
|
ad162f3366 | ||
|
|
5d07830339 | ||
|
|
b310d25ee3 | ||
|
|
443ccbd807 | ||
|
|
8cdecf80c7 | ||
|
|
a16d5435de | ||
|
|
ec02422226 | ||
|
|
cc5d438550 | ||
|
|
806d116501 | ||
|
|
066c9d9fec | ||
|
|
5b3b9fbc30 | ||
|
|
d15e189b7c | ||
|
|
1bd9974f89 | ||
|
|
90296d87df | ||
|
|
75b287771a | ||
|
|
5765504796 | ||
|
|
dda8c0c9e0 | ||
|
|
ce9d668602 | ||
|
|
39c2c5f25f | ||
|
|
12a7d794b4 | ||
|
|
ff8b0300ae | ||
|
|
f882df4cb7 | ||
|
|
e1300005cb | ||
|
|
e599ab9214 | ||
|
|
92acf62884 | ||
|
|
c2fb57fce9 | ||
|
|
3699d26e5d | ||
|
|
6eb0159ea1 | ||
|
|
433913c77a | ||
|
|
d955feef61 | ||
|
|
5377b9b618 | ||
|
|
5c9371c575 | ||
|
|
23d916f191 | ||
|
|
35d4914518 | ||
|
|
eb2ec71d2b | ||
|
|
dc50758dc9 | ||
|
|
9775d71c28 | ||
|
|
c40e4ee9ee | ||
|
|
2b469c385c | ||
|
|
a104fe45aa | ||
|
|
257df25a67 | ||
|
|
2a977557c2 | ||
|
|
d0e9f03311 | ||
|
|
97ca699170 | ||
|
|
702537e8fd | ||
|
|
83a3488d0d | ||
|
|
450e938092 | ||
|
|
b88e076f27 | ||
|
|
0fe90df01e | ||
|
|
66ad909908 | ||
|
|
77d74717d2 | ||
|
|
63f683982f | ||
|
|
9525ce8299 | ||
|
|
d7b8ec1274 | ||
|
|
96cd16faf7 | ||
|
|
9ddc7501fe | ||
|
|
301c496fb2 | ||
|
|
3eb265c5f7 | ||
|
|
049338e83b | ||
|
|
a336e9f460 | ||
|
|
0294cf8c4a | ||
|
|
c5183309ae | ||
|
|
0a15cb1e13 | ||
|
|
9546cc42b2 | ||
|
|
ac01262655 | ||
|
|
6ea962c1fa | ||
|
|
9e35283273 | ||
|
|
9c8e1d9c9f | ||
|
|
7d324b3fd4 | ||
|
|
badc5738ff | ||
|
|
8feaf4410f | ||
|
|
4e224d761e | ||
|
|
e775abdc5a | ||
|
|
60754c9380 | ||
|
|
c890ff5605 | ||
|
|
9f9c0059a5 | ||
|
|
4eabd417b9 | ||
|
|
c218de9567 | ||
|
|
4b5ca5ecf4 | ||
|
|
edbf46a751 | ||
|
|
c9c90bb86a | ||
|
|
437a608d2b | ||
|
|
b638eef1c6 | ||
|
|
b7cec8a0c4 | ||
|
|
28578bd6b0 | ||
|
|
160004fa7e | ||
|
|
f4332761f9 | ||
|
|
a4d1a18850 | ||
|
|
c3e1e55e9c | ||
|
|
e20bcd19b9 | ||
|
|
1fbf213ada | ||
|
|
c2d2359a8c | ||
|
|
586a2a065e | ||
|
|
adf43b7e35 | ||
|
|
45a4cddeef | ||
|
|
69f62551c7 | ||
|
|
f1bdf502be | ||
|
|
e89b3795f8 | ||
|
|
20b169e8eb | ||
|
|
1480ee2779 | ||
|
|
41c9741b72 | ||
|
|
f9e5096ceb | ||
|
|
a9b2a4940e | ||
|
|
f66c6ab8fc | ||
|
|
73902d5f92 | ||
|
|
0bb5f9f297 | ||
|
|
16ad8502d2 | ||
|
|
ad68e6057e | ||
|
|
54b4faeeff | ||
|
|
a7f69545f2 | ||
|
|
93ea558ec3 | ||
|
|
d0cdc208e3 | ||
|
|
0d7c483bd5 | ||
|
|
3f211c6277 | ||
|
|
79e93edfef | ||
|
|
44e8efda36 | ||
|
|
9726ac6f12 | ||
|
|
898d8c6449 | ||
|
|
01006ed76d | ||
|
|
2936823d03 | ||
|
|
7d05d53f9e | ||
|
|
f3074461ed | ||
|
|
146f832919 | ||
|
|
a622707608 | ||
|
|
6da43b15c8 | ||
|
|
d0bb7b075e | ||
|
|
c1ecd74644 | ||
|
|
a1aada0777 | ||
|
|
c55a8eeccd | ||
|
|
73cc8adcab | ||
|
|
7bb05f7f26 | ||
|
|
7f0803c3f6 | ||
|
|
1185ea4f96 | ||
|
|
43db51a664 | ||
|
|
d35cdc91f8 | ||
|
|
8d643277c0 | ||
|
|
5be1858b45 | ||
|
|
13d6e16630 | ||
|
|
dcb1cbbdb7 | ||
|
|
f7f077be3e | ||
|
|
3d79416520 | ||
|
|
c559e70270 | ||
|
|
efcc15d89d | ||
|
|
d17fe6bb7a | ||
|
|
01235ff398 | ||
|
|
3d6e490505 | ||
|
|
bd3491d210 | ||
|
|
d139146e0b | ||
|
|
b36da06fad | ||
|
|
d20c5e1773 | ||
|
|
0afc0d59a4 | ||
|
|
26481c547a | ||
|
|
45fe8c182b | ||
|
|
c25ddd0dbc | ||
|
|
efc9a10fdf | ||
|
|
a8eb9dfedf | ||
|
|
87cf5cb932 | ||
|
|
e1ca2c0b98 | ||
|
|
a9295751c8 | ||
|
|
2a46a5c00a | ||
|
|
d3b7af3c5f | ||
|
|
db59f24873 | ||
|
|
5645bf7982 | ||
|
|
6cbf87b52c | ||
|
|
bc642deebd | ||
|
|
e84a9643f8 | ||
|
|
e9af0ebdc5 | ||
|
|
29ee8a035b | ||
|
|
81ac4e8d01 | ||
|
|
ecc68d373f | ||
|
|
3032572f18 | ||
|
|
bcee6abb65 | ||
|
|
7e0b8ddf50 | ||
|
|
91dcb508b3 | ||
|
|
d549e2722d | ||
|
|
3bb29c8308 | ||
|
|
0121228d88 | ||
|
|
cbafa7110a | ||
|
|
06791beabd | ||
|
|
68b9857409 | ||
|
|
112a0df8c2 | ||
|
|
73717278ff | ||
|
|
5fa79926db | ||
|
|
06f97ac2f1 | ||
|
|
c2b4961b8d | ||
|
|
9b3838b912 | ||
|
|
946ea19371 | ||
|
|
419e011d0b | ||
|
|
b0157c9bd2 | ||
|
|
37d146e8fa | ||
|
|
063d982750 | ||
|
|
fbfeaa0f95 | ||
|
|
9b11b02658 | ||
|
|
3e435c419a | ||
|
|
1b37ba8daa | ||
|
|
b529219a0e | ||
|
|
d9b3eff18f | ||
|
|
cb5ada6ec9 | ||
|
|
baf7ffd441 | ||
|
|
2b4ca80a95 | ||
|
|
b5963936fd | ||
|
|
354ed9ede0 | ||
|
|
7ad9b8ff3e | ||
|
|
6dc522a044 | ||
|
|
3e91bc8c1e | ||
|
|
3218c544dc | ||
|
|
1ae11da036 | ||
|
|
84e36d758e | ||
|
|
06ede80435 | ||
|
|
dbc57060ee | ||
|
|
798bd46d0a | ||
|
|
c95f388d8d | ||
|
|
a9024ebc6b | ||
|
|
33bc2d8a6b | ||
|
|
cc60f2f308 | ||
|
|
edaa51593b | ||
|
|
e2265dd6f7 | ||
|
|
e1cf89c3bf | ||
|
|
8cd1541893 | ||
|
|
9d510815b4 | ||
|
|
44d22d93da | ||
|
|
f7405a82e6 | ||
|
|
04f3e44c3a | ||
|
|
6cc207a10c | ||
|
|
6b5e615a23 | ||
|
|
46268a7cf3 | ||
|
|
3682fbf531 | ||
|
|
0928b54d90 | ||
|
|
5a10339adc | ||
|
|
7c412cbec8 | ||
|
|
d235ca8ed8 | ||
|
|
97511be64a | ||
|
|
3bd5aaa251 | ||
|
|
ae2d9d8387 | ||
|
|
33c9694d26 | ||
|
|
dbede7f81a | ||
|
|
c8ad2bb454 | ||
|
|
18c52a5e23 | ||
|
|
ca1954ff80 | ||
|
|
5a3574734c | ||
|
|
5c6d10b2db | ||
|
|
7e96ced4c4 | ||
|
|
8da259cabc | ||
|
|
f978d739bb | ||
|
|
7b2d50e93e | ||
|
|
8bec50663f | ||
|
|
f4f5063efe | ||
|
|
11782ac34d | ||
|
|
bfec3fff36 | ||
|
|
d8c0a56577 | ||
|
|
ff1326a44f | ||
|
|
1fa4fccbcc | ||
|
|
323b41fd58 | ||
|
|
3d2b881b0e | ||
|
|
def41af469 | ||
|
|
4750aba763 | ||
|
|
5a9249dee1 | ||
|
|
064fc0a8e2 | ||
|
|
67de70432c | ||
|
|
facd71bd71 | ||
|
|
96e6270520 | ||
|
|
51c45e86ce |
131
Changelog.txt
131
Changelog.txt
@@ -6,6 +6,135 @@ Key:
|
||||
= Fix
|
||||
! Change
|
||||
- Removal
|
||||
|
||||
Version 1.3.10
|
||||
+ Added 1.3.1 compatibility
|
||||
+ Added permission node for Iron Grip ability (mcmmo.ability.unarmed.irongrip)
|
||||
+ Added ability for custom blocks to drop a range of items.
|
||||
+ Added Ability API functions
|
||||
+ Added 50% & 150% XP boost perks
|
||||
+ Added "lucky" perk for donors
|
||||
= Fixed /inspect not working on offline players
|
||||
= Fixed custom blocks, tools and armors not loading properly
|
||||
= Fixed duplication bug with sticky pistons
|
||||
= Fixed "GenericLabel belonging to mcMMO..." message
|
||||
= Fixed menu exit button not working
|
||||
= Fixed Repair enchant downgrade not working
|
||||
= Fixed NPE caused by Spout players after a /reload
|
||||
= Fixed ConcurrentModificationException on world unload
|
||||
= Fixed players never being removed from memory (memory leak)
|
||||
= Fixed admin chat being seen by everyone
|
||||
= Fixed issue with UTFDataFormatException occurring on occasion when trying to load Chunklets
|
||||
= Fixed ArrayIndexOutOfBounds error caused when trying to use /xplock after logging in but before gaining XP
|
||||
= Fixed custom tools not properly respecting the Ability_Enabled flag.
|
||||
= Fixed "lower tool" messages still being displayed even when ability messages are disabled.
|
||||
= Fixed custom blocks not dropping the proper item with Super Breaker when Silk Touch is used
|
||||
= Fixed custom woodcutting blocks throwing errors.
|
||||
= Fixed possible ClassCastException from catching something other than a mob when using the Shake Mob skill
|
||||
! Changed the format by which Chunklets are stored to be much smaller, and much faster to load
|
||||
! Optimized how player placed blocks are tracked
|
||||
|
||||
Version 1.3.09
|
||||
+ Added compatibility with AntiCheat (Which I highly recommend to prevent cheating)
|
||||
+ Added several permission nodes to give individual users special perks (Double/Triple/Quadruple XP)
|
||||
+ Added reduced cooldown permission nodes as special perks (1/4, 1/3, 1/2 cooldown)
|
||||
+ Added increased activation time permissions nodes as special perks (+4, +8, and +12 seconds)
|
||||
+ Added API for plugins to add custom tools directly via Spout - repair / abilities do not work ATM
|
||||
+ Added offline party members to the list displayed by /party
|
||||
+ Added possibility to kick offline members from parties
|
||||
= Fixed bug that would cause a NPE for players that had no parties
|
||||
= Fixed Vampirism not notifying the correct amount of stolen levels
|
||||
= Fixed bug with Acrobatics not saving you from deadly falls
|
||||
= Fixed /mcremove being applied only after a reload
|
||||
= Fixed Archery PVE disablement not working properly
|
||||
= Fixed possible NPE when a projectile is shot by a dispenser or doesn't have any shooter
|
||||
= Fixed issue with NoCheatPlus and Serrated Strikes / Skull Splitter (fight.noswing)
|
||||
= Fixed tiny memory leak concerning Archery
|
||||
= Fixed bug where you could receive Archery XP from Potions
|
||||
= Fixed bug where Chunklets for the < 64 y coordinates would not be properly loaded
|
||||
= Fixed exploit with block duplication via piston pushing
|
||||
= Fixed bug with falling sand/gravel not being tracked
|
||||
= Fixed bug with Tree Feller not working with custom axes
|
||||
= Fixed bug with locale strings when trying to teleport to a non-existent player
|
||||
= Fixed bug with Tree Feller changing durability before checking for axe splintering
|
||||
= Fixed bug with Repair Mastery permission due to typo
|
||||
= Fixed bug with repairing items that use metadata
|
||||
= Fixed bug with Chunklets not being reloaded on /reload
|
||||
= Fixed possible NPE when falling with no item in hand
|
||||
! API methods can now only be used in a static way
|
||||
! Arrows shot from a bow having the Infinity enchantment can no longer be retrieved
|
||||
! Arrows that aren't shot by an entity are now able to be dodged (currently only from dispensers)
|
||||
! Changed Spout settings to be in their own config file (spout.yml)
|
||||
! Changed file format for parties (parties.yml), previous files are no longer used
|
||||
! Changed mcMMO to inform on corrupt Chunklets and make new ones
|
||||
|
||||
Version 1.3.08
|
||||
+ Added more notifications about Vampirism and Hardcore mode on player death
|
||||
+ Added information about Hardcore mode when joining a server running Hardcore mode
|
||||
+ Added new hidden.yml inside the jar for very sensitive config options for advanced users
|
||||
+ Added option to disable Chunklets for servers which do not have doubledrops and do not care about xp farming
|
||||
+ Added new "Max_Seconds" setting in config.yml to limit the max time of abilities
|
||||
+ Added new repair configs to allow customization of the repair skill
|
||||
+ Added message to inform users about hardcore mode on login
|
||||
= Fixed exploit where you could gain tons of Acrobatics XP from spamming Ender Pearls
|
||||
= Fixed normal pistons marking a block as user-placed on retract if it wasn't a sticky piston (thanks turt2live!)
|
||||
= Fixed handling of the Unbreaking enchantment so that tools are actually damaged as they should now
|
||||
= Fixed hurting pet cats with serrated strikes
|
||||
! Changed Hardcore Vampirism to require the victim to have at least half the skill level of the killer in order for vampirism to proc (this is to avoid exploitation)
|
||||
! Changed Hardcore Vampirism to steal a minimum of 1 skill level from a player no matter the percentage
|
||||
! Changed Hardcore & Vampirism to not be executed if percentages were set to zero or below
|
||||
! Changed Vampirism to actually remove stats from the victim
|
||||
! Changed Vampirism to inform the victim of their stat loss
|
||||
! Changed Mining to allow Silk Touch to work again since the dupe exploit has been fixed.
|
||||
! Changed Metrics to also report if the server uses plugin profiling
|
||||
- Removed level and item settings from Repair skill in config.yml
|
||||
|
||||
Version 1.3.07
|
||||
+ Added ability to gain XP from custom blocks. Enable custom blocks in the config file, then enter the data in the blocks.yml file.
|
||||
+ Added ability to gain XP with custom tools. Enable custom tools in the config file, then enter the data in the tools.yml file.
|
||||
+ Added ability to repair custom tools. Enable custom tools in the config file, then enter the data in the tools.yml file.
|
||||
+ Added ability to repair custom armor. Enable custom armor in the config file, then enter the data in the armor.yml file.
|
||||
+ Added functionality which makes a new folder in all world files "mcmmo_data" to store player placed block information in
|
||||
+ Added new configurable Hardcore mode functionality to mcMMO
|
||||
+ Added new configurable Vampirism PVP stat leech for Hardcore mode
|
||||
+ Added new bypass permission node for the negative penalties of Hardcore mode 'mcmmo.bypass.hardcoremode'
|
||||
+ Added configurable level curve multiplier which allows for tweaking the steepness of the XP needed to level formula
|
||||
+ Added a permission node for Archery bonus damage
|
||||
+ Added a permission node for Greater Impact ability
|
||||
+ Added permission nodes for Treasure & Magic Hunter for Fishing
|
||||
+ Added a permission node for Farmer's Diet
|
||||
+ Added config options for enabling/disabling specific double drops
|
||||
+ Added automatic zip backup of flatfile database & config files
|
||||
+ Added config options to enable/disable specific skills for PVP & PVE
|
||||
= Fixed bug where Tree Feller was looking at the wrong blocks for determining how much to take down.
|
||||
= Fixed bug where Green Terra consumed seeds even on Mossy Stone Brick
|
||||
= Fixed bug where the client didn't reflect the Stone Brick to Mossy Stone Brick change
|
||||
= Fixed bug where an arrow could bounce off entities on daze proc
|
||||
= Fixed bug where a player could gain Acrobatics experience while riding a cart
|
||||
= Fixed /party not working properly with 2 arguments
|
||||
= Fixed /party not showing properly the member list
|
||||
= Fixed /ability not checking the right permission
|
||||
= Fixed rare NPE on /party command
|
||||
= Fixed Arrow Retrieval dropping only one arrow
|
||||
= Fixed /p and /a incompatibilities with bChatManager
|
||||
= Fixed Iron Grip working reversely
|
||||
= Fixed NPE when user clicked the HUD button with Spout
|
||||
= Fixed bug where the permission node for Impact didn't work
|
||||
= Fixed some bypass nodes defaulting true for Ops
|
||||
= Fixed bug with trying to use Chimera Wing while standing on a half-block
|
||||
= Fixed duplication bug when a placed block was mined after a server restart
|
||||
= Fixed exploit where shooting yourself with an arrow gave Archery XP
|
||||
! Changed the mcMMO motd to link to the new website rather than the wiki
|
||||
! Changed bleeding ticks damage to 1 from 2
|
||||
! Changed Mining to ignore blocks when the pick is enchanted with Silk Touch
|
||||
! Changed Super Breaker to be non-functional when used with a Silk Touch enchanted pick
|
||||
! Changed MySQL to save player information 50ms apart from each other to reduce the load on the MySQL server
|
||||
! Changed the permission node for Blast Mining detonation to mcmmo.ability.blastmining.detonate (was mcmmo.skills.blastmining) for the sake of consistency
|
||||
! Changed skill commands to only display what you have permissions for
|
||||
! Changed mcMMO to use a new storage system for player placed blocks
|
||||
- Removed some unused permission nodes
|
||||
- Removed a few config options in favor of permissions nodes (Hunger Bonus, Armor/Tool Repair, Instant Wheat Regrowth)
|
||||
- Removed level requirement for repairing string tools from the config file
|
||||
|
||||
Version 1.3.06
|
||||
+ Added Iron Golem XP for aggressive golems
|
||||
@@ -31,7 +160,7 @@ Version 1.3.06
|
||||
! Changed Bleeding to now stack to a finite number on Monsters and will wear off eventually
|
||||
! Changed how we handled the config file to prevent any bugs when returning values
|
||||
! Changed locale files to use a new naming scheme. This breaks ALL old locale files. If you want to assist with re-translating anything, go to getlocalization.com/mcMMO
|
||||
! Changed mcremove to check for users in the MySQL DB before sending queries to remove them
|
||||
! Changed /mcremove to check for users in the MySQL DB before sending queries to remove them
|
||||
! Changed how the tree feller threshold worked for the better
|
||||
! Changed /mcremove to no longer kick players when they are removed from database
|
||||
! Changed /mcremove to work on offline users for FlatFile
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
== mcMMO
|
||||
**The RPG lovers mod**
|
||||
|
||||
=== Forums
|
||||
http://forums.mcmmo.info Talk with developers and the community about 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.
|
||||
|
||||
|
||||
73
extras/repair.chain.yml
Normal file
73
extras/repair.chain.yml
Normal file
@@ -0,0 +1,73 @@
|
||||
#
|
||||
# Any file named repair.*.yml in the mcmmmo folder will be loaded as a repair config
|
||||
# All repair configs have a main section titled "Repairables"
|
||||
# Afterwards, all sub-items are considered a Repairable to be loaded
|
||||
# The bare minimum of a Repairable is that it have an ItemId, a RepairMaterialId, and a MaximumDurability
|
||||
#
|
||||
# ItemId: This is the id of the item to be repairable.
|
||||
## This is required to be set.
|
||||
#
|
||||
# ItemType: This is the type of item to be repaired, this is only important to permissions.
|
||||
## Valid values are ARMOR, TOOL, and OTHER.
|
||||
## This defaults to OTHER.
|
||||
#
|
||||
# MaterialType: This is the type of the material of the item to be repaired, this is only important for permissions.
|
||||
## Valid values are STRING, LEATHER, WOOD, STONE, IRON, GOLD, DIAMOND, and OTHER
|
||||
## This defaults to OTHER.
|
||||
#
|
||||
# RepairMaterialId: This is the id of the item used to repair this repairable.
|
||||
## This is required to be set.
|
||||
#
|
||||
# RepairMaterialMetadata: This is the metadata of the item used to repair this repairable.
|
||||
## A value of -1 means to ignore all metadata when repairing.
|
||||
## This defaults to -1
|
||||
#
|
||||
# MaximumDurability: This is the maximum durability of the item.
|
||||
## This is required to be set.
|
||||
#
|
||||
# MinimumLevel: This is the minimum repair level needed to repair this item.
|
||||
## Valid values are > 0
|
||||
## This defaults to 0
|
||||
#
|
||||
# MinimumQuantity: This is the minimum number of items needed to repair this item ignoring all other repair bonuses.
|
||||
## This is typically the number of the repair material needed to create a new item, for example for a sword it is 2, for an axe it is 3
|
||||
## This defaults to 2
|
||||
#
|
||||
# XpMultiplier: This is the amount to multiply the xp bonus by.
|
||||
## This defaults to 1
|
||||
#
|
||||
#
|
||||
# The following is an example of a repair.*.yml config which adds the ability to repair Chainmail armor using fire.
|
||||
#
|
||||
#
|
||||
###
|
||||
Repairables:
|
||||
ChainHelmet:
|
||||
ItemId: 302
|
||||
ItemType: ARMOR
|
||||
RepairMaterialId: 51
|
||||
MaximumDurability: 165
|
||||
MinimumQuantity: 5
|
||||
XpMultiplier: 2
|
||||
ChainChest:
|
||||
ItemId: 303
|
||||
ItemType: ARMOR
|
||||
RepairMaterialId: 51
|
||||
MaximumDurability: 240
|
||||
MinimumQuantity: 8
|
||||
XpMultiplier: 2
|
||||
ChainLegs:
|
||||
ItemId: 304
|
||||
ItemType: ARMOR
|
||||
RepairMaterialId: 51
|
||||
MaximumDurability: 225
|
||||
MinimumQuantity: 7
|
||||
XpMultiplier: 2
|
||||
ChainBoots:
|
||||
ItemId: 305
|
||||
ItemType: ARMOR
|
||||
RepairMaterialId: 51
|
||||
RepairMaterialMetadata: -1
|
||||
MaximumDurability: 195
|
||||
MinimumQuantity: 4
|
||||
XpMultiplier: 2
|
||||
8
pom.xml
8
pom.xml
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>1.3.06</version>
|
||||
<version>1.3.10</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<issueManagement>
|
||||
@@ -128,6 +128,12 @@
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit-dep</artifactId>
|
||||
<version>4.10</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
47
src/main/java/com/gmail/nossr50/api/AbilityAPI.java
Normal file
47
src/main/java/com/gmail/nossr50/api/AbilityAPI.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class AbilityAPI {
|
||||
|
||||
public static boolean berserkEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.BERSERK);
|
||||
}
|
||||
|
||||
public static boolean gigaDrillBreakerEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.GIGA_DRILL_BREAKER);
|
||||
}
|
||||
|
||||
public static boolean greenTerraEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.GREEN_TERRA);
|
||||
}
|
||||
|
||||
public static boolean serratedStrikesEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.SERRATED_STRIKES);
|
||||
}
|
||||
|
||||
public static boolean skullSplitterEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.SKULL_SPLIITER);
|
||||
}
|
||||
|
||||
public static boolean superBreakerEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.SUPER_BREAKER);
|
||||
}
|
||||
|
||||
public static boolean treeFellerEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.TREE_FELLER);
|
||||
}
|
||||
|
||||
public static boolean isAnyAbilityEnabled(Player player) {
|
||||
for (AbilityType ability : AbilityType.values()) {
|
||||
if (Users.getProfile(player).getAbilityMode(ability)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,10 @@ import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class ChatAPI {
|
||||
public final class ChatAPI {
|
||||
|
||||
private ChatAPI() {}
|
||||
|
||||
/**
|
||||
* Send a message to all members of a party
|
||||
* </br>
|
||||
@@ -19,7 +22,7 @@ public class ChatAPI {
|
||||
* @param party The name of the party to send to
|
||||
* @param message The message to send
|
||||
*/
|
||||
public void sendPartyChat(String sender, String party, String message) {
|
||||
public static void sendPartyChat(String sender, String party, String message) {
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(sender, party, message);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
@@ -33,7 +36,7 @@ public class ChatAPI {
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
if (Users.getProfile(player).inParty()) {
|
||||
if (Users.getProfile(player).getParty().equalsIgnoreCase(chatEvent.getParty())) {
|
||||
if (Users.getProfile(player).getParty().getName().equalsIgnoreCase(chatEvent.getParty())) {
|
||||
player.sendMessage(pPrefix + chatEvent.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -48,7 +51,7 @@ public class ChatAPI {
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param message The message to send
|
||||
*/
|
||||
public void sendAdminChat(String sender, String message) {
|
||||
public static void sendAdminChat(String sender, String message) {
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(sender, message);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
|
||||
@@ -3,10 +3,12 @@ package com.gmail.nossr50.api;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class ExperienceAPI {
|
||||
public final class ExperienceAPI {
|
||||
|
||||
private ExperienceAPI() {}
|
||||
|
||||
/**
|
||||
* Check the XP of a player. This should be called after giving XP to process level-ups.
|
||||
@@ -14,12 +16,12 @@ public class ExperienceAPI {
|
||||
* @param player The player to check
|
||||
* @param skillType The skill to check
|
||||
*/
|
||||
private void checkXP(Player player, SkillType skillType) {
|
||||
private static void checkXP(Player player, SkillType skillType) {
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
Skills.XpCheckAll(player);
|
||||
Skills.xpCheckAll(player, Users.getProfile(player));
|
||||
}
|
||||
else {
|
||||
Skills.XpCheckSkill(skillType, player);
|
||||
Skills.xpCheckSkill(skillType, player, Users.getProfile(player));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +34,8 @@ public class ExperienceAPI {
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*/
|
||||
public void addRawXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getProfile(player).addXPOverride(skillType, XP);
|
||||
public static void addRawXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getPlayer(player).addXPOverride(skillType, XP);
|
||||
checkXP(player, skillType);
|
||||
}
|
||||
|
||||
@@ -46,8 +48,8 @@ public class ExperienceAPI {
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*/
|
||||
public void addMultipliedXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getProfile(player).addXPOverrideBonus(skillType, XP);
|
||||
public static void addMultipliedXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getPlayer(player).addXPOverrideBonus(skillType, XP);
|
||||
checkXP(player, skillType);
|
||||
}
|
||||
|
||||
@@ -60,8 +62,8 @@ public class ExperienceAPI {
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*/
|
||||
public void addXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getProfile(player).addXP(skillType, XP);
|
||||
public static void addXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getPlayer(player).addXP(skillType, XP);
|
||||
checkXP(player, skillType);
|
||||
}
|
||||
|
||||
@@ -74,7 +76,7 @@ public class ExperienceAPI {
|
||||
* @param skillType The skill to get XP for
|
||||
* @return the amount of XP in a given skill
|
||||
*/
|
||||
public int getXP(Player player, SkillType skillType) {
|
||||
public static int getXP(Player player, SkillType skillType) {
|
||||
return Users.getProfile(player).getSkillXpLevel(skillType);
|
||||
}
|
||||
|
||||
@@ -87,7 +89,7 @@ public 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 int getXPToNextLevel(Player player, SkillType skillType) {
|
||||
public static int getXPToNextLevel(Player player, SkillType skillType) {
|
||||
return Users.getProfile(player).getXpToLevel(skillType);
|
||||
}
|
||||
|
||||
@@ -101,7 +103,7 @@ public class ExperienceAPI {
|
||||
* @param levels Number of levels to add
|
||||
* @param notify True if this should fire a level up notification, false otherwise.
|
||||
*/
|
||||
public void addLevel(Player player, SkillType skillType, int levels, boolean notify) {
|
||||
public static void addLevel(Player player, SkillType skillType, int levels, boolean notify) {
|
||||
Users.getProfile(player).addLevels(skillType, levels);
|
||||
|
||||
if (notify) {
|
||||
@@ -118,7 +120,7 @@ public class ExperienceAPI {
|
||||
* @param skillType The skill to get the level for
|
||||
* @return the level of a given skill
|
||||
*/
|
||||
public int getLevel(Player player, SkillType skillType) {
|
||||
public static int getLevel(Player player, SkillType skillType) {
|
||||
return Users.getProfile(player).getSkillLevel(skillType);
|
||||
}
|
||||
|
||||
@@ -130,7 +132,46 @@ public class ExperienceAPI {
|
||||
* @param player The player to get the power level for
|
||||
* @return the power level of the player
|
||||
*/
|
||||
public int getPowerLevel(Player player) {
|
||||
return Users.getProfile(player).getPowerLevel();
|
||||
public static int getPowerLevel(Player player) {
|
||||
return Users.getPlayer(player).getPowerLevel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, SkillType skillType, int skillLevel) {
|
||||
Users.getProfile(player).modifySkill(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
|
||||
*/
|
||||
public static void setXP(Player player, SkillType skillType, int newValue) {
|
||||
Users.getProfile(player).setSkillXPLevel(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
|
||||
*/
|
||||
public static void removeXP(Player player, SkillType skillType, int xp) {
|
||||
Users.getProfile(player).removeXP(skillType, xp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PartyAPI {
|
||||
public final class PartyAPI {
|
||||
|
||||
private PartyAPI() {}
|
||||
|
||||
/**
|
||||
* Get the name of the party a player is in.
|
||||
@@ -17,8 +20,8 @@ public class PartyAPI {
|
||||
* @param player The player to check the party name of
|
||||
* @return the name of the player's party
|
||||
*/
|
||||
public String getPartyName(Player player) {
|
||||
return Users.getProfile(player).getParty();
|
||||
public static String getPartyName(Player player) {
|
||||
return Users.getProfile(player).getParty().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,7 +32,7 @@ public class PartyAPI {
|
||||
* @param player The player to check
|
||||
* @return true if the player is in a party, false otherwise
|
||||
*/
|
||||
public boolean inParty(Player player) {
|
||||
public static boolean inParty(Player player) {
|
||||
return Users.getProfile(player).inParty();
|
||||
}
|
||||
|
||||
@@ -42,19 +45,19 @@ public class PartyAPI {
|
||||
* @param playerb The second player to check
|
||||
* @return true if the two players are in the same party, false otherwise
|
||||
*/
|
||||
public boolean inSameParty(Player playera, Player playerb) {
|
||||
return Party.getInstance().inSameParty(playera, playerb);
|
||||
public static boolean inSameParty(Player playera, Player playerb) {
|
||||
return PartyManager.getInstance().inSameParty(playera, playerb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all current party names.
|
||||
* Get a list of all current parties.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @return the list of parties.
|
||||
*/
|
||||
public ArrayList<String> getParties() {
|
||||
return Party.getInstance().getParties();
|
||||
public static List<Party> getParties() {
|
||||
return PartyManager.getInstance().getParties();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,8 +68,8 @@ public class PartyAPI {
|
||||
* @param player The player to add to the party
|
||||
* @param partyName The party to add the player to
|
||||
*/
|
||||
public void addToParty(Player player, String partyName) {
|
||||
Party.getInstance().addToParty(player, Users.getProfile(player), partyName, false, null);
|
||||
public static void addToParty(Player player, String partyName) {
|
||||
PartyManager.getInstance().addToParty(player.getName(), Users.getProfile(player), PartyManager.getInstance().getParty(partyName)); //TODO this will throw a NPE if the party doesn't exist
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,8 +79,8 @@ public class PartyAPI {
|
||||
*
|
||||
* @param player The player to remove
|
||||
*/
|
||||
public void removeFromParty(Player player) {
|
||||
Party.getInstance().removeFromParty(player, Users.getProfile(player));
|
||||
public static void removeFromParty(Player player) {
|
||||
PartyManager.getInstance().removeFromParty(player.getName(), Users.getProfile(player).getParty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,8 +91,8 @@ public class PartyAPI {
|
||||
* @param partyName The party name
|
||||
* @return the leader of the party
|
||||
*/
|
||||
public Player getPartyLeader(String partyName) {
|
||||
return Party.getInstance().getPartyLeader(partyName);
|
||||
public static String getPartyLeader(String partyName) {
|
||||
return PartyManager.getInstance().getPartyLeader(partyName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,8 +103,8 @@ public class PartyAPI {
|
||||
* @param partyName The name of the party to set the leader of
|
||||
* @param player The player to set as leader
|
||||
*/
|
||||
public void setPartyLeader(String partyName, String player) {
|
||||
Party.getInstance().setPartyLeader(partyName, player);
|
||||
public static void setPartyLeader(String partyName, String player) {
|
||||
PartyManager.getInstance().setPartyLeader(player, PartyManager.getInstance().getParty(partyName));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,8 +115,8 @@ public class PartyAPI {
|
||||
* @param player The player to check
|
||||
* @return all the players in the player's party
|
||||
*/
|
||||
public ArrayList<Player> getAllMembers(Player player) {
|
||||
return Party.getInstance().getAllMembers(player);
|
||||
public static List<String> getAllMembers(Player player) {
|
||||
return PartyManager.getInstance().getAllMembers(player);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,8 +127,8 @@ public class PartyAPI {
|
||||
* @param partyName The party to check
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public ArrayList<Player> getOnlineMembers(String partyName) {
|
||||
return Party.getInstance().getOnlineMembers(partyName);
|
||||
public static List<Player> getOnlineMembers(String partyName) {
|
||||
return PartyManager.getInstance().getOnlineMembers(partyName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,7 +139,7 @@ public class PartyAPI {
|
||||
* @param player The player to check
|
||||
* @return all online players in the player's party
|
||||
*/
|
||||
public ArrayList<Player> getOnlineMembers(Player player) {
|
||||
return Party.getInstance().getOnlineMembers(player);
|
||||
public static List<Player> getOnlineMembers(Player player) {
|
||||
return PartyManager.getInstance().getOnlineMembers(player);
|
||||
}
|
||||
}
|
||||
|
||||
54
src/main/java/com/gmail/nossr50/api/SpoutToolsAPI.java
Normal file
54
src/main/java/com/gmail/nossr50/api/SpoutToolsAPI.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.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>();
|
||||
|
||||
/**
|
||||
* Add a custom Spout tool to mcMMO for XP gain & ability use.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param spoutTool The tool to add
|
||||
* @param type The type of tool to add
|
||||
*/
|
||||
public static void addCustomTool(ItemStack spoutTool, ToolType type) {
|
||||
switch (type) {
|
||||
case AXE:
|
||||
spoutAxes.add(spoutTool);
|
||||
break;
|
||||
|
||||
case HOE:
|
||||
spoutHoes.add(spoutTool);
|
||||
break;
|
||||
|
||||
case PICKAXE:
|
||||
spoutPickaxes.add(spoutTool);
|
||||
break;
|
||||
|
||||
case SHOVEL:
|
||||
spoutShovels.add(spoutTool);
|
||||
break;
|
||||
|
||||
case SWORD:
|
||||
spoutSwords.add(spoutTool);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,8 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class CommandHelper {
|
||||
@@ -23,7 +23,7 @@ public class CommandHelper {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (player != null && !Permissions.getInstance().permission(player, permission)) {
|
||||
if (!Permissions.getInstance().permission(player, permission)) {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
@@ -49,28 +49,28 @@ public class CommandHelper {
|
||||
*/
|
||||
public static void printGatheringSkills(Player inspect, CommandSender display) {
|
||||
if (Skills.hasGatheringSkills(inspect)) {
|
||||
PlayerProfile PP = Users.getProfile(inspect);
|
||||
PlayerProfile profile = Users.getProfile(inspect);
|
||||
|
||||
display.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
||||
|
||||
if (Permissions.getInstance().excavation(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Excavation.Listener"), PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().fishing(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Fishing.Listener"), PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().herbalism(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Herbalism.Listener"), PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().mining(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Mining.Listener"), PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().woodcutting(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Woodcutting.Listener"), PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Woodcutting.Listener"), profile.getSkillLevel(SkillType.WOODCUTTING), profile.getSkillXpLevel(SkillType.WOODCUTTING), profile.getXpToLevel(SkillType.WOODCUTTING) }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,28 +87,28 @@ public class CommandHelper {
|
||||
*/
|
||||
public static void printCombatSkills(Player inspect, CommandSender display) {
|
||||
if (Skills.hasCombatSkills(inspect)) {
|
||||
PlayerProfile PP = Users.getProfile(inspect);
|
||||
PlayerProfile profile = Users.getProfile(inspect);
|
||||
|
||||
display.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
|
||||
|
||||
if (Permissions.getInstance().axes(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Axes.Listener"), PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().archery(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Archery.Listener"), PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().swords(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Swords.Listener"), PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().taming(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Taming.Listener"), PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().unarmed(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Unarmed.Listener"), PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Unarmed.Listener"), profile.getSkillLevel(SkillType.UNARMED), profile.getSkillXpLevel(SkillType.UNARMED), profile.getXpToLevel(SkillType.UNARMED) }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,15 +125,15 @@ public class CommandHelper {
|
||||
*/
|
||||
public static void printMiscSkills(Player inspect, CommandSender display) {
|
||||
if (Skills.hasMiscSkills(inspect)) {
|
||||
PlayerProfile PP = Users.getProfile(inspect);
|
||||
PlayerProfile profile = Users.getProfile(inspect);
|
||||
display.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
|
||||
|
||||
if (Permissions.getInstance().acrobatics(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Acrobatics.Listener"), PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().repair(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Repair.Listener"), PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR) }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
85
src/main/java/com/gmail/nossr50/commands/SkillCommand.java
Normal file
85
src/main/java/com/gmail/nossr50/commands/SkillCommand.java
Normal file
@@ -0,0 +1,85 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public abstract class SkillCommand implements CommandExecutor {
|
||||
private SkillType skill;
|
||||
private String skillString;
|
||||
private String permission;
|
||||
|
||||
protected Player player;
|
||||
protected PlayerProfile profile;
|
||||
protected float skillValue;
|
||||
|
||||
protected DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
protected Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
public SkillCommand(SkillType skill) {
|
||||
this.skill = skill;
|
||||
this.skillString = Misc.getCapitalized(skill.toString());
|
||||
this.permission = "mcmmo.skills." + skillString.toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, permission)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
player = (Player) sender;
|
||||
profile = Users.getProfile(player);
|
||||
|
||||
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();
|
||||
}
|
||||
@@ -12,8 +12,8 @@ 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.skills.Skills;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class AddlevelsCommand implements CommandExecutor{
|
||||
@@ -26,7 +26,7 @@ public class AddlevelsCommand implements CommandExecutor{
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
OfflinePlayer modifiedPlayer;
|
||||
PlayerProfile PP;
|
||||
PlayerProfile profile;
|
||||
int levels;
|
||||
SkillType skill;
|
||||
String skillName;
|
||||
@@ -48,7 +48,7 @@ public class AddlevelsCommand implements CommandExecutor{
|
||||
modifiedPlayer = (Player) sender;
|
||||
levels = Integer.valueOf(args[1]);
|
||||
skill = Skills.getSkillType(args[0]);
|
||||
PP = Users.getProfile(modifiedPlayer);
|
||||
profile = Users.getProfile(modifiedPlayer);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
@@ -57,7 +57,7 @@ public class AddlevelsCommand implements CommandExecutor{
|
||||
skillName = Misc.getCapitalized(skill.toString());
|
||||
}
|
||||
|
||||
PP.addLevels(skill, levels);
|
||||
profile.addLevels(skill, levels);
|
||||
sender.sendMessage(ChatColor.GREEN + "You were awarded " + levels + " levels in " + skillName + "!"); //TODO: Needs more locale.
|
||||
}
|
||||
}
|
||||
@@ -70,9 +70,9 @@ public class AddlevelsCommand implements CommandExecutor{
|
||||
case 3:
|
||||
modifiedPlayer = plugin.getServer().getOfflinePlayer(args[0]);
|
||||
String playerName = modifiedPlayer.getName();
|
||||
PP = Users.getProfile(modifiedPlayer);
|
||||
profile = Users.getProfile(modifiedPlayer);
|
||||
|
||||
if (!PP.isLoaded()) {
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8,10 +8,12 @@ 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.skills.Skills;
|
||||
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?
|
||||
@@ -47,7 +49,9 @@ public class AddxpCommand implements CommandExecutor {
|
||||
xp = Integer.valueOf(args[1]);
|
||||
skill = Skills.getSkillType(args[0]);
|
||||
|
||||
Users.getProfile(modifiedPlayer).addXPOverride(skill, xp);
|
||||
PlayerProfile profile = Users.getProfile(modifiedPlayer);
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(modifiedPlayer);
|
||||
mcMMOPlayer.addXPOverride(skill, xp);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
@@ -59,10 +63,10 @@ public class AddxpCommand implements CommandExecutor {
|
||||
modifiedPlayer.sendMessage(ChatColor.GREEN + "You were awarded " + xp + " experience in " + skillName + "!"); //TODO: Needs more locale.
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
Skills.XpCheckAll(modifiedPlayer);
|
||||
Skills.xpCheckAll(modifiedPlayer, profile);
|
||||
}
|
||||
else {
|
||||
Skills.XpCheckSkill(skill, modifiedPlayer);
|
||||
Skills.xpCheckSkill(skill, modifiedPlayer, profile);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -78,8 +82,10 @@ public class AddxpCommand implements CommandExecutor {
|
||||
case 3:
|
||||
modifiedPlayer = plugin.getServer().getPlayer(args[0]);
|
||||
String playerName = modifiedPlayer.getName();
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(modifiedPlayer);
|
||||
PlayerProfile profile = Users.getProfile(modifiedPlayer);
|
||||
|
||||
if (!Users.getProfile(modifiedPlayer).isLoaded()) {
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
@@ -94,7 +100,7 @@ public class AddxpCommand implements CommandExecutor {
|
||||
skill = Skills.getSkillType(args[1]);
|
||||
String message;
|
||||
|
||||
Users.getProfile(modifiedPlayer).addXPOverride(skill, xp);
|
||||
mcMMOPlayer.addXPOverride(skill, xp);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
@@ -109,10 +115,10 @@ public class AddxpCommand implements CommandExecutor {
|
||||
modifiedPlayer.sendMessage(ChatColor.GREEN + "You were awarded " + xp + " experience in " + skillName + "!"); //TODO: Needs more locale.
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
Skills.XpCheckAll(modifiedPlayer);
|
||||
Skills.xpCheckAll(modifiedPlayer, profile);
|
||||
}
|
||||
else {
|
||||
Skills.XpCheckSkill(skill, modifiedPlayer);
|
||||
Skills.xpCheckSkill(skill, modifiedPlayer, profile);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
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.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@@ -16,16 +15,8 @@ import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class InspectCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public InspectCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
OfflinePlayer target;
|
||||
PlayerProfile PP;
|
||||
String usage = "Proper usage is /inspect <player>"; //TODO: Needs more locale.
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.inspect")) {
|
||||
@@ -34,22 +25,21 @@ public class InspectCommand implements CommandExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
target = plugin.getServer().getOfflinePlayer(args[0]);
|
||||
PP = Users.getProfile(target);
|
||||
McMMOPlayer mcmmoPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
if (target.isOnline()) {
|
||||
Player player = (Player) target;
|
||||
if (mcmmoPlayer != null) {
|
||||
Player target = mcmmoPlayer.getPlayer();
|
||||
|
||||
if (sender instanceof Player && !sender.isOp() && !Misc.isNear(((Player) sender).getLocation(), player.getLocation(), 5.0) && !Permissions.getInstance().inspectDistanceBypass((Player) sender)) {
|
||||
if (sender instanceof Player && !sender.isOp() && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !Permissions.getInstance().inspectDistanceBypass((Player) sender)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", new Object[] { target.getName() }));
|
||||
CommandHelper.printGatheringSkills(player, sender);
|
||||
CommandHelper.printCombatSkills(player, sender);
|
||||
CommandHelper.printMiscSkills(player, sender);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { PP.getPowerLevel() }));
|
||||
CommandHelper.printGatheringSkills(target, sender);
|
||||
CommandHelper.printCombatSkills(target, sender);
|
||||
CommandHelper.printMiscSkills(target, sender);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { mcmmoPlayer.getPowerLevel() }));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -59,7 +49,9 @@ public class InspectCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!PP.isLoaded()) {
|
||||
PlayerProfile profile = new PlayerProfile(args[0], false); //Temporary Profile
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
@@ -67,22 +59,22 @@ public class InspectCommand implements CommandExecutor {
|
||||
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"), PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Fishing.Listener"), PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Herbalism.Listener"), PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Mining.Listener"), PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Woodcutting.Listener"), PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) }));
|
||||
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"), PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Archery.Listener"), PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Swords.Listener"), PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Taming.Listener"), PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Unarmed.Listener"), PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) }));
|
||||
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"), PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Repair.Listener"), PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) }));
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ 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;
|
||||
|
||||
@@ -19,7 +18,6 @@ public class McstatsCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
||||
@@ -28,7 +26,7 @@ public class McstatsCommand implements CommandExecutor {
|
||||
CommandHelper.printCombatSkills(player);
|
||||
CommandHelper.printMiscSkills(player);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { String.valueOf(PP.getPowerLevel()) }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { String.valueOf(Users.getPlayer(player).getPowerLevel()) }));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,32 +1,24 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class MmoeditCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public MmoeditCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
OfflinePlayer modifiedPlayer;
|
||||
PlayerProfile PP;
|
||||
PlayerProfile profile;
|
||||
int newValue;
|
||||
SkillType skill;
|
||||
String skillName;
|
||||
@@ -45,10 +37,10 @@ public class MmoeditCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (Misc.isInt(args[1])) {
|
||||
modifiedPlayer = (Player) sender;
|
||||
Player player = (Player) sender;
|
||||
newValue = Integer.valueOf(args[1]);
|
||||
skill = Skills.getSkillType(args[0]);
|
||||
PP = Users.getProfile(modifiedPlayer);
|
||||
profile = Users.getProfile(player);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
@@ -57,7 +49,7 @@ public class MmoeditCommand implements CommandExecutor {
|
||||
skillName = Misc.getCapitalized(skill.toString());
|
||||
}
|
||||
|
||||
PP.modifySkill(skill, newValue);
|
||||
profile.modifySkill(skill, newValue);
|
||||
sender.sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
|
||||
}
|
||||
else {
|
||||
@@ -71,46 +63,46 @@ public class MmoeditCommand implements CommandExecutor {
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
modifiedPlayer = plugin.getServer().getOfflinePlayer(args[0]);
|
||||
String playerName = modifiedPlayer.getName();
|
||||
PP = Users.getProfile(modifiedPlayer);
|
||||
|
||||
if (!PP.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
if (!Misc.isInt(args[2])) {
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Skills.isSkill(args[1])) {
|
||||
skill = Skills.getSkillType(args[1]);
|
||||
|
||||
if (skill == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Misc.isInt(args[2])) {
|
||||
newValue = Integer.valueOf(args[2]);
|
||||
skill = Skills.getSkillType(args[1]);
|
||||
String message;
|
||||
|
||||
Users.getProfile(modifiedPlayer).modifySkill(skill, newValue);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
message = ChatColor.RED + "All skills have been modified for " + playerName + "."; //TODO: Use locale
|
||||
}
|
||||
else {
|
||||
skillName = Misc.getCapitalized(skill.toString());
|
||||
message = ChatColor.RED + skillName + " has been modified for " + playerName + "."; //TODO: Use locale
|
||||
}
|
||||
|
||||
sender.sendMessage(message);
|
||||
|
||||
if (modifiedPlayer.isOnline()) {
|
||||
((Player) modifiedPlayer).sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
|
||||
}
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
skillName = Misc.getCapitalized(skill.toString());
|
||||
}
|
||||
|
||||
newValue = Integer.valueOf(args[2]);
|
||||
McMMOPlayer mcmmoPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
if (mcmmoPlayer != null) {
|
||||
profile = mcmmoPlayer.getProfile();
|
||||
|
||||
profile.modifySkill(skill, newValue);
|
||||
mcmmoPlayer.getPlayer().sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
|
||||
sender.sendMessage(ChatColor.RED + skillName + " has been modified for " + args[0] + "."); //TODO: Use locale
|
||||
}
|
||||
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:
|
||||
|
||||
@@ -26,7 +26,7 @@ public class MmoupdateCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GRAY + "Starting conversion..."); //TODO: Needs more locale.
|
||||
Users.clearUsers();
|
||||
Users.clearAll();
|
||||
convertToMySQL();
|
||||
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
|
||||
@@ -13,8 +13,8 @@ import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class XprateCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
private static int oldrate = Config.getInstance().xpGainMultiplier;
|
||||
public static boolean xpevent = false;
|
||||
private static int oldRate = Config.getInstance().xpGainMultiplier;
|
||||
private static boolean xpEvent = false;
|
||||
|
||||
public XprateCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
@@ -33,16 +33,16 @@ public class XprateCommand implements CommandExecutor {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("reset")) {
|
||||
if (xpevent) {
|
||||
if (xpEvent) {
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
x.sendMessage(LocaleLoader.getString("Commands.xprate.over"));
|
||||
}
|
||||
|
||||
xpevent = !xpevent;
|
||||
Config.getInstance().xpGainMultiplier = oldrate;
|
||||
xpEvent = !xpEvent;
|
||||
Config.getInstance().xpGainMultiplier = oldRate;
|
||||
}
|
||||
else {
|
||||
Config.getInstance().xpGainMultiplier = oldrate;
|
||||
Config.getInstance().xpGainMultiplier = oldRate;
|
||||
}
|
||||
}
|
||||
else if (Misc.isInt(args[0])) {
|
||||
@@ -56,10 +56,10 @@ public class XprateCommand implements CommandExecutor {
|
||||
|
||||
case 2:
|
||||
if (Misc.isInt(args[0])) {
|
||||
oldrate = Config.getInstance().xpGainMultiplier;
|
||||
oldRate = Config.getInstance().xpGainMultiplier;
|
||||
|
||||
if (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")) {
|
||||
xpevent = Boolean.valueOf(args[1]);
|
||||
xpEvent = Boolean.valueOf(args[1]);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage3);
|
||||
@@ -67,7 +67,7 @@ public class XprateCommand implements CommandExecutor {
|
||||
|
||||
Config.getInstance().xpGainMultiplier = Misc.getInt(args[0]);
|
||||
|
||||
if (xpevent) {
|
||||
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}));
|
||||
@@ -90,4 +90,8 @@ public class XprateCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isXpEventRunning() {
|
||||
return xpEvent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,20 +18,20 @@ public class McabilityCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) {
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.ability")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerProfile PP = Users.getProfile((Player) sender);
|
||||
PlayerProfile profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (PP.getAbilityUse()) {
|
||||
if (profile.getAbilityUse()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
||||
}
|
||||
|
||||
PP.toggleAbilityUse();
|
||||
profile.toggleAbilityUse();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class MccCommand implements CommandExecutor {
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Other"));
|
||||
player.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
|
||||
player.sendMessage("/mctop " + LocaleLoader.getString("m.mccLeaderboards"));
|
||||
player.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards"));
|
||||
|
||||
if (Permissions.getInstance().mcAbility(player)) {
|
||||
player.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
|
||||
|
||||
@@ -22,16 +22,16 @@ public class McgodCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerProfile PP = Users.getProfile((Player) sender);
|
||||
PlayerProfile profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (PP.getGodMode()) {
|
||||
if (profile.getGodMode()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
|
||||
}
|
||||
|
||||
PP.toggleGodMode();
|
||||
profile.toggleGodMode();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ 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) {
|
||||
String description = LocaleLoader.getString("mcMMO.Description");
|
||||
@@ -19,14 +19,14 @@ public class McmmoCommand implements CommandExecutor {
|
||||
sender.sendMessage(mcSplit);
|
||||
|
||||
if (Config.getInstance().getDonateMessageEnabled()) {
|
||||
if (Config.getInstance().spoutEnabled && sender instanceof SpoutPlayer) {
|
||||
SpoutPlayer sPlayer = (SpoutPlayer) sender;
|
||||
if (mcMMO.spoutEnabled && sender instanceof SpoutPlayer) {
|
||||
SpoutPlayer spoutPlayer = (SpoutPlayer) sender;
|
||||
|
||||
sPlayer.sendNotification(ChatColor.YELLOW + "[mcMMO]" + ChatColor.GOLD + " Donate!", ChatColor.GREEN + "nossr50@gmail.com", Material.DIAMOND);
|
||||
spoutPlayer.sendNotification(ChatColor.YELLOW + "[mcMMO]" + ChatColor.GOLD + " Donate!", ChatColor.GREEN + "mcmmodev@gmail.com", Material.DIAMOND);
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + "Donation Info:");
|
||||
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "nossr50@gmail.com" + ChatColor.GOLD + " Paypal");
|
||||
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "mcmmodev@gmail.com" + ChatColor.GOLD + " Paypal");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class McrefreshCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
OfflinePlayer player;
|
||||
PlayerProfile PP;
|
||||
PlayerProfile profile;
|
||||
String usage = ChatColor.RED + "Proper usage is /mcrefresh [player]"; //TODO: Needs more locale
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcrefresh")) {
|
||||
@@ -34,7 +34,7 @@ public class McrefreshCommand implements CommandExecutor {
|
||||
case 0:
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
PP = Users.getProfile(player);
|
||||
profile = Users.getProfile(player);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
@@ -44,10 +44,10 @@ public class McrefreshCommand implements CommandExecutor {
|
||||
|
||||
case 1:
|
||||
player = plugin.getServer().getOfflinePlayer(args[0]);
|
||||
PP = Users.getProfile(player);
|
||||
profile = Users.getProfile(player);
|
||||
String playerName = player.getName();
|
||||
|
||||
if (!PP.isLoaded()) {
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
@@ -61,10 +61,10 @@ public class McrefreshCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
PP.setRecentlyHurt((long) 0);
|
||||
PP.resetCooldowns();
|
||||
PP.resetToolPrepMode();
|
||||
PP.resetAbilityMode();
|
||||
profile.setRecentlyHurt(0);
|
||||
profile.resetCooldowns();
|
||||
profile.resetToolPrepMode();
|
||||
profile.resetAbilityMode();
|
||||
|
||||
if (player.isOnline()) {
|
||||
((Player) player).sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.gmail.nossr50.commands.mc;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -13,15 +14,20 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.SpoutHud;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McremoveCommand implements CommandExecutor {
|
||||
private final String location = mcMMO.usersFile;
|
||||
private final String location;
|
||||
private final mcMMO plugin;
|
||||
|
||||
public McremoveCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
this.location = mcMMO.getUsersFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,7 +45,7 @@ public class McremoveCommand implements CommandExecutor {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
playerName = args[0];
|
||||
success = ChatColor.GREEN + playerName + "was successfully removed from the database!"; //TODO: Locale
|
||||
success = ChatColor.GREEN + playerName + " was successfully removed from the database!"; //TODO: Locale
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -49,31 +55,32 @@ public class McremoveCommand implements CommandExecutor {
|
||||
|
||||
/* MySQL */
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
int userId = 0;
|
||||
userId = mcMMO.database.getInt("SELECT id FROM " + tablePrefix + "users WHERE user = '" + playerName + "'");
|
||||
userId = database.getInt("SELECT id FROM " + tablePrefix + "users WHERE user = '" + playerName + "'");
|
||||
|
||||
if (userId > 0) {
|
||||
mcMMO.database.write("DELETE FROM "
|
||||
database.write("DELETE FROM "
|
||||
+ databaseName + "."
|
||||
+ tablePrefix + "users WHERE "
|
||||
+ tablePrefix + "users.id=" + userId);
|
||||
|
||||
mcMMO.database.write("DELETE FROM "
|
||||
database.write("DELETE FROM "
|
||||
+ databaseName + "."
|
||||
+ tablePrefix + "cooldowns WHERE "
|
||||
+ tablePrefix + "cooldowns.user_id=" + userId);
|
||||
|
||||
mcMMO.database.write("DELETE FROM "
|
||||
database.write("DELETE FROM "
|
||||
+ databaseName + "."
|
||||
+ tablePrefix + "huds WHERE "
|
||||
+ tablePrefix + "huds.user_id=" + userId);
|
||||
|
||||
mcMMO.database.write("DELETE FROM "
|
||||
database.write("DELETE FROM "
|
||||
+ databaseName + "."
|
||||
+ tablePrefix + "skills WHERE "
|
||||
+ tablePrefix + "skills.user_id=" + userId);
|
||||
|
||||
mcMMO.database.write("DELETE FROM "
|
||||
database.write("DELETE FROM "
|
||||
+ databaseName + "."
|
||||
+ tablePrefix + "experience WHERE "
|
||||
+ tablePrefix + "experience.user_id=" + userId);
|
||||
@@ -95,11 +102,25 @@ public class McremoveCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
//Force PlayerProfile stuff to update
|
||||
Player player = plugin.getServer().getPlayer(playerName);
|
||||
McMMOPlayer mcmmoPlayer = Users.getPlayer(playerName);
|
||||
|
||||
if (player != null && Users.players.containsKey(playerName.toLowerCase())) {
|
||||
Users.removeUser(player);
|
||||
Users.addUser(player);
|
||||
if (mcmmoPlayer != null) {
|
||||
Player player = mcmmoPlayer.getPlayer();
|
||||
SpoutHud spoutHud = mcmmoPlayer.getProfile().getSpoutHud();
|
||||
|
||||
if (spoutHud != null) {
|
||||
spoutHud.removeWidgets();
|
||||
}
|
||||
|
||||
Users.remove(playerName);
|
||||
|
||||
if (player.isOnline()) {
|
||||
Users.addUser(player);
|
||||
|
||||
if (mcMMO.spoutEnabled) {
|
||||
SpoutStuff.reloadSpoutPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -108,9 +129,12 @@ public class McremoveCommand implements CommandExecutor {
|
||||
private boolean removeFlatFileUser(String playerName) {
|
||||
boolean worked = false;
|
||||
|
||||
BufferedReader in = null;
|
||||
FileWriter out = null;
|
||||
|
||||
try {
|
||||
FileReader file = new FileReader(location);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
in = new BufferedReader(file);
|
||||
StringBuilder writer = new StringBuilder();
|
||||
String line = "";
|
||||
|
||||
@@ -127,16 +151,32 @@ public class McremoveCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
in.close();
|
||||
FileWriter out = new FileWriter(location); //Write out the new file
|
||||
out = new FileWriter(location); //Write out the new file
|
||||
out.write(writer.toString());
|
||||
out.close();
|
||||
|
||||
return worked;
|
||||
}
|
||||
catch (Exception e) {
|
||||
plugin.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
return worked;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,19 +7,21 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.util.Leaderboard;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class MctopCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String usage = ChatColor.RED + "Proper usage is /mctop [skill] [page]"; //TODO: Needs more locale.
|
||||
|
||||
|
||||
if (!Config.getInstance().getUseMySQL()) {
|
||||
|
||||
switch (args.length) {
|
||||
@@ -106,7 +108,7 @@ public class MctopCommand implements CommandExecutor {
|
||||
private void flatfileDisplay(int page, String skill, CommandSender sender) {
|
||||
String[] info = Leaderboard.retrieveInfo(skill, page);
|
||||
|
||||
if (skill == "ALL") {
|
||||
if (skill.equals("ALL")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||
}
|
||||
else {
|
||||
@@ -133,9 +135,11 @@ public class MctopCommand implements CommandExecutor {
|
||||
|
||||
private void sqlDisplay(int page, String query, CommandSender sender) {
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.read("SELECT " + query + ", user_id FROM " + tablePrefix + "skills WHERE " + query + " > 0 ORDER BY " + query + " DESC ");
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
|
||||
if (query == "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing") {
|
||||
HashMap<Integer, ArrayList<String>> userslist = database.read("SELECT " + query + ", user_id FROM " + tablePrefix + "skills WHERE " + query + " > 0 ORDER BY " + query + " DESC ");
|
||||
|
||||
if (query.equals("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||
}
|
||||
else {
|
||||
@@ -143,11 +147,11 @@ public class MctopCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
for (int i = (page * 10) - 9; i <= (page * 10); i++) {
|
||||
if (i > userslist.size() || mcMMO.database.read("SELECT user FROM " + tablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null) {
|
||||
if (i > userslist.size() || database.read("SELECT user FROM " + tablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
HashMap<Integer, ArrayList<String>> username = mcMMO.database.read("SELECT user FROM " + tablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'");
|
||||
HashMap<Integer, ArrayList<String>> username = database.read("SELECT user FROM " + tablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'");
|
||||
sender.sendMessage(String.valueOf(i) + ". " + ChatColor.GREEN + userslist.get(i).get(0) + " - " + ChatColor.WHITE + username.get(1).get(0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class ACommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile PP;
|
||||
PlayerProfile profile;
|
||||
String usage = ChatColor.RED + "Proper usage is /a <message>"; //TODO: Needs more locale.
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.chat.adminchat")) {
|
||||
@@ -33,15 +33,15 @@ public class ACommand implements CommandExecutor {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (sender instanceof Player) {
|
||||
PP = Users.getProfile((Player) sender);
|
||||
profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (PP.getPartyChatMode()) {
|
||||
PP.togglePartyChat();
|
||||
if (profile.getPartyChatMode()) {
|
||||
profile.togglePartyChat();
|
||||
}
|
||||
|
||||
PP.toggleAdminChat();
|
||||
profile.toggleAdminChat();
|
||||
|
||||
if (PP.getAdminChatMode()) {
|
||||
if (profile.getAdminChatMode()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.AdminChat.On"));
|
||||
}
|
||||
else {
|
||||
@@ -55,23 +55,35 @@ public class ACommand implements CommandExecutor {
|
||||
return true;
|
||||
|
||||
default:
|
||||
String message = args[0];
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(args[0]);
|
||||
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
message = message + " " + args [i];
|
||||
buffer.append(" ");
|
||||
buffer.append(args[i]);
|
||||
}
|
||||
|
||||
String message = buffer.toString();
|
||||
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
PP = Users.getProfile(player);
|
||||
|
||||
if (PP.getAdminChatMode()) {
|
||||
player.chat(message);
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), message);
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
PP.toggleAdminChat();
|
||||
player.chat(message);
|
||||
PP.toggleAdminChat();
|
||||
|
||||
message = chatEvent.getMessage();
|
||||
String prefix = ChatColor.AQUA + "{" + ChatColor.WHITE + player.getName() + ChatColor.AQUA + "} ";
|
||||
|
||||
plugin.getLogger().info("[A]<" + player.getName() + "> " + message);
|
||||
|
||||
for (Player otherPlayer : plugin.getServer().getOnlinePlayers()) {
|
||||
if (Permissions.getInstance().adminChat(otherPlayer) || otherPlayer.isOp()) {
|
||||
otherPlayer.sendMessage(prefix + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -12,6 +12,7 @@ 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 {
|
||||
@@ -32,32 +33,33 @@ public class AcceptCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
|
||||
if (PP.hasPartyInvite()) {
|
||||
Party partyInstance = Party.getInstance();
|
||||
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);
|
||||
|
||||
if (PP.inParty()) {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, PP.getParty(), PP.getInvite(), EventReason.CHANGED_PARTIES);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
partyInstance.removeFromParty(player, PP);
|
||||
partyManagerInstance.removeFromParty(player.getName(), party);
|
||||
}
|
||||
else {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, PP.getInvite(), EventReason.JOINED_PARTY);
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, playerProfile.getInvite().getName(), EventReason.JOINED_PARTY);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
PP.acceptInvite();
|
||||
partyInstance.addToParty(player, PP, PP.getParty(), true, null);
|
||||
|
||||
partyManagerInstance.joinInvitedParty(player, playerProfile);
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
|
||||
|
||||
@@ -11,6 +11,7 @@ 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.
|
||||
@@ -36,11 +37,9 @@ public class InviteCommand implements CommandExecutor {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
|
||||
Party partyInstance = Party.getInstance();
|
||||
|
||||
if (!PP.inParty()) {
|
||||
if (!playerProfile.inParty()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
return true;
|
||||
}
|
||||
@@ -48,13 +47,12 @@ public class InviteCommand implements CommandExecutor {
|
||||
Player target = plugin.getServer().getPlayer(args[0]);
|
||||
|
||||
if (target != null) {
|
||||
if (partyInstance.canInvite(player, PP)) {
|
||||
PlayerProfile PPt = Users.getProfile(target);
|
||||
PPt.modifyInvite(PP.getParty());
|
||||
|
||||
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[] { PPt.getInvite(), player.getName() }));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", new Object[] {party.getName(), player.getName()}));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ 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 {
|
||||
@@ -23,26 +24,25 @@ public class PCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile PP;
|
||||
PlayerProfile profile;
|
||||
String usage = ChatColor.RED + "Proper usage is /p <party-name> <message>"; //TODO: Needs more locale.
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (sender instanceof Player) {
|
||||
PP = Users.getProfile((Player) sender);
|
||||
profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (PP.getAdminChatMode()) {
|
||||
PP.toggleAdminChat();
|
||||
if (profile.getAdminChatMode()) {
|
||||
profile.toggleAdminChat();
|
||||
}
|
||||
|
||||
PP.togglePartyChat();
|
||||
profile.togglePartyChat();
|
||||
|
||||
if (PP.getPartyChatMode()) {
|
||||
if (profile.getPartyChatMode()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.Chat.On"));
|
||||
}
|
||||
else {
|
||||
@@ -58,26 +58,37 @@ public class PCommand implements CommandExecutor {
|
||||
default:
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
PP = Users.getProfile(player);
|
||||
Party party = Users.getProfile(player).getParty();
|
||||
|
||||
if (!PP.inParty()) {
|
||||
if (party == null) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
return true;
|
||||
}
|
||||
|
||||
String message = args[0];
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(args[0]);
|
||||
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
message = message + " " + args [i];
|
||||
buffer.append(" ");
|
||||
buffer.append(args[i]);
|
||||
}
|
||||
|
||||
if (PP.getPartyChatMode()) {
|
||||
player.chat(message);
|
||||
String message = buffer.toString();
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), party.getName(), message);
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
PP.togglePartyChat();
|
||||
player.chat(message);
|
||||
PP.togglePartyChat();
|
||||
|
||||
message = chatEvent.getMessage();
|
||||
String prefix = ChatColor.GREEN + "(" + ChatColor.WHITE + player.getName() + ChatColor.GREEN + ") ";
|
||||
|
||||
plugin.getLogger().info("[P](" + party.getName() + ")" + "<" + player.getName() + "> " + message);
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
member.sendMessage(prefix + message);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -86,17 +97,21 @@ public class PCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Party.getInstance().isParty(args[0])) {
|
||||
if (!PartyManager.getInstance().isParty(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
|
||||
return true;
|
||||
}
|
||||
|
||||
String message = args[1];
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(args[1]);
|
||||
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
message = message + " " + args [i];
|
||||
buffer.append(" ");
|
||||
buffer.append(args[i]);
|
||||
}
|
||||
|
||||
String message = buffer.toString();
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent("Console", args[0], message);
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
@@ -109,8 +124,8 @@ public class PCommand implements CommandExecutor {
|
||||
|
||||
plugin.getLogger().info("[P](" + args[0] + ")" + "<*Console*> " + message);
|
||||
|
||||
for (Player player : Party.getInstance().getOnlineMembers(args[0])) {
|
||||
player.sendMessage(prefix + message);
|
||||
for (Player member : PartyManager.getInstance().getOnlineMembers(args[0])) {
|
||||
member.sendMessage(prefix + message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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;
|
||||
@@ -13,6 +14,7 @@ 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 {
|
||||
@@ -34,60 +36,54 @@ public class PartyCommand implements CommandExecutor {
|
||||
|
||||
Player player = (Player) sender;
|
||||
String playerName = player.getName();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
|
||||
Party partyInstance = Party.getInstance();
|
||||
boolean inParty = PP.inParty();
|
||||
String partyName = PP.getParty();
|
||||
boolean isLeader = partyInstance.isPartyLeader(playerName, partyName);
|
||||
|
||||
if (PP.inParty() && (!partyInstance.isParty(PP.getParty()) || !partyInstance.isInParty(player, PP))) {
|
||||
partyInstance.addToParty(player, PP, PP.getParty(), false, null);
|
||||
}
|
||||
PartyManager partyManagerInstance = PartyManager.getInstance();
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!inParty) {
|
||||
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 {
|
||||
String tempList = "";
|
||||
Server server = plugin.getServer();
|
||||
String leader = party.getLeader();
|
||||
StringBuffer tempList = new StringBuffer();
|
||||
|
||||
for (Player p : partyInstance.getAllMembers(player)) {
|
||||
if (p.equals(partyInstance.getPartyLeader(partyName))) {
|
||||
tempList = ChatColor.GOLD + p.getName();
|
||||
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 = ChatColor.WHITE + p.getName();
|
||||
tempList.append(ChatColor.GRAY);
|
||||
}
|
||||
|
||||
tempList.append(otherPlayerName + " ");
|
||||
}
|
||||
|
||||
if (isLeader) {
|
||||
tempList += ChatColor.GOLD + playerName;
|
||||
}
|
||||
else {
|
||||
tempList += ChatColor.WHITE + playerName;
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.InParty", new Object[] { partyName }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Members", new Object[] { tempList }));
|
||||
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 (inParty) {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, null, EventReason.LEFT_PARTY);
|
||||
if (party != null) {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), null, EventReason.LEFT_PARTY);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
partyInstance.removeFromParty(player, PP);
|
||||
partyManagerInstance.removeFromParty(playerName, party);
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
|
||||
}
|
||||
else {
|
||||
@@ -103,13 +99,13 @@ public class PartyCommand implements CommandExecutor {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.7"));
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("lock")) {
|
||||
if (inParty) {
|
||||
if (isLeader) {
|
||||
if (partyInstance.isPartyLocked(partyName)) {
|
||||
if (party != null) {
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
if (party.isLocked()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.IsLocked"));
|
||||
}
|
||||
else {
|
||||
partyInstance.lockParty(partyName);
|
||||
party.setLocked(true);
|
||||
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
||||
}
|
||||
}
|
||||
@@ -122,13 +118,13 @@ public class PartyCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("unlock")) {
|
||||
if (inParty) {
|
||||
if (isLeader) {
|
||||
if (!partyInstance.isPartyLocked(partyName)) {
|
||||
if (party != null) {
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
if (!party.isLocked()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.IsntLocked"));
|
||||
}
|
||||
else {
|
||||
partyInstance.unlockParty(partyName);
|
||||
party.setLocked(false);
|
||||
player.sendMessage(LocaleLoader.getString("Party.Unlocked"));
|
||||
}
|
||||
}
|
||||
@@ -141,15 +137,15 @@ public class PartyCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (inParty) {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, args[0], EventReason.CHANGED_PARTIES);
|
||||
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;
|
||||
}
|
||||
|
||||
partyInstance.removeFromParty(player, PP);
|
||||
partyManagerInstance.removeFromParty(playerName, party);
|
||||
}
|
||||
else {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY);
|
||||
@@ -160,58 +156,40 @@ public class PartyCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
partyInstance.addToParty(player, PP, args[0], false, null);
|
||||
partyManagerInstance.joinParty(player, playerProfile, args[0], null);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (!partyInstance.isParty(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PP.inParty()) {
|
||||
if (playerProfile.inParty()) {
|
||||
if (args[0].equalsIgnoreCase("password")) {
|
||||
if (isLeader) {
|
||||
if (!partyInstance.isPartyLocked(partyName)) {
|
||||
partyInstance.lockParty(partyName);
|
||||
}
|
||||
|
||||
partyInstance.setPartyPassword(partyName, args[1]);
|
||||
player.sendMessage(LocaleLoader.getString("Party.PasswordSet", new Object[] { args[1] }));
|
||||
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 (isLeader) {
|
||||
Player target = plugin.getServer().getPlayer(args[1]);
|
||||
|
||||
if (target == null) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
if (!party.getMembers().contains(args[1])) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]}));
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerProfile PPt = Users.getProfile(target);
|
||||
String targetName = target.getName();
|
||||
|
||||
if (!partyInstance.inSameParty(player, (Player) target)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { targetName }));
|
||||
return true;
|
||||
}
|
||||
|
||||
else {
|
||||
String partyName = party.getName();
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, null, EventReason.KICKED_FROM_PARTY);
|
||||
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
partyInstance.removeFromParty(target, PPt);
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Kick", new Object[] { partyName }));
|
||||
partyManagerInstance.removeFromParty(args[1], party);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -219,39 +197,26 @@ public class PartyCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("owner")) {
|
||||
if (isLeader) {
|
||||
Player target = plugin.getServer().getPlayer(args[1]);
|
||||
|
||||
if (target == null) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
if (!party.getMembers().contains(args[1])) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]}));
|
||||
return true;
|
||||
}
|
||||
|
||||
String targetName = target.getName();
|
||||
|
||||
if (!partyInstance.inSameParty(player, (Player) target)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { targetName }));
|
||||
return true;
|
||||
}
|
||||
|
||||
else {
|
||||
partyInstance.setPartyLeader(partyName, targetName);
|
||||
partyManagerInstance.setPartyLeader(args[1], party);
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, args[0], EventReason.CHANGED_PARTIES);
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), args[0], EventReason.CHANGED_PARTIES);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
partyInstance.removeFromParty(player, PP);
|
||||
partyInstance.addToParty(player, PP, args[0], false, args[1]);
|
||||
partyManagerInstance.removeFromParty(playerName, party);
|
||||
partyManagerInstance.joinParty(player, playerProfile, args[0], args[1]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -262,7 +227,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
partyInstance.addToParty(player, PP, args[0], false, args[1]);
|
||||
partyManagerInstance.joinParty(player, playerProfile, args[0], args[1]);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -12,7 +12,7 @@ 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.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PtpCommand implements CommandExecutor {
|
||||
@@ -37,14 +37,9 @@ public class PtpCommand implements CommandExecutor {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (!Party.getInstance().isInParty(player, PP)) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PP.getRecentlyHurt() + (Config.getInstance().getPTPCommandCooldown() * 1000) > System.currentTimeMillis()) {
|
||||
if (profile.getRecentlyHurt() + (Config.getInstance().getPTPCommandCooldown() * 1000) > System.currentTimeMillis()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", new Object[] { Config.getInstance().getPTPCommandCooldown() }));
|
||||
return true;
|
||||
}
|
||||
@@ -57,7 +52,7 @@ public class PtpCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (target == null) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Invalid"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -66,8 +61,8 @@ public class PtpCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Party.getInstance().inSameParty(player, target)) {
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, PP.getParty());
|
||||
if (PartyManager.getInstance().inSameParty(player, target)) {
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, profile.getParty().getName());
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
|
||||
@@ -1,20 +1,10 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
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.commands.SkillCommand;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class AcrobaticsCommand implements CommandExecutor {
|
||||
private float skillValue;
|
||||
public class AcrobaticsCommand extends SkillCommand {
|
||||
private String dodgeChance;
|
||||
private String rollChance;
|
||||
private String gracefulRollChance;
|
||||
@@ -23,31 +13,48 @@ public class AcrobaticsCommand implements CommandExecutor {
|
||||
private boolean canRoll;
|
||||
private boolean canGracefulRoll;
|
||||
|
||||
public AcrobaticsCommand() {
|
||||
super(SkillType.ACROBATICS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
protected void dataCalculations() {
|
||||
if (skillValue >= 1000) {
|
||||
dodgeChance = "20.00%";
|
||||
rollChance = "100.00%";
|
||||
gracefulRollChance = "100.00%";
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.acrobatics")) {
|
||||
return true;
|
||||
else if (skillValue >= 800) {
|
||||
dodgeChance = "20.00%";
|
||||
rollChance = percent.format(skillValue / 1000);
|
||||
gracefulRollChance = "100.00%";
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
skillValue = (float) PP.getSkillLevel(SkillType.ACROBATICS);
|
||||
dataCalculations(skillValue);
|
||||
permissionsCheck(player);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Acrobatics.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Acrobatics") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) }));
|
||||
|
||||
if (canDodge || canGracefulRoll || canRoll) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
else if (skillValue >= 500) {
|
||||
dodgeChance = percent.format(skillValue / 4000);
|
||||
rollChance = percent.format(skillValue / 1000);
|
||||
gracefulRollChance = "100.00%";
|
||||
}
|
||||
else {
|
||||
dodgeChance = percent.format(skillValue / 4000);
|
||||
rollChance = percent.format(skillValue / 1000);
|
||||
gracefulRollChance = percent.format(skillValue / 500);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canDodge = permInstance.dodge(player);
|
||||
canRoll = permInstance.roll(player);
|
||||
canGracefulRoll = permInstance.gracefulRoll(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canDodge || canGracefulRoll || canRoll;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (canRoll) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1") }));
|
||||
}
|
||||
@@ -59,11 +66,15 @@ public class AcrobaticsCommand implements CommandExecutor {
|
||||
if (canDodge) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.4"), LocaleLoader.getString("Acrobatics.Effect.5") }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canDodge || canGracefulRoll || canRoll) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
}
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canDodge || canGracefulRoll || canRoll;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canRoll) {
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", new Object[] { rollChance }));
|
||||
}
|
||||
@@ -75,39 +86,5 @@ public class AcrobaticsCommand implements CommandExecutor {
|
||||
if (canDodge) {
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance }));
|
||||
}
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.ACROBATICS, player, args);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void dataCalculations(float skillValue) {
|
||||
if (skillValue >= 1000) {
|
||||
dodgeChance = "20";
|
||||
rollChance = "100";
|
||||
gracefulRollChance = "100";
|
||||
}
|
||||
else if (skillValue >= 800) {
|
||||
dodgeChance = "20";
|
||||
rollChance = String.valueOf(skillValue / 10);
|
||||
gracefulRollChance = "100";
|
||||
}
|
||||
else if (skillValue >= 500) {
|
||||
dodgeChance = String.valueOf(skillValue / 40);
|
||||
rollChance = String.valueOf(skillValue / 10);
|
||||
gracefulRollChance = "100";
|
||||
}
|
||||
else {
|
||||
dodgeChance = String.valueOf(skillValue / 40);
|
||||
rollChance = String.valueOf(skillValue / 10);
|
||||
gracefulRollChance = String.valueOf(skillValue / 5);
|
||||
}
|
||||
}
|
||||
|
||||
private void permissionsCheck(Player player) {
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
canDodge = permInstance.dodge(player);
|
||||
canRoll = permInstance.roll(player);
|
||||
canGracefulRoll = permInstance.gracefulRoll(player);
|
||||
}
|
||||
}
|
||||
@@ -1,68 +1,80 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
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.commands.SkillCommand;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class ArcheryCommand implements CommandExecutor {
|
||||
private float skillValue;
|
||||
public class ArcheryCommand extends SkillCommand {
|
||||
private String skillShotBonus;
|
||||
private String dazeChance;
|
||||
private String retrieveChance;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
private boolean canSkillShot;
|
||||
private boolean canDaze;
|
||||
private boolean canRetrieve;
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.archery")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
skillValue = (float) PP.getSkillLevel(SkillType.ARCHERY);
|
||||
dataCalculations(skillValue);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Archery.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Archery") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5") }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", new Object[] { skillShotBonus }));
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", new Object[] { dazeChance }));
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance }));
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.ARCHERY, player, args);
|
||||
|
||||
return true;
|
||||
public ArcheryCommand() {
|
||||
super(SkillType.ARCHERY);
|
||||
}
|
||||
|
||||
private void dataCalculations(float skillValue) {
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
if (skillValue >= 1000) {
|
||||
skillShotBonus = "200";
|
||||
dazeChance = "50";
|
||||
retrieveChance = "100";
|
||||
skillShotBonus = "200.00%";
|
||||
dazeChance = "50.00%";
|
||||
retrieveChance = "100.00%";
|
||||
}
|
||||
else {
|
||||
skillShotBonus = String.valueOf((int) skillValue / 5);
|
||||
dazeChance = String.valueOf(skillValue / 20);
|
||||
retrieveChance = String.valueOf(skillValue / 10);
|
||||
skillShotBonus = percent.format(((int) skillValue / 50) * 0.1D); //TODO: Not sure if this is the best way to calculate this or not...
|
||||
dazeChance = percent.format(skillValue / 2000);
|
||||
retrieveChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canSkillShot = permInstance.archeryBonus(player);
|
||||
canDaze = permInstance.daze(player);
|
||||
canRetrieve = permInstance.trackArrows(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canSkillShot || canDaze || canRetrieve;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (canSkillShot) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canDaze) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canRetrieve) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5") }));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canSkillShot || canDaze || canRetrieve;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canSkillShot) {
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", new Object[] { skillShotBonus }));
|
||||
}
|
||||
|
||||
if (canDaze) {
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", new Object[] { dazeChance }));
|
||||
}
|
||||
|
||||
if (canRetrieve) {
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,84 +1,108 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
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.commands.SkillCommand;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class AxesCommand implements CommandExecutor {
|
||||
private float skillValue;
|
||||
public class AxesCommand extends SkillCommand {
|
||||
private String critChance;
|
||||
private String bonusDamage;
|
||||
private String impactDamage;
|
||||
private String greaterImpactDamage;
|
||||
private String skullSplitterLength;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
private boolean canSkullSplitter;
|
||||
private boolean canCritical;
|
||||
private boolean canBonusDamage;
|
||||
private boolean canImpact;
|
||||
private boolean canGreaterImpact;
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.axes")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
skillValue = (float) PP.getSkillLevel(SkillType.AXES);
|
||||
dataCalculations(skillValue);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Axes.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Axes") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.0"), LocaleLoader.getString("Axes.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.2"), LocaleLoader.getString("Axes.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.4"), LocaleLoader.getString("Axes.Effect.5") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.6"), LocaleLoader.getString("Axes.Effect.7") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.8"), LocaleLoader.getString("Axes.Effect.9") }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", new Object[] { critChance }));
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", new Object[] {bonusDamage}) }));
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", new Object[] {impactDamage}) }));
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", new Object[] {greaterImpactDamage}) }));
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", new Object[] { skullSplitterLength }));
|
||||
|
||||
return true;
|
||||
public AxesCommand() {
|
||||
super(SkillType.AXES);
|
||||
}
|
||||
|
||||
private void dataCalculations(float skillValue) {
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
impactDamage = String.valueOf(5 + ((int) skillValue / 30));
|
||||
skullSplitterLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||
greaterImpactDamage = "2";
|
||||
|
||||
if (skillValue >= 1000) {
|
||||
critChance = "37.5";
|
||||
if (skillValue >= 750) {
|
||||
critChance = "37.50";
|
||||
bonusDamage = "4";
|
||||
greaterImpactDamage = "2";
|
||||
}
|
||||
else if (skillValue >= 750) {
|
||||
critChance = "37.5";
|
||||
bonusDamage = "4";
|
||||
greaterImpactDamage = "2";
|
||||
}
|
||||
else if (skillValue >= 200) {
|
||||
critChance = String.valueOf(skillValue / 20);
|
||||
critChance = percent.format(skillValue / 2000);
|
||||
bonusDamage = "4";
|
||||
greaterImpactDamage = "2";
|
||||
}
|
||||
else {
|
||||
critChance = String.valueOf(skillValue / 20);
|
||||
critChance = percent.format(skillValue / 2000);
|
||||
bonusDamage = String.valueOf((int) skillValue / 50);
|
||||
greaterImpactDamage = "2";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canSkullSplitter = permInstance.skullSplitter(player);
|
||||
canCritical = permInstance.criticalHit(player);
|
||||
canBonusDamage = permInstance.axeBonus(player);
|
||||
canImpact = permInstance.impact(player);
|
||||
canGreaterImpact = permInstance.greaterImpact(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
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) {
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", new Object[] { critChance }));
|
||||
}
|
||||
|
||||
if (canSkullSplitter) {
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", new Object[] { skullSplitterLength }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,54 +1,55 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
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.commands.SkillCommand;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class ExcavationCommand implements CommandExecutor {
|
||||
private float skillValue;
|
||||
public class ExcavationCommand extends SkillCommand {
|
||||
private String gigaDrillBreakerLength;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
private boolean canGigaDrill;
|
||||
private boolean canTreasureHunt;
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.excavation")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
skillValue = (float) PP.getSkillLevel(SkillType.EXCAVATION);
|
||||
dataCalculations(skillValue);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Excavation.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Excavation") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Excavation.Effect.0"), LocaleLoader.getString("Excavation.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3") }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", new Object[] { gigaDrillBreakerLength }));
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.EXCAVATION, player, args);
|
||||
|
||||
return true;
|
||||
public ExcavationCommand() {
|
||||
super(SkillType.EXCAVATION);
|
||||
}
|
||||
|
||||
private void dataCalculations(float skillValue) {
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
gigaDrillBreakerLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canGigaDrill = permInstance.gigaDrillBreaker(player);
|
||||
canTreasureHunt = permInstance.excavationTreasures(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canGigaDrill || canTreasureHunt;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
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) {
|
||||
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", new Object[] { gigaDrillBreakerLength }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,55 +1,78 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
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.commands.SkillCommand;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.Fishing;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.skills.gathering.Fishing;
|
||||
|
||||
public class FishingCommand extends SkillCommand {
|
||||
private int lootTier;
|
||||
private String magicChance;
|
||||
|
||||
private boolean canTreasureHunt;
|
||||
private boolean canMagicHunt;
|
||||
private boolean canShake;
|
||||
|
||||
public FishingCommand() {
|
||||
super(SkillType.FISHING);
|
||||
}
|
||||
|
||||
public class FishingCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
protected void dataCalculations() {
|
||||
lootTier = Fishing.getFishingLootTier(profile);
|
||||
magicChance = percent.format((float) lootTier / 15);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canTreasureHunt = permInstance.fishingTreasures(player);
|
||||
canMagicHunt = permInstance.fishingMagic(player);
|
||||
canShake = permInstance.shakeMob(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canTreasureHunt || canMagicHunt || canShake;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1") }));
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.fishing")) {
|
||||
return true;
|
||||
if (canMagicHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3") }));
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Fishing.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Fishing") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5") }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", new Object[] { Fishing.getFishingLootTier(PP) }));
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Info"));
|
||||
|
||||
//TODO: Do we really need to display this twice? Not like there are any associated stats.
|
||||
if (PP.getSkillLevel(SkillType.FISHING) < 150) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Fishing.Ability.Locked.0") }));
|
||||
if (canShake) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canTreasureHunt || canMagicHunt || canShake;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", new Object[] { lootTier }));
|
||||
}
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.FISHING, player, args);
|
||||
if (canMagicHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", new Object[] { magicChance }));
|
||||
}
|
||||
|
||||
return true;
|
||||
if (canShake) {
|
||||
//TODO: Do we really need to display this twice? Not like there are any associated stats.
|
||||
if (skillValue < 150) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Fishing.Ability.Locked.0") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,108 +1,141 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
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.commands.SkillCommand;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class HerbalismCommand implements CommandExecutor {
|
||||
private float skillValue;
|
||||
public class HerbalismCommand extends SkillCommand {
|
||||
private String greenTerraLength;
|
||||
private String greenThumbChance;
|
||||
private String greenThumbStage;
|
||||
private String farmersDietRank;
|
||||
private String doubleDropChance;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
private boolean canGreenTerra;
|
||||
private boolean canGreenThumbWheat;
|
||||
private boolean canGreenThumbBlocks;
|
||||
private boolean canFarmersDiet;
|
||||
private boolean canDoubleDrop;
|
||||
private boolean doubleDropsDisabled;
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.herbalism")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
skillValue = (float) PP.getSkillLevel(SkillType.HERBALISM);
|
||||
dataCalculations(skillValue);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Herbalism.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Herbalism") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.4"), LocaleLoader.getString("Herbalism.Effect.5") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.6"), LocaleLoader.getString("Herbalism.Effect.7") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9") }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", new Object[] { greenTerraLength }));
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", new Object[] { greenThumbChance }));
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", new Object[] { greenThumbStage }));
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.FD", new Object[] { farmersDietRank } ));
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", new Object[] { doubleDropChance }));
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.HERBALISM, player, args);
|
||||
|
||||
return true;
|
||||
public HerbalismCommand() {
|
||||
super(SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
private void dataCalculations(float skillValue) {
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
greenTerraLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||
|
||||
if (skillValue >= 1500) {
|
||||
greenThumbChance = "100";
|
||||
greenThumbChance = "100.00%";
|
||||
greenThumbStage = "4";
|
||||
farmersDietRank = "5";
|
||||
doubleDropChance = "100";
|
||||
doubleDropChance = "100.00%";
|
||||
}
|
||||
else if (skillValue >= 1000) {
|
||||
greenThumbChance = String.valueOf(skillValue / 15);
|
||||
greenThumbChance = percent.format(skillValue / 1500);
|
||||
greenThumbStage = "4";
|
||||
farmersDietRank = "5";
|
||||
doubleDropChance = "100";
|
||||
doubleDropChance = "100.00%";
|
||||
}
|
||||
else if (skillValue >= 800) {
|
||||
greenThumbChance = String.valueOf(skillValue / 15);
|
||||
greenThumbChance = percent.format(skillValue / 1500);
|
||||
greenThumbStage = "4";
|
||||
farmersDietRank = "4";
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else if (skillValue >= 600) {
|
||||
greenThumbChance = String.valueOf(skillValue / 15);
|
||||
greenThumbChance = percent.format(skillValue / 1500);
|
||||
greenThumbStage = "4";
|
||||
farmersDietRank = "3";
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else if (skillValue >= 400) {
|
||||
greenThumbChance = String.valueOf(skillValue / 15);
|
||||
greenThumbChance = percent.format(skillValue / 1500);
|
||||
greenThumbStage = "3";
|
||||
farmersDietRank = "2";
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else if (skillValue >= 200) {
|
||||
greenThumbChance = String.valueOf(skillValue / 15);
|
||||
greenThumbChance = percent.format(skillValue / 1500);
|
||||
greenThumbStage = "2";
|
||||
farmersDietRank = "1";
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else {
|
||||
greenThumbChance = String.valueOf(skillValue / 15);
|
||||
greenThumbChance = percent.format(skillValue / 1500);
|
||||
greenThumbStage = "1";
|
||||
farmersDietRank = "1";
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
canGreenTerra = permInstance.greenTerra(player);
|
||||
canGreenThumbWheat = permInstance.greenThumbWheat(player);
|
||||
canGreenThumbBlocks = permInstance.greenThumbBlocks(player);
|
||||
canFarmersDiet = permInstance.farmersDiet(player);
|
||||
canDoubleDrop = permInstance.herbalismDoubleDrops(player);
|
||||
doubleDropsDisabled = configInstance.herbalismDoubleDropsDisabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (canGreenTerra) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canGreenThumbWheat) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canGreenThumbBlocks) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.4"), LocaleLoader.getString("Herbalism.Effect.5") }));
|
||||
}
|
||||
|
||||
if (canFarmersDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.6"), LocaleLoader.getString("Herbalism.Effect.7") }));
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9") }));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canGreenTerra) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", new Object[] { greenTerraLength }));
|
||||
}
|
||||
|
||||
if (canGreenThumbBlocks || canGreenThumbWheat) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", new Object[] { greenThumbChance }));
|
||||
}
|
||||
|
||||
if (canGreenThumbWheat) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", new Object[] { greenThumbStage }));
|
||||
}
|
||||
|
||||
if (canFarmersDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.FD", new Object[] { farmersDietRank } ));
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", new Object[] { doubleDropChance }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,138 +1,169 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
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.commands.SkillCommand;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class MiningCommand implements CommandExecutor {
|
||||
private float skillValue;
|
||||
public class MiningCommand extends SkillCommand {
|
||||
private String doubleDropChance;
|
||||
private String superBreakerLength;
|
||||
private int blastMiningRank;
|
||||
private int blastRadiusIncrease;
|
||||
private int blastDamageDecrease;
|
||||
private String blastMiningRank;
|
||||
private String blastRadiusIncrease;
|
||||
private String blastDamageDecrease;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
private boolean canSuperBreaker;
|
||||
private boolean canDoubleDrop;
|
||||
private boolean canBlast;
|
||||
private boolean canBiggerBombs;
|
||||
private boolean canDemoExpert;
|
||||
private boolean doubleDropsDisabled;
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.mining")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
skillValue = (float) PP.getSkillLevel(SkillType.MINING);
|
||||
dataCalculations(skillValue);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Mining.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Mining") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.0"), LocaleLoader.getString("Mining.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.2"), LocaleLoader.getString("Mining.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.4"), LocaleLoader.getString("Mining.Effect.5") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.6"), LocaleLoader.getString("Mining.Effect.7") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.8"), LocaleLoader.getString("Mining.Effect.9") }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", new Object[] { doubleDropChance }));
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", new Object[] { superBreakerLength }));
|
||||
|
||||
if (PP.getSkillLevel(SkillType.MINING) < 125) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.0") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", new Object[] { blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect." + (blastMiningRank - 1)) }));
|
||||
}
|
||||
|
||||
if (PP.getSkillLevel(SkillType.MINING) < 250) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.1") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Radius.Increase", new Object[] { blastRadiusIncrease }));
|
||||
}
|
||||
|
||||
if (PP.getSkillLevel(SkillType.MINING) < 500) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.2") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Effect.Decrease", new Object[] { blastDamageDecrease }));
|
||||
}
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.MINING, player, args);
|
||||
|
||||
return true;
|
||||
public MiningCommand() {
|
||||
super(SkillType.MINING);
|
||||
}
|
||||
|
||||
private void dataCalculations(float skillValue) {
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
superBreakerLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||
|
||||
if (skillValue >= 1000) {
|
||||
blastMiningRank = 8;
|
||||
blastDamageDecrease = 100;
|
||||
blastRadiusIncrease = 4;
|
||||
doubleDropChance = "100";
|
||||
blastMiningRank = "8";
|
||||
blastDamageDecrease = "100.00%";
|
||||
blastRadiusIncrease = "4";
|
||||
doubleDropChance = "100.00%";
|
||||
}
|
||||
else if (skillValue >= 875) {
|
||||
blastMiningRank = 7;
|
||||
blastDamageDecrease = 50;
|
||||
blastRadiusIncrease = 3;
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
blastMiningRank = "7";
|
||||
blastDamageDecrease = "50.00%";
|
||||
blastRadiusIncrease = "3";
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else if (skillValue >= 750) {
|
||||
blastMiningRank = 6;
|
||||
blastDamageDecrease = 50;
|
||||
blastRadiusIncrease = 3;
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
blastMiningRank = "6";
|
||||
blastDamageDecrease = "50.00%";
|
||||
blastRadiusIncrease = "3";
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else if (skillValue >= 625) {
|
||||
blastMiningRank = 5;
|
||||
blastDamageDecrease = 25;
|
||||
blastRadiusIncrease = 2;
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
blastMiningRank = "5";
|
||||
blastDamageDecrease = "25.00%";
|
||||
blastRadiusIncrease = "2";
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else if (skillValue >= 500) {
|
||||
blastMiningRank = 4;
|
||||
blastDamageDecrease = 25;
|
||||
blastRadiusIncrease = 2;
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
blastMiningRank = "4";
|
||||
blastDamageDecrease = "25.00%";
|
||||
blastRadiusIncrease = "2";
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else if (skillValue >= 375) {
|
||||
blastMiningRank = 3;
|
||||
blastDamageDecrease = 0;
|
||||
blastRadiusIncrease = 1;
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
blastMiningRank = "3";
|
||||
blastDamageDecrease = "0.00%";
|
||||
blastRadiusIncrease = "1";
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else if (skillValue >= 250) {
|
||||
blastMiningRank = 2;
|
||||
blastDamageDecrease = 0;
|
||||
blastRadiusIncrease = 1;
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
blastMiningRank = "2";
|
||||
blastDamageDecrease = "0.00%";
|
||||
blastRadiusIncrease = "1";
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else if (skillValue >= 125) {
|
||||
blastMiningRank = 1;
|
||||
blastDamageDecrease = 0;
|
||||
blastRadiusIncrease = 0;
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
blastMiningRank = "1";
|
||||
blastDamageDecrease = "0.00%";
|
||||
blastRadiusIncrease = "0";
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
else {
|
||||
blastMiningRank = 0;
|
||||
blastDamageDecrease = 0;
|
||||
blastRadiusIncrease = 0;
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
blastMiningRank = "0";
|
||||
blastDamageDecrease = "0.00%";
|
||||
blastRadiusIncrease = "0";
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
canBiggerBombs = permInstance.biggerBombs(player);
|
||||
canBlast = permInstance.blastMining(player);
|
||||
canDemoExpert = permInstance.demolitionsExpertise(player);
|
||||
canDoubleDrop = permInstance.miningDoubleDrops(player);
|
||||
canSuperBreaker = permInstance.superBreaker(player);
|
||||
doubleDropsDisabled = configInstance.miningDoubleDropsDisabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled) || canSuperBreaker;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
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) {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", new Object[] { doubleDropChance }));
|
||||
}
|
||||
|
||||
if (canSuperBreaker) {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", new Object[] { superBreakerLength }));
|
||||
}
|
||||
|
||||
if (canBlast) {
|
||||
if (skillValue < 125) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.0") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", new Object[] { blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect." + (Misc.getInt(blastMiningRank) - 1)) }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canBiggerBombs) {
|
||||
if (skillValue < 250) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.1") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Radius.Increase", new Object[] { blastRadiusIncrease }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canDemoExpert) {
|
||||
if (skillValue < 500) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.2") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Effect.Decrease", new Object[] { blastDamageDecrease }));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,73 +1,142 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
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.mcMMO;
|
||||
import com.gmail.nossr50.commands.SkillCommand;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.Repair;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
|
||||
public class RepairCommand implements CommandExecutor {
|
||||
private float skillValue;
|
||||
public class RepairCommand extends SkillCommand {
|
||||
private int arcaneForgingRank;
|
||||
private String repairMasteryBonus;
|
||||
private String superRepairChance;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
private boolean canSuperRepair;
|
||||
private boolean canMasterRepair;
|
||||
private boolean canArcaneForge;
|
||||
private boolean canRepairStone;
|
||||
private boolean canRepairIron;
|
||||
private boolean canRepairGold;
|
||||
private boolean canRepairDiamond;
|
||||
private boolean canRepairString;
|
||||
private boolean canRepairLeather;
|
||||
private boolean canRepairWood;
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.repair")) {
|
||||
return true;
|
||||
}
|
||||
private int diamondLevel;
|
||||
private int goldLevel;
|
||||
private int ironLevel;
|
||||
private int stoneLevel;
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
skillValue = (float) PP.getSkillLevel(SkillType.REPAIR);
|
||||
dataCalculations(skillValue);
|
||||
|
||||
int arcaneForgingRank = Repair.getArcaneForgingRank(PP);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Repair.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Repair") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.6", new Object[] { Config.getInstance().getRepairDiamondLevelRequirement() }), LocaleLoader.getString("Repair.Effect.7") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9") }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", new Object[] { repairMasteryBonus }));
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", new Object[] { superRepairChance }));
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", new Object[] { arcaneForgingRank }));
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", new Object[] { Repair.getEnchantChance(arcaneForgingRank) }));
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", new Object[] { Repair.getDowngradeChance(arcaneForgingRank) }));
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.REPAIR, player, args);
|
||||
|
||||
return true;
|
||||
public RepairCommand() {
|
||||
super(SkillType.REPAIR);
|
||||
}
|
||||
|
||||
private void dataCalculations(float skillValue) {
|
||||
repairMasteryBonus = String.valueOf(skillValue / 5);
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
// We're using pickaxes here, not the best but it works
|
||||
Repairable diamondRepairable = mcMMO.repairManager.getRepairable(278);
|
||||
Repairable goldRepairable = mcMMO.repairManager.getRepairable(285);
|
||||
Repairable ironRepairable = mcMMO.repairManager.getRepairable(257);
|
||||
Repairable stoneRepairable = mcMMO.repairManager.getRepairable(274);
|
||||
|
||||
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
|
||||
goldLevel = (goldRepairable == null) ? 0 : goldRepairable.getMinimumLevel();
|
||||
ironLevel = (ironRepairable == null) ? 0 : ironRepairable.getMinimumLevel();
|
||||
stoneLevel = (stoneRepairable == null) ? 0 : stoneRepairable.getMinimumLevel();
|
||||
|
||||
repairMasteryBonus = percent.format(skillValue / 500);
|
||||
|
||||
if (skillValue >= 1000) {
|
||||
superRepairChance = "100";
|
||||
superRepairChance = "100.00%";
|
||||
}
|
||||
else {
|
||||
superRepairChance = String.valueOf(skillValue / 10);
|
||||
superRepairChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
|
||||
arcaneForgingRank = Repair.getArcaneForgingRank(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canSuperRepair = permInstance.repairBonus(player);
|
||||
canMasterRepair = permInstance.repairMastery(player);
|
||||
canArcaneForge = permInstance.arcaneForging(player);
|
||||
canRepairDiamond = permInstance.diamondRepair(player);
|
||||
canRepairGold = permInstance.goldRepair(player);
|
||||
canRepairIron = permInstance.ironRepair(player);
|
||||
canRepairStone = permInstance.stoneRepair(player);
|
||||
canRepairString = permInstance.stringRepair(player);
|
||||
canRepairLeather = permInstance.leatherRepair(player);
|
||||
canRepairWood = permInstance.woodRepair(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canArcaneForge || canRepairDiamond || canRepairGold || canRepairIron || canMasterRepair || canRepairStone || canSuperRepair || canRepairString || canRepairWood || canRepairLeather;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1") }));
|
||||
|
||||
if (canMasterRepair) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canSuperRepair) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5") }));
|
||||
}
|
||||
|
||||
/* Repair Level Requirements */
|
||||
|
||||
if (canRepairStone && stoneLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.14", new Object[] { stoneLevel }), LocaleLoader.getString("Repair.Effect.15") }));
|
||||
}
|
||||
|
||||
if (canRepairIron && ironLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.12", new Object[] { ironLevel }), LocaleLoader.getString("Repair.Effect.13") }));
|
||||
}
|
||||
|
||||
if (canRepairGold && goldLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.10", new Object[] { goldLevel }), LocaleLoader.getString("Repair.Effect.11") }));
|
||||
}
|
||||
|
||||
if (canRepairDiamond && diamondLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.6", new Object[] { diamondLevel }), LocaleLoader.getString("Repair.Effect.7") }));
|
||||
}
|
||||
|
||||
if (canArcaneForge) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9") }));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canArcaneForge || canMasterRepair || canSuperRepair;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canMasterRepair) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", new Object[] { repairMasteryBonus }));
|
||||
}
|
||||
|
||||
if (canSuperRepair) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", new Object[] { superRepairChance }));
|
||||
}
|
||||
|
||||
if (canArcaneForge) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", new Object[] { arcaneForgingRank }));
|
||||
|
||||
if (Config.getInstance().getArcaneForgingEnchantLossEnabled()) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", new Object[] { Repair.getEnchantChance(arcaneForgingRank) }));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getArcaneForgingDowngradeEnabled()) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", new Object[] { Repair.getDowngradeChance(arcaneForgingRank) }));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,79 +1,91 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
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.commands.SkillCommand;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SwordsCommand implements CommandExecutor {
|
||||
private float skillValue;
|
||||
public class SwordsCommand extends SkillCommand {
|
||||
private String counterAttackChance;
|
||||
private String bleedLength;
|
||||
private String bleedChance;
|
||||
private String serratedStrikesLength;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
private boolean canCounter;
|
||||
private boolean canSerratedStrike;
|
||||
private boolean canBleed;
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.swords")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
skillValue = (float) PP.getSkillLevel(SkillType.SWORDS);
|
||||
dataCalculations(skillValue);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Swords.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Swords") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.0"), LocaleLoader.getString("Swords.Effect.1") }));
|
||||
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") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.6"), LocaleLoader.getString("Swords.Effect.7") }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", new Object[] { counterAttackChance }));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", new Object[] { bleedLength }));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", new Object[] { bleedChance }));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", new Object[] { serratedStrikesLength }));
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.SWORDS, player, args);
|
||||
|
||||
return true;
|
||||
public SwordsCommand() {
|
||||
super(SkillType.SWORDS);
|
||||
}
|
||||
|
||||
private void dataCalculations(float skillValue) {
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
serratedStrikesLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||
|
||||
if (skillValue >= 750) {
|
||||
bleedLength = "3";
|
||||
bleedChance = "75";
|
||||
counterAttackChance = "30";
|
||||
bleedChance = "75.00%";
|
||||
counterAttackChance = "30.00%";
|
||||
}
|
||||
else if (skillValue >= 600) {
|
||||
bleedLength = "2";
|
||||
bleedChance = String.valueOf(skillValue / 10);
|
||||
counterAttackChance = "30";
|
||||
bleedChance = percent.format(skillValue / 1000);
|
||||
counterAttackChance = "30.00%";
|
||||
}
|
||||
else {
|
||||
bleedLength = "2";
|
||||
bleedChance = String.valueOf(skillValue / 10);
|
||||
counterAttackChance = String.valueOf(skillValue / 20);
|
||||
bleedChance = percent.format(skillValue / 1000);
|
||||
counterAttackChance = percent.format(skillValue / 2000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canBleed = permInstance.swordsBleed(player);
|
||||
canCounter = permInstance.counterAttack(player);
|
||||
canSerratedStrike = permInstance.serratedStrikes(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canBleed || canCounter || canSerratedStrike;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (canCounter) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.0"), LocaleLoader.getString("Swords.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canSerratedStrike) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.2"), LocaleLoader.getString("Swords.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.4"), LocaleLoader.getString("Swords.Effect.5") }));
|
||||
}
|
||||
|
||||
if (canBleed) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.6"), LocaleLoader.getString("Swords.Effect.7") }));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canBleed || canCounter || canSerratedStrike;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canCounter) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", new Object[] { counterAttackChance }));
|
||||
}
|
||||
|
||||
if (canBleed) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", new Object[] { bleedLength }));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", new Object[] { bleedChance }));
|
||||
}
|
||||
|
||||
if (canSerratedStrike) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", new Object[] { serratedStrikesLength }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,104 +1,145 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
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.commands.SkillCommand;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class TamingCommand implements CommandExecutor {
|
||||
private float skillValue;
|
||||
public class TamingCommand extends SkillCommand {
|
||||
private String goreChance;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
private boolean canBeastLore;
|
||||
private boolean canGore;
|
||||
private boolean canSharpenedClaws;
|
||||
private boolean canEnvironmentallyAware;
|
||||
private boolean canThickFur;
|
||||
private boolean canShockProof;
|
||||
private boolean canCallWild;
|
||||
private boolean canFastFood;
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.taming")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
skillValue = (float) PP.getSkillLevel(SkillType.TAMING);
|
||||
dataCalculations(skillValue);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Taming.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Taming") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.2"), LocaleLoader.getString("Taming.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.4"), LocaleLoader.getString("Taming.Effect.5") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.6"), LocaleLoader.getString("Taming.Effect.7") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.8"), LocaleLoader.getString("Taming.Effect.9") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.10"), LocaleLoader.getString("Taming.Effect.11") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17") }));
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", new Object[] { Config.getInstance().getTamingCOTWOcelotCost() }));
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Effect.15", new Object[] { Config.getInstance().getTamingCOTWWolfCost() }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
|
||||
if (PP.getSkillLevel(SkillType.TAMING) < 100) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.0") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1") }));
|
||||
}
|
||||
|
||||
if (PP.getSkillLevel(SkillType.TAMING) < 250) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.1") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3") }));
|
||||
}
|
||||
|
||||
if (PP.getSkillLevel(SkillType.TAMING) < 500) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.2") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5") }));
|
||||
}
|
||||
|
||||
if (PP.getSkillLevel(SkillType.TAMING) < 750) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.3") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7") }));
|
||||
}
|
||||
|
||||
if (PP.getSkillLevel(SkillType.TAMING) < 50) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.4") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9 ") }));
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", new Object[] { goreChance }));
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.TAMING, player, args);
|
||||
|
||||
return true;
|
||||
public TamingCommand() {
|
||||
super(SkillType.TAMING);
|
||||
}
|
||||
|
||||
private void dataCalculations(float skillValue) {
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
if (skillValue >= 1000) {
|
||||
goreChance = "100";
|
||||
goreChance = "100.00%";
|
||||
}
|
||||
else {
|
||||
goreChance = String.valueOf(skillValue / 10);
|
||||
goreChance = percent.format(skillValue / 1000);
|
||||
} }
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canBeastLore = permInstance.beastLore(player);
|
||||
canCallWild = permInstance.callOfTheWild(player);
|
||||
canEnvironmentallyAware = permInstance.environmentallyAware(player);
|
||||
canFastFood = permInstance.fastFoodService(player);
|
||||
canGore = permInstance.gore(player);
|
||||
canSharpenedClaws = permInstance.sharpenedClaws(player);
|
||||
canShockProof = permInstance.shockProof(player);
|
||||
canThickFur = permInstance.thickFur(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canBeastLore || canCallWild || canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
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 < 50) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.4") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9") }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canEnvironmentallyAware) {
|
||||
if (skillValue < 100) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.0") }));
|
||||
}
|
||||
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 < 250) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.1") }));
|
||||
}
|
||||
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 < 500) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.2") }));
|
||||
}
|
||||
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 < 750) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.3") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7") }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canGore) {
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", new Object[] { goreChance }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,78 +1,97 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
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.commands.SkillCommand;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class UnarmedCommand implements CommandExecutor {
|
||||
private float skillValue;
|
||||
public class UnarmedCommand extends SkillCommand {
|
||||
private String berserkLength;
|
||||
private String deflectChance;
|
||||
private String disarmChance;
|
||||
private String ironArmBonus;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
private boolean canBerserk;
|
||||
private boolean canDisarm;
|
||||
private boolean canBonusDamage;
|
||||
private boolean canDeflect;
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.unarmed")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
skillValue = (float) PP.getSkillLevel(SkillType.UNARMED);
|
||||
dataCalculations(skillValue);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Unarmed.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Unarmed") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.2"), LocaleLoader.getString("Unarmed.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.4"), LocaleLoader.getString("Unarmed.Effect.5") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7") }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", new Object[] {ironArmBonus}) }));
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", new Object[] { deflectChance }));
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", new Object[] { disarmChance }));
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", new Object[] { berserkLength }));
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.UNARMED, player, args);
|
||||
|
||||
return true;
|
||||
public UnarmedCommand() {
|
||||
super(SkillType.UNARMED);
|
||||
}
|
||||
|
||||
private void dataCalculations(float skillValue) {
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
berserkLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||
|
||||
if (skillValue >= 1000) {
|
||||
disarmChance = "33.3";
|
||||
deflectChance = "50";
|
||||
disarmChance = "33.33%";
|
||||
deflectChance = "50.00%";
|
||||
ironArmBonus = "8";
|
||||
}
|
||||
else if (skillValue >= 250) {
|
||||
disarmChance = String.valueOf(skillValue / 30);
|
||||
deflectChance = String.valueOf(skillValue / 20);
|
||||
disarmChance = percent.format(skillValue / 3000);
|
||||
deflectChance = percent.format(skillValue / 2000);
|
||||
ironArmBonus = "8";
|
||||
}
|
||||
else {
|
||||
disarmChance = String.valueOf(skillValue / 30);
|
||||
deflectChance = String.valueOf(skillValue / 20);
|
||||
disarmChance = percent.format(skillValue / 3000);
|
||||
deflectChance = percent.format(skillValue / 2000);
|
||||
ironArmBonus = String.valueOf(3 + ((int) skillValue / 50));
|
||||
} }
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canBerserk = permInstance.berserk(player);
|
||||
canBonusDamage = permInstance.unarmedBonus(player);
|
||||
canDeflect = permInstance.deflect(player);
|
||||
canDisarm = permInstance.disarm(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canBerserk || canBonusDamage || canDeflect || canDisarm;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (canBerserk) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canDisarm) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.2"), LocaleLoader.getString("Unarmed.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canBonusDamage) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.4"), LocaleLoader.getString("Unarmed.Effect.5") }));
|
||||
}
|
||||
|
||||
if (canDeflect) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7") }));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canBerserk || canBonusDamage || canDeflect || canDisarm;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canBonusDamage) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", new Object[] {ironArmBonus}) }));
|
||||
}
|
||||
|
||||
if (canDeflect) {
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", new Object[] { deflectChance }));
|
||||
}
|
||||
|
||||
if (canDisarm) {
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", new Object[] { disarmChance }));
|
||||
}
|
||||
|
||||
if (canBerserk) {
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", new Object[] { berserkLength }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,72 +1,88 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
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.commands.SkillCommand;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class WoodcuttingCommand implements CommandExecutor {
|
||||
private float skillValue;
|
||||
public class WoodcuttingCommand extends SkillCommand {
|
||||
private String treeFellerLength;
|
||||
private String doubleDropChance;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
private boolean canTreeFell;
|
||||
private boolean canLeafBlow;
|
||||
private boolean canDoubleDrop;
|
||||
private boolean doubleDropsDisabled;
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.woodcutting")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
skillValue = (float) PP.getSkillLevel(SkillType.UNARMED);
|
||||
dataCalculations(skillValue);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("WoodCutting.SkillName") }));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.WoodCutting") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3") }));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5") }));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||
|
||||
if (PP.getSkillLevel(SkillType.WOODCUTTING) < 100) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Woodcutting.Ability.Locked.0") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1") }));
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }));
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }));
|
||||
|
||||
Page.grabGuidePageForSkill(SkillType.WOODCUTTING, player, args);
|
||||
|
||||
return true;
|
||||
public WoodcuttingCommand() {
|
||||
super(SkillType.WOODCUTTING);
|
||||
}
|
||||
|
||||
private void dataCalculations(float skillValue) {
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
treeFellerLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||
|
||||
if (skillValue >= 1000) {
|
||||
doubleDropChance = "100";
|
||||
doubleDropChance = "100.00%";
|
||||
}
|
||||
else {
|
||||
doubleDropChance = String.valueOf(skillValue / 10);
|
||||
doubleDropChance = percent.format(skillValue / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
canTreeFell = permInstance.treeFeller(player);
|
||||
canDoubleDrop = permInstance.woodcuttingDoubleDrops(player);
|
||||
canLeafBlow = permInstance.leafBlower(player);
|
||||
doubleDropsDisabled = configInstance.woodcuttingDoubleDropsDisabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return (canDoubleDrop && !doubleDropsDisabled) || canLeafBlow || canTreeFell;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
if (canTreeFell) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1") }));
|
||||
}
|
||||
|
||||
if (canLeafBlow) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3") }));
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5") }));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return (canDoubleDrop && !doubleDropsDisabled) || canLeafBlow || canTreeFell;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
//TODO: Remove? Basically duplicates the above.
|
||||
if (canLeafBlow) {
|
||||
if (skillValue < 100) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Woodcutting.Ability.Locked.0") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1") }));
|
||||
}
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }));
|
||||
}
|
||||
|
||||
if (canTreeFell) {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,21 +8,14 @@ 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.HUDType;
|
||||
import com.gmail.nossr50.datatypes.HUDmmo;
|
||||
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.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class MchudCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public MchudCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String usage = ChatColor.RED + "Proper usage is /mchud <hud-type>"; //TODO: Locale
|
||||
@@ -32,45 +25,37 @@ public class MchudCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Config.getInstance().spoutEnabled || !Config.getInstance().getSpoutXPBarEnabled()) {
|
||||
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:
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
HUDType hud;
|
||||
for (HudType hudType : HudType.values()) {
|
||||
if (hudType.toString().equalsIgnoreCase(args[0])) {
|
||||
playerProfile.setHudType(hudType);
|
||||
spoutHud.initializeXpBar();
|
||||
spoutHud.updateXpBar();
|
||||
|
||||
if (args[0].equalsIgnoreCase("disabled")) {
|
||||
hud = HUDType.DISABLED;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("standard")) {
|
||||
hud = HUDType.STANDARD;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("small")) {
|
||||
hud = HUDType.SMALL;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("retro")) {
|
||||
hud = HUDType.RETRO;
|
||||
}
|
||||
else {
|
||||
player.sendMessage(invalid);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (SpoutStuff.playerHUDs.containsKey(player)) {
|
||||
SpoutStuff.playerHUDs.get(player).resetHUD();
|
||||
SpoutStuff.playerHUDs.remove(player);
|
||||
PP.setHUDType(hud);
|
||||
SpoutStuff.playerHUDs.put(player, new HUDmmo(player, plugin));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMessage(invalid);
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
player.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,15 +6,17 @@ 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.skills.Skills;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
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 {
|
||||
@@ -26,51 +28,60 @@ public class XplockCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Config.getInstance().spoutEnabled || !Config.getInstance().getSpoutXPBarEnabled() || !Config.getInstance().getCommandXPLockEnabled()) {
|
||||
if (!mcMMO.spoutEnabled || !SpoutConfig.getInstance().getXPBarEnabled() || !Config.getInstance().getCommandXPLockEnabled()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
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 (PP.getXpBarLocked()) {
|
||||
PP.toggleXpBarLocked();
|
||||
if (spoutHud.getXpBarLocked()) {
|
||||
spoutHud.toggleXpBarLocked();
|
||||
player.sendMessage(LocaleLoader.getString("Commands.xplock.unlocked"));
|
||||
return true;
|
||||
}
|
||||
|
||||
SkillType lastGained = PP.getLastGained();
|
||||
SkillType lastGained = spoutHud.getLastGained();
|
||||
|
||||
if (lastGained != null) {
|
||||
PP.toggleXpBarLocked();
|
||||
PP.setSkillLock(lastGained);
|
||||
spoutHud.toggleXpBarLocked();
|
||||
spoutHud.setSkillLock(lastGained);
|
||||
player.sendMessage(LocaleLoader.getString("Commands.xplock.locked", new Object[] { Misc.getCapitalized(lastGained.toString()) }));
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
player.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (Skills.isSkill(args[0])) {
|
||||
if (Permissions.getInstance().permission(player, "mcmmo.skills." + args[0].toLowerCase())) {
|
||||
PP.setXpBarLocked(true);
|
||||
PP.setSkillLock(Skills.getSkillType(args[0]));
|
||||
SpoutStuff.updateXpBar(player);
|
||||
spoutHud.setXpBarLocked(true);
|
||||
spoutHud.setSkillLock(Skills.getSkillType(args[0]));
|
||||
spoutHud.updateXpBar();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.xplock.locked", new Object[] { Misc.getCapitalized(args[0]) }));
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
player.sendMessage(usage);
|
||||
return true;
|
||||
|
||||
@@ -1,20 +1,31 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.HUDType;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class Config extends ConfigLoader {
|
||||
public int xpGainMultiplier = 1;
|
||||
private static Config instance;
|
||||
public int xpGainMultiplier = 1;
|
||||
|
||||
private Config() {
|
||||
super("config.yml");
|
||||
xpGainMultiplier = getExperienceGainsGlobalMultiplier();
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static Config getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new Config(mcMMO.p);
|
||||
instance = new Config();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {}
|
||||
|
||||
/*
|
||||
* GENERAL SETTINGS
|
||||
*/
|
||||
@@ -33,7 +44,8 @@ public class Config extends ConfigLoader {
|
||||
public String getMySQLUserName() { return config.getString("MySQL.Database.User_Name", "UserName"); } //Really should be labeled under MySQL.User_Name instead...
|
||||
public int getMySQLServerPort() { return config.getInt("MySQL.Server.Port", 3306); }
|
||||
public String getMySQLServerName() { return config.getString("MySQL.Server.Address", "localhost"); }
|
||||
public String getMySQLUserPassword() {
|
||||
|
||||
public String getMySQLUserPassword() {
|
||||
if (config.getString("MySQL.Database.User_Password", null) != null) {
|
||||
return config.getString("MySQL.Database.User_Password", null);
|
||||
}
|
||||
@@ -42,6 +54,17 @@ public class Config extends ConfigLoader {
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 boolean getHardcoreVampirismEnabled() { return config.getBoolean("Hardcore.Vampirism", false); }
|
||||
|
||||
/* 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); }
|
||||
@@ -95,6 +118,16 @@ public class Config extends ConfigLoader {
|
||||
public int getAbilityCooldownSkullSplitter() { return config.getInt("Abilities.Cooldowns.Skull_Splitter", 240); }
|
||||
public int getAbilityCooldownBlastMining() { return config.getInt("Abilities.Cooldowns.Blast_Mining", 60); }
|
||||
|
||||
/* Max ticks */
|
||||
public int getAbilityMaxTicksGreenTerra() { return config.getInt("Abilities.Max_Seconds.Green_Terra", 0); }
|
||||
public int getAbilityMaxTicksSuperBreaker() { return config.getInt("Abilities.Max_Seconds.Super_Breaker", 0); }
|
||||
public int getAbilityMaxTicksGigaDrillBreaker() { return config.getInt("Abilities.Max_Seconds.Giga_Drill_Breaker", 0); }
|
||||
public int getAbilityMaxTicksTreeFeller() { return config.getInt("Abilities.Max_Seconds.Tree_Feller", 0); }
|
||||
public int getAbilityMaxTicksBerserk() { return config.getInt("Abilities.Max_Seconds.Berserk", 0); }
|
||||
public int getAbilityMaxTicksSerratedStrikes() { return config.getInt("Abilities.Max_Seconds.Serrated_Strikes", 0); }
|
||||
public int getAbilityMaxTicksSkullSplitter() { return config.getInt("Abilities.Max_Seconds.Skull_Splitter", 0); }
|
||||
public int getAbilityMaxTicksBlastMining() { return config.getInt("Abilities.Max_Seconds.Blast_Mining", 0); }
|
||||
|
||||
/* Thresholds */
|
||||
public int getTreeFellerThreshold() { return config.getInt("Abilities.Limits.Tree_Feller_Threshold", 500); }
|
||||
|
||||
@@ -130,14 +163,45 @@ public class Config extends ConfigLoader {
|
||||
public int getHerbalismXPNetherWart() { return config.getInt("Experience.Herbalism.Nether_Wart", 50); }
|
||||
public int getHerbalismXPLilyPads() { return config.getInt("Experience.Herbalism.Lily_Pads", 100); }
|
||||
public int getHerbalismXPVines() { return config.getInt("Experience.Herbalism.Vines", 10); }
|
||||
public boolean getHerbalismHungerBonusEnabled() { return config.getBoolean("Skills.Herbalism.Hunger_Bonus", true); }
|
||||
public boolean getHerbalismWheatRegrowth() { return config.getBoolean("Skills.Herbalism.Instant_Wheat_Regrowth", true); }
|
||||
|
||||
public boolean getHerbalismGreenThumbCobbleToMossy() { return config.getBoolean("Skills.Herbalism.Green_Thumb.Cobble_To_Mossy", true); }
|
||||
public boolean getHerbalismGreenThumbSmoothbrickToMossy() { return config.getBoolean("Skills.Herbalism.Green_Thumb.SmoothBrick_To_MossyBrick", true); }
|
||||
public boolean getHerbalismGreenThumbDirtToGrass() { return config.getBoolean("Skills.Herbalism.Green_Thumb.Dirt_To_Grass", true); }
|
||||
|
||||
public boolean getBrownMushroomsDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Brown_Mushrooms", true); }
|
||||
public boolean getCactiDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Cacti", true); }
|
||||
public boolean getWheatDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Wheat", true); }
|
||||
public boolean getMelonsDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Melons", true); }
|
||||
public boolean getNetherWartsDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Nether_Warts", true); }
|
||||
public boolean getPumpkinsDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Pumpkins", true); }
|
||||
public boolean getRedMushroomsDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Red_Mushrooms", true); }
|
||||
public boolean getRedRosesDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Red_Roses", true); }
|
||||
public boolean getSugarCaneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Sugar_Cane", true); }
|
||||
public boolean getVinesDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Vines", true); }
|
||||
public boolean getWaterLiliesDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Water_Lilies", true); }
|
||||
public boolean getYellowFlowersDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Yellow_Flowers", true); }
|
||||
|
||||
public boolean herbalismDoubleDropsDisabled() {
|
||||
ConfigurationSection section = config.getConfigurationSection("Double_Drops.Herbalism");
|
||||
Set<String> keys = section.getKeys(false);
|
||||
Iterator<String> iterator = keys.iterator();
|
||||
|
||||
boolean disabled = true;
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String key = iterator.next();
|
||||
|
||||
if (config.getBoolean("Double_Drops.Herbalism." + key)) {
|
||||
disabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return disabled;
|
||||
}
|
||||
|
||||
/* Mining */
|
||||
public int getMiningXPGoldOre() { return config.getInt("Experience.Mining.Gold", 250); }
|
||||
public int getMiningXPGoldOre() { return config.getInt("Experience.Mining.Gold", 250); }
|
||||
public int getMiningXPDiamondOre() { return config.getInt("Experience.Mining.Diamond", 750); }
|
||||
public int getMiningXPIronOre() { return config.getInt("Experience.Mining.Iron", 250); }
|
||||
public int getMiningXPRedstoneOre() { return config.getInt("Experience.Mining.Redstone", 150); }
|
||||
@@ -150,29 +214,46 @@ public class Config extends ConfigLoader {
|
||||
public int getMiningXPSandstone() { return config.getInt("Experience.Mining.Sandstone", 30); }
|
||||
public int getMiningXPEndStone() { return config.getInt("Experience.Mining.End_Stone", 150); }
|
||||
public int getMiningXPMossyStone() { return config.getInt("Experience.Mining.Moss_Stone", 30); }
|
||||
|
||||
|
||||
public boolean getCoalDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Coal", true); }
|
||||
public boolean getDiamondDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Diamond", true); }
|
||||
public boolean getEndStoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.End_Stone", true); }
|
||||
public boolean getGlowstoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Glowstone", true); }
|
||||
public boolean getGoldDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Gold", true); }
|
||||
public boolean getIronDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Iron", true); }
|
||||
public boolean getLapisDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Lapis", true); }
|
||||
public boolean getMossyCobblestoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Moss_Stone", true); }
|
||||
public boolean getNetherrackDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Netherrack", true); }
|
||||
public boolean getObsidianDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Obsidian", true); }
|
||||
public boolean getRedstoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Redstone", true); }
|
||||
public boolean getSandstoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Sandstone", true); }
|
||||
public boolean getStoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Stone", true); }
|
||||
|
||||
public boolean miningDoubleDropsDisabled() {
|
||||
ConfigurationSection section = config.getConfigurationSection("Double_Drops.Mining");
|
||||
Set<String> keys = section.getKeys(false);
|
||||
Iterator<String> iterator = keys.iterator();
|
||||
|
||||
boolean disabled = true;
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String key = iterator.next();
|
||||
|
||||
if (config.getBoolean("Double_Drops.Mining." + key)) {
|
||||
disabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return disabled;
|
||||
}
|
||||
|
||||
public int getDetonatorItemID() { return config.getInt("Skills.Mining.Detonator_ID", 259); }
|
||||
|
||||
/* Repair */
|
||||
public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); }
|
||||
public int getRepairAnvilId() { return config.getInt("Skills.Repair.Anvil_ID", 42); }
|
||||
|
||||
public int getRepairGoldMaterial() { return config.getInt("Skills.Repair.Gold.ID", 266); }
|
||||
public int getRepairStoneMaterial() { return config.getInt("Skills.Repair.Stone.ID", 4); }
|
||||
public int getRepairWoodMaterial() { return config.getInt("Skills.Repair.Wood.ID", 5); }
|
||||
public int getRepairDiamondMaterial() { return config.getInt("Skills.Repair.Diamond.ID", 264); }
|
||||
public int getRepairIronMaterial() { return config.getInt("Skills.Repair.Iron.ID", 265); }
|
||||
public int getRepairStringMaterial() { return config.getInt("Skills.Repair.String.ID", 287); }
|
||||
public int getRepairLeatherMaterial() { return config.getInt("Skills.Repair.Leather.ID", 334); }
|
||||
|
||||
public boolean getRepairArmorAllowed() { return config.getBoolean("Skills.Repair.Can_Repair_Armor", true); }
|
||||
public boolean getRepairToolsAllowed() { return config.getBoolean("Skills.Repair.Can_Repair_Tools", true); }
|
||||
public int getRepairDiamondLevelRequirement() { return config.getInt("Skills.Repair.Diamond.Level_Required", 50); }
|
||||
public int getRepairIronLevelRequirement() { return config.getInt("Skills.Repair.Iron.Level_Required", 0); }
|
||||
public int getRepairGoldLevelRequirement() { return config.getInt("Skills.Repair.Gold.Level_Required", 0); }
|
||||
public int getRepairStoneLevelRequirement() { return config.getInt("Skills.Repair.Stone.Level_Required", 0); }
|
||||
public int getRepairStringLevelRequirement() { return config.getInt("Skills.Repair.String.Level_Required", 0); }
|
||||
|
||||
/* 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); }
|
||||
@@ -185,6 +266,30 @@ public class Config extends ConfigLoader {
|
||||
public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); }
|
||||
public int getWoodcuttingXPJungle() { return config.getInt("Experience.Woodcutting.Jungle", 100); }
|
||||
|
||||
public boolean getOakDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Oak", true); }
|
||||
public boolean getBirchDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Birch", true); }
|
||||
public boolean getSpruceDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Spruce", true); }
|
||||
public boolean getJungleDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Jungle", true); }
|
||||
|
||||
public boolean woodcuttingDoubleDropsDisabled() {
|
||||
ConfigurationSection section = config.getConfigurationSection("Double_Drops.Woodcutting");
|
||||
Set<String> keys = section.getKeys(false);
|
||||
Iterator<String> iterator = keys.iterator();
|
||||
|
||||
boolean disabled = true;
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String key = iterator.next();
|
||||
|
||||
if (config.getBoolean("Double_Drops.Woodcutting." + key)) {
|
||||
disabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return disabled;
|
||||
}
|
||||
|
||||
/* Arcane Forging */
|
||||
public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Arcane_Forging.Downgrades.Enabled", true); }
|
||||
public int getArcaneForgingDowngradeChanceRank1() { return config.getInt("Arcane_Forging.Downgrades.Chance.Rank_1", 75); }
|
||||
@@ -216,6 +321,20 @@ public class Config extends ConfigLoader {
|
||||
public int getLevelCapWoodcutting() { return config.getInt("Skills.Woodcutting.Level_Cap", 0); }
|
||||
public int getPowerLevelCap() { return config.getInt("General.Power_Level_Cap", 0); }
|
||||
|
||||
/* PVP & PVE Settings */
|
||||
public boolean getAcrobaticsPVP() { return config.getBoolean("Skills.Acrobatics.Enabled_For_PVP", true); }
|
||||
public boolean getAcrobaticsPVE() { return config.getBoolean("Skills.Acrobatics.Enabled_For_PVE", true); }
|
||||
public boolean getArcheryPVP() { return config.getBoolean("Skills.Archery.Enabled_For_PVP", true); }
|
||||
public boolean getArcheryPVE() { return config.getBoolean("Skills.Archery.Enabled_For_PVE", true); }
|
||||
public boolean getAxesPVP() { return config.getBoolean("Skills.Axes.Enabled_For_PVP", true); }
|
||||
public boolean getAxesPVE() { return config.getBoolean("Skills.Axes.Enabled_For_PVE", true); }
|
||||
public boolean getSwordsPVP() { return config.getBoolean("Skills.Swords.Enabled_For_PVP", true); }
|
||||
public boolean getSwordsPVE() { return config.getBoolean("Skills.Swords.Enabled_For_PVE", true); }
|
||||
public boolean getTamingPVP() { return config.getBoolean("Skills.Taming.Enabled_For_PVP", true); }
|
||||
public boolean getTamingPVE() { return config.getBoolean("Skills.Taming.Enabled_For_PVE", true); }
|
||||
public boolean getUnarmedPVP() { return config.getBoolean("Skills.Unarmed.Enabled_For_PVP", true); }
|
||||
public boolean getUnarmedPVE() { return config.getBoolean("Skills.Unarmed.Enabled_For_PVE", true); }
|
||||
|
||||
/*
|
||||
* XP SETTINGS
|
||||
*/
|
||||
@@ -227,7 +346,6 @@ public class Config extends ConfigLoader {
|
||||
|
||||
/* Combat XP Multipliers */
|
||||
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience.Gains.Multiplier.PVP", 1.0); }
|
||||
|
||||
public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); }
|
||||
public double getCreeperXP() { return config.getDouble("Experience.Combat.Multiplier.Creeper", 4.0); }
|
||||
public double getSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Skeleton", 2.0); }
|
||||
@@ -245,6 +363,7 @@ public class Config extends ConfigLoader {
|
||||
public double getIronGolemXP() { return config.getDouble("Experience.Combat.Multiplier.Iron_Golem", 2.0); }
|
||||
|
||||
/* XP Formula Multiplier */
|
||||
public int getFormulaMultiplierCurve() { return config.getInt("Experience.Formula.Curve_Modifier", 20); }
|
||||
public double getFormulaMultiplierTaming() { return config.getDouble("Experience.Formula.Multiplier.Taming", 1.0); }
|
||||
public double getFormulaMultiplierMining() { return config.getDouble("Experience.Formula.Multiplier.Mining", 1.0); }
|
||||
public double getFormulaMultiplierRepair() { return config.getDouble("Experience.Formula.Multiplier.Repair", 1.0); }
|
||||
@@ -257,106 +376,4 @@ public class Config extends ConfigLoader {
|
||||
public double getFormulaMultiplierAxes() { return config.getDouble("Experience.Formula.Multiplier.Axes", 1.0); }
|
||||
public double getFormulaMultiplierAcrobatics() { return config.getDouble("Experience.Formula.Multiplier.Acrobatics", 1.0); }
|
||||
public double getFormulaMultiplierFishing() { return config.getDouble("Experience.Formula.Multiplier.Fishing", 1.0); }
|
||||
|
||||
/*
|
||||
* SPOUT SETTINGS
|
||||
*/
|
||||
|
||||
public boolean spoutEnabled;
|
||||
public boolean getShowPowerLevelForSpout() { return config.getBoolean("Spout.HUD.Show_Power_Level", true); }
|
||||
|
||||
/* Spout XP Bar */
|
||||
public boolean getSpoutXPBarEnabled() { return config.getBoolean("Spout.XP.Bar.Enabled", true); }
|
||||
public boolean getSpoutXPBarIconEnabled() { return config.getBoolean("Spout.XP.Icon.Enabled", true); }
|
||||
public int getSpoutXPBarXPosition() { return config.getInt("Spout.XP.Bar.X_POS", 95); }
|
||||
public int getSpoutXPBarYPosition() { return config.getInt("Spout.XP.Bar.Y_POS", 6); }
|
||||
public int getSpoutXPIconXPosition() { return config.getInt("Spout.XP.Icon.X_POS", 78); }
|
||||
public int getSpoutXPIconYPosition() { return config.getInt("Spout.XP.Icon.Y_POS", 2); }
|
||||
|
||||
/* Spout HUD Colors */
|
||||
public double getSpoutRetroHUDXPBorderRed() { return config.getDouble("Spout.HUD.Retro.Colors.Border.RED", 0.0); }
|
||||
public double getSpoutRetroHUDXPBorderGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Border.GREEN", 0.0); }
|
||||
public double getSpoutRetroHUDXPBorderBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Border.BLUE", 0.0); }
|
||||
public double getSpoutRetroHUDXPBackgroundRed() { return config.getDouble("Spout.HUD.Retro.Colors.Background.RED", 0.75); }
|
||||
public double getSpoutRetroHUDXPBackgroundGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Background.GREEN", 0.75); }
|
||||
public double getSpoutRetroHUDXPBackgroundBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Background.BLUE", 0.75); }
|
||||
|
||||
public double getSpoutRetroHUDAcrobaticsRed() { return config.getDouble("Spout.HUD.Retro.Colors.Acrobatics.RED", 0.3); }
|
||||
public double getSpoutRetroHUDAcrobaticsGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Acrobatics.GREEN", 0.3); }
|
||||
public double getSpoutRetroHUDAcrobaticsBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Acrobatics.BLUE", 0.75); }
|
||||
public double getSpoutRetroHUDArcheryRed() { return config.getDouble("Spout.HUD.Retro.Colors.Archery.RED", 0.3); }
|
||||
public double getSpoutRetroHUDArcheryGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Archery.GREEN", 0.3); }
|
||||
public double getSpoutRetroHUDArcheryBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Archery.BLUE", 0.75); }
|
||||
public double getSpoutRetroHUDAxesRed() { return config.getDouble("Spout.HUD.Retro.Colors.Axes.RED", 0.3); }
|
||||
public double getSpoutRetroHUDAxesGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Axes.GREEN", 0.3); }
|
||||
public double getSpoutRetroHUDAxesBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Axes.BLUE", 0.75); }
|
||||
public double getSpoutRetroHUDExcavationRed() { return config.getDouble("Spout.HUD.Retro.Colors.Excavation.RED", 0.3); }
|
||||
public double getSpoutRetroHUDExcavationGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Excavation.GREEN", 0.3); }
|
||||
public double getSpoutRetroHUDExcavationBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Excavation.BLUE", 0.75); }
|
||||
public double getSpoutRetroHUDHerbalismRed() { return config.getDouble("Spout.HUD.Retro.Colors.Herbalism.RED", 0.3); }
|
||||
public double getSpoutRetroHUDHerbalismGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Herbalism.GREEN", 0.3); }
|
||||
public double getSpoutRetroHUDHerbalismBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Herbalism.BLUE", 0.75); }
|
||||
public double getSpoutRetroHUDMiningRed() { return config.getDouble("Spout.HUD.Retro.Colors.Mining.RED", 0.3); }
|
||||
public double getSpoutRetroHUDMiningGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Mining.GREEN", 0.3); }
|
||||
public double getSpoutRetroHUDMiningBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Mining.BLUE", 0.75); }
|
||||
public double getSpoutRetroHUDRepairRed() { return config.getDouble("Spout.HUD.Retro.Colors.Repair.RED", 0.3); }
|
||||
public double getSpoutRetroHUDRepairGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Repair.GREEN", 0.3); }
|
||||
public double getSpoutRetroHUDRepairBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Repair.BLUE", 0.75); }
|
||||
public double getSpoutRetroHUDSwordsRed() { return config.getDouble("Spout.HUD.Retro.Colors.Swords.RED", 0.3); }
|
||||
public double getSpoutRetroHUDSwordsGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Swords.GREEN", 0.3); }
|
||||
public double getSpoutRetroHUDSwordsBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Swords.BLUE", 0.75); }
|
||||
public double getSpoutRetroHUDTamingRed() { return config.getDouble("Spout.HUD.Retro.Colors.Taming.RED", 0.3); }
|
||||
public double getSpoutRetroHUDTamingGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Taming.GREEN", 0.3); }
|
||||
public double getSpoutRetroHUDTamingBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Taming.BLUE", 0.75); }
|
||||
public double getSpoutRetroHUDUnarmedRed() { return config.getDouble("Spout.HUD.Retro.Colors.Unarmed.RED", 0.3); }
|
||||
public double getSpoutRetroHUDUnarmedGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Unarmed.GREEN", 0.3); }
|
||||
public double getSpoutRetroHUDUnarmedBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Unarmed.BLUE", 0.75); }
|
||||
public double getSpoutRetroHUDWoodcuttingRed() { return config.getDouble("Spout.HUD.Retro.Colors.Woodcutting.RED", 0.3); }
|
||||
public double getSpoutRetroHUDWoodcuttingGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Woodcutting.GREEN", 0.3); }
|
||||
public double getSpoutRetroHUDWoodcuttingBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Woodcutting.BLUE", 0.75); }
|
||||
public double getSpoutRetroHUDFishingRed() { return config.getDouble("Spout.HUD.Retro.Colors.Fishing.RED", 0.3); }
|
||||
public double getSpoutRetroHUDFishingGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Fishing.GREEN", 0.3); }
|
||||
public double getSpoutRetroHUDFishingBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Fishing.BLUE", 0.75); }
|
||||
|
||||
/*
|
||||
* CONFIG LOADING
|
||||
*/
|
||||
|
||||
public HUDType defaulthud;
|
||||
|
||||
private Config(mcMMO plugin) {
|
||||
super(plugin, "config.yml");
|
||||
config = plugin.getConfig();
|
||||
xpGainMultiplier = getExperienceGainsGlobalMultiplier();
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void load() {
|
||||
// If it doesn't exist, copy it from the .jar
|
||||
if (!configFile.exists()) {
|
||||
dataFolder.mkdir();
|
||||
plugin.saveDefaultConfig();
|
||||
}
|
||||
|
||||
addDefaults();
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
plugin.getLogger().info("Loading mcMMO config.yml File...");
|
||||
|
||||
// Setup default HUD
|
||||
String temp = config.getString("Spout.HUD.Default", "STANDARD");
|
||||
|
||||
for (HUDType x : HUDType.values()) {
|
||||
if (x.toString().toLowerCase().equalsIgnoreCase(temp.toString().toLowerCase())) {
|
||||
defaulthud = x;
|
||||
}
|
||||
}
|
||||
|
||||
if(defaulthud == null)
|
||||
defaulthud = HUDType.STANDARD;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,55 +1,79 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public abstract class ConfigLoader {
|
||||
|
||||
protected static final mcMMO plugin = mcMMO.p;
|
||||
protected String fileName;
|
||||
protected File configFile;
|
||||
protected File dataFolder;
|
||||
protected final mcMMO plugin;
|
||||
protected FileConfiguration config;
|
||||
|
||||
public ConfigLoader(mcMMO plugin, String fileName){
|
||||
this.plugin = plugin;
|
||||
dataFolder = plugin.getDataFolder();
|
||||
configFile = new File(dataFolder, File.separator + fileName);
|
||||
public ConfigLoader(String relativePath, String fileName){
|
||||
this.fileName = fileName;
|
||||
configFile = new File(plugin.getDataFolder(), relativePath + File.separator + fileName);
|
||||
loadFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load this config file.
|
||||
*/
|
||||
protected abstract void load();
|
||||
public ConfigLoader(String fileName){
|
||||
this.fileName = fileName;
|
||||
configFile = new File(plugin.getDataFolder(), fileName);
|
||||
loadFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save this config file.
|
||||
*/
|
||||
private void saveConfig() {
|
||||
try {
|
||||
config.save(configFile);
|
||||
protected void loadFile() {
|
||||
if (!configFile.exists()) {
|
||||
plugin.getLogger().info("Creating mcMMO " + fileName + " File...");
|
||||
createFile();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
else {
|
||||
plugin.getLogger().info("Loading mcMMO " + fileName + " File...");
|
||||
}
|
||||
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the defaults to this config file.
|
||||
*/
|
||||
protected void addDefaults() {
|
||||
|
||||
// Load from included config.yml
|
||||
config.options().copyDefaults(true);
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the keys from this config file.
|
||||
*/
|
||||
protected abstract void loadKeys();
|
||||
|
||||
protected void createFile() {
|
||||
if (configFile.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
configFile.getParentFile().mkdirs();
|
||||
|
||||
InputStream inputStream = plugin.getResource(fileName);
|
||||
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
copyStreamToFile(inputStream, configFile);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
plugin.getLogger().severe("Missing ressource file: '" + fileName + "' please notify the plugin authors");
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyStreamToFile(InputStream inputStream, File file) throws Exception {
|
||||
OutputStream outputStream = new FileOutputStream(file);
|
||||
|
||||
int read = 0;
|
||||
byte[] bytes = new byte[1024];
|
||||
|
||||
while ((read = inputStream.read(bytes)) != -1) {
|
||||
outputStream.write(bytes, 0, read);
|
||||
}
|
||||
|
||||
inputStream.close();
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
36
src/main/java/com/gmail/nossr50/config/HiddenConfig.java
Normal file
36
src/main/java/com/gmail/nossr50/config/HiddenConfig.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class HiddenConfig {
|
||||
private static HiddenConfig instance;
|
||||
private static String fileName;
|
||||
private static YamlConfiguration config;
|
||||
private static boolean chunkletsEnabled;
|
||||
|
||||
public HiddenConfig(String fileName) {
|
||||
HiddenConfig.fileName = fileName;
|
||||
load();
|
||||
}
|
||||
|
||||
public static HiddenConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new HiddenConfig("hidden.yml");
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (mcMMO.p.getResource(fileName) != null) {
|
||||
config = YamlConfiguration.loadConfiguration(mcMMO.p.getResource(fileName));
|
||||
chunkletsEnabled = config.getBoolean("Options.Chunklets", true);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getChunkletsEnabled() {
|
||||
return chunkletsEnabled;
|
||||
}
|
||||
}
|
||||
94
src/main/java/com/gmail/nossr50/config/SpoutConfig.java
Normal file
94
src/main/java/com/gmail/nossr50/config/SpoutConfig.java
Normal file
@@ -0,0 +1,94 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import com.gmail.nossr50.datatypes.HudType;
|
||||
|
||||
public class SpoutConfig extends ConfigLoader {
|
||||
private static SpoutConfig instance;
|
||||
public HudType defaultHudType;
|
||||
|
||||
private SpoutConfig() {
|
||||
super("spout.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static SpoutConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new SpoutConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
// Setup default HUD
|
||||
String temp = config.getString("Spout.HUD.Default", "STANDARD");
|
||||
|
||||
for (HudType hudType : HudType.values()) {
|
||||
if (hudType.toString().equalsIgnoreCase(temp.toString())) {
|
||||
defaultHudType = hudType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (defaultHudType == null) {
|
||||
defaultHudType = HudType.STANDARD;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); }
|
||||
public String getMenuKey() { return config.getString("Menu.Key", "KEY_M"); }
|
||||
|
||||
/* XP Bar */
|
||||
public boolean getXPBarEnabled() { return config.getBoolean("XP.Bar.Enabled", true); }
|
||||
public boolean getXPBarIconEnabled() { return config.getBoolean("XP.Icon.Enabled", true); }
|
||||
public int getXPBarXPosition() { return config.getInt("XP.Bar.X_POS", 95); }
|
||||
public int getXPBarYPosition() { return config.getInt("XP.Bar.Y_POS", 6); }
|
||||
public int getXPIconXPosition() { return config.getInt("XP.Icon.X_POS", 78); }
|
||||
public int getXPIconYPosition() { return config.getInt("XP.Icon.Y_POS", 2); }
|
||||
|
||||
/* HUD Colors */
|
||||
public double getRetroHUDXPBorderRed() { return config.getDouble("HUD.Retro.Colors.Border.RED", 0.0); }
|
||||
public double getRetroHUDXPBorderGreen() { return config.getDouble("HUD.Retro.Colors.Border.GREEN", 0.0); }
|
||||
public double getRetroHUDXPBorderBlue() { return config.getDouble("HUD.Retro.Colors.Border.BLUE", 0.0); }
|
||||
public double getRetroHUDXPBackgroundRed() { return config.getDouble("HUD.Retro.Colors.Background.RED", 0.75); }
|
||||
public double getRetroHUDXPBackgroundGreen() { return config.getDouble("HUD.Retro.Colors.Background.GREEN", 0.75); }
|
||||
public double getRetroHUDXPBackgroundBlue() { return config.getDouble("HUD.Retro.Colors.Background.BLUE", 0.75); }
|
||||
|
||||
public double getRetroHUDAcrobaticsRed() { return config.getDouble("HUD.Retro.Colors.Acrobatics.RED", 0.3); }
|
||||
public double getRetroHUDAcrobaticsGreen() { return config.getDouble("HUD.Retro.Colors.Acrobatics.GREEN", 0.3); }
|
||||
public double getRetroHUDAcrobaticsBlue() { return config.getDouble("HUD.Retro.Colors.Acrobatics.BLUE", 0.75); }
|
||||
public double getRetroHUDArcheryRed() { return config.getDouble("HUD.Retro.Colors.Archery.RED", 0.3); }
|
||||
public double getRetroHUDArcheryGreen() { return config.getDouble("HUD.Retro.Colors.Archery.GREEN", 0.3); }
|
||||
public double getRetroHUDArcheryBlue() { return config.getDouble("HUD.Retro.Colors.Archery.BLUE", 0.75); }
|
||||
public double getRetroHUDAxesRed() { return config.getDouble("HUD.Retro.Colors.Axes.RED", 0.3); }
|
||||
public double getRetroHUDAxesGreen() { return config.getDouble("HUD.Retro.Colors.Axes.GREEN", 0.3); }
|
||||
public double getRetroHUDAxesBlue() { return config.getDouble("HUD.Retro.Colors.Axes.BLUE", 0.75); }
|
||||
public double getRetroHUDExcavationRed() { return config.getDouble("HUD.Retro.Colors.Excavation.RED", 0.3); }
|
||||
public double getRetroHUDExcavationGreen() { return config.getDouble("HUD.Retro.Colors.Excavation.GREEN", 0.3); }
|
||||
public double getRetroHUDExcavationBlue() { return config.getDouble("HUD.Retro.Colors.Excavation.BLUE", 0.75); }
|
||||
public double getRetroHUDHerbalismRed() { return config.getDouble("HUD.Retro.Colors.Herbalism.RED", 0.3); }
|
||||
public double getRetroHUDHerbalismGreen() { return config.getDouble("HUD.Retro.Colors.Herbalism.GREEN", 0.3); }
|
||||
public double getRetroHUDHerbalismBlue() { return config.getDouble("HUD.Retro.Colors.Herbalism.BLUE", 0.75); }
|
||||
public double getRetroHUDMiningRed() { return config.getDouble("HUD.Retro.Colors.Mining.RED", 0.3); }
|
||||
public double getRetroHUDMiningGreen() { return config.getDouble("HUD.Retro.Colors.Mining.GREEN", 0.3); }
|
||||
public double getRetroHUDMiningBlue() { return config.getDouble("HUD.Retro.Colors.Mining.BLUE", 0.75); }
|
||||
public double getRetroHUDRepairRed() { return config.getDouble("HUD.Retro.Colors.Repair.RED", 0.3); }
|
||||
public double getRetroHUDRepairGreen() { return config.getDouble("HUD.Retro.Colors.Repair.GREEN", 0.3); }
|
||||
public double getRetroHUDRepairBlue() { return config.getDouble("HUD.Retro.Colors.Repair.BLUE", 0.75); }
|
||||
public double getRetroHUDSwordsRed() { return config.getDouble("HUD.Retro.Colors.Swords.RED", 0.3); }
|
||||
public double getRetroHUDSwordsGreen() { return config.getDouble("HUD.Retro.Colors.Swords.GREEN", 0.3); }
|
||||
public double getRetroHUDSwordsBlue() { return config.getDouble("HUD.Retro.Colors.Swords.BLUE", 0.75); }
|
||||
public double getRetroHUDTamingRed() { return config.getDouble("HUD.Retro.Colors.Taming.RED", 0.3); }
|
||||
public double getRetroHUDTamingGreen() { return config.getDouble("HUD.Retro.Colors.Taming.GREEN", 0.3); }
|
||||
public double getRetroHUDTamingBlue() { return config.getDouble("HUD.Retro.Colors.Taming.BLUE", 0.75); }
|
||||
public double getRetroHUDUnarmedRed() { return config.getDouble("HUD.Retro.Colors.Unarmed.RED", 0.3); }
|
||||
public double getRetroHUDUnarmedGreen() { return config.getDouble("HUD.Retro.Colors.Unarmed.GREEN", 0.3); }
|
||||
public double getRetroHUDUnarmedBlue() { return config.getDouble("HUD.Retro.Colors.Unarmed.BLUE", 0.75); }
|
||||
public double getRetroHUDWoodcuttingRed() { return config.getDouble("HUD.Retro.Colors.Woodcutting.RED", 0.3); }
|
||||
public double getRetroHUDWoodcuttingGreen() { return config.getDouble("HUD.Retro.Colors.Woodcutting.GREEN", 0.3); }
|
||||
public double getRetroHUDWoodcuttingBlue() { return config.getDouble("HUD.Retro.Colors.Woodcutting.BLUE", 0.75); }
|
||||
public double getRetroHUDFishingRed() { return config.getDouble("HUD.Retro.Colors.Fishing.RED", 0.3); }
|
||||
public double getRetroHUDFishingGreen() { return config.getDouble("HUD.Retro.Colors.Fishing.GREEN", 0.3); }
|
||||
public double getRetroHUDFishingBlue() { return config.getDouble("HUD.Retro.Colors.Fishing.BLUE", 0.75); }
|
||||
}
|
||||
@@ -5,28 +5,19 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.Treasure;
|
||||
|
||||
public class LoadTreasures extends ConfigLoader{
|
||||
private static LoadTreasures instance;
|
||||
|
||||
public static LoadTreasures getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new LoadTreasures(mcMMO.p);
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public class TreasuresConfig extends ConfigLoader{
|
||||
private static TreasuresConfig instance;
|
||||
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
|
||||
@@ -40,29 +31,21 @@ public class LoadTreasures extends ConfigLoader{
|
||||
public List<FishingTreasure> fishingRewardsTier4 = new ArrayList<FishingTreasure>();
|
||||
public List<FishingTreasure> fishingRewardsTier5 = new ArrayList<FishingTreasure>();
|
||||
|
||||
private LoadTreasures(mcMMO plugin) {
|
||||
super(plugin, "treasures.yml");
|
||||
config = plugin.getTreasuresConfig();
|
||||
load();
|
||||
private TreasuresConfig() {
|
||||
super("treasures.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void load() {
|
||||
|
||||
// If it doesn't exist, copy it from the .jar
|
||||
if (!configFile.exists()) {
|
||||
dataFolder.mkdir();
|
||||
plugin.saveTreasuresConfig();
|
||||
public static TreasuresConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new TreasuresConfig();
|
||||
}
|
||||
|
||||
addDefaults();
|
||||
loadKeys();
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
plugin.getLogger().info("Loading mcMMO treasures.yml File...");
|
||||
|
||||
Map<String, Treasure> treasures = new HashMap<String, Treasure>();
|
||||
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures");
|
||||
Set<String> treasureConfigSet = treasureSection.getKeys(false);
|
||||
@@ -95,7 +78,7 @@ public class LoadTreasures extends ConfigLoader{
|
||||
int data = config.getInt("Treasures." + treasureName + ".Data");
|
||||
|
||||
if (Material.getMaterial(id) == null) {
|
||||
reason.add("Invlid id: " + id);
|
||||
reason.add("Invalid id: " + id);
|
||||
}
|
||||
|
||||
if (amount < 1) {
|
||||
@@ -207,11 +190,13 @@ public class LoadTreasures extends ConfigLoader{
|
||||
|
||||
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
|
||||
List<String> fishingTreasures = config.getStringList("Fishing.Treasure");
|
||||
Iterator<String> treasureIterator = treasures.keySet().iterator();
|
||||
// Iterator<String> treasureIterator = treasures.keySet().iterator();
|
||||
Iterator<Entry<String,Treasure>> treasureIterator = treasures.entrySet().iterator();
|
||||
|
||||
while (treasureIterator.hasNext()) {
|
||||
String treasureKey = treasureIterator.next();
|
||||
Treasure treasure = treasures.get(treasureKey);
|
||||
Entry<String,Treasure> nextEntry = treasureIterator.next();
|
||||
String treasureKey = nextEntry.getKey();
|
||||
Treasure treasure = nextEntry.getValue();
|
||||
|
||||
if (treasure instanceof FishingTreasure) {
|
||||
if (!fishingTreasures.contains(treasureKey)) {
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
|
||||
public class CustomArmorConfig extends ConfigLoader{
|
||||
private static CustomArmorConfig instance;
|
||||
private List<Repairable> repairables;
|
||||
public List<Integer> customBootIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customChestplateIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customHelmetIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customLeggingIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customIDs = new ArrayList<Integer>();
|
||||
public List<CustomItem> customArmorList = new ArrayList<CustomItem>();
|
||||
public HashMap<Integer, CustomItem> customArmor = new HashMap<Integer, CustomItem>();
|
||||
|
||||
public CustomArmorConfig() {
|
||||
super("ModConfigs", "armor.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static CustomArmorConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new CustomArmorConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
loadArmor("Boots", customBootIDs);
|
||||
loadArmor("Chestplates", customChestplateIDs);
|
||||
loadArmor("Helmets", customHelmetIDs);
|
||||
loadArmor("Leggings", customLeggingIDs);
|
||||
}
|
||||
|
||||
private void loadArmor(String armorType, List<Integer> idList) {
|
||||
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
|
||||
Set<String> armorConfigSet = armorSection.getKeys(false);
|
||||
Iterator<String> iterator = armorConfigSet.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String armorName = iterator.next();
|
||||
|
||||
int id = config.getInt(armorType + "." + armorName + ".ID", 0);
|
||||
boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable");
|
||||
int repairID = config.getInt(armorType + "." + armorName + ".Repair_Material_ID", 0);
|
||||
byte repairData = (byte) config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Value", 0);
|
||||
int repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Quantity", 0);
|
||||
short durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 0);
|
||||
|
||||
if (id == 0) {
|
||||
plugin.getLogger().warning("Missing ID. This item will be skipped.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) {
|
||||
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable.");
|
||||
repairable = false;
|
||||
}
|
||||
|
||||
CustomItem armor;
|
||||
|
||||
if (repairable) {
|
||||
repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability));
|
||||
}
|
||||
|
||||
armor = new CustomItem(id, durability);
|
||||
|
||||
idList.add(id);
|
||||
customIDs.add(id);
|
||||
customArmorList.add(armor);
|
||||
customArmor.put(id, armor);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Repairable> getLoadedRepairables() {
|
||||
if(repairables == null) return new ArrayList<Repairable>();
|
||||
return repairables;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
|
||||
public class CustomBlocksConfig extends ConfigLoader {
|
||||
private static CustomBlocksConfig instance;
|
||||
public List<ItemStack> customExcavationBlocks = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customHerbalismBlocks = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customMiningBlocks = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customWoodcuttingBlocks = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customOres = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customLogs = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customLeaves = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customAbilityBlocks = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customItems = new ArrayList<ItemStack>();
|
||||
public List<CustomBlock> customBlocks = new ArrayList<CustomBlock>();
|
||||
|
||||
public CustomBlocksConfig() {
|
||||
super("ModConfigs", "blocks.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static CustomBlocksConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new CustomBlocksConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
loadBlocks("Excavation", customExcavationBlocks);
|
||||
loadBlocks("Herbalism", customHerbalismBlocks);
|
||||
loadBlocks("Mining", customMiningBlocks);
|
||||
loadBlocks("Woodcutting", customWoodcuttingBlocks);
|
||||
loadBlocks("Ability_Blocks", customAbilityBlocks);
|
||||
}
|
||||
|
||||
private void loadBlocks(String skillType, List<ItemStack> blockList) {
|
||||
ConfigurationSection skillSection = config.getConfigurationSection(skillType);
|
||||
Set<String> skillConfigSet = skillSection.getKeys(false);
|
||||
Iterator<String> iterator = skillConfigSet.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String blockName = iterator.next();
|
||||
|
||||
int id = config.getInt(skillType + "." + blockName + ".ID", 0);
|
||||
byte data = (byte) config.getInt(skillType + "." + blockName + ".Data_Value", 0);
|
||||
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain", 0);
|
||||
int tier = config.getInt(skillType + "." + blockName + ".Tier", 1);
|
||||
boolean dropItem = config.getBoolean(skillType + "." + blockName + ".Drop_Item", false);
|
||||
int dropID = config.getInt(skillType + "." + blockName + ".Drop_Item_ID", 0);
|
||||
byte dropData = (byte) config.getInt(skillType + "." + blockName + ".Drop_Item_Data_Value", 0);
|
||||
int minimumDropAmount = config.getInt(skillType + "." + blockName + ".Min_Drop_Item_Amount", 1);
|
||||
int maxiumDropAmount = config.getInt(skillType + "." + blockName + ".Max_Drop_Item_Amount", 1);
|
||||
|
||||
CustomBlock block;
|
||||
ItemStack itemDrop;
|
||||
ItemStack blockItem;
|
||||
|
||||
if (id == 0) {
|
||||
plugin.getLogger().warning("Missing ID. This block will be skipped.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (skillType.equals("Ability_Blocks")) {
|
||||
blockItem = new ItemStack(id, 1, (short) 0, data);
|
||||
blockList.add(blockItem);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (dropItem && dropID == 0) {
|
||||
plugin.getLogger().warning("Incomplete item drop information. This block will drop itself.");
|
||||
dropItem = false;
|
||||
}
|
||||
|
||||
if (dropItem) {
|
||||
itemDrop = new ItemStack(dropID, 1, (short) 0, dropData);
|
||||
}
|
||||
else {
|
||||
itemDrop = new ItemStack(id, 1, (short) 0, data);
|
||||
}
|
||||
|
||||
block = new CustomBlock(minimumDropAmount, maxiumDropAmount, itemDrop, tier, xp, data, id);
|
||||
blockItem = new ItemStack(id, 1, (short) 0, data);
|
||||
|
||||
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
||||
customOres.add(blockItem);
|
||||
}
|
||||
else if (skillType.equals("Woodcutting")) {
|
||||
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
|
||||
customLogs.add(blockItem);
|
||||
}
|
||||
else {
|
||||
customLeaves.add(blockItem);
|
||||
block.setXpGain(0); //Leaves don't grant XP
|
||||
}
|
||||
}
|
||||
|
||||
blockList.add(blockItem);
|
||||
customItems.add(blockItem);
|
||||
customBlocks.add(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
|
||||
public class CustomToolsConfig extends ConfigLoader {
|
||||
private static CustomToolsConfig instance;
|
||||
private List<Repairable> repairables;
|
||||
public List<Integer> customAxeIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customBowIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customHoeIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customPickaxeIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customShovelIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customSwordIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customIDs = new ArrayList<Integer>();
|
||||
public List<CustomTool> customToolList = new ArrayList<CustomTool>();
|
||||
public HashMap<Integer, CustomTool> customTools = new HashMap<Integer, CustomTool>();
|
||||
|
||||
private CustomToolsConfig() {
|
||||
super("ModConfigs", "tools.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static CustomToolsConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new CustomToolsConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
loadTool("Axes", customAxeIDs);
|
||||
loadTool("Bows", customBowIDs);
|
||||
loadTool("Hoes", customHoeIDs);
|
||||
loadTool("Pickaxes", customPickaxeIDs);
|
||||
loadTool("Shovels", customShovelIDs);
|
||||
loadTool("Swords", customSwordIDs);
|
||||
}
|
||||
|
||||
private void loadTool(String toolType, List<Integer> idList) {
|
||||
ConfigurationSection toolSection = config.getConfigurationSection(toolType);
|
||||
Set<String> toolConfigSet = toolSection.getKeys(false);
|
||||
Iterator<String> iterator = toolConfigSet.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String toolName = iterator.next();
|
||||
|
||||
int id = config.getInt(toolType + "." + toolName + ".ID", 0);
|
||||
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);
|
||||
boolean abilityEnabled = config.getBoolean(toolType + "." + toolName + ".Ability_Enabled", true);
|
||||
int tier = config.getInt(toolType + "." + toolName + ".Tier", 1);
|
||||
boolean repairable = config.getBoolean(toolType + "." + toolName + ".Repairable");
|
||||
int repairID = config.getInt(toolType + "." + toolName + ".Repair_Material_ID", 0);
|
||||
byte repairData = (byte) config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Value", 0);
|
||||
int repairQuantity = config.getInt(toolType + "." + toolName + ".Repair_Material_Quantity", 0);
|
||||
short durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 0);
|
||||
|
||||
if (id == 0) {
|
||||
plugin.getLogger().warning("Missing ID. This item will be skipped.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) {
|
||||
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable.");
|
||||
repairable = false;
|
||||
}
|
||||
|
||||
CustomTool tool;
|
||||
|
||||
if (repairable) {
|
||||
repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability));
|
||||
}
|
||||
|
||||
tool = new CustomTool(tier, abilityEnabled, multiplier, durability, id);
|
||||
|
||||
idList.add(id);
|
||||
customIDs.add(id);
|
||||
customToolList.add(tool);
|
||||
customTools.put(id, tool);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Repairable> getLoadedRepairables() {
|
||||
if(repairables == null) return new ArrayList<Repairable>();
|
||||
return repairables;
|
||||
}
|
||||
}
|
||||
109
src/main/java/com/gmail/nossr50/config/repair/RepairConfig.java
Normal file
109
src/main/java/com/gmail/nossr50/config/repair/RepairConfig.java
Normal file
@@ -0,0 +1,109 @@
|
||||
package com.gmail.nossr50.config.repair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.skills.repair.RepairItemType;
|
||||
import com.gmail.nossr50.skills.repair.RepairMaterialType;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
|
||||
public class RepairConfig extends ConfigLoader {
|
||||
private List<Repairable> repairables;
|
||||
|
||||
public RepairConfig(String fileName) {
|
||||
super(fileName);
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
ConfigurationSection section = config.getConfigurationSection("Repairables");
|
||||
Set<String> keys = section.getKeys(false);
|
||||
|
||||
for (String key : keys) {
|
||||
// Validate all the things!
|
||||
List<String> reason = new ArrayList<String>();
|
||||
|
||||
if (!config.contains("Repairables." + key + ".ItemId")) {
|
||||
reason.add(key + " is missing ItemId");
|
||||
}
|
||||
|
||||
if (!config.contains("Repairables." + key + ".RepairMaterialId")) {
|
||||
reason.add(key + " is missing RepairMaterialId");
|
||||
}
|
||||
|
||||
if (!config.contains("Repairables." + key + ".MaximumDurability")) {
|
||||
reason.add(key + " is missing MaximumDurability");
|
||||
}
|
||||
|
||||
int itemId = config.getInt("Repairables." + key + ".ItemId", 0);
|
||||
int repairMaterialId = config.getInt("Repairables." + key + ".RepairMaterialId", 0);
|
||||
int maximumDurability = config.getInt("Repairables." + key + ".MaximumDurability", 0);
|
||||
|
||||
int repairMetadata = config.getInt("Repairables." + key + ".RepairMaterialMetadata", -1);
|
||||
int minimumLevel = config.getInt("Repairables." + key + ".MinimumLevel", 0);
|
||||
int minimumQuantity = config.getInt("Repairables." + key + ".MinimumQuantity", 2);
|
||||
double xpMultiplier = config.getDouble("Repairables." + key + ".XpMultiplier", 1);
|
||||
|
||||
RepairItemType repairItemType = RepairItemType.OTHER;
|
||||
RepairMaterialType repairMaterialType = RepairMaterialType.OTHER;
|
||||
|
||||
String repairItemTypeString = config.getString("Repairables." + key + ".ItemType", "OTHER");
|
||||
String repairMaterialTypeString = config.getString("Repairables." + key + ".MaterialType", "OTHER");
|
||||
|
||||
if (minimumLevel < 0) {
|
||||
reason.add(key + " has an invalid MinimumLevel of " + minimumLevel);
|
||||
}
|
||||
|
||||
if (minimumQuantity < 0) {
|
||||
reason.add(key + " has an invalid MinimumQuantity of " + minimumQuantity);
|
||||
}
|
||||
|
||||
try {
|
||||
repairItemType = RepairItemType.valueOf(repairItemTypeString);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
reason.add(key + " has an invalid ItemType of " + repairItemTypeString);
|
||||
}
|
||||
|
||||
try {
|
||||
repairMaterialType = RepairMaterialType.valueOf(repairMaterialTypeString);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
reason.add(key + " has an invalid MaterialType of " + repairMaterialTypeString);
|
||||
}
|
||||
|
||||
if (noErrorsInRepairable(reason)) {
|
||||
Repairable repairable = RepairableFactory.getRepairable(itemId, repairMaterialId, (byte) repairMetadata, minimumLevel, minimumQuantity, (short) maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
|
||||
repairables.add(repairable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected List<Repairable> getLoadedRepairables() {
|
||||
if (repairables == null) {
|
||||
return new ArrayList<Repairable>();
|
||||
}
|
||||
|
||||
return repairables;
|
||||
}
|
||||
|
||||
private boolean noErrorsInRepairable(List<String> issues) {
|
||||
if (issues.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
for (String issue : issues) {
|
||||
plugin.getLogger().warning(issue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.gmail.nossr50.config.repair;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
|
||||
public class RepairConfigManager {
|
||||
private List<Repairable> repairables;
|
||||
|
||||
public RepairConfigManager(mcMMO plugin) {
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
Pattern pattern = Pattern.compile("repair\\.(?:.+)\\.yml");
|
||||
File dataFolder = plugin.getDataFolder();
|
||||
File vanilla = new File(dataFolder, "repair.vanilla.yml");
|
||||
|
||||
if (!vanilla.exists()) {
|
||||
plugin.saveResource("repair.vanilla.yml", false);
|
||||
}
|
||||
|
||||
for (String fileName : dataFolder.list()) {
|
||||
if (!pattern.matcher(fileName).matches()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
File file = new File(dataFolder, fileName);
|
||||
|
||||
if (file.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
RepairConfig rConfig = new RepairConfig(fileName);
|
||||
List<Repairable> rConfigRepairables = rConfig.getLoadedRepairables();
|
||||
|
||||
if (rConfigRepairables != null) {
|
||||
repairables.addAll(rConfigRepairables);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<Repairable> getLoadedRepairables() {
|
||||
if (repairables == null) {
|
||||
return new ArrayList<Repairable>();
|
||||
}
|
||||
|
||||
return repairables;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.Excavation;
|
||||
import com.gmail.nossr50.skills.Herbalism;
|
||||
import com.gmail.nossr50.skills.Mining;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public enum AbilityType {
|
||||
BERSERK(
|
||||
Config.getInstance().getAbilityCooldownBerserk(),
|
||||
Config.getInstance().getAbilityMaxTicksBerserk(),
|
||||
"Unarmed.Skills.Berserk.On",
|
||||
"Unarmed.Skills.Berserk.Off",
|
||||
"Unarmed.Skills.Berserk.Other.On",
|
||||
@@ -21,6 +21,7 @@ public enum AbilityType {
|
||||
|
||||
SUPER_BREAKER(
|
||||
Config.getInstance().getAbilityCooldownSuperBreaker(),
|
||||
Config.getInstance().getAbilityMaxTicksSuperBreaker(),
|
||||
"Mining.Skills.SuperBreaker.On",
|
||||
"Mining.Skills.SuperBreaker.Off",
|
||||
"Mining.Skills.SuperBreaker.Other.On",
|
||||
@@ -29,6 +30,7 @@ public enum AbilityType {
|
||||
|
||||
GIGA_DRILL_BREAKER(
|
||||
Config.getInstance().getAbilityCooldownGigaDrillBreaker(),
|
||||
Config.getInstance().getAbilityMaxTicksGigaDrillBreaker(),
|
||||
"Excavation.Skills.GigaDrillBreaker.On",
|
||||
"Excavation.Skills.GigaDrillBreaker.Off",
|
||||
"Excavation.Skills.GigaDrillBreaker.Other.On",
|
||||
@@ -37,6 +39,7 @@ public enum AbilityType {
|
||||
|
||||
GREEN_TERRA(
|
||||
Config.getInstance().getAbilityCooldownGreenTerra(),
|
||||
Config.getInstance().getAbilityMaxTicksGreenTerra(),
|
||||
"Herbalism.Skills.GTe.On",
|
||||
"Herbalism.Skills.GTe.Off",
|
||||
"Herbalism.Skills.GTe.Other.On",
|
||||
@@ -45,6 +48,7 @@ public enum AbilityType {
|
||||
|
||||
SKULL_SPLIITER(
|
||||
Config.getInstance().getAbilityCooldownSkullSplitter(),
|
||||
Config.getInstance().getAbilityMaxTicksSkullSplitter(),
|
||||
"Axes.Skills.SS.On",
|
||||
"Axes.Skills.SS.Off",
|
||||
"Axes.Skills.SS.Other.On",
|
||||
@@ -53,6 +57,7 @@ public enum AbilityType {
|
||||
|
||||
TREE_FELLER(
|
||||
Config.getInstance().getAbilityCooldownTreeFeller(),
|
||||
Config.getInstance().getAbilityMaxTicksTreeFeller(),
|
||||
"Woodcutting.Skills.TreeFeller.On",
|
||||
"Woodcutting.Skills.TreeFeller.Off",
|
||||
"Woodcutting.Skills.TreeFeller.Other.On",
|
||||
@@ -61,6 +66,7 @@ public enum AbilityType {
|
||||
|
||||
SERRATED_STRIKES(
|
||||
Config.getInstance().getAbilityCooldownSerratedStrikes(),
|
||||
Config.getInstance().getAbilityMaxTicksSerratedStrikes(),
|
||||
"Swords.Skills.SS.On",
|
||||
"Swords.Skills.SS.Off",
|
||||
"Swords.Skills.SS.Other.On",
|
||||
@@ -69,6 +75,7 @@ public enum AbilityType {
|
||||
|
||||
BLAST_MINING(
|
||||
Config.getInstance().getAbilityCooldownBlastMining(),
|
||||
Config.getInstance().getAbilityMaxTicksBlastMining(),
|
||||
null,
|
||||
null,
|
||||
"Mining.Blast.Other.On",
|
||||
@@ -76,6 +83,7 @@ public enum AbilityType {
|
||||
null),
|
||||
|
||||
LEAF_BLOWER(
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
null,
|
||||
@@ -84,14 +92,16 @@ public enum AbilityType {
|
||||
null);
|
||||
|
||||
private int cooldown;
|
||||
private int maxTicks;
|
||||
private String abilityOn;
|
||||
private String abilityOff;
|
||||
private String abilityPlayer;
|
||||
private String abilityRefresh;
|
||||
private String abilityPlayerOff;
|
||||
|
||||
private AbilityType(int cooldown, String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
|
||||
private AbilityType(int cooldown, int maxTicks, String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
|
||||
this.cooldown = cooldown;
|
||||
this.maxTicks = maxTicks;
|
||||
this.abilityOn = abilityOn;
|
||||
this.abilityOff = abilityOff;
|
||||
this.abilityPlayer = abilityPlayer;
|
||||
@@ -123,6 +133,10 @@ public enum AbilityType {
|
||||
return LocaleLoader.getString(this.abilityRefresh);
|
||||
}
|
||||
|
||||
public int getMaxTicks() {
|
||||
return this.maxTicks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the permissions for this ability.
|
||||
*
|
||||
@@ -130,33 +144,35 @@ public enum AbilityType {
|
||||
* @return true if the player has permissions, false otherwise
|
||||
*/
|
||||
public boolean getPermissions(Player player) {
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
switch (this) {
|
||||
case BERSERK:
|
||||
return Permissions.getInstance().berserk(player);
|
||||
return permInstance.berserk(player);
|
||||
|
||||
case BLAST_MINING:
|
||||
return Permissions.getInstance().blastMining(player);
|
||||
return permInstance.blastMining(player);
|
||||
|
||||
case GIGA_DRILL_BREAKER:
|
||||
return Permissions.getInstance().gigaDrillBreaker(player);
|
||||
return permInstance.gigaDrillBreaker(player);
|
||||
|
||||
case GREEN_TERRA:
|
||||
return Permissions.getInstance().greenTerra(player);
|
||||
return permInstance.greenTerra(player);
|
||||
|
||||
case LEAF_BLOWER:
|
||||
return Permissions.getInstance().leafBlower(player);
|
||||
return permInstance.leafBlower(player);
|
||||
|
||||
case SERRATED_STRIKES:
|
||||
return Permissions.getInstance().serratedStrikes(player);
|
||||
return permInstance.serratedStrikes(player);
|
||||
|
||||
case SKULL_SPLIITER:
|
||||
return Permissions.getInstance().skullSplitter(player);
|
||||
return permInstance.skullSplitter(player);
|
||||
|
||||
case SUPER_BREAKER:
|
||||
return Permissions.getInstance().superBreaker(player);
|
||||
return permInstance.superBreaker(player);
|
||||
|
||||
case TREE_FELLER:
|
||||
return Permissions.getInstance().treeFeller(player);
|
||||
return permInstance.treeFeller(player);
|
||||
|
||||
default:
|
||||
return false;
|
||||
@@ -166,28 +182,28 @@ public enum AbilityType {
|
||||
/**
|
||||
* Check if a block is affected by this ability.
|
||||
*
|
||||
* @param material The block type to check
|
||||
* @param Block the block to check
|
||||
* @return true if the block is affected by this ability, false otherwise
|
||||
*/
|
||||
public boolean blockCheck(Material material) {
|
||||
public boolean blockCheck(Block block) {
|
||||
switch (this) {
|
||||
case BERSERK:
|
||||
return (Excavation.canBeGigaDrillBroken(material) || material.equals(Material.SNOW));
|
||||
return (BlockChecks.canBeGigaDrillBroken(block) || block.getType() == Material.SNOW);
|
||||
|
||||
case GIGA_DRILL_BREAKER:
|
||||
return Excavation.canBeGigaDrillBroken(material);
|
||||
return BlockChecks.canBeGigaDrillBroken(block);
|
||||
|
||||
case GREEN_TERRA:
|
||||
return Herbalism.makeMossy(material);
|
||||
return BlockChecks.makeMossy(block);
|
||||
|
||||
case LEAF_BLOWER:
|
||||
return material.equals(Material.LEAVES);
|
||||
return block.getType() == Material.LEAVES;
|
||||
|
||||
case SUPER_BREAKER:
|
||||
return Mining.canBeSuperBroken(material);
|
||||
return BlockChecks.canBeSuperBroken(block);
|
||||
|
||||
case TREE_FELLER:
|
||||
return material.equals(Material.LOG);
|
||||
return block.getType() == Material.LOG;
|
||||
|
||||
default:
|
||||
return false;
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
public enum HUDType {
|
||||
DISABLED,
|
||||
STANDARD,
|
||||
SMALL,
|
||||
RETRO;
|
||||
}
|
||||
@@ -1,413 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
import org.getspout.spoutapi.gui.Color;
|
||||
import org.getspout.spoutapi.gui.GenericGradient;
|
||||
import org.getspout.spoutapi.gui.GenericTexture;
|
||||
import org.getspout.spoutapi.gui.RenderPriority;
|
||||
import org.getspout.spoutapi.gui.Widget;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class HUDmmo {
|
||||
private int center_x = 427 / 2;
|
||||
|
||||
private String playerName;
|
||||
private final mcMMO plugin;
|
||||
|
||||
private Widget xpbar = null;
|
||||
private GenericGradient xpfill = null;
|
||||
private GenericGradient xpbg = null;
|
||||
private GenericGradient xpicon_bg = null;
|
||||
private GenericGradient xpicon_border = null;
|
||||
private GenericTexture xpicon = null;
|
||||
|
||||
public HUDmmo(Player player, mcMMO plugin) {
|
||||
this.playerName = player.getName();
|
||||
this.plugin = plugin;
|
||||
initializeHUD(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the HUD.
|
||||
*
|
||||
* @param player Player whose HUD to initialize
|
||||
*/
|
||||
public void initializeHUD(Player player) {
|
||||
HUDType type = Users.getProfile(player).getHUDType();
|
||||
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
|
||||
|
||||
switch (type) {
|
||||
case RETRO:
|
||||
initializeXpBarDisplayRetro(sPlayer);
|
||||
break;
|
||||
|
||||
case STANDARD:
|
||||
initializeXpBarDisplayStandard(sPlayer);
|
||||
break;
|
||||
|
||||
case SMALL:
|
||||
initializeXpBarDisplaySmall(sPlayer);
|
||||
break;
|
||||
|
||||
case DISABLED:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the XP bar.
|
||||
*
|
||||
* @param type Type of XP bar
|
||||
* @param player Player whose XP bar to update
|
||||
*/
|
||||
public void updateXpBarDisplay(HUDType type, Player player) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
switch (type) {
|
||||
case RETRO:
|
||||
updateXpBarRetro(player, PP);
|
||||
break;
|
||||
|
||||
case STANDARD:
|
||||
updateXpBarStandard(player, PP);
|
||||
break;
|
||||
|
||||
case SMALL:
|
||||
updateXpBarStandard(player, PP);
|
||||
break;
|
||||
|
||||
case DISABLED:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset a player's HUD.
|
||||
*/
|
||||
public void resetHUD() {
|
||||
SpoutPlayer sPlayer = SpoutStuff.getSpoutPlayer(playerName);
|
||||
|
||||
if (sPlayer != null) {
|
||||
sPlayer.getMainScreen().removeWidgets(plugin);
|
||||
|
||||
//Reset the objects
|
||||
xpbar = null;
|
||||
xpfill = null;
|
||||
xpbg = null;
|
||||
xpicon = null;
|
||||
|
||||
sPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Retro XP bar.
|
||||
*
|
||||
* @param sPlayer Player to initialize XP bar for
|
||||
*/
|
||||
private void initializeXpBarDisplayRetro(SpoutPlayer sPlayer) {
|
||||
Color border = new Color((float) Config.getInstance().getSpoutRetroHUDXPBorderRed(), (float) Config.getInstance().getSpoutRetroHUDXPBorderGreen(), (float) Config.getInstance().getSpoutRetroHUDXPBorderBlue(), 1f);
|
||||
Color green = new Color(0f, 1f, 0f, 1f);
|
||||
Color background = new Color((float) Config.getInstance().getSpoutRetroHUDXPBackgroundRed(), (float) Config.getInstance().getSpoutRetroHUDXPBackgroundGreen(), (float) Config.getInstance().getSpoutRetroHUDXPBackgroundBlue(), 1f);
|
||||
Color darkbg = new Color(0.2f, 0.2f, 0.2f, 1f);
|
||||
|
||||
xpicon = new GenericTexture();
|
||||
xpbar = new GenericGradient();
|
||||
xpfill = new GenericGradient();
|
||||
xpbg = new GenericGradient();
|
||||
|
||||
xpicon_bg = new GenericGradient();
|
||||
xpicon_border = new GenericGradient();
|
||||
|
||||
xpicon_bg.setBottomColor(darkbg);
|
||||
xpicon_bg.setTopColor(darkbg);
|
||||
xpicon_bg.setWidth(4);
|
||||
xpicon_bg.setHeight(4);
|
||||
xpicon_bg.setPriority(RenderPriority.High);
|
||||
xpicon_bg.setX(142);
|
||||
xpicon_bg.setY(10);
|
||||
xpicon_bg.setDirty(true);
|
||||
|
||||
xpicon_border.setBottomColor(border);
|
||||
xpicon_border.setTopColor(border);
|
||||
xpicon_border.setWidth(6);
|
||||
xpicon_border.setHeight(6);
|
||||
xpicon_border.setPriority(RenderPriority.Highest);
|
||||
xpicon_border.setX(141);
|
||||
xpicon_border.setY(9);
|
||||
xpicon_border.setDirty(true);
|
||||
|
||||
xpicon.setWidth(6);
|
||||
xpicon.setHeight(6);
|
||||
xpicon.setX(141);
|
||||
xpicon.setY(9);
|
||||
xpicon.setPriority(RenderPriority.Normal);
|
||||
xpicon.setDirty(true);
|
||||
xpicon.setUrl("Icon_r.png");
|
||||
|
||||
xpbar.setWidth(128);
|
||||
xpbar.setHeight(4);
|
||||
xpbar.setX(149);
|
||||
xpbar.setY(10);
|
||||
((GenericGradient) xpbar).setBottomColor(border);
|
||||
((GenericGradient) xpbar).setTopColor(border);
|
||||
xpbar.setPriority(RenderPriority.Highest);
|
||||
xpbar.setDirty(true);
|
||||
|
||||
xpfill.setWidth(0);
|
||||
xpfill.setHeight(2);
|
||||
xpfill.setX(150);
|
||||
xpfill.setY(11);
|
||||
xpfill.setBottomColor(green);
|
||||
xpfill.setTopColor(green);
|
||||
xpfill.setPriority(RenderPriority.Lowest);
|
||||
xpfill.setDirty(true);
|
||||
|
||||
xpbg.setWidth(126);
|
||||
xpbg.setHeight(2);
|
||||
xpbg.setX(150);
|
||||
xpbg.setY(11);
|
||||
xpbg.setBottomColor(background);
|
||||
xpbg.setTopColor(background);
|
||||
xpbg.setPriority(RenderPriority.Low);
|
||||
xpbg.setDirty(true);
|
||||
|
||||
if (Config.getInstance().getSpoutXPBarEnabled()) {
|
||||
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
|
||||
sPlayer.getMainScreen().attachWidget(plugin, xpfill);
|
||||
sPlayer.getMainScreen().attachWidget(plugin, xpbg);
|
||||
|
||||
if (Config.getInstance().getSpoutXPBarIconEnabled()) {
|
||||
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
|
||||
sPlayer.getMainScreen().attachWidget(plugin, xpicon_bg);
|
||||
sPlayer.getMainScreen().attachWidget(plugin, xpicon_border);
|
||||
}
|
||||
}
|
||||
|
||||
sPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Standard XP bar.
|
||||
*
|
||||
* @param sPlayer Player to initialize XP bar for
|
||||
*/
|
||||
public void initializeXpBarDisplayStandard(SpoutPlayer sPlayer) {
|
||||
if (Config.getInstance().getSpoutXPBarEnabled()) {
|
||||
xpbar = new GenericTexture();
|
||||
|
||||
((GenericTexture) xpbar).setUrl("xpbar_inc000.png");
|
||||
|
||||
xpbar.setX(Config.getInstance().getSpoutXPBarXPosition());
|
||||
xpbar.setY(Config.getInstance().getSpoutXPBarYPosition());
|
||||
xpbar.setHeight(8);
|
||||
xpbar.setWidth(256);
|
||||
|
||||
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
|
||||
|
||||
if (Config.getInstance().getSpoutXPBarIconEnabled()) {
|
||||
xpicon = new GenericTexture();
|
||||
|
||||
xpicon.setUrl("Icon.png");
|
||||
xpicon.setHeight(16);
|
||||
xpicon.setWidth(32);
|
||||
xpicon.setX(Config.getInstance().getSpoutXPIconXPosition());
|
||||
xpicon.setY(Config.getInstance().getSpoutXPIconYPosition());
|
||||
xpicon.setDirty(true);
|
||||
|
||||
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
|
||||
}
|
||||
}
|
||||
|
||||
sPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Small XP bar.
|
||||
*
|
||||
* @param sPlayer Player to initialize XP bar for
|
||||
*/
|
||||
private void initializeXpBarDisplaySmall(SpoutPlayer sPlayer) {
|
||||
if (Config.getInstance().getSpoutXPBarEnabled()) {
|
||||
xpbar = new GenericTexture();
|
||||
|
||||
((GenericTexture)xpbar).setUrl("xpbar_inc000.png");
|
||||
xpbar.setX(center_x - 64);
|
||||
xpbar.setY(Config.getInstance().getSpoutXPBarYPosition());
|
||||
xpbar.setHeight(4);
|
||||
xpbar.setWidth(128);
|
||||
|
||||
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
|
||||
|
||||
if (Config.getInstance().getSpoutXPBarIconEnabled()) {
|
||||
xpicon = new GenericTexture();
|
||||
|
||||
xpicon.setUrl("Icon.png");
|
||||
xpicon.setHeight(8);
|
||||
xpicon.setWidth(16);
|
||||
xpicon.setX(center_x - (8 + 64));
|
||||
xpicon.setY(Config.getInstance().getSpoutXPIconYPosition() + 2);
|
||||
xpicon.setDirty(true);
|
||||
|
||||
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
|
||||
}
|
||||
}
|
||||
|
||||
sPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update XP bar for Standard & Small styles.
|
||||
*
|
||||
* @param player Player whose XP bar to update
|
||||
* @param PP Profile of the given player
|
||||
*/
|
||||
private void updateXpBarStandard(Player player, PlayerProfile PP) {
|
||||
if (!Config.getInstance().getSpoutXPBarEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkillType theType = getType(PP);
|
||||
|
||||
if (theType == null) { //Can this ever actually BE null? (Yes, it's null when the player has just logged in. It's not null when they gain XP in anything)
|
||||
return;
|
||||
}
|
||||
|
||||
((GenericTexture) xpicon).setUrl(Misc.getCapitalized(theType.toString()) + ".png");
|
||||
xpicon.setDirty(true);
|
||||
|
||||
((GenericTexture) xpbar).setUrl(getUrlBar(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.STANDARD)));
|
||||
xpbar.setDirty(true);
|
||||
|
||||
SpoutManager.getPlayer(player).getMainScreen().setDirty(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update XP bar for Retro styles.
|
||||
*
|
||||
* @param player Player whose XP bar to update
|
||||
* @param PP Profile of the given player
|
||||
*/
|
||||
private void updateXpBarRetro(Player player, PlayerProfile PP) {
|
||||
if (!Config.getInstance().getSpoutXPBarEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkillType theType = getType(PP);
|
||||
|
||||
if (theType == null) { //Can this ever actually BE null? (Yes, it's null when the player has just logged in. It's not null when they gain XP in anything)
|
||||
return;
|
||||
}
|
||||
|
||||
Color color = getRetroColor(theType);
|
||||
|
||||
xpicon.setUrl(Misc.getCapitalized(theType.toString()) + "_r.png");
|
||||
|
||||
xpfill.setBottomColor(color);
|
||||
xpfill.setTopColor(color);
|
||||
xpfill.setWidth(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.RETRO));
|
||||
xpfill.setDirty(true);
|
||||
|
||||
SpoutManager.getPlayer(player).getMainScreen().setDirty(true);
|
||||
}
|
||||
|
||||
private static Color getRetroColor(SkillType type) {
|
||||
switch (type) {
|
||||
case ACROBATICS:
|
||||
return new Color((float) Config.getInstance().getSpoutRetroHUDAcrobaticsRed(), (float) Config.getInstance().getSpoutRetroHUDAcrobaticsGreen(), (float) Config.getInstance().getSpoutRetroHUDAcrobaticsBlue(), 1f);
|
||||
|
||||
case ARCHERY:
|
||||
return new Color((float) Config.getInstance().getSpoutRetroHUDArcheryRed(), (float) Config.getInstance().getSpoutRetroHUDArcheryGreen(), (float) Config.getInstance().getSpoutRetroHUDArcheryBlue(), 1f);
|
||||
|
||||
case AXES:
|
||||
return new Color((float) Config.getInstance().getSpoutRetroHUDAxesRed(), (float) Config.getInstance().getSpoutRetroHUDAxesGreen(), (float) Config.getInstance().getSpoutRetroHUDAxesBlue(), 1f);
|
||||
|
||||
case EXCAVATION:
|
||||
return new Color((float) Config.getInstance().getSpoutRetroHUDExcavationRed(), (float) Config.getInstance().getSpoutRetroHUDExcavationGreen(), (float) Config.getInstance().getSpoutRetroHUDExcavationBlue(), 1f);
|
||||
|
||||
case HERBALISM:
|
||||
return new Color((float) Config.getInstance().getSpoutRetroHUDHerbalismRed(), (float) Config.getInstance().getSpoutRetroHUDHerbalismGreen(), (float) Config.getInstance().getSpoutRetroHUDHerbalismBlue(), 1f);
|
||||
|
||||
case MINING:
|
||||
return new Color((float) Config.getInstance().getSpoutRetroHUDMiningRed(), (float) Config.getInstance().getSpoutRetroHUDMiningGreen(), (float) Config.getInstance().getSpoutRetroHUDMiningBlue(), 1f);
|
||||
|
||||
case REPAIR:
|
||||
return new Color((float) Config.getInstance().getSpoutRetroHUDRepairRed(), (float) Config.getInstance().getSpoutRetroHUDRepairGreen(), (float) Config.getInstance().getSpoutRetroHUDRepairBlue(), 1f);
|
||||
|
||||
case SWORDS:
|
||||
return new Color((float) Config.getInstance().getSpoutRetroHUDSwordsRed(), (float) Config.getInstance().getSpoutRetroHUDSwordsGreen(), (float) Config.getInstance().getSpoutRetroHUDSwordsBlue(), 1f);
|
||||
|
||||
case TAMING:
|
||||
return new Color((float) Config.getInstance().getSpoutRetroHUDTamingRed(), (float) Config.getInstance().getSpoutRetroHUDTamingGreen(), (float) Config.getInstance().getSpoutRetroHUDTamingBlue(), 1f);
|
||||
|
||||
case UNARMED:
|
||||
return new Color((float) Config.getInstance().getSpoutRetroHUDUnarmedRed(), (float) Config.getInstance().getSpoutRetroHUDUnarmedGreen(), (float) Config.getInstance().getSpoutRetroHUDUnarmedBlue(), 1f);
|
||||
|
||||
case WOODCUTTING:
|
||||
return new Color((float) Config.getInstance().getSpoutRetroHUDWoodcuttingRed(), (float) Config.getInstance().getSpoutRetroHUDWoodcuttingGreen(), (float) Config.getInstance().getSpoutRetroHUDWoodcuttingBlue(), 1f);
|
||||
|
||||
case FISHING:
|
||||
return new Color((float) Config.getInstance().getSpoutRetroHUDFishingRed(), (float) Config.getInstance().getSpoutRetroHUDFishingGreen(), (float) Config.getInstance().getSpoutRetroHUDFishingBlue(), 1f);
|
||||
|
||||
default:
|
||||
return new Color(0.3f, 0.3f, 0.75f, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getUrlBar(Integer number) {
|
||||
char[] num = number.toString().toCharArray();
|
||||
|
||||
switch (num.length) {
|
||||
case 1:
|
||||
return "xpbar_inc00" + number + ".png";
|
||||
|
||||
case 2:
|
||||
return "xpbar_inc0" + number + ".png";
|
||||
|
||||
default:
|
||||
return "xpbar_inc" + number + ".png";
|
||||
}
|
||||
}
|
||||
|
||||
private static Integer getXpInc(int skillxp, int xptolevel, HUDType hud) {
|
||||
double percentage = (double) skillxp / xptolevel;
|
||||
double inc;
|
||||
|
||||
switch (hud) {
|
||||
case RETRO:
|
||||
inc = 0.0079365079365079;
|
||||
break;
|
||||
|
||||
case STANDARD:
|
||||
inc = 0.0039370078740157;
|
||||
break;
|
||||
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
return (int) (percentage / inc);
|
||||
}
|
||||
|
||||
private static SkillType getType(PlayerProfile PP) {
|
||||
if (PP.getXpBarLocked()) {
|
||||
return PP.getSkillLock();
|
||||
}
|
||||
else {
|
||||
return PP.getLastGained();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
src/main/java/com/gmail/nossr50/datatypes/HudType.java
Normal file
12
src/main/java/com/gmail/nossr50/datatypes/HudType.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
public enum HudType {
|
||||
DISABLED,
|
||||
STANDARD,
|
||||
SMALL,
|
||||
RETRO;
|
||||
|
||||
public HudType getNext() {
|
||||
return values()[(ordinal() + 1) % values().length];
|
||||
}
|
||||
}
|
||||
235
src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java
Normal file
235
src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java
Normal file
@@ -0,0 +1,235 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
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.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModChecks;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McMMOPlayer {
|
||||
private Player player;
|
||||
private PlayerProfile profile;
|
||||
|
||||
private Party party;
|
||||
private Party invite;
|
||||
|
||||
public McMMOPlayer (Player player) {
|
||||
String playerName = player.getName();
|
||||
this.player = player;
|
||||
this.profile = new PlayerProfile(playerName, true);
|
||||
this.party = PartyManager.getInstance().getPlayerParty(playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the power level of this player.
|
||||
*
|
||||
* @return the power level of the player
|
||||
*/
|
||||
public int getPowerLevel() {
|
||||
int powerLevel = 0;
|
||||
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.getPermissions(player)) {
|
||||
powerLevel += profile.getSkillLevel(type);
|
||||
}
|
||||
}
|
||||
|
||||
return powerLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the party XP modifier.
|
||||
*
|
||||
* @param skillType Type of skill to check
|
||||
* @return the party bonus multiplier
|
||||
*/
|
||||
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 = 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.getGameMode().equals(GameMode.CREATIVE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double bonusModifier = 0;
|
||||
|
||||
if (inParty()) {
|
||||
bonusModifier = calculatePartyXPModifier(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());
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
profile.setSkillXPLevel(skillType, profile.getSkillXpLevel(skillType) + xp);
|
||||
|
||||
SpoutHud spoutHud = profile.getSpoutHud();
|
||||
|
||||
if (spoutHud != null) {
|
||||
spoutHud.setLastGained(skillType);
|
||||
}
|
||||
}
|
||||
|
||||
// Players & Profiles
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public PlayerProfile getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
// Party Stuff
|
||||
|
||||
public void setInvite(Party invite) {
|
||||
this.invite = invite;
|
||||
}
|
||||
|
||||
public Party getInvite() {
|
||||
return invite;
|
||||
}
|
||||
|
||||
public boolean hasPartyInvite() {
|
||||
if (invite != null) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setParty(Party party) {
|
||||
this.party = party;
|
||||
}
|
||||
|
||||
public Party getParty() {
|
||||
return party;
|
||||
}
|
||||
|
||||
public boolean inParty() {
|
||||
if (party != null) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeParty() {
|
||||
party = null;
|
||||
}
|
||||
|
||||
public void removeInvite() {
|
||||
invite = null;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
102
src/main/java/com/gmail/nossr50/datatypes/SpoutHud.java
Normal file
102
src/main/java/com/gmail/nossr50/datatypes/SpoutHud.java
Normal file
@@ -0,0 +1,102 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.popups.Menu;
|
||||
import com.gmail.nossr50.datatypes.popups.XpBar;
|
||||
|
||||
public class SpoutHud {
|
||||
private Player player;
|
||||
private PlayerProfile profile;
|
||||
|
||||
private SkillType lastGained;
|
||||
private SkillType skillLock;
|
||||
private boolean xpBarLocked;
|
||||
|
||||
private Menu menu;
|
||||
private XpBar xpBar;
|
||||
|
||||
public SpoutHud(McMMOPlayer mcMMOPlayer) {
|
||||
this.player = mcMMOPlayer.getPlayer();
|
||||
this.profile = mcMMOPlayer.getProfile();
|
||||
|
||||
initializeXpBar();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the HUD.
|
||||
*/
|
||||
public void initializeXpBar() {
|
||||
if (SpoutConfig.getInstance().getXPBarEnabled()) {
|
||||
if (xpBar != null) {
|
||||
xpBar.removeWidgets();
|
||||
}
|
||||
|
||||
xpBar = new XpBar(SpoutManager.getPlayer(player), profile.getHudType());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the XP bar.
|
||||
*/
|
||||
public void updateXpBar() {
|
||||
SkillType skillType = xpBarLocked ? skillLock : lastGained;
|
||||
|
||||
if (skillType == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
xpBar.update(skillType, profile);
|
||||
}
|
||||
|
||||
public boolean isMenuOpened() {
|
||||
return (menu != null) ? true : false;
|
||||
}
|
||||
|
||||
public void openMenu() {
|
||||
menu = new Menu(SpoutManager.getPlayer(player), profile);
|
||||
}
|
||||
|
||||
public void onMenuClose() {
|
||||
menu = null;
|
||||
}
|
||||
|
||||
public void removeWidgets() {
|
||||
if (menu != null) {
|
||||
menu.close();
|
||||
}
|
||||
|
||||
SpoutManager.getPlayer(player).getMainScreen().removeWidgets(mcMMO.p);
|
||||
}
|
||||
|
||||
public SkillType getLastGained() {
|
||||
return lastGained;
|
||||
}
|
||||
|
||||
public void setLastGained(SkillType type) {
|
||||
this.lastGained = type;
|
||||
}
|
||||
|
||||
public boolean getXpBarLocked() {
|
||||
return xpBarLocked;
|
||||
}
|
||||
|
||||
public void setXpBarLocked(boolean locked) {
|
||||
this.xpBarLocked = locked;
|
||||
}
|
||||
|
||||
public void toggleXpBarLocked() {
|
||||
xpBarLocked = !xpBarLocked;
|
||||
}
|
||||
|
||||
public SkillType getSkillLock() {
|
||||
return skillLock;
|
||||
}
|
||||
|
||||
public void setSkillLock(SkillType type) {
|
||||
this.skillLock = type;
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public enum ToolType {
|
||||
return ItemChecks.isHoe(is);
|
||||
|
||||
case PICKAXE:
|
||||
return ItemChecks.isMiningPick(is);
|
||||
return ItemChecks.isPickaxe(is);
|
||||
|
||||
case SHOVEL:
|
||||
return ItemChecks.isShovel(is);
|
||||
|
||||
@@ -2,8 +2,6 @@ package com.gmail.nossr50.datatypes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerStat;
|
||||
|
||||
public class Tree {
|
||||
|
||||
private TreeNode root = null;
|
||||
|
||||
@@ -2,8 +2,6 @@ package com.gmail.nossr50.datatypes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerStat;
|
||||
|
||||
public class TreeNode {
|
||||
TreeNode left = null;
|
||||
TreeNode right = null;
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.buttons;
|
||||
|
||||
import org.getspout.spoutapi.gui.GenericButton;
|
||||
|
||||
public class ButtonEscape extends GenericButton {
|
||||
|
||||
public ButtonEscape() {
|
||||
this.setText("EXIT");
|
||||
this.setWidth(60);
|
||||
this.setHeight(20);
|
||||
this.setDirty(true);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.buttons;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
|
||||
public class ButtonHUDStyle extends ButtonToggle {
|
||||
|
||||
public ButtonHUDStyle(PlayerProfile PP) {
|
||||
super("HUD Type: ", PP.getHUDType().toString(), "Change your HUD style!"); //TODO: Needs more locale
|
||||
}
|
||||
|
||||
public void updateText(PlayerProfile PP) {
|
||||
super.updateText("HUD Type: ", PP.getHUDType().toString()); //TODO: Needs more locale
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.buttons;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
|
||||
public class ButtonPartyToggle extends ButtonToggle {
|
||||
|
||||
public ButtonPartyToggle(PlayerProfile PP) {
|
||||
super("Party HUD: ", ((Boolean) PP.getPartyHUD()).toString(), "Toggle the Party HUD!"); //TODO: Needs more locale
|
||||
}
|
||||
|
||||
public void updateText(PlayerProfile PP) {
|
||||
super.updateText("Party HUD: ", ((Boolean) PP.getPartyHUD()).toString()); //TODO: Needs more locale
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.buttons;
|
||||
|
||||
import org.getspout.spoutapi.gui.GenericButton;
|
||||
|
||||
public class ButtonToggle extends GenericButton{
|
||||
|
||||
public ButtonToggle(String text1, String text2, String tooltip) {
|
||||
this.setText(text1 + text2);
|
||||
this.setTooltip(tooltip);
|
||||
this.setWidth(120);
|
||||
this.setHeight(20);
|
||||
this.setDirty(true);
|
||||
}
|
||||
|
||||
public void updateText(String text1, String text2) {
|
||||
this.setText(text1 + text2);
|
||||
this.setDirty(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.gmail.nossr50.datatypes.buttons;
|
||||
|
||||
import org.getspout.spoutapi.gui.GenericButton;
|
||||
|
||||
public class McmmoButton extends GenericButton {
|
||||
private Slot slot;
|
||||
|
||||
public McmmoButton(String text, String toolTip) {
|
||||
this.setText(text);
|
||||
this.setTooltip(toolTip);
|
||||
}
|
||||
|
||||
public void connect(Slot slot) {
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public void activate() {
|
||||
slot.activate();
|
||||
}
|
||||
|
||||
public interface Slot {
|
||||
public void activate();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.gmail.nossr50.datatypes.mods;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CustomBlock {
|
||||
private int itemID;
|
||||
private byte dataValue;
|
||||
private int xpGain;
|
||||
private int tier;
|
||||
private ItemStack itemDrop;
|
||||
private int minimumDropAmount;
|
||||
private int maximumDropAmount;
|
||||
|
||||
public CustomBlock(int minimumDropAmount, int maximumDropAmount, ItemStack itemDrop, int tier, int xpGain, byte dataValue, int itemID) {
|
||||
this.itemID = itemID;
|
||||
this.dataValue = dataValue;
|
||||
this.xpGain = xpGain;
|
||||
this.tier = tier;
|
||||
this.itemDrop = itemDrop;
|
||||
this.minimumDropAmount = minimumDropAmount;
|
||||
this.maximumDropAmount = maximumDropAmount;
|
||||
}
|
||||
|
||||
public int getItemID() {
|
||||
return itemID;
|
||||
}
|
||||
|
||||
public void setItemID(int itemID) {
|
||||
this.itemID = itemID;
|
||||
}
|
||||
|
||||
public byte getDataValue() {
|
||||
return dataValue;
|
||||
}
|
||||
|
||||
public void setDataValue(byte dataValue) {
|
||||
this.dataValue = dataValue;
|
||||
}
|
||||
|
||||
public int getXpGain() {
|
||||
return xpGain;
|
||||
}
|
||||
|
||||
public void setXpGain(int xpGain) {
|
||||
this.xpGain = xpGain;
|
||||
}
|
||||
|
||||
public int getTier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
public void setTier(int tier) {
|
||||
this.tier = tier;
|
||||
}
|
||||
|
||||
public ItemStack getItemDrop() {
|
||||
return itemDrop;
|
||||
}
|
||||
|
||||
public void setItemDrop(ItemStack itemDrop) {
|
||||
this.itemDrop = itemDrop;
|
||||
}
|
||||
|
||||
public int getMinimumDropAmount() {
|
||||
return minimumDropAmount;
|
||||
}
|
||||
|
||||
public void setMinimumDropAmount(int minimumDropAmount) {
|
||||
this.minimumDropAmount = minimumDropAmount;
|
||||
}
|
||||
|
||||
public int getMaximumDropAmount() {
|
||||
return maximumDropAmount;
|
||||
}
|
||||
|
||||
public void setMaximumDropAmount(int maximumDropAmount) {
|
||||
this.maximumDropAmount = maximumDropAmount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.gmail.nossr50.datatypes.mods;
|
||||
|
||||
public class CustomItem {
|
||||
protected int itemID;
|
||||
protected short durability;
|
||||
|
||||
public CustomItem(int itemID, short durability) {
|
||||
this.itemID = itemID;
|
||||
this.durability = durability;
|
||||
}
|
||||
|
||||
public int getItemID() {
|
||||
return itemID;
|
||||
}
|
||||
|
||||
public void setItemID(int itemID) {
|
||||
this.itemID = itemID;
|
||||
}
|
||||
|
||||
public short getDurability() {
|
||||
return durability;
|
||||
}
|
||||
|
||||
public void setDurability(short durability) {
|
||||
this.durability = durability;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.gmail.nossr50.datatypes.mods;
|
||||
|
||||
public class CustomTool extends CustomItem {
|
||||
private double xpMultiplier;
|
||||
private boolean abilityEnabled;
|
||||
private int tier;
|
||||
|
||||
public CustomTool(int tier, boolean abilityEnabled, double xpMultiplier, short durability, int itemID) {
|
||||
super(itemID, durability);
|
||||
this.xpMultiplier = xpMultiplier;
|
||||
this.abilityEnabled = abilityEnabled;
|
||||
this.tier = tier;
|
||||
}
|
||||
|
||||
public double getXpMultiplier() {
|
||||
return xpMultiplier;
|
||||
}
|
||||
|
||||
public void setXpMultiplier(Double xpMultiplier) {
|
||||
this.xpMultiplier = xpMultiplier;
|
||||
}
|
||||
|
||||
public boolean isAbilityEnabled() {
|
||||
return abilityEnabled;
|
||||
}
|
||||
|
||||
public void setAbilityEnabled(boolean abilityEnabled) {
|
||||
this.abilityEnabled = abilityEnabled;
|
||||
}
|
||||
|
||||
public int getTier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
public void setTier(int tier) {
|
||||
this.tier = tier;
|
||||
}
|
||||
}
|
||||
79
src/main/java/com/gmail/nossr50/datatypes/popups/Menu.java
Normal file
79
src/main/java/com/gmail/nossr50/datatypes/popups/Menu.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package com.gmail.nossr50.datatypes.popups;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.getspout.spoutapi.gui.GenericLabel;
|
||||
import org.getspout.spoutapi.gui.GenericPopup;
|
||||
import org.getspout.spoutapi.gui.InGameHUD;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.HudType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SpoutHud;
|
||||
import com.gmail.nossr50.datatypes.buttons.McmmoButton;
|
||||
import com.gmail.nossr50.datatypes.buttons.McmmoButton.Slot;
|
||||
|
||||
public class Menu extends GenericPopup {
|
||||
private McmmoButton hudButton;
|
||||
private McmmoButton escapeButton;
|
||||
private GenericLabel titleLabel = new GenericLabel();
|
||||
private GenericLabel escapeLabel = new GenericLabel();
|
||||
private static int centerX = 427 / 2;
|
||||
private static int centerY = 240 / 2;
|
||||
|
||||
public Menu(final SpoutPlayer spoutPlayer, final PlayerProfile playerProfile) {
|
||||
//240, 427 are the bottom right
|
||||
titleLabel.setText(ChatColor.GOLD + "~mcMMO Menu~"); //TODO: Needs more locale
|
||||
titleLabel.setWidth(100);
|
||||
titleLabel.setHeight(100);
|
||||
titleLabel.setX(centerX - 35);
|
||||
titleLabel.setY((centerY / 2) - 20);
|
||||
|
||||
escapeLabel.setText(ChatColor.GRAY + "Press ESCAPE to exit!"); //TODO: Needs more locale
|
||||
escapeLabel.setWidth(100);
|
||||
escapeLabel.setHeight(100);
|
||||
escapeLabel.setX(titleLabel.getX() - 15);
|
||||
escapeLabel.setY(titleLabel.getY() + 10);
|
||||
|
||||
hudButton = new McmmoButton("HUD Type: " + playerProfile.getHudType().toString(), "Change your HUD style!");
|
||||
hudButton.setWidth(120);
|
||||
hudButton.setHeight(20);
|
||||
hudButton.setX(centerX - (hudButton.getWidth() / 2));
|
||||
hudButton.setY(centerY / 2);
|
||||
hudButton.connect(new Slot() {
|
||||
@Override
|
||||
public void activate() {
|
||||
HudType nextHudType = playerProfile.getHudType().getNext();
|
||||
SpoutHud spoutHud = playerProfile.getSpoutHud();
|
||||
|
||||
playerProfile.setHudType(nextHudType);
|
||||
spoutHud.initializeXpBar();
|
||||
spoutHud.updateXpBar();
|
||||
hudButton.setText("HUD Type: " + nextHudType.toString());
|
||||
hudButton.setDirty(true);
|
||||
}
|
||||
});
|
||||
|
||||
escapeButton = new McmmoButton("EXIT", null);
|
||||
escapeButton.setWidth(60);
|
||||
escapeButton.setHeight(20);
|
||||
escapeButton.setX(centerX - (escapeButton.getWidth() / 2));
|
||||
escapeButton.setY((centerY / 2) + (escapeButton.getHeight() * 2) + 5);
|
||||
escapeButton.connect(new Slot() {
|
||||
@Override
|
||||
public void activate() {
|
||||
spoutPlayer.getMainScreen().closePopup();
|
||||
}
|
||||
});
|
||||
|
||||
attachWidget(mcMMO.p, hudButton);
|
||||
attachWidget(mcMMO.p, titleLabel);
|
||||
attachWidget(mcMMO.p, escapeLabel);
|
||||
attachWidget(mcMMO.p, escapeButton);
|
||||
|
||||
InGameHUD inGameHud = spoutPlayer.getMainScreen();
|
||||
|
||||
inGameHud.attachPopupScreen(this);
|
||||
inGameHud.setDirty(true);
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.popups;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.getspout.spoutapi.gui.GenericLabel;
|
||||
import org.getspout.spoutapi.gui.GenericPopup;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.buttons.ButtonEscape;
|
||||
import com.gmail.nossr50.datatypes.buttons.ButtonHUDStyle;
|
||||
import com.gmail.nossr50.datatypes.buttons.ButtonPartyToggle;
|
||||
|
||||
public class PopupMMO extends GenericPopup {
|
||||
|
||||
private ButtonHUDStyle HUDButton = null;
|
||||
private ButtonPartyToggle PartyButton = null;
|
||||
private ButtonEscape EscapeButton = null;
|
||||
private GenericLabel mcMMO_label = new GenericLabel();
|
||||
private GenericLabel tip_escape = new GenericLabel();
|
||||
private int center_x = 427 / 2;
|
||||
private int center_y = 240 / 2;
|
||||
|
||||
public PopupMMO(Player player, PlayerProfile PP, mcMMO plugin) {
|
||||
|
||||
//240, 427 are the bottom right
|
||||
mcMMO_label.setText(ChatColor.GOLD + "~mcMMO Menu~"); //TODO: Needs more locale
|
||||
mcMMO_label.setX(center_x - 35);
|
||||
mcMMO_label.setY((center_y / 2) - 20);
|
||||
mcMMO_label.setDirty(true);
|
||||
|
||||
tip_escape.setText(ChatColor.GRAY + "Press ESCAPE to exit!"); //TODO: Needs more locale
|
||||
tip_escape.setX(mcMMO_label.getX() - 15);
|
||||
tip_escape.setY(mcMMO_label.getY() + 10);
|
||||
tip_escape.setDirty(true);
|
||||
|
||||
HUDButton = new ButtonHUDStyle(PP);
|
||||
HUDButton.setX(center_x - (HUDButton.getWidth() / 2));
|
||||
HUDButton.setY(center_y / 2);
|
||||
HUDButton.setDirty(true);
|
||||
|
||||
EscapeButton = new ButtonEscape();
|
||||
EscapeButton.setX(center_x - (EscapeButton.getWidth() / 2));
|
||||
EscapeButton.setY((center_y / 2) + (HUDButton.getHeight() * 2) + 5);
|
||||
EscapeButton.setDirty(true);
|
||||
|
||||
this.attachWidget(plugin, HUDButton);
|
||||
this.attachWidget(plugin, mcMMO_label);
|
||||
this.attachWidget(plugin, tip_escape);
|
||||
this.attachWidget(plugin, EscapeButton);
|
||||
|
||||
this.setDirty(true);
|
||||
}
|
||||
|
||||
public void updateButtons(PlayerProfile PP) {
|
||||
HUDButton.updateText(PP);
|
||||
PartyButton.updateText(PP);
|
||||
this.setDirty(true);
|
||||
}
|
||||
}
|
||||
320
src/main/java/com/gmail/nossr50/datatypes/popups/XpBar.java
Normal file
320
src/main/java/com/gmail/nossr50/datatypes/popups/XpBar.java
Normal file
@@ -0,0 +1,320 @@
|
||||
package com.gmail.nossr50.datatypes.popups;
|
||||
|
||||
import org.getspout.spoutapi.gui.Color;
|
||||
import org.getspout.spoutapi.gui.GenericGradient;
|
||||
import org.getspout.spoutapi.gui.GenericTexture;
|
||||
import org.getspout.spoutapi.gui.InGameHUD;
|
||||
import org.getspout.spoutapi.gui.RenderPriority;
|
||||
import org.getspout.spoutapi.gui.Widget;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.HudType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class XpBar {
|
||||
private SpoutPlayer spoutPlayer;
|
||||
|
||||
private Widget xpBar;
|
||||
private GenericGradient xpFill;
|
||||
private GenericGradient xpBackground;
|
||||
private GenericGradient xpIconBackground;
|
||||
private GenericGradient xpIconBorder;
|
||||
private GenericTexture xpIcon;
|
||||
|
||||
public XpBar(SpoutPlayer spoutPlayer, HudType hudType) {
|
||||
this.spoutPlayer = spoutPlayer;
|
||||
|
||||
switch (hudType) {
|
||||
case RETRO:
|
||||
initializeXpBarRetro();
|
||||
break;
|
||||
|
||||
case STANDARD:
|
||||
initializeXpBarStandard();
|
||||
break;
|
||||
|
||||
case SMALL:
|
||||
initializeXpBarSmall();
|
||||
break;
|
||||
|
||||
case DISABLED:
|
||||
break;
|
||||
}
|
||||
|
||||
spoutPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Retro XP bar.
|
||||
*/
|
||||
private void initializeXpBarRetro() {
|
||||
Color border = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBorderRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderBlue(), 1f);
|
||||
Color green = new Color(0f, 1f, 0f, 1f);
|
||||
Color background = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBackgroundRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundBlue(), 1f);
|
||||
|
||||
xpBar = new GenericGradient();
|
||||
xpFill = new GenericGradient();
|
||||
xpBackground = new GenericGradient();
|
||||
|
||||
xpBar.setWidth(128);
|
||||
xpBar.setHeight(4);
|
||||
xpBar.setX(149);
|
||||
xpBar.setY(10);
|
||||
((GenericGradient) xpBar).setBottomColor(border);
|
||||
((GenericGradient) xpBar).setTopColor(border);
|
||||
xpBar.setPriority(RenderPriority.Highest);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBar);
|
||||
|
||||
xpFill.setWidth(0);
|
||||
xpFill.setHeight(2);
|
||||
xpFill.setX(150);
|
||||
xpFill.setY(11);
|
||||
xpFill.setBottomColor(green);
|
||||
xpFill.setTopColor(green);
|
||||
xpFill.setPriority(RenderPriority.Lowest);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpFill);
|
||||
|
||||
xpBackground.setWidth(126);
|
||||
xpBackground.setHeight(2);
|
||||
xpBackground.setX(150);
|
||||
xpBackground.setY(11);
|
||||
xpBackground.setBottomColor(background);
|
||||
xpBackground.setTopColor(background);
|
||||
xpBackground.setPriority(RenderPriority.Low);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBackground);
|
||||
|
||||
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
|
||||
Color darkbg = new Color(0.2f, 0.2f, 0.2f, 1f);
|
||||
|
||||
xpIconBackground = new GenericGradient();
|
||||
xpIconBorder = new GenericGradient();
|
||||
xpIcon = new GenericTexture();
|
||||
|
||||
xpIconBackground.setBottomColor(darkbg);
|
||||
xpIconBackground.setTopColor(darkbg);
|
||||
xpIconBackground.setWidth(4);
|
||||
xpIconBackground.setHeight(4);
|
||||
xpIconBackground.setPriority(RenderPriority.High);
|
||||
xpIconBackground.setX(142);
|
||||
xpIconBackground.setY(10);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIconBackground);
|
||||
|
||||
xpIconBorder.setBottomColor(border);
|
||||
xpIconBorder.setTopColor(border);
|
||||
xpIconBorder.setWidth(6);
|
||||
xpIconBorder.setHeight(6);
|
||||
xpIconBorder.setPriority(RenderPriority.Highest);
|
||||
xpIconBorder.setX(141);
|
||||
xpIconBorder.setY(9);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIconBorder);
|
||||
|
||||
xpIcon.setWidth(6);
|
||||
xpIcon.setHeight(6);
|
||||
xpIcon.setX(141);
|
||||
xpIcon.setY(9);
|
||||
xpIcon.setPriority(RenderPriority.Normal);
|
||||
xpIcon.setUrl("Icon_r.png");
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIcon);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Standard XP bar.
|
||||
*/
|
||||
private void initializeXpBarStandard() {
|
||||
xpBar = new GenericTexture();
|
||||
|
||||
((GenericTexture) xpBar).setUrl("xpbar_inc000.png");
|
||||
xpBar.setX(SpoutConfig.getInstance().getXPBarXPosition());
|
||||
xpBar.setY(SpoutConfig.getInstance().getXPBarYPosition());
|
||||
xpBar.setHeight(8);
|
||||
xpBar.setWidth(256);
|
||||
xpBar.setPriority(RenderPriority.Lowest);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBar);
|
||||
|
||||
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
|
||||
xpIcon = new GenericTexture();
|
||||
|
||||
xpIcon.setUrl("Icon.png");
|
||||
xpIcon.setHeight(16);
|
||||
xpIcon.setWidth(32);
|
||||
xpIcon.setX(SpoutConfig.getInstance().getXPIconXPosition());
|
||||
xpIcon.setY(SpoutConfig.getInstance().getXPIconYPosition());
|
||||
xpIcon.setPriority(RenderPriority.High);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIcon);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Small XP bar.
|
||||
*/
|
||||
private void initializeXpBarSmall() {
|
||||
xpBar = new GenericTexture();
|
||||
|
||||
((GenericTexture)xpBar).setUrl("xpbar_inc000.png");
|
||||
xpBar.setX(427 / 2 - 64);
|
||||
xpBar.setY(SpoutConfig.getInstance().getXPBarYPosition());
|
||||
xpBar.setHeight(4);
|
||||
xpBar.setWidth(128);
|
||||
xpBar.setPriority(RenderPriority.Lowest);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBar);
|
||||
|
||||
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
|
||||
xpIcon = new GenericTexture();
|
||||
|
||||
xpIcon.setUrl("Icon.png");
|
||||
xpIcon.setHeight(8);
|
||||
xpIcon.setWidth(16);
|
||||
xpIcon.setX(427 / 2 - (8 + 64));
|
||||
xpIcon.setY(SpoutConfig.getInstance().getXPIconYPosition() + 2);
|
||||
xpIcon.setPriority(RenderPriority.High);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIcon);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the XP bar.
|
||||
*
|
||||
* @param skillType
|
||||
* @param playerProfile
|
||||
*/
|
||||
public void update(SkillType skillType, PlayerProfile playerProfile) {
|
||||
switch (playerProfile.getHudType()) {
|
||||
case RETRO:
|
||||
updateXpBarRetro(skillType, playerProfile);
|
||||
break;
|
||||
|
||||
case STANDARD:
|
||||
case SMALL:
|
||||
updateXpBarStandard(skillType, playerProfile);
|
||||
break;
|
||||
|
||||
case DISABLED:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update XP bar for Standard & Small styles.
|
||||
*
|
||||
* @param skillType
|
||||
* @param playerProfile
|
||||
*/
|
||||
private void updateXpBarStandard(SkillType skillType, PlayerProfile playerProfile) {
|
||||
xpIcon.setUrl(Misc.getCapitalized(skillType.toString()) + ".png");
|
||||
|
||||
((GenericTexture) xpBar).setUrl(getUrlBar(getXpInc(playerProfile.getSkillXpLevel(skillType), playerProfile.getXpToLevel(skillType), HudType.STANDARD)));
|
||||
|
||||
spoutPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update XP bar for Retro styles.
|
||||
*
|
||||
* @param skillType
|
||||
*/
|
||||
private void updateXpBarRetro(SkillType skillType, PlayerProfile playerProfile) {
|
||||
Color color = getRetroColor(skillType);
|
||||
|
||||
xpIcon.setUrl(Misc.getCapitalized(skillType.toString()) + "_r.png");
|
||||
|
||||
xpFill.setBottomColor(color);
|
||||
xpFill.setTopColor(color);
|
||||
xpFill.setWidth(getXpInc(playerProfile.getSkillXpLevel(skillType), playerProfile.getXpToLevel(skillType), HudType.RETRO));
|
||||
|
||||
spoutPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
|
||||
private static Color getRetroColor(SkillType type) {
|
||||
switch (type) {
|
||||
case ACROBATICS:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDAcrobaticsRed(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsGreen(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsBlue(), 1f);
|
||||
|
||||
case ARCHERY:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDArcheryRed(), (float) SpoutConfig.getInstance().getRetroHUDArcheryGreen(), (float) SpoutConfig.getInstance().getRetroHUDArcheryBlue(), 1f);
|
||||
|
||||
case AXES:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDAxesRed(), (float) SpoutConfig.getInstance().getRetroHUDAxesGreen(), (float) SpoutConfig.getInstance().getRetroHUDAxesBlue(), 1f);
|
||||
|
||||
case EXCAVATION:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDExcavationRed(), (float) SpoutConfig.getInstance().getRetroHUDExcavationGreen(), (float) SpoutConfig.getInstance().getRetroHUDExcavationBlue(), 1f);
|
||||
|
||||
case HERBALISM:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDHerbalismRed(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismGreen(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismBlue(), 1f);
|
||||
|
||||
case MINING:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDMiningRed(), (float) SpoutConfig.getInstance().getRetroHUDMiningGreen(), (float) SpoutConfig.getInstance().getRetroHUDMiningBlue(), 1f);
|
||||
|
||||
case REPAIR:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDRepairRed(), (float) SpoutConfig.getInstance().getRetroHUDRepairGreen(), (float) SpoutConfig.getInstance().getRetroHUDRepairBlue(), 1f);
|
||||
|
||||
case SWORDS:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDSwordsRed(), (float) SpoutConfig.getInstance().getRetroHUDSwordsGreen(), (float) SpoutConfig.getInstance().getRetroHUDSwordsBlue(), 1f);
|
||||
|
||||
case TAMING:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDTamingRed(), (float) SpoutConfig.getInstance().getRetroHUDTamingGreen(), (float) SpoutConfig.getInstance().getRetroHUDTamingBlue(), 1f);
|
||||
|
||||
case UNARMED:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDUnarmedRed(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedGreen(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedBlue(), 1f);
|
||||
|
||||
case WOODCUTTING:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDWoodcuttingRed(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingGreen(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingBlue(), 1f);
|
||||
|
||||
case FISHING:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDFishingRed(), (float) SpoutConfig.getInstance().getRetroHUDFishingGreen(), (float) SpoutConfig.getInstance().getRetroHUDFishingBlue(), 1f);
|
||||
|
||||
default:
|
||||
return new Color(0.3f, 0.3f, 0.75f, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getUrlBar(Integer number) {
|
||||
char[] num = number.toString().toCharArray();
|
||||
|
||||
switch (num.length) {
|
||||
case 1:
|
||||
return "xpbar_inc00" + number + ".png";
|
||||
|
||||
case 2:
|
||||
return "xpbar_inc0" + number + ".png";
|
||||
|
||||
default:
|
||||
return "xpbar_inc" + number + ".png";
|
||||
}
|
||||
}
|
||||
|
||||
private static Integer getXpInc(int skillXp, int xpToLevel, HudType hudType) {
|
||||
double percentage = (double) skillXp / xpToLevel;
|
||||
double inc;
|
||||
|
||||
switch (hudType) {
|
||||
case RETRO:
|
||||
inc = 0.0079365079365079;
|
||||
break;
|
||||
|
||||
case STANDARD:
|
||||
inc = 0.0039370078740157;
|
||||
break;
|
||||
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
return (int) (percentage / inc);
|
||||
}
|
||||
|
||||
public void removeWidgets() {
|
||||
InGameHUD inGameHud = spoutPlayer.getMainScreen();
|
||||
|
||||
if (xpBar != null) inGameHud.removeWidget(xpBar);
|
||||
if (xpFill != null) inGameHud.removeWidget(xpFill);
|
||||
if (xpBackground != null) inGameHud.removeWidget(xpBackground);
|
||||
if (xpIconBackground != null) inGameHud.removeWidget(xpIconBackground);
|
||||
if (xpIconBorder != null) inGameHud.removeWidget(xpIconBorder);
|
||||
if (xpIcon != null) inGameHud.removeWidget(xpIcon);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public abstract class Treasure {
|
||||
private int xp;
|
||||
private Double dropChance;
|
||||
private double dropChance;
|
||||
private int dropLevel;
|
||||
private ItemStack drop;
|
||||
|
||||
@@ -31,7 +31,7 @@ public abstract class Treasure {
|
||||
this.xp = xp;
|
||||
}
|
||||
|
||||
public Double getDropChance() {
|
||||
public double getDropChance() {
|
||||
return dropChance;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,4 +12,4 @@ public class FakeBlockBreakEvent extends BlockBreakEvent {
|
||||
public FakeBlockBreakEvent(Block theBlock, Player player) {
|
||||
super(theBlock, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.gmail.nossr50.events.fake;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -58,10 +58,11 @@ public class McMMOItemSpawnEvent extends Event implements Cancellable {
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
|
||||
/** Rest of file is required boilerplate for custom events **/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@@ -2,27 +2,6 @@ package com.gmail.nossr50.listeners;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.ToolType;
|
||||
import com.gmail.nossr50.skills.Excavation;
|
||||
import com.gmail.nossr50.skills.Herbalism;
|
||||
import com.gmail.nossr50.skills.Mining;
|
||||
import com.gmail.nossr50.skills.Repair;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.skills.WoodCutting;
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
|
||||
import org.bukkit.CropState;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@@ -32,14 +11,37 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import org.getspout.spoutapi.sound.SoundEffect;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.ToolType;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
import com.gmail.nossr50.runnables.StickyPistonTracker;
|
||||
import com.gmail.nossr50.skills.gathering.Excavation;
|
||||
import com.gmail.nossr50.skills.gathering.Herbalism;
|
||||
import com.gmail.nossr50.skills.gathering.Mining;
|
||||
import com.gmail.nossr50.skills.gathering.WoodCutting;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.ModChecks;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class BlockListener implements Listener {
|
||||
private final mcMMO plugin;
|
||||
|
||||
@@ -58,16 +60,35 @@ public class BlockListener implements Listener {
|
||||
BlockFace direction = event.getDirection();
|
||||
|
||||
for (Block b : blocks) {
|
||||
if (b.hasMetadata("mcmmoPlacedBlock")) {
|
||||
b.getRelative(direction).setMetadata("mcmmoNeedsTracking", new FixedMetadataValue(plugin, true));
|
||||
b.removeMetadata("mcmmoPlacedBlock", plugin);
|
||||
}
|
||||
if (mcMMO.placeStore.isTrue(b)) {
|
||||
b.getRelative(direction).setMetadata("pistonTrack", new FixedMetadataValue(plugin, true));
|
||||
mcMMO.placeStore.setFalse(b);
|
||||
}
|
||||
}
|
||||
|
||||
for (Block b : blocks) {
|
||||
if (b.getRelative(direction).hasMetadata("mcmmoNeedsTracking")) {
|
||||
b.getRelative(direction).setMetadata("mcmmoPlacedBlock", new FixedMetadataValue(plugin, true));
|
||||
b.getRelative(direction).removeMetadata("mcmmoNeedsTracking", plugin);
|
||||
if (b.getRelative(direction).hasMetadata("pistonTrack")) {
|
||||
mcMMO.placeStore.setTrue(b.getRelative(direction));
|
||||
b.getRelative(direction).removeMetadata("pistonTrack", plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor BlockPhysics events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||
//TODO: Figure out how to REMOVE metadata from the location the sand/gravel fell from.
|
||||
Material type = event.getChangedType();
|
||||
|
||||
if (type == Material.GRAVEL || type == Material.SAND) {
|
||||
Block fallenBlock = event.getBlock().getRelative(BlockFace.UP);
|
||||
|
||||
if (fallenBlock.getType() == type) {
|
||||
mcMMO.placeStore.setTrue(fallenBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,11 +100,9 @@ public class BlockListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
Block block = event.getRetractLocation().getBlock();
|
||||
|
||||
if (block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
block.removeMetadata("mcmmoPlacedBlock", plugin);
|
||||
event.getBlock().getRelative(event.getDirection()).setMetadata("mcmmoPlacedBlock", new FixedMetadataValue(plugin, true));
|
||||
if (event.isSticky()) {
|
||||
//Needed only because under some circumstances Minecraft doesn't move the block
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StickyPistonTracker(event), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,31 +113,35 @@ public class BlockListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
Block block = event.getBlock();
|
||||
Player player = event.getPlayer();
|
||||
int id = block.getTypeId();
|
||||
Material mat = block.getType();
|
||||
Material type = block.getType();
|
||||
|
||||
/* Code to prevent issues with placed falling Sand/Gravel not being tracked */
|
||||
if (mat.equals(Material.SAND) || mat.equals(Material.GRAVEL)) {
|
||||
if (type.equals(Material.SAND) || type.equals(Material.GRAVEL)) {
|
||||
for (int y = -1; y + block.getY() >= 0; y--) {
|
||||
if (block.getRelative(0, y, 0).getType().equals(Material.AIR)) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
Block newLocation = block.getRelative(0, y + 1, 0);
|
||||
newLocation.setMetadata("mcmmoPlacedBlock", new FixedMetadataValue(plugin, true));
|
||||
mcMMO.placeStore.setTrue(newLocation);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
|
||||
if (BlockChecks.shouldBeWatched(mat)) {
|
||||
block.setMetadata("mcmmoPlacedBlock", new FixedMetadataValue(plugin, true));
|
||||
if (BlockChecks.shouldBeWatched(block)) {
|
||||
if (!((type == Material.SAND || type == Material.GRAVEL) && block.getRelative(BlockFace.DOWN).getType() == Material.AIR)) { //Don't wanna track sand that's gonna fall.
|
||||
mcMMO.placeStore.setTrue(block);
|
||||
}
|
||||
}
|
||||
|
||||
if (id == Config.getInstance().getRepairAnvilId() && Config.getInstance().getRepairAnvilMessagesEnabled()) {
|
||||
if (id == configInstance.getRepairAnvilId() && configInstance.getRepairAnvilMessagesEnabled()) {
|
||||
Repair.placedAnvilCheck(player, id);
|
||||
}
|
||||
}
|
||||
@@ -130,80 +153,103 @@ public class BlockListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
Block block = event.getBlock();
|
||||
Material mat = block.getType();
|
||||
ItemStack inhand = player.getItemInHand();
|
||||
|
||||
if (event instanceof FakeBlockBreakEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* HERBALISM
|
||||
*/
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
/* Green Terra */
|
||||
if (PP.getToolPreparationMode(ToolType.HOE) && Permissions.getInstance().greenTerra(player) && ((mat.equals(Material.CROPS) && block.getData() == CropState.RIPE.getData()) || Herbalism.canBeGreenTerra(mat))) {
|
||||
Skills.abilityCheck(player, SkillType.HERBALISM);
|
||||
if (profile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Triple drops */
|
||||
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && Herbalism.canBeGreenTerra(mat)) {
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||
}
|
||||
Block block = event.getBlock();
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
|
||||
if (Permissions.getInstance().herbalism(player) && Herbalism.canBeGreenTerra(mat)) {
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||
}
|
||||
Config configInstance = Config.getInstance();
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
/*
|
||||
* MINING
|
||||
*/
|
||||
|
||||
if (Permissions.getInstance().mining(player) && Mining.canBeSuperBroken(mat)) {
|
||||
if (Config.getInstance().getMiningRequiresTool() && ItemChecks.isMiningPick(inhand)) {
|
||||
Mining.miningBlockCheck(player, block);
|
||||
/* HERBALISM */
|
||||
if (BlockChecks.canBeGreenTerra(block)) {
|
||||
/* Green Terra */
|
||||
if (profile.getToolPreparationMode(ToolType.HOE) && permInstance.greenTerra(player)) {
|
||||
Skills.abilityCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
else if (!Config.getInstance().getMiningRequiresTool()) {
|
||||
|
||||
/* Triple drops */
|
||||
if (profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||
}
|
||||
|
||||
if (permInstance.herbalism(player)) {
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
/* MINING */
|
||||
else if (BlockChecks.canBeSuperBroken(block) && permInstance.mining(player)) {
|
||||
if (configInstance.getMiningRequiresTool()) {
|
||||
if (ItemChecks.isPickaxe(inHand)) {
|
||||
Mining.miningBlockCheck(player, block);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Mining.miningBlockCheck(player, block);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WOOD CUTTING
|
||||
*/
|
||||
|
||||
if (Permissions.getInstance().woodcutting(player) && mat.equals(Material.LOG)) {
|
||||
if (Config.getInstance().getWoodcuttingRequiresTool() && ItemChecks.isAxe(inhand)) {
|
||||
/* WOOD CUTTING */
|
||||
else if (BlockChecks.isLog(block) && permInstance.woodcutting(player)) {
|
||||
if (configInstance.getWoodcuttingRequiresTool()) {
|
||||
if (ItemChecks.isAxe(inHand)) {
|
||||
WoodCutting.woodcuttingBlockCheck(player, block);
|
||||
}
|
||||
}
|
||||
else {
|
||||
WoodCutting.woodcuttingBlockCheck(player, block);
|
||||
}
|
||||
else if (!Config.getInstance().getWoodcuttingRequiresTool()) {
|
||||
WoodCutting.woodcuttingBlockCheck(player, block);
|
||||
|
||||
if (profile.getAbilityMode(AbilityType.TREE_FELLER) && permInstance.treeFeller(player) && ItemChecks.isAxe(inHand)) {
|
||||
WoodCutting.treeFeller(event);
|
||||
}
|
||||
}
|
||||
|
||||
if (PP.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.getInstance().treeFeller(player) && ItemChecks.isAxe(inhand)) {
|
||||
WoodCutting.treeFeller(event);
|
||||
}
|
||||
|
||||
/*
|
||||
* EXCAVATION
|
||||
*/
|
||||
|
||||
if (Excavation.canBeGigaDrillBroken(mat) && Permissions.getInstance().excavation(player) && !block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
if (Config.getInstance().getExcavationRequiresTool() && ItemChecks.isShovel(inhand)) {
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
/* EXCAVATION */
|
||||
else if (BlockChecks.canBeGigaDrillBroken(block) && permInstance.excavation(player) && !mcMMO.placeStore.isTrue(block)) {
|
||||
if (configInstance.getExcavationRequiresTool()) {
|
||||
if (ItemChecks.isShovel(inHand)) {
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
}
|
||||
}
|
||||
else if (!Config.getInstance().getExcavationRequiresTool()) {
|
||||
else {
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
}
|
||||
}
|
||||
|
||||
//Remove metadata when broken
|
||||
if (block.hasMetadata("mcmmoPlacedBlock") && BlockChecks.shouldBeWatched(mat)) {
|
||||
block.removeMetadata("mcmmoPlacedBlock", plugin);
|
||||
if (BlockChecks.shouldBeWatched(block)) {
|
||||
mcMMO.placeStore.setFalse(block);
|
||||
}
|
||||
|
||||
//Remove metadata from fallen sand/gravel
|
||||
Material aboveType = block.getRelative(BlockFace.UP).getType();
|
||||
|
||||
if (aboveType == Material.SAND || aboveType == Material.GRAVEL) {
|
||||
for (int y = 1; block.getY() + y <= block.getWorld().getMaxHeight(); y++) {
|
||||
Block relative = block.getRelative(0, y, 0);
|
||||
Material relativeType = relative.getType();
|
||||
|
||||
if ((relativeType == Material.SAND || relativeType == Material.GRAVEL) && mcMMO.placeStore.isTrue(relative)) {
|
||||
mcMMO.placeStore.setFalse(relative);
|
||||
}
|
||||
else if (!BlockChecks.shouldBeWatched(relative) && mcMMO.placeStore.isTrue(relative)){
|
||||
mcMMO.placeStore.setFalse(relative);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,87 +260,104 @@ public class BlockListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
|
||||
if (event instanceof FakeBlockDamageEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int LEAF_BLOWER_LEVEL = 100;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
ItemStack inhand = player.getItemInHand();
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (profile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
Block block = event.getBlock();
|
||||
Material mat = block.getType();
|
||||
Material material = block.getType();
|
||||
|
||||
Config configInstance = Config.getInstance();
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
/*
|
||||
* ABILITY PREPARATION CHECKS
|
||||
*/
|
||||
if (BlockChecks.abilityBlockCheck(mat)) {
|
||||
if (PP.getToolPreparationMode(ToolType.HOE) && (Herbalism.canBeGreenTerra(mat) || Herbalism.makeMossy(mat))) {
|
||||
if (BlockChecks.abilityBlockCheck(block)) {
|
||||
if (profile.getToolPreparationMode(ToolType.HOE) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.makeMossy(block))) {
|
||||
Skills.abilityCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
else if (PP.getToolPreparationMode(ToolType.AXE) && mat.equals(Material.LOG) && Permissions.getInstance().treeFeller(player)) { //Why are we checking the permissions here?
|
||||
else if (profile.getToolPreparationMode(ToolType.AXE) && BlockChecks.isLog(block) && permInstance.treeFeller(player)) { //TODO: Why are we checking the permissions here?
|
||||
Skills.abilityCheck(player, SkillType.WOODCUTTING);
|
||||
}
|
||||
else if (PP.getToolPreparationMode(ToolType.PICKAXE) && Mining.canBeSuperBroken(mat)) {
|
||||
else if (profile.getToolPreparationMode(ToolType.PICKAXE) && BlockChecks.canBeSuperBroken(block)) {
|
||||
Skills.abilityCheck(player, SkillType.MINING);
|
||||
}
|
||||
else if (PP.getToolPreparationMode(ToolType.SHOVEL) && Excavation.canBeGigaDrillBroken(mat)) {
|
||||
else if (profile.getToolPreparationMode(ToolType.SHOVEL) && BlockChecks.canBeGigaDrillBroken(block)) {
|
||||
Skills.abilityCheck(player, SkillType.EXCAVATION);
|
||||
}
|
||||
else if (PP.getToolPreparationMode(ToolType.FISTS) && (Excavation.canBeGigaDrillBroken(mat) || mat.equals(Material.SNOW))) {
|
||||
else if (profile.getToolPreparationMode(ToolType.FISTS) && (BlockChecks.canBeGigaDrillBroken(block) || material.equals(Material.SNOW))) {
|
||||
Skills.abilityCheck(player, SkillType.UNARMED);
|
||||
}
|
||||
}
|
||||
|
||||
/* TREE FELLER SOUNDS */
|
||||
if (Config.getInstance().spoutEnabled && mat.equals(Material.LOG) && PP.getAbilityMode(AbilityType.TREE_FELLER)) {
|
||||
if (mcMMO.spoutEnabled && BlockChecks.isLog(block) && profile.getAbilityMode(AbilityType.TREE_FELLER)) {
|
||||
SpoutSounds.playSoundForPlayer(SoundEffect.FIZZ, player, block.getLocation());
|
||||
}
|
||||
|
||||
/*
|
||||
* ABILITY TRIGGER CHECKS
|
||||
*/
|
||||
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && Permissions.getInstance().greenTerra(player) && Herbalism.makeMossy(mat)) {
|
||||
if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && permInstance.greenTerra(player) && BlockChecks.makeMossy(block)) {
|
||||
Herbalism.greenTerra(player, block);
|
||||
}
|
||||
else if (PP.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
|
||||
if (Config.getInstance().getExcavationRequiresTool() && ItemChecks.isShovel(inhand)) {
|
||||
event.setInstaBreak(true);
|
||||
Excavation.gigaDrillBreaker(player, block);
|
||||
else if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
|
||||
if (configInstance.getExcavationRequiresTool()) {
|
||||
if (ItemChecks.isShovel(inHand)) {
|
||||
event.setInstaBreak(true);
|
||||
Excavation.gigaDrillBreaker(player, block);
|
||||
}
|
||||
}
|
||||
else if (!Config.getInstance().getExcavationRequiresTool()) {
|
||||
else {
|
||||
event.setInstaBreak(true);
|
||||
Excavation.gigaDrillBreaker(player, block);
|
||||
}
|
||||
}
|
||||
else if (PP.getAbilityMode(AbilityType.BERSERK) && Skills.triggerCheck(player, block, AbilityType.BERSERK)) {
|
||||
if (inhand.getType().equals(Material.AIR)) {
|
||||
else if (profile.getAbilityMode(AbilityType.BERSERK) && Skills.triggerCheck(player, block, AbilityType.BERSERK)) {
|
||||
if (inHand.getType().equals(Material.AIR)) {
|
||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||
plugin.getServer().getPluginManager().callEvent(armswing);
|
||||
|
||||
event.setInstaBreak(true);
|
||||
}
|
||||
|
||||
if (Config.getInstance().spoutEnabled) {
|
||||
if (mcMMO.spoutEnabled) {
|
||||
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
||||
}
|
||||
}
|
||||
else if (PP.getAbilityMode(AbilityType.SUPER_BREAKER) && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
|
||||
if (Config.getInstance().getMiningRequiresTool() && ItemChecks.isMiningPick(inhand)) {
|
||||
event.setInstaBreak(true);
|
||||
Mining.SuperBreakerBlockCheck(player, block);
|
||||
}
|
||||
else if (!Config.getInstance().getMiningRequiresTool()) {
|
||||
event.setInstaBreak(true);
|
||||
Mining.SuperBreakerBlockCheck(player, block);
|
||||
}
|
||||
}
|
||||
else if (PP.getSkillLevel(SkillType.WOODCUTTING) >= LEAF_BLOWER_LEVEL && mat.equals(Material.LEAVES)) {
|
||||
if (Config.getInstance().getWoodcuttingRequiresTool() && ItemChecks.isAxe(inhand)) {
|
||||
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||
else if (profile.getAbilityMode(AbilityType.SUPER_BREAKER) && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
|
||||
if (configInstance.getMiningRequiresTool()) {
|
||||
if (ItemChecks.isPickaxe(inHand)) {
|
||||
event.setInstaBreak(true);
|
||||
WoodCutting.leafBlower(player, block);
|
||||
Mining.superBreakerBlockCheck(player, block);
|
||||
}
|
||||
}
|
||||
else if (!Config.getInstance().getWoodcuttingRequiresTool() && !inhand.getType().equals(Material.SHEARS)) {
|
||||
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||
else {
|
||||
event.setInstaBreak(true);
|
||||
Mining.superBreakerBlockCheck(player, block);
|
||||
}
|
||||
}
|
||||
else if (profile.getSkillLevel(SkillType.WOODCUTTING) >= LEAF_BLOWER_LEVEL && (material.equals(Material.LEAVES) || (configInstance.getBlockModsEnabled() && ModChecks.isCustomLeafBlock(block)))) {
|
||||
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||
if (configInstance.getWoodcuttingRequiresTool()) {
|
||||
if (ItemChecks.isAxe(inHand)) {
|
||||
event.setInstaBreak(true);
|
||||
WoodCutting.leafBlower(player, block);
|
||||
}
|
||||
}
|
||||
else if (!inHand.getType().equals(Material.SHEARS)) {
|
||||
event.setInstaBreak(true);
|
||||
WoodCutting.leafBlower(player, block);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -28,16 +31,16 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.Acrobatics;
|
||||
import com.gmail.nossr50.skills.Archery;
|
||||
import com.gmail.nossr50.skills.BlastMining;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.skills.Taming;
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||
import com.gmail.nossr50.skills.archery.Archery;
|
||||
import com.gmail.nossr50.skills.gathering.BlastMining;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.util.Combat;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class EntityListener implements Listener {
|
||||
@@ -58,26 +61,41 @@ public class EntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity defender = event.getEntity();
|
||||
Entity attacker = event.getDamager();
|
||||
Entity defender = event.getEntity();
|
||||
|
||||
if (attacker instanceof Player && defender instanceof Player) {
|
||||
if (!defender.getWorld().getPVP()) {
|
||||
if (attacker instanceof Projectile) {
|
||||
attacker = ((Projectile) attacker).getShooter();
|
||||
}
|
||||
else if (attacker instanceof Tameable) {
|
||||
AnimalTamer animalTamer = ((Tameable) attacker).getOwner();
|
||||
|
||||
if (animalTamer instanceof Entity) {
|
||||
attacker = (Entity) animalTamer;
|
||||
}
|
||||
}
|
||||
|
||||
if (defender instanceof Player) {
|
||||
Player defendingPlayer = (Player) defender;
|
||||
|
||||
if (!defendingPlayer.isOnline()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Party.getInstance().inSameParty((Player)defender, (Player)attacker)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
if (attacker instanceof Player) {
|
||||
if (PartyManager.getInstance().inSameParty(defendingPlayer, (Player) attacker)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for invincibility */
|
||||
if (defender instanceof LivingEntity) {
|
||||
LivingEntity livingDefender = (LivingEntity)defender;
|
||||
LivingEntity livingDefender = (LivingEntity) defender;
|
||||
|
||||
if (!Misc.isInvincible(livingDefender, event)) {
|
||||
Combat.combatChecks(event, plugin);
|
||||
Combat.combatChecks(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,45 +112,54 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
EntityType type = entity.getType();
|
||||
DamageCause cause = event.getCause();
|
||||
|
||||
switch(type) {
|
||||
case PLAYER:
|
||||
|
||||
if (!(entity instanceof LivingEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity lEntity = (LivingEntity) entity;
|
||||
|
||||
if (lEntity instanceof Player) {
|
||||
/* Check for invincibility */
|
||||
Player player = (Player) entity;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if (PP.getGodMode()) {
|
||||
if (!player.isOnline()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (profile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (profile.getGodMode()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Misc.isInvincible(player, event)) {
|
||||
if (cause == DamageCause.FALL && Permissions.getInstance().acrobatics(player)) {
|
||||
Acrobatics.acrobaticsCheck(player, event);
|
||||
if (cause == DamageCause.FALL && !player.isInsideVehicle() && !(player.getItemInHand().getType() == Material.ENDER_PEARL)) {
|
||||
AcrobaticsManager acroManager = new AcrobaticsManager(player);
|
||||
acroManager.rollCheck(event);
|
||||
}
|
||||
else if (cause == DamageCause.BLOCK_EXPLOSION && Permissions.getInstance().demolitionsExpertise(player)) {
|
||||
BlastMining.demolitionsExpertise(player, event);
|
||||
}
|
||||
|
||||
if (event.getDamage() >= 1) {
|
||||
PP.setRecentlyHurt(System.currentTimeMillis());
|
||||
profile.actualizeRecentlyHurt();
|
||||
}
|
||||
}
|
||||
break;
|
||||
} else if (lEntity instanceof Tameable) {
|
||||
Tameable pet = (Tameable) lEntity;
|
||||
AnimalTamer owner = pet.getOwner();
|
||||
|
||||
case WOLF:
|
||||
Wolf wolf = (Wolf) entity;
|
||||
|
||||
if ((!Misc.isInvincible(wolf, event)) && wolf.isTamed() && (wolf.getOwner() instanceof Player)) {
|
||||
Taming.preventDamage(event);
|
||||
if ((!Misc.isInvincible(lEntity, event)) && pet.isTamed() && (owner instanceof Player) && pet instanceof Wolf) {
|
||||
TamingManager tamingManager = new TamingManager((Player) owner);
|
||||
tamingManager.preventDamage(event);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,12 +171,10 @@ public class EntityListener implements Listener {
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
LivingEntity entity = event.getEntity();
|
||||
|
||||
entity.setFireTicks(0);
|
||||
|
||||
/* Remove bleed track */
|
||||
BleedTimer.remove(entity);
|
||||
|
||||
Archery.arrowRetrievalCheck(entity, plugin);
|
||||
Archery.arrowRetrievalCheck(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,8 +203,8 @@ public class EntityListener implements Listener {
|
||||
if (entity instanceof TNTPrimed) {
|
||||
int id = entity.getEntityId();
|
||||
|
||||
if (plugin.tntTracker.containsKey(id)) {
|
||||
Player player = plugin.tntTracker.get(id);
|
||||
if (plugin.tntIsTracked(id)) {
|
||||
Player player = plugin.getTNTPlayer(id);
|
||||
|
||||
if (Permissions.getInstance().biggerBombs(player)) {
|
||||
BlastMining.biggerBombs(player, event);
|
||||
@@ -200,10 +225,10 @@ public class EntityListener implements Listener {
|
||||
if (event.getEntity() instanceof TNTPrimed) {
|
||||
int id = entity.getEntityId();
|
||||
|
||||
if (plugin.tntTracker.containsKey(id)) {
|
||||
Player player = plugin.tntTracker.get(id);
|
||||
if (plugin.tntIsTracked(id)) {
|
||||
Player player = plugin.getTNTPlayer(id);
|
||||
BlastMining.dropProcessing(player, event);
|
||||
plugin.tntTracker.remove(id);
|
||||
plugin.removeFromTNTTracker(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -215,65 +240,67 @@ public class EntityListener implements Listener {
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.LOW)
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
if (Config.getInstance().getHerbalismHungerBonusEnabled()) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int currentFoodLevel = player.getFoodLevel();
|
||||
int newFoodLevel = event.getFoodLevel();
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
int currentFoodLevel = player.getFoodLevel();
|
||||
int newFoodLevel = event.getFoodLevel();
|
||||
|
||||
/*
|
||||
* Some foods have 3 ranks
|
||||
* Some foods have 5 ranks
|
||||
* The number of ranks is based on how 'common' the item is
|
||||
* We can adjust this quite easily if we find something is giving too much of a bonus
|
||||
*/
|
||||
if (!Permissions.getInstance().farmersDiet(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (newFoodLevel > currentFoodLevel) {
|
||||
Material food = player.getItemInHand().getType();
|
||||
int herbLevel = PP.getSkillLevel(SkillType.HERBALISM);
|
||||
int foodChange = newFoodLevel - currentFoodLevel;
|
||||
int rankChange = 0;
|
||||
/*
|
||||
* Some foods have 3 ranks
|
||||
* Some foods have 5 ranks
|
||||
* The number of ranks is based on how 'common' the item is
|
||||
* We can adjust this quite easily if we find something is giving too much of a bonus
|
||||
*/
|
||||
|
||||
switch (food) {
|
||||
case BREAD:
|
||||
/* BREAD RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||
rankChange = 200;
|
||||
break;
|
||||
if (newFoodLevel > currentFoodLevel) {
|
||||
Material food = player.getItemInHand().getType();
|
||||
int herbLevel = profile.getSkillLevel(SkillType.HERBALISM);
|
||||
int foodChange = newFoodLevel - currentFoodLevel;
|
||||
int rankChange = 0;
|
||||
|
||||
case COOKIE:
|
||||
/* COOKIE RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
rankChange = 400;
|
||||
break;
|
||||
switch (food) {
|
||||
case BREAD:
|
||||
/* BREAD RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||
rankChange = 200;
|
||||
break;
|
||||
|
||||
case MELON:
|
||||
/* MELON RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
rankChange = 400;
|
||||
break;
|
||||
case COOKIE:
|
||||
/* COOKIE RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
rankChange = 400;
|
||||
break;
|
||||
|
||||
case MUSHROOM_SOUP:
|
||||
/* MUSHROOM SOUP RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
rankChange = 200;
|
||||
break;
|
||||
case MELON:
|
||||
/* MELON RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
rankChange = 400;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
case MUSHROOM_SOUP:
|
||||
/* MUSHROOM SOUP RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
rankChange = 200;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 200; i <= 1000; i += rankChange) {
|
||||
if (herbLevel >= i) {
|
||||
foodChange++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 200; i <= 1000; i += rankChange) {
|
||||
if (herbLevel >= i) {
|
||||
foodChange++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure we don't go over the max value */
|
||||
newFoodLevel = currentFoodLevel + foodChange;
|
||||
if (newFoodLevel > 20) {
|
||||
event.setFoodLevel(20);
|
||||
}
|
||||
else {
|
||||
event.setFoodLevel(newFoodLevel);
|
||||
}
|
||||
/* Make sure we don't go over the max value */
|
||||
newFoodLevel = currentFoodLevel + foodChange;
|
||||
if (newFoodLevel > 20) {
|
||||
event.setFoodLevel(20);
|
||||
}
|
||||
else {
|
||||
event.setFoodLevel(newFoodLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -289,7 +316,7 @@ public class EntityListener implements Listener {
|
||||
Player player = (Player) event.getOwner();
|
||||
|
||||
if (Permissions.getInstance().taming(player) && !event.getEntity().hasMetadata("mcmmoSummoned")) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
EntityType type = event.getEntityType();
|
||||
int xp = 0;
|
||||
|
||||
@@ -306,8 +333,7 @@ public class EntityListener implements Listener {
|
||||
break;
|
||||
}
|
||||
|
||||
PP.addXP(SkillType.TAMING, xp);
|
||||
Skills.XpCheckSkill(SkillType.TAMING, player);
|
||||
Skills.xpProcessing(player, profile, SkillType.TAMING, xp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.util.Hardcore;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class HardcoreListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor PlayerDeath events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||
Player player = event.getEntity(); //Note this returns a Player object for this subevent
|
||||
|
||||
if (!Permissions.getInstance().hardcoremodeBypass(player)) {
|
||||
if (Config.getInstance().getHardcoreVampirismEnabled()) {
|
||||
Hardcore.invokeVampirism(player.getKiller(), player);
|
||||
}
|
||||
|
||||
Hardcore.invokeStatPenalty(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -22,14 +19,12 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.general.XprateCommand;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.runnables.RemoveProfileFromMemoryTask;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
@@ -37,16 +32,15 @@ import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.skills.BlastMining;
|
||||
import com.gmail.nossr50.skills.Fishing;
|
||||
import com.gmail.nossr50.skills.Herbalism;
|
||||
import com.gmail.nossr50.skills.Repair;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.skills.Taming;
|
||||
import com.gmail.nossr50.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.gathering.BlastMining;
|
||||
import com.gmail.nossr50.skills.gathering.Fishing;
|
||||
import com.gmail.nossr50.skills.gathering.Herbalism;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.Item;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
@@ -64,18 +58,22 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerWorldChangeEvent(PlayerChangedWorldEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (PP.getGodMode()) {
|
||||
if (profile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (profile.getGodMode()) {
|
||||
if (!Permissions.getInstance().mcgod(player)) {
|
||||
PP.toggleGodMode();
|
||||
profile.toggleGodMode();
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Forbidden"));
|
||||
}
|
||||
}
|
||||
|
||||
if (PP.inParty()) {
|
||||
if (profile.inParty()) {
|
||||
if (!Permissions.getInstance().party(player)) {
|
||||
PP.removeParty();
|
||||
profile.removeParty();
|
||||
player.sendMessage(LocaleLoader.getString("Party.Forbidden"));
|
||||
}
|
||||
}
|
||||
@@ -99,6 +97,10 @@ public class PlayerListener implements Listener {
|
||||
break;
|
||||
|
||||
case CAUGHT_ENTITY:
|
||||
if (!(event.getCaught() instanceof LivingEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Users.getProfile(player).getSkillLevel(SkillType.FISHING) >= 150 && Permissions.getInstance().shakeMob(player)) {
|
||||
Fishing.shakeMob(event);
|
||||
}
|
||||
@@ -117,7 +119,13 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
||||
if (Users.getProfile(event.getPlayer()).getAbilityMode(AbilityType.BERSERK)) {
|
||||
PlayerProfile profile = Users.getProfile(event.getPlayer());
|
||||
|
||||
if (profile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (profile.getAbilityMode(AbilityType.BERSERK)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -129,7 +137,7 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
Users.addUser(event.getPlayer());
|
||||
Users.addUser(event.getPlayer()).getProfile().actualizeRespawnATS();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,16 +151,8 @@ public class PlayerListener implements Listener {
|
||||
|
||||
/* GARBAGE COLLECTION */
|
||||
|
||||
//Remove Spout Stuff
|
||||
if (Config.getInstance().spoutEnabled && SpoutStuff.playerHUDs.containsKey(player)) {
|
||||
SpoutStuff.playerHUDs.remove(player);
|
||||
}
|
||||
|
||||
//Bleed it out
|
||||
BleedTimer.bleedOut(player);
|
||||
|
||||
//Schedule PlayerProfile removal 2 minutes after quitting
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RemoveProfileFromMemoryTask(player.getName()), 2400);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,17 +164,54 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Permissions.getInstance().motd(player) && Config.getInstance().getMOTDEnabled()) {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.MOTD", new Object[] {plugin.getDescription().getVersion()}));
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.Wiki"));
|
||||
//TODO: Locale ALL the things.
|
||||
if (Config.getInstance().getMOTDEnabled() && Permissions.getInstance().motd(player)) {
|
||||
String prefix = ChatColor.GOLD + "[mcMMO] ";
|
||||
String perkPrefix = ChatColor.RED + "[mcMMO Perks] ";
|
||||
|
||||
player.sendMessage(prefix + ChatColor.YELLOW + "Running version " + ChatColor.DARK_AQUA + plugin.getDescription().getVersion()); //TODO: Locale
|
||||
|
||||
if (Config.getInstance().getHardcoreEnabled()) {
|
||||
if (Config.getInstance().getHardcoreVampirismEnabled()) {
|
||||
player.sendMessage(prefix + ChatColor.DARK_RED + "Hardcore & Vampirism enabled.");
|
||||
player.sendMessage(prefix + ChatColor.DARK_AQUA + "Skill Death Penalty: " + ChatColor.DARK_RED + Config.getInstance().getHardcoreDeathStatPenaltyPercentage() + "% " + ChatColor.DARK_AQUA + "Vampirism Stat Leech: " + ChatColor.DARK_RED + Config.getInstance().getHardcoreVampirismStatLeechPercentage() + "%");
|
||||
}
|
||||
else {
|
||||
player.sendMessage(prefix + ChatColor.DARK_RED + "Hardcore enabled.");
|
||||
player.sendMessage(prefix + ChatColor.DARK_AQUA + "Skill Death Penalty: " + ChatColor.DARK_RED + Config.getInstance().getHardcoreDeathStatPenaltyPercentage() + "%");
|
||||
}
|
||||
}
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
|
||||
player.sendMessage(perkPrefix + ChatColor.DARK_AQUA + "Quadruple XP - Receive 4x XP.");
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.triple")) {
|
||||
player.sendMessage(perkPrefix + ChatColor.DARK_AQUA + "Triple XP - Receive 3x XP.");
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.double")) {
|
||||
player.sendMessage(perkPrefix + ChatColor.DARK_AQUA + "Double XP - Receive 2x XP.");
|
||||
}
|
||||
|
||||
player.sendMessage(ChatColor.GOLD+"[mcMMO] " + ChatColor.GREEN + "http://www.mcmmo.info" + ChatColor.YELLOW + " - mcMMO Website & Forums"); //TODO: Locale
|
||||
//player.sendMessage(LocaleLoader.getString("mcMMO.MOTD", new Object[] {plugin.getDescription().getVersion()}));
|
||||
//player.sendMessage(LocaleLoader.getString("mcMMO.Website"));
|
||||
}
|
||||
|
||||
//THIS IS VERY BAD WAY TO DO THINGS, NEED BETTER WAY
|
||||
if (XprateCommand.xpevent) {
|
||||
if (XprateCommand.isXpEventRunning()) {
|
||||
player.sendMessage(LocaleLoader.getString("XPRate.Event", new Object[] {Config.getInstance().xpGainMultiplier}));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
PlayerProfile profile = Users.getProfile(event.getPlayer());
|
||||
|
||||
if (profile != null) {
|
||||
profile.actualizeRespawnATS();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor PlayerInteract events.
|
||||
*
|
||||
@@ -183,33 +220,34 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
Action action = event.getAction();
|
||||
Block block = event.getClickedBlock();
|
||||
ItemStack is = player.getItemInHand();
|
||||
Material mat;
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
Material material;
|
||||
|
||||
/* Fix for NPE on interacting with air */
|
||||
if (block == null) {
|
||||
mat = Material.AIR;
|
||||
material = Material.AIR;
|
||||
}
|
||||
else {
|
||||
mat = block.getType();
|
||||
material = block.getType();
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
case RIGHT_CLICK_BLOCK:
|
||||
|
||||
/* REPAIR CHECKS */
|
||||
if (Permissions.getInstance().repair(player) && block.getTypeId() == Config.getInstance().getRepairAnvilId() && (ItemChecks.isTool(is) || ItemChecks.isArmor(is))) {
|
||||
Repair.repairCheck(player, is);
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
if (Permissions.getInstance().repair(player) && block.getTypeId() == Config.getInstance().getRepairAnvilId()) {
|
||||
if (mcMMO.repairManager.isRepairable(inHand)) {
|
||||
mcMMO.repairManager.handleRepair(player, inHand);
|
||||
event.setCancelled(true);
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
/* ACTIVATION CHECKS */
|
||||
if (Config.getInstance().getAbilitiesEnabled() && BlockChecks.abilityBlockCheck(mat)) {
|
||||
if (!mat.equals(Material.DIRT) && !mat.equals(Material.GRASS) && !mat.equals(Material.SOIL)) {
|
||||
if (Config.getInstance().getAbilitiesEnabled() && BlockChecks.abilityBlockCheck(block)) {
|
||||
if (!material.equals(Material.DIRT) && !material.equals(Material.GRASS) && !material.equals(Material.SOIL)) {
|
||||
Skills.activationCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
@@ -222,17 +260,17 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
/* GREEN THUMB CHECK */
|
||||
if (Permissions.getInstance().greenThumbBlocks(player) && Herbalism.makeMossy(mat) && is.getType().equals(Material.SEEDS)) {
|
||||
Herbalism.greenThumbBlocks(is, player, block);
|
||||
if (inHand.getType().equals(Material.SEEDS) && BlockChecks.makeMossy(block) && Permissions.getInstance().greenThumbBlocks(player)) {
|
||||
Herbalism.greenThumbBlocks(inHand, player, block);
|
||||
}
|
||||
|
||||
/* ITEM CHECKS */
|
||||
if (BlockChecks.abilityBlockCheck(mat)) {
|
||||
Item.itemchecks(player);
|
||||
if (BlockChecks.abilityBlockCheck(block)) {
|
||||
Item.itemChecks(player);
|
||||
}
|
||||
|
||||
/* BLAST MINING CHECK */
|
||||
if (player.isSneaking() && Permissions.getInstance().blastMining(player) && is.getTypeId() == Config.getInstance().getDetonatorItemID()) {
|
||||
if (player.isSneaking() && inHand.getTypeId() == Config.getInstance().getDetonatorItemID() && Permissions.getInstance().blastMining(player)) {
|
||||
BlastMining.detonate(event, player, plugin);
|
||||
}
|
||||
|
||||
@@ -252,10 +290,10 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
/* ITEM CHECKS */
|
||||
Item.itemchecks(player);
|
||||
Item.itemChecks(player);
|
||||
|
||||
/* BLAST MINING CHECK */
|
||||
if (player.isSneaking() && Permissions.getInstance().blastMining(player) && is.getTypeId() == Config.getInstance().getDetonatorItemID()) {
|
||||
if (player.isSneaking() && inHand.getTypeId() == Config.getInstance().getDetonatorItemID() && Permissions.getInstance().blastMining(player)) {
|
||||
BlastMining.detonate(event, player, plugin);
|
||||
}
|
||||
|
||||
@@ -265,12 +303,16 @@ public class PlayerListener implements Listener {
|
||||
case LEFT_CLICK_BLOCK:
|
||||
|
||||
/* CALL OF THE WILD CHECKS */
|
||||
if (player.isSneaking() && Permissions.getInstance().taming(player)) {
|
||||
if (is.getType().equals(Material.RAW_FISH)) {
|
||||
Taming.animalSummon(EntityType.OCELOT, player, plugin);
|
||||
if (player.isSneaking()) {
|
||||
Material type = inHand.getType();
|
||||
|
||||
if (type == Material.RAW_FISH) {
|
||||
TamingManager tamingManager = new TamingManager(player);
|
||||
tamingManager.summonOcelot();
|
||||
}
|
||||
else if (is.getType().equals(Material.BONE)) {
|
||||
Taming.animalSummon(EntityType.WOLF, player, plugin);
|
||||
else if (type == Material.BONE) {
|
||||
TamingManager tamingManager = new TamingManager(player);
|
||||
tamingManager.summonWolf();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,66 +328,65 @@ public class PlayerListener implements Listener {
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerChat(PlayerChatEvent event) {
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
boolean partyChat = PP.getPartyChatMode();
|
||||
boolean adminChat = PP.getAdminChatMode();
|
||||
Set<Player> recipients = event.getRecipients();
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
Set<Player> intendedRecipients = new HashSet<Player>();
|
||||
ChatColor color = null;
|
||||
if (profile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (partyChat || adminChat) {
|
||||
if (partyChat) {
|
||||
if (!PP.inParty()) {
|
||||
player.sendMessage("You're not in a party, type /p to leave party chat mode."); //TODO: Use mcLocale
|
||||
return;
|
||||
}
|
||||
if (profile.getPartyChatMode()) {
|
||||
Party party = profile.getParty();
|
||||
|
||||
color = ChatColor.GREEN;
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), PP.getParty(), event.getMessage());
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if(chatEvent.isCancelled()) return;
|
||||
|
||||
event.setMessage(chatEvent.getMessage());
|
||||
|
||||
for (Player x : Party.getInstance().getOnlineMembers(player)) {
|
||||
intendedRecipients.add(x);
|
||||
}
|
||||
|
||||
event.setFormat(color + "(" + ChatColor.WHITE + "%1$s" + color + ") %2$s");
|
||||
if (party == null) {
|
||||
player.sendMessage("You're not in a party, type /p to leave party chat mode."); //TODO: Use mcLocale
|
||||
return;
|
||||
}
|
||||
|
||||
if (adminChat) {
|
||||
color = ChatColor.AQUA;
|
||||
String partyName = party.getName();
|
||||
String playerName = player.getName();
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(playerName, partyName, event.getMessage());
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), event.getMessage());
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if(chatEvent.isCancelled()) return;
|
||||
|
||||
event.setMessage(chatEvent.getMessage());
|
||||
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
if (x.isOp() || Permissions.getInstance().adminChat(x)) {
|
||||
intendedRecipients.add(x);
|
||||
}
|
||||
}
|
||||
|
||||
event.setFormat(color + "{" + ChatColor.WHITE + "%1$s" + color + "} %2$s");
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
recipients.retainAll(intendedRecipients);
|
||||
String prefix = ChatColor.GREEN + "(" + ChatColor.WHITE + playerName + ChatColor.GREEN + ") ";
|
||||
|
||||
plugin.getLogger().info("[P](" + partyName + ")" + "<" + playerName + "> " + chatEvent.getMessage());
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
member.sendMessage(prefix + chatEvent.getMessage());
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (profile.getAdminChatMode()) {
|
||||
String playerName = player.getName();
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(playerName, event.getMessage());
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String prefix = ChatColor.AQUA + "{" + ChatColor.WHITE + playerName + ChatColor.AQUA + "} ";
|
||||
|
||||
plugin.getLogger().info("[A]<" + playerName + "> " + chatEvent.getMessage());
|
||||
|
||||
for (Player otherPlayer : plugin.getServer().getOnlinePlayers()) {
|
||||
if (Permissions.getInstance().adminChat(otherPlayer) || otherPlayer.isOp()) {
|
||||
otherPlayer.sendMessage(prefix + chatEvent.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Dynamically aliasing commands need to be re-done.
|
||||
// For now, using a command with an alias will send both the original command, and the mcMMO command
|
||||
|
||||
/**
|
||||
* Monitor PlayerCommandPreprocess events.
|
||||
*
|
||||
@@ -354,18 +395,16 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
String message = event.getMessage();
|
||||
|
||||
if (!message.startsWith("/")) {
|
||||
return;
|
||||
}
|
||||
|
||||
String command = message.substring(1).split(" ")[0];
|
||||
String lowerCaseCommand = command.toLowerCase();
|
||||
|
||||
if (plugin.aliasMap.containsKey(command)) {
|
||||
if (command.equalsIgnoreCase(plugin.aliasMap.get(command))) {
|
||||
if (plugin.commandIsAliased(lowerCaseCommand)) {
|
||||
//We should find a better way to avoid string replacement where the alias is equals to the command
|
||||
if (command.equals(plugin.getCommandAlias(lowerCaseCommand))) {
|
||||
return;
|
||||
}
|
||||
event.getPlayer().chat(message.replaceFirst(command, plugin.aliasMap.get(command)));
|
||||
|
||||
event.setMessage(message.replace(command, plugin.getCommandAlias(lowerCaseCommand)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.getspout.spoutapi.event.input.KeyPressedEvent;
|
||||
import org.getspout.spoutapi.gui.ScreenType;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.popups.PopupMMO;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SpoutInputListener implements Listener {
|
||||
private mcMMO plugin;
|
||||
|
||||
public SpoutInputListener(mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor Spout KeyPressed events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler
|
||||
public void onKeyPressedEvent(KeyPressedEvent event) {
|
||||
SpoutPlayer sPlayer = event.getPlayer();
|
||||
|
||||
if (!sPlayer.isSpoutCraftEnabled() || sPlayer.getMainScreen().getActivePopup() != null || event.getScreenType() != ScreenType.GAME_SCREEN) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getKey() == SpoutStuff.keypress) {
|
||||
if (!SpoutStuff.playerScreens.containsKey(sPlayer)) {
|
||||
PopupMMO mmoPop = new PopupMMO(sPlayer, Users.getProfile(sPlayer), plugin);
|
||||
|
||||
SpoutStuff.playerScreens.put(sPlayer, mmoPop);
|
||||
sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer));
|
||||
sPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
else {
|
||||
sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer));
|
||||
sPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,24 +3,24 @@ package com.gmail.nossr50.listeners;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.getspout.spoutapi.event.input.KeyPressedEvent;
|
||||
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
|
||||
import org.getspout.spoutapi.event.screen.ScreenCloseEvent;
|
||||
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
||||
import org.getspout.spoutapi.gui.Button;
|
||||
import org.getspout.spoutapi.gui.ScreenType;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.HUDmmo;
|
||||
import com.gmail.nossr50.config.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.SpoutHud;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.buttons.McmmoButton;
|
||||
import com.gmail.nossr50.datatypes.popups.Menu;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SpoutListener implements Listener {
|
||||
//Why do we have this here? We never use it...
|
||||
mcMMO plugin = null;
|
||||
|
||||
public SpoutListener(mcMMO pluginx) {
|
||||
plugin = pluginx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor SpoutCraftEnable events.
|
||||
*
|
||||
@@ -28,19 +28,66 @@ public class SpoutListener implements Listener {
|
||||
*/
|
||||
@EventHandler
|
||||
public void onSpoutCraftEnable(SpoutCraftEnableEvent event) {
|
||||
SpoutPlayer sPlayer = event.getPlayer();
|
||||
PlayerProfile PPs = Users.getProfile(sPlayer);
|
||||
SpoutPlayer spoutPlayer = event.getPlayer();
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(spoutPlayer);
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
|
||||
//TODO: Add custom titles based on skills
|
||||
if (Config.getInstance().getShowPowerLevelForSpout()) {
|
||||
sPlayer.setTitle(sPlayer.getName()+ "\n" + ChatColor.YELLOW + "P" + ChatColor.GOLD + "lvl"
|
||||
+ ChatColor.WHITE+"." + ChatColor.GREEN + String.valueOf(PPs.getPowerLevel()));
|
||||
if (SpoutConfig.getInstance().getShowPowerLevel()) {
|
||||
spoutPlayer.setTitle(spoutPlayer.getName() + "\n" + ChatColor.YELLOW + "P" + ChatColor.GOLD + "lvl" + ChatColor.WHITE+"." + ChatColor.GREEN + String.valueOf(mcMMOPlayer.getPowerLevel()));
|
||||
}
|
||||
|
||||
if (sPlayer.isSpoutCraftEnabled()) {
|
||||
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin)); //Setup Party HUD stuff
|
||||
|
||||
PPs.toggleSpoutEnabled();
|
||||
profile.setSpoutHud(new SpoutHud(mcMMOPlayer)); //Setup Party HUD stuff
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor Spout ButtonClick events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler
|
||||
public void onButtonClick(ButtonClickEvent event) {
|
||||
Button button = event.getButton();
|
||||
|
||||
if (button instanceof McmmoButton) {
|
||||
((McmmoButton) button).activate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor Spout ScreenClose events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler
|
||||
public void onScreenClose(ScreenCloseEvent event) {
|
||||
if (event.getScreen() instanceof Menu) {
|
||||
SpoutPlayer spoutPlayer = event.getPlayer();
|
||||
|
||||
Users.getProfile(spoutPlayer).getSpoutHud().onMenuClose();
|
||||
spoutPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor Spout KeyPressed events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler
|
||||
public void onKeyPressedEvent(KeyPressedEvent event) {
|
||||
SpoutPlayer spoutPlayer = event.getPlayer();
|
||||
|
||||
if (spoutPlayer.getMainScreen().getActivePopup() != null || event.getScreenType() != ScreenType.GAME_SCREEN) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getKey() == SpoutStuff.keypress) {
|
||||
SpoutHud spoutHud = Users.getProfile(spoutPlayer).getSpoutHud();
|
||||
|
||||
if (!spoutHud.isMenuOpened()) {
|
||||
spoutHud.openMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
|
||||
import org.getspout.spoutapi.event.screen.ScreenCloseEvent;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.HUDType;
|
||||
import com.gmail.nossr50.datatypes.HUDmmo;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.buttons.ButtonEscape;
|
||||
import com.gmail.nossr50.datatypes.buttons.ButtonHUDStyle;
|
||||
import com.gmail.nossr50.datatypes.buttons.ButtonPartyToggle;
|
||||
import com.gmail.nossr50.datatypes.popups.PopupMMO;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SpoutScreenListener implements Listener {
|
||||
//Why do we have this here? We never use it...
|
||||
mcMMO plugin = null;
|
||||
|
||||
public SpoutScreenListener(mcMMO pluginx) {
|
||||
plugin = pluginx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor Spout ButtonClick events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler
|
||||
public void onButtonClick(ButtonClickEvent event) {
|
||||
SpoutPlayer sPlayer = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(sPlayer);
|
||||
|
||||
if (event.getButton() instanceof ButtonHUDStyle) {
|
||||
if (SpoutStuff.playerHUDs.containsKey(sPlayer)) {
|
||||
SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
|
||||
SpoutStuff.playerHUDs.remove(sPlayer);
|
||||
|
||||
switch (PP.getHUDType()) {
|
||||
case RETRO:
|
||||
PP.setHUDType(HUDType.STANDARD);
|
||||
break;
|
||||
|
||||
case STANDARD:
|
||||
PP.setHUDType(HUDType.SMALL);
|
||||
break;
|
||||
|
||||
case SMALL:
|
||||
PP.setHUDType(HUDType.DISABLED);
|
||||
break;
|
||||
|
||||
case DISABLED:
|
||||
PP.setHUDType(HUDType.RETRO);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin));
|
||||
SpoutStuff.playerScreens.get(sPlayer).updateButtons(PP);
|
||||
}
|
||||
}
|
||||
else if (event.getButton() instanceof ButtonEscape) {
|
||||
sPlayer.getMainScreen().closePopup();
|
||||
}
|
||||
else if (event.getButton() instanceof ButtonPartyToggle) {
|
||||
PP.togglePartyHUD();
|
||||
ButtonPartyToggle bpt = (ButtonPartyToggle) event.getButton();
|
||||
bpt.updateText(PP);
|
||||
SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
|
||||
SpoutStuff.playerHUDs.get(sPlayer).initializeHUD(sPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor Spout ScreenClose events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler
|
||||
public void onScreenClose(ScreenCloseEvent event) {
|
||||
if (event.getScreen() instanceof PopupMMO) {
|
||||
SpoutStuff.playerScreens.remove(event.getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
37
src/main/java/com/gmail/nossr50/listeners/WorldListener.java
Normal file
37
src/main/java/com/gmail/nossr50/listeners/WorldListener.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldSaveEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class WorldListener implements Listener {
|
||||
@EventHandler
|
||||
public void onWorldLoad(WorldLoadEvent event) {
|
||||
File dataDir = new File(event.getWorld().getWorldFolder(), "mcmmo_data");
|
||||
if(!dataDir.exists()) {
|
||||
dataDir.mkdir();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldUnload(WorldUnloadEvent event) {
|
||||
mcMMO.placeStore.unloadWorld(event.getWorld());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldSave(WorldSaveEvent event) {
|
||||
mcMMO.placeStore.saveWorld(event.getWorld());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChunkUnload(ChunkUnloadEvent event) {
|
||||
mcMMO.placeStore.chunkUnloaded(event.getChunk().getX(), event.getChunk().getZ(), event.getWorld());
|
||||
}
|
||||
}
|
||||
@@ -1,87 +1,168 @@
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.commands.skills.*;
|
||||
import com.gmail.nossr50.commands.spout.*;
|
||||
import com.gmail.nossr50.commands.mc.*;
|
||||
import com.gmail.nossr50.commands.party.*;
|
||||
import com.gmail.nossr50.commands.general.*;
|
||||
import com.gmail.nossr50.config.*;
|
||||
import com.gmail.nossr50.runnables.*;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.util.Leaderboard;
|
||||
import com.gmail.nossr50.util.Metrics;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.listeners.BlockListener;
|
||||
import com.gmail.nossr50.listeners.EntityListener;
|
||||
import com.gmail.nossr50.listeners.PlayerListener;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.shatteredlands.shatt.backup.ZipLibrary;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
import com.gmail.nossr50.commands.general.AddlevelsCommand;
|
||||
import com.gmail.nossr50.commands.general.AddxpCommand;
|
||||
import com.gmail.nossr50.commands.general.InspectCommand;
|
||||
import com.gmail.nossr50.commands.general.McstatsCommand;
|
||||
import com.gmail.nossr50.commands.general.MmoeditCommand;
|
||||
import com.gmail.nossr50.commands.general.MmoupdateCommand;
|
||||
import com.gmail.nossr50.commands.general.XprateCommand;
|
||||
import com.gmail.nossr50.commands.mc.McabilityCommand;
|
||||
import com.gmail.nossr50.commands.mc.MccCommand;
|
||||
import com.gmail.nossr50.commands.mc.McgodCommand;
|
||||
import com.gmail.nossr50.commands.mc.McmmoCommand;
|
||||
import com.gmail.nossr50.commands.mc.McrefreshCommand;
|
||||
import com.gmail.nossr50.commands.mc.McremoveCommand;
|
||||
import com.gmail.nossr50.commands.mc.MctopCommand;
|
||||
import com.gmail.nossr50.commands.party.ACommand;
|
||||
import com.gmail.nossr50.commands.party.AcceptCommand;
|
||||
import com.gmail.nossr50.commands.party.InviteCommand;
|
||||
import com.gmail.nossr50.commands.party.PCommand;
|
||||
import com.gmail.nossr50.commands.party.PartyCommand;
|
||||
import com.gmail.nossr50.commands.party.PtpCommand;
|
||||
import com.gmail.nossr50.commands.skills.AcrobaticsCommand;
|
||||
import com.gmail.nossr50.commands.skills.ArcheryCommand;
|
||||
import com.gmail.nossr50.commands.skills.AxesCommand;
|
||||
import com.gmail.nossr50.commands.skills.ExcavationCommand;
|
||||
import com.gmail.nossr50.commands.skills.FishingCommand;
|
||||
import com.gmail.nossr50.commands.skills.HerbalismCommand;
|
||||
import com.gmail.nossr50.commands.skills.MiningCommand;
|
||||
import com.gmail.nossr50.commands.skills.RepairCommand;
|
||||
import com.gmail.nossr50.commands.skills.SwordsCommand;
|
||||
import com.gmail.nossr50.commands.skills.TamingCommand;
|
||||
import com.gmail.nossr50.commands.skills.UnarmedCommand;
|
||||
import com.gmail.nossr50.commands.skills.WoodcuttingCommand;
|
||||
import com.gmail.nossr50.commands.spout.MchudCommand;
|
||||
import com.gmail.nossr50.commands.spout.XplockCommand;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.HiddenConfig;
|
||||
import com.gmail.nossr50.config.TreasuresConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomToolsConfig;
|
||||
import com.gmail.nossr50.config.repair.RepairConfigManager;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.listeners.BlockListener;
|
||||
import com.gmail.nossr50.listeners.EntityListener;
|
||||
import com.gmail.nossr50.listeners.HardcoreListener;
|
||||
import com.gmail.nossr50.listeners.PlayerListener;
|
||||
import com.gmail.nossr50.listeners.WorldListener;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.runnables.ChunkletUnloader;
|
||||
import com.gmail.nossr50.runnables.SaveTimer;
|
||||
import com.gmail.nossr50.runnables.SkillMonitor;
|
||||
import com.gmail.nossr50.runnables.SpoutStart;
|
||||
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||
import com.gmail.nossr50.skills.repair.RepairManagerFactory;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.util.Leaderboard;
|
||||
import com.gmail.nossr50.util.Metrics;
|
||||
import com.gmail.nossr50.util.Metrics.Graph;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.blockmeta.ChunkletManager;
|
||||
import com.gmail.nossr50.util.blockmeta.ChunkletManagerFactory;
|
||||
|
||||
public class mcMMO extends JavaPlugin {
|
||||
|
||||
private final PlayerListener playerListener = new PlayerListener(this);
|
||||
private final BlockListener blockListener = new BlockListener(this);
|
||||
private final EntityListener entityListener = new EntityListener(this);
|
||||
private final WorldListener worldListener = new WorldListener();
|
||||
private final HardcoreListener hardcoreListener = new HardcoreListener();
|
||||
|
||||
public HashMap<String, String> aliasMap = new HashMap<String, String>(); //Alias - Command
|
||||
public HashMap<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
|
||||
public HashMap<Integer, Player> tntTracker = new HashMap<Integer, Player>();
|
||||
private HashMap<String, String> aliasMap = new HashMap<String, String>(); //Alias - Command
|
||||
private HashMap<Integer, String> tntTracker = new HashMap<Integer, String>();
|
||||
|
||||
public static File versionFile;
|
||||
public static Database database;
|
||||
private static Database database;
|
||||
public static mcMMO p;
|
||||
|
||||
//Jar stuff
|
||||
public static File mcmmo;
|
||||
public static ChunkletManager placeStore;
|
||||
public static RepairManager repairManager;
|
||||
|
||||
/* Jar Stuff */
|
||||
public static File mcmmo;
|
||||
|
||||
//File Paths
|
||||
public static String mainDirectory;
|
||||
public static String flatFileDirectory;
|
||||
public static String usersFile;
|
||||
public static String leaderboardDirectory;
|
||||
private static String mainDirectory;
|
||||
private static String flatFileDirectory;
|
||||
private static String usersFile;
|
||||
private static String leaderboardDirectory;
|
||||
private static String modDirectory;
|
||||
|
||||
//Spout Check
|
||||
public static boolean spoutEnabled;
|
||||
|
||||
/**
|
||||
* Things to be run when the plugin is enabled.
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
p = this;
|
||||
mcmmo = getFile();
|
||||
setupFilePaths();
|
||||
|
||||
mainDirectory = getDataFolder().getPath() + File.separator;
|
||||
flatFileDirectory = mainDirectory + "FlatFileStuff" + File.separator;
|
||||
leaderboardDirectory = flatFileDirectory + "Leaderboards" + File.separator;
|
||||
usersFile = flatFileDirectory + "mcmmo.users";
|
||||
//Force the loading of config files
|
||||
Config configInstance = Config.getInstance();
|
||||
TreasuresConfig.getInstance();
|
||||
HiddenConfig.getInstance();
|
||||
|
||||
if (!Config.getInstance().getUseMySQL()) {
|
||||
List<Repairable> repairables = new ArrayList<Repairable>();
|
||||
|
||||
if (configInstance.getToolModsEnabled()) {
|
||||
repairables.addAll(CustomToolsConfig.getInstance().getLoadedRepairables());
|
||||
}
|
||||
|
||||
if (configInstance.getArmorModsEnabled()) {
|
||||
repairables.addAll(CustomArmorConfig.getInstance().getLoadedRepairables());
|
||||
}
|
||||
|
||||
if (configInstance.getBlockModsEnabled()) {
|
||||
CustomBlocksConfig.getInstance();
|
||||
}
|
||||
|
||||
//Load repair configs, make manager, and register them at this time
|
||||
RepairConfigManager rManager = new RepairConfigManager(this);
|
||||
repairables.addAll(rManager.getLoadedRepairables());
|
||||
repairManager = RepairManagerFactory.getRepairManager(repairables.size());
|
||||
repairManager.registerRepairables(repairables);
|
||||
|
||||
if (!configInstance.getUseMySQL()) {
|
||||
Users.loadUsers();
|
||||
}
|
||||
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
PluginManager pluginManager = getServer().getPluginManager();
|
||||
|
||||
//Register events
|
||||
pm.registerEvents(playerListener, this);
|
||||
pm.registerEvents(blockListener, this);
|
||||
pm.registerEvents(entityListener, this);
|
||||
pluginManager.registerEvents(playerListener, this);
|
||||
pluginManager.registerEvents(blockListener, this);
|
||||
pluginManager.registerEvents(entityListener, this);
|
||||
pluginManager.registerEvents(worldListener, this);
|
||||
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
if (configInstance.getHardcoreEnabled()) {
|
||||
pluginManager.registerEvents(hardcoreListener, this);
|
||||
}
|
||||
|
||||
PluginDescriptionFile pdfFile = getDescription();
|
||||
|
||||
//Setup the leaderboards
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
if (configInstance.getUseMySQL()) {
|
||||
database = new Database(this);
|
||||
database.createStructure();
|
||||
}
|
||||
@@ -99,37 +180,61 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
//Schedule Spout Activation 1 second after start-up
|
||||
scheduler.scheduleSyncDelayedTask(this, new SpoutStart(this), 20);
|
||||
//Periodic save timer (Saves every 10 minutes)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(this), 0, Config.getInstance().getSaveInterval() * 1200);
|
||||
//Periodic save timer (Saves every 10 minutes by default)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(this), 0, configInstance.getSaveInterval() * 1200);
|
||||
//Regen & Cooldown timer (Runs every second)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new SkillMonitor(this), 0, 20);
|
||||
//Bleed timer (Runs every two seconds)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new BleedTimer(), 0, 40);
|
||||
//Chunklet unloader (Runs every 20 seconds by default)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new ChunkletUnloader(), 0, ChunkletUnloader.RUN_INTERVAL * 20);
|
||||
|
||||
registerCommands();
|
||||
|
||||
if (Config.getInstance().getStatsTrackingEnabled()) {
|
||||
if (configInstance.getStatsTrackingEnabled()) {
|
||||
try {
|
||||
Metrics metrics = new Metrics(this);
|
||||
metrics.start();
|
||||
Metrics metrics = new Metrics(this);
|
||||
|
||||
Graph graph = metrics.createGraph("Percentage of servers using timings");
|
||||
|
||||
if (pluginManager.useTimings()) {
|
||||
graph.addPlotter(new Metrics.Plotter("Enabled") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (IOException e) {
|
||||
else {
|
||||
graph.addPlotter(new Metrics.Plotter("Disabled") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
metrics.start();
|
||||
}
|
||||
catch (IOException e) {
|
||||
System.out.println("Failed to submit stats.");
|
||||
}
|
||||
}
|
||||
|
||||
// Get our ChunkletManager
|
||||
placeStore = ChunkletManagerFactory.getChunkletManager();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get profile of the player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player Player whose profile to get
|
||||
* @return the PlayerProfile object
|
||||
* Setup the various storage file paths
|
||||
*/
|
||||
public PlayerProfile getPlayerProfile(Player player) {
|
||||
return Users.getProfile(player);
|
||||
public void setupFilePaths() {
|
||||
mcmmo = getFile();
|
||||
mainDirectory = getDataFolder().getPath() + File.separator;
|
||||
flatFileDirectory = mainDirectory + "FlatFileStuff" + File.separator;
|
||||
usersFile = flatFileDirectory + "mcmmo.users";
|
||||
leaderboardDirectory = flatFileDirectory + "Leaderboards" + File.separator;
|
||||
modDirectory = mainDirectory + "ModConfigs" + File.separator;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,33 +245,54 @@ public class mcMMO extends JavaPlugin {
|
||||
* @param playerName Name of player whose profile to get
|
||||
* @return the PlayerProfile object
|
||||
*/
|
||||
public PlayerProfile getPlayerProfileByName(String playerName) {
|
||||
return Users.getProfileByName(playerName);
|
||||
public PlayerProfile getPlayerProfile(String playerName) {
|
||||
return Users.getProfile(playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get profile of the offline player.
|
||||
* Get profile of the player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player Offline player whose profile to get
|
||||
* @param player player whose profile to get
|
||||
* @return the PlayerProfile object
|
||||
*/
|
||||
public PlayerProfile getOfflinePlayerProfile(OfflinePlayer player) {
|
||||
public PlayerProfile getPlayerProfile(OfflinePlayer player) {
|
||||
return Users.getProfile(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get profile of the player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player player whose profile to get
|
||||
* @return the PlayerProfile object
|
||||
*/
|
||||
@Deprecated
|
||||
public PlayerProfile getPlayerProfile(Player player) {
|
||||
return Users.getProfile(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Things to be run when the plugin is disabled.
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Users.saveAll(); //Make sure to save player information if the server shuts down
|
||||
PartyManager.getInstance().saveParties();
|
||||
getServer().getScheduler().cancelTasks(this); //This removes our tasks
|
||||
placeStore.saveAll(); //Save our metadata
|
||||
placeStore.cleanUp(); //Cleanup empty metadata stores
|
||||
|
||||
//Make sure to save player information if the server shuts down
|
||||
for (PlayerProfile x : Users.getProfiles().values()) {
|
||||
x.save();
|
||||
//Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
|
||||
try {
|
||||
ZipLibrary.mcMMObackup();
|
||||
}
|
||||
catch (IOException e) {
|
||||
getLogger().severe(e.toString());
|
||||
}
|
||||
|
||||
this.getServer().getScheduler().cancelTasks(this); //This removes our tasks
|
||||
System.out.println("mcMMO was disabled."); //How informative!
|
||||
}
|
||||
|
||||
@@ -174,7 +300,6 @@ public class mcMMO extends JavaPlugin {
|
||||
* Register the commands.
|
||||
*/
|
||||
private void registerCommands() {
|
||||
|
||||
//Register aliases with the aliasmap (used in the playercommandpreprocessevent to ugly alias them to actual commands)
|
||||
//Skills commands
|
||||
aliasMap.put(LocaleLoader.getString("Acrobatics.SkillName").toLowerCase(), "acrobatics");
|
||||
@@ -188,7 +313,7 @@ public class mcMMO extends JavaPlugin {
|
||||
aliasMap.put(LocaleLoader.getString("Swords.SkillName").toLowerCase(), "swords");
|
||||
aliasMap.put(LocaleLoader.getString("Taming.SkillName").toLowerCase(), "taming");
|
||||
aliasMap.put(LocaleLoader.getString("Unarmed.SkillName").toLowerCase(), "unarmed");
|
||||
aliasMap.put(LocaleLoader.getString("WoodCutting.SkillName").toLowerCase(), "woodcutting");
|
||||
aliasMap.put(LocaleLoader.getString("Woodcutting.SkillName").toLowerCase(), "woodcutting");
|
||||
|
||||
//Register commands
|
||||
//Skills commands
|
||||
@@ -205,145 +330,178 @@ public class mcMMO extends JavaPlugin {
|
||||
getCommand("unarmed").setExecutor(new UnarmedCommand());
|
||||
getCommand("woodcutting").setExecutor(new WoodcuttingCommand());
|
||||
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
//mc* commands
|
||||
if (Config.getInstance().getCommandMCRemoveEnabled()) {
|
||||
if (configInstance.getCommandMCRemoveEnabled()) {
|
||||
getCommand("mcremove").setExecutor(new McremoveCommand(this));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandMCAbilityEnabled()) {
|
||||
if (configInstance.getCommandMCAbilityEnabled()) {
|
||||
getCommand("mcability").setExecutor(new McabilityCommand());
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandMCCEnabled()) {
|
||||
if (configInstance.getCommandMCCEnabled()) {
|
||||
getCommand("mcc").setExecutor(new MccCommand());
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandMCGodEnabled()) {
|
||||
if (configInstance.getCommandMCGodEnabled()) {
|
||||
getCommand("mcgod").setExecutor(new McgodCommand());
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandmcMMOEnabled()) {
|
||||
if (configInstance.getCommandmcMMOEnabled()) {
|
||||
getCommand("mcmmo").setExecutor(new McmmoCommand());
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandMCRefreshEnabled()) {
|
||||
if (configInstance.getCommandMCRefreshEnabled()) {
|
||||
getCommand("mcrefresh").setExecutor(new McrefreshCommand(this));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandMCTopEnabled()) {
|
||||
if (configInstance.getCommandMCTopEnabled()) {
|
||||
getCommand("mctop").setExecutor(new MctopCommand());
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandMCStatsEnabled()) {
|
||||
if (configInstance.getCommandMCStatsEnabled()) {
|
||||
getCommand("mcstats").setExecutor(new McstatsCommand());
|
||||
}
|
||||
|
||||
//Party commands
|
||||
if (Config.getInstance().getCommandAcceptEnabled()) {
|
||||
if (configInstance.getCommandAcceptEnabled()) {
|
||||
getCommand("accept").setExecutor(new AcceptCommand(this));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandAdminChatAEnabled()) {
|
||||
if (configInstance.getCommandAdminChatAEnabled()) {
|
||||
getCommand("a").setExecutor(new ACommand(this));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandInviteEnabled()) {
|
||||
if (configInstance.getCommandInviteEnabled()) {
|
||||
getCommand("invite").setExecutor(new InviteCommand(this));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandPartyEnabled()) {
|
||||
if (configInstance.getCommandPartyEnabled()) {
|
||||
getCommand("party").setExecutor(new PartyCommand(this));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandPartyChatPEnabled()) {
|
||||
if (configInstance.getCommandPartyChatPEnabled()) {
|
||||
getCommand("p").setExecutor(new PCommand(this));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandPTPEnabled()) {
|
||||
if (configInstance.getCommandPTPEnabled()) {
|
||||
getCommand("ptp").setExecutor(new PtpCommand(this));
|
||||
}
|
||||
|
||||
//Other commands
|
||||
if (Config.getInstance().getCommandAddXPEnabled()) {
|
||||
if (configInstance.getCommandAddXPEnabled()) {
|
||||
getCommand("addxp").setExecutor(new AddxpCommand(this));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandAddLevelsEnabled()) {
|
||||
if (configInstance.getCommandAddLevelsEnabled()) {
|
||||
getCommand("addlevels").setExecutor(new AddlevelsCommand(this));
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandMmoeditEnabled()) {
|
||||
getCommand("mmoedit").setExecutor(new MmoeditCommand(this));
|
||||
if (configInstance.getCommandMmoeditEnabled()) {
|
||||
getCommand("mmoedit").setExecutor(new MmoeditCommand());
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandInspectEnabled()) {
|
||||
getCommand("inspect").setExecutor(new InspectCommand(this));
|
||||
if (configInstance.getCommandInspectEnabled()) {
|
||||
getCommand("inspect").setExecutor(new InspectCommand());
|
||||
}
|
||||
|
||||
if (Config.getInstance().getCommandXPRateEnabled()) {
|
||||
if (configInstance.getCommandXPRateEnabled()) {
|
||||
getCommand("xprate").setExecutor(new XprateCommand(this));
|
||||
}
|
||||
|
||||
getCommand("mmoupdate").setExecutor(new MmoupdateCommand(this));
|
||||
|
||||
//Spout commands
|
||||
if (Config.getInstance().getCommandXPLockEnabled()) {
|
||||
if (configInstance.getCommandXPLockEnabled()) {
|
||||
getCommand("xplock").setExecutor(new XplockCommand());
|
||||
}
|
||||
|
||||
getCommand("mchud").setExecutor(new MchudCommand(this));
|
||||
}
|
||||
|
||||
/*
|
||||
* Boilerplate Custom Config Stuff
|
||||
*/
|
||||
|
||||
private FileConfiguration treasuresConfig = null;
|
||||
private File treasuresConfigFile = null;
|
||||
|
||||
/**
|
||||
* Reload the Treasures.yml file.
|
||||
*/
|
||||
public void reloadTreasuresConfig() {
|
||||
if (treasuresConfigFile == null) {
|
||||
treasuresConfigFile = new File(getDataFolder(), "treasures.yml");
|
||||
}
|
||||
|
||||
treasuresConfig = YamlConfiguration.loadConfiguration(treasuresConfigFile);
|
||||
InputStream defConfigStream = getResource("treasures.yml"); // Look for defaults in the jar
|
||||
|
||||
if (defConfigStream != null) {
|
||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
|
||||
treasuresConfig.setDefaults(defConfig);
|
||||
}
|
||||
getCommand("mchud").setExecutor(new MchudCommand());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Treasures config information.
|
||||
* Checks to see if the alias map contains the given key.
|
||||
*
|
||||
* @return the configuration object for treasures.yml
|
||||
* @param command The command to check
|
||||
* @return true if the command is in the map, false otherwise
|
||||
*/
|
||||
public FileConfiguration getTreasuresConfig() {
|
||||
if (treasuresConfig == null) {
|
||||
reloadTreasuresConfig();
|
||||
}
|
||||
|
||||
return treasuresConfig;
|
||||
public boolean commandIsAliased(String command) {
|
||||
return aliasMap.containsKey(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the Treasures config informtion.
|
||||
* Get the alias of a given command.
|
||||
*
|
||||
* @param command The command to retrieve the alias of
|
||||
* @return the alias of the command
|
||||
*/
|
||||
public void saveTreasuresConfig() {
|
||||
if (treasuresConfig == null || treasuresConfigFile == null) {
|
||||
return;
|
||||
}
|
||||
public String getCommandAlias(String command) {
|
||||
return aliasMap.get(command);
|
||||
}
|
||||
|
||||
try {
|
||||
treasuresConfig.save(treasuresConfigFile);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
this.getLogger().severe("Could not save config to " + treasuresConfigFile + ex.toString());
|
||||
}
|
||||
/**
|
||||
* Add a set of values to the TNT tracker.
|
||||
*
|
||||
* @param tntID The EntityID of the TNT
|
||||
* @param playerName The name of the detonating player
|
||||
*/
|
||||
public void addToTNTTracker(int tntID, String playerName) {
|
||||
tntTracker.put(tntID, playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a given TNT Entity is tracked.
|
||||
*
|
||||
* @param tntID The EntityID of the TNT
|
||||
* @return true if the TNT is being tracked, false otherwise
|
||||
*/
|
||||
public boolean tntIsTracked(int tntID) {
|
||||
return tntTracker.containsKey(tntID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the player who detonated the TNT.
|
||||
*
|
||||
* @param tntID The EntityID of the TNT
|
||||
* @return the Player who detonated it
|
||||
*/
|
||||
public Player getTNTPlayer(int tntID) {
|
||||
return getServer().getPlayer(tntTracker.get(tntID));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove TNT from the tracker after it explodes.
|
||||
*
|
||||
* @param tntID The EntityID of the TNT
|
||||
*/
|
||||
public void removeFromTNTTracker(int tntID) {
|
||||
tntTracker.remove(tntID);
|
||||
}
|
||||
|
||||
public static String getMainDirectory() {
|
||||
return mainDirectory;
|
||||
}
|
||||
|
||||
public static String getFlatFileDirectory() {
|
||||
return flatFileDirectory;
|
||||
}
|
||||
|
||||
public static String getUsersFile() {
|
||||
return usersFile;
|
||||
}
|
||||
|
||||
public static String getLeaderboardDirectory() {
|
||||
return leaderboardDirectory;
|
||||
}
|
||||
|
||||
public static String getModDirectory() {
|
||||
return modDirectory;
|
||||
}
|
||||
|
||||
public static Database getPlayerDatabase() {
|
||||
return database;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,649 +1,65 @@
|
||||
package com.gmail.nossr50.party;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.EOFException;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Party {
|
||||
public static String pluginPath;
|
||||
public static String partyPlayersFile;
|
||||
public static String partyLocksFile;
|
||||
public static String partyPasswordsFile;
|
||||
private List<String> members = new ArrayList<String>();
|
||||
private String leader;
|
||||
private String name;
|
||||
private String password;
|
||||
private boolean locked;
|
||||
|
||||
HashMap<String, HashMap<String, Boolean>> partyPlayers = new HashMap<String, HashMap<String, Boolean>>();
|
||||
HashMap<String, Boolean> partyLocks = new HashMap<String, Boolean>();
|
||||
HashMap<String, String> partyPasswords = new HashMap<String, String>();
|
||||
|
||||
private static mcMMO plugin;
|
||||
private static volatile Party instance;
|
||||
|
||||
private Party() {
|
||||
plugin = mcMMO.p;
|
||||
pluginPath = plugin.getDataFolder().getPath();
|
||||
partyPlayersFile = pluginPath + File.separator + "FlatFileStuff" + File.separator + "partyPlayers";
|
||||
partyLocksFile = pluginPath + File.separator + "FlatFileStuff" + File.separator + "partyLocks";
|
||||
partyPasswordsFile = pluginPath + File.separator + "FlatFileStuff" + File.separator + "partyPasswords";
|
||||
new File(pluginPath + File.separator + "FlatFileStuff").mkdir();
|
||||
loadParties();
|
||||
public List<String> getMembers() {
|
||||
return members;
|
||||
}
|
||||
|
||||
public static Party getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new Party();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
public List<Player> getOnlineMembers() {
|
||||
Player[] onlinePlayers = mcMMO.p.getServer().getOnlinePlayers();
|
||||
List<Player> onlineMembers = new ArrayList<Player>();
|
||||
|
||||
/**
|
||||
* Check if two players are in the same party.
|
||||
*
|
||||
* @param playera The first player
|
||||
* @param playerb The second player
|
||||
* @return true if they are in the same party, false otherwise
|
||||
*/
|
||||
public boolean inSameParty(Player playera, Player playerb){
|
||||
PlayerProfile PPa = Users.getProfile(playera);
|
||||
PlayerProfile PPb = Users.getProfile(playerb);
|
||||
|
||||
if ((PPa.inParty() && PPb.inParty()) && (PPa.getParty().equals(PPb.getParty()))) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of players in this player's party.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @param players A list of players to
|
||||
* @return the number of players in this player's party
|
||||
*/
|
||||
public int partyCount(Player player) {
|
||||
if (player != null) {
|
||||
return getAllMembers(player).size();
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void informPartyMembers(Player player) {
|
||||
String playerName = player.getName();
|
||||
|
||||
if (player != null) {
|
||||
for (Player p : getOnlineMembers(player)) {
|
||||
if (p.getName() != playerName) {
|
||||
p.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", new Object[] {playerName}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all online players in this player's party.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return all online players in the player's party
|
||||
*/
|
||||
public ArrayList<Player> getOnlineMembers(Player player) {
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
|
||||
if (player != null) {
|
||||
for (Player p : plugin.getServer().getOnlinePlayers()) {
|
||||
if (inSameParty(player, p)) {
|
||||
players.add(p);
|
||||
}
|
||||
for (Player onlinePlayer : onlinePlayers) {
|
||||
if (members.contains(onlinePlayer.getName())) {
|
||||
onlineMembers.add(onlinePlayer);
|
||||
}
|
||||
}
|
||||
|
||||
return players;
|
||||
return onlineMembers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all online players in this party.
|
||||
*
|
||||
* @param partyName The party to check
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public ArrayList<Player> getOnlineMembers(String partyName) {
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
|
||||
for (Player p : plugin.getServer().getOnlinePlayers()) {
|
||||
PlayerProfile PP = Users.getProfile(p);
|
||||
|
||||
if (PP.inParty()) {
|
||||
if (PP.getParty().equalsIgnoreCase(partyName)) {
|
||||
players.add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return players;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all players in this player's party.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return all the players in the player's party
|
||||
*/
|
||||
public ArrayList<Player> getAllMembers(Player player) {
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
HashMap<String, PlayerProfile> profiles = Users.getProfiles();
|
||||
|
||||
if (player != null) {
|
||||
for (String name : profiles.keySet()) {
|
||||
Player p = profiles.get(name).getPlayer();
|
||||
if (inSameParty(p, player)) {
|
||||
players.add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return players;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all current party names.
|
||||
*
|
||||
* @return the list of parties.
|
||||
*/
|
||||
public ArrayList<String> getParties() {
|
||||
String location = mcMMO.usersFile;
|
||||
ArrayList<String> parties = new ArrayList<String>();
|
||||
|
||||
try {
|
||||
FileReader file = new FileReader(location);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
String line = "";
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
String[] character = line.split(":");
|
||||
String theparty = null;
|
||||
|
||||
//Party
|
||||
if (character.length > 3) {
|
||||
theparty = character[3];
|
||||
}
|
||||
|
||||
if (!parties.contains(theparty)) {
|
||||
parties.add(theparty);
|
||||
}
|
||||
}
|
||||
in.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
return parties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify party members when the party owner changes.
|
||||
*
|
||||
* @param newOwnerName The name of the new party owner
|
||||
*/
|
||||
private void informPartyMembersOwnerChange(String newOwnerName) {
|
||||
Player newOwner = plugin.getServer().getPlayer(newOwnerName);
|
||||
|
||||
if (newOwner != null) {
|
||||
for (Player p : getOnlineMembers(newOwner)) {
|
||||
if (p.getName() != newOwnerName) {
|
||||
p.sendMessage(newOwnerName + " is the new party owner."); //TODO: Needs more locale
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify party members when the a party member quits.
|
||||
*
|
||||
* @param player The player that quit
|
||||
*/
|
||||
private void informPartyMembersQuit(Player player) {
|
||||
String playerName = player.getName();
|
||||
|
||||
if (player != null) {
|
||||
for (Player p : getOnlineMembers(player)) {
|
||||
if (p.getName() != playerName) {
|
||||
p.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", new Object[] {playerName}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a player from a party.
|
||||
*
|
||||
* @param player The player to remove
|
||||
* @param PP The profile of the player to remove
|
||||
*/
|
||||
public void removeFromParty(Player player, PlayerProfile PP) {
|
||||
String party = PP.getParty();
|
||||
String playerName = player.getName();
|
||||
|
||||
//Stop NPE... hopefully
|
||||
if (!isParty(party) || !isInParty(player, PP)) {
|
||||
addToParty(player, PP, party, false, null);
|
||||
}
|
||||
|
||||
informPartyMembersQuit(player);
|
||||
|
||||
if (isPartyLeader(playerName, party)) {
|
||||
if (isPartyLocked(party)) {
|
||||
unlockParty(party);
|
||||
}
|
||||
}
|
||||
|
||||
partyPlayers.get(party).remove(playerName);
|
||||
|
||||
if (isPartyEmpty(party)) {
|
||||
deleteParty(party);
|
||||
}
|
||||
|
||||
PP.removeParty();
|
||||
savePartyFile(partyPlayersFile, partyPlayers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a player to a party.
|
||||
*
|
||||
* @param player The player to add to the party
|
||||
* @param PP The profile of the player to add to the party
|
||||
* @param newParty The party to add the player to
|
||||
* @param invite true if the player was invited to this party, false otherwise
|
||||
* @param password the password for this party, null if there was no password
|
||||
*/
|
||||
public void addToParty(Player player, PlayerProfile PP, String newParty, Boolean invite, String password) {
|
||||
String playerName = player.getName();
|
||||
|
||||
//Fix for FFS
|
||||
newParty = newParty.replace(":", ".");
|
||||
|
||||
//Don't care about passwords on invites
|
||||
if (!invite) {
|
||||
|
||||
//Don't care about passwords if it isn't locked
|
||||
if (isPartyLocked(newParty)) {
|
||||
if (isPartyPasswordProtected(newParty)) {
|
||||
if (password == null) {
|
||||
player.sendMessage("This party requires a password. Use /party <party> <password> to join it."); //TODO: Needs more locale.
|
||||
return;
|
||||
}
|
||||
else if(!password.equalsIgnoreCase(getPartyPassword(newParty))) {
|
||||
player.sendMessage("Party password incorrect."); //TODO: Needs more locale.
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage("Party is locked."); //TODO: Needs more locale.
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
PP.acceptInvite();
|
||||
}
|
||||
|
||||
//New party?
|
||||
if (!isParty(newParty)) {
|
||||
putNestedEntry(partyPlayers, newParty, playerName, true);
|
||||
|
||||
//Get default locking behavior from config?
|
||||
partyLocks.put(newParty, false);
|
||||
partyPasswords.put(newParty, null);
|
||||
saveParties();
|
||||
}
|
||||
else {
|
||||
putNestedEntry(partyPlayers, newParty, playerName, false);
|
||||
savePartyFile(partyPlayersFile, partyPlayers);
|
||||
}
|
||||
|
||||
PP.setParty(newParty);
|
||||
informPartyMembers(player);
|
||||
|
||||
if (!invite) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", new Object[]{ newParty }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", new Object[]{ PP.getParty() }));
|
||||
}
|
||||
}
|
||||
|
||||
private static <U,V,W> W putNestedEntry(HashMap<U, HashMap<V, W>> nest, U nestKey, V nestedKey, W nestedValue) {
|
||||
HashMap<V,W> nested = nest.get(nestKey);
|
||||
|
||||
if (nested == null) {
|
||||
nested = new HashMap<V,W>();
|
||||
nest.put(nestKey, nested);
|
||||
}
|
||||
|
||||
return nested.put(nestedKey, nestedValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock a party.
|
||||
*
|
||||
* @param partyName The party to lock
|
||||
*/
|
||||
public void lockParty(String partyName) {
|
||||
partyLocks.put(partyName, true);
|
||||
savePartyFile(partyLocksFile, partyLocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock a party.
|
||||
*
|
||||
* @param partyName The party to unlock
|
||||
*/
|
||||
public void unlockParty(String partyName) {
|
||||
partyLocks.put(partyName, false);
|
||||
savePartyFile(partyLocksFile, partyLocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a party.
|
||||
*
|
||||
* @param partyName The party to delete
|
||||
*/
|
||||
private void deleteParty(String partyName) {
|
||||
partyPlayers.remove(partyName);
|
||||
partyLocks.remove(partyName);
|
||||
partyPasswords.remove(partyName);
|
||||
saveParties();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the password for a party.
|
||||
*
|
||||
* @param partyName The party name
|
||||
* @param password The new party password
|
||||
*/
|
||||
public void setPartyPassword(String partyName, String password) {
|
||||
if (password.equalsIgnoreCase("\"\"")) { //What's with that password string?
|
||||
password = null;
|
||||
}
|
||||
|
||||
partyPasswords.put(partyName, password);
|
||||
savePartyFile(partyPasswordsFile, partyPasswords);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the leader of a party.
|
||||
*
|
||||
* @param partyName The party name
|
||||
* @return the leader of the party
|
||||
*/
|
||||
public Player getPartyLeader(String partyName) {
|
||||
Player leader = null;
|
||||
|
||||
for (String name : partyPlayers.get(partyName).keySet()) {
|
||||
if (partyPlayers.get(partyName).get(name)) {
|
||||
leader = plugin.getServer().getPlayer(name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public String getLeader() {
|
||||
return leader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the leader of a party.
|
||||
*
|
||||
* @param partyName The party name
|
||||
* @param playerName The name of the player to set as leader
|
||||
*/
|
||||
public void setPartyLeader(String partyName, String playerName) {
|
||||
for (String name : partyPlayers.get(partyName).keySet()) {
|
||||
if (name.equalsIgnoreCase(playerName)) {
|
||||
partyPlayers.get(partyName).put(playerName, true);
|
||||
informPartyMembersOwnerChange(playerName);
|
||||
plugin.getServer().getPlayer(playerName).sendMessage("You are now the party owner."); //TODO: Needs more locale.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (partyPlayers.get(partyName).get(name)) {
|
||||
plugin.getServer().getPlayer(name).sendMessage("You are no longer party owner."); //TODO: Needs more locale.
|
||||
partyPlayers.get(partyName).put(name, false);
|
||||
}
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the password of a party.
|
||||
*
|
||||
* @param partyName The party name
|
||||
* @return The password of this party
|
||||
*/
|
||||
public String getPartyPassword(String partyName) {
|
||||
return partyPasswords.get(partyName);
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player can invite others to their party.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @param PP The profile of the given player
|
||||
* @return true if the player can invite, false otherwise
|
||||
*/
|
||||
public boolean canInvite(Player player, PlayerProfile PP) {
|
||||
String party = PP.getParty();
|
||||
|
||||
if (isPartyLocked(party) && !isPartyLeader(player.getName(), party)) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
public boolean isLocked() {
|
||||
return locked;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a string is a valid party name.
|
||||
*
|
||||
* @param partyName The party name to check
|
||||
* @return true if this is a valid party, false otherwise
|
||||
*/
|
||||
public boolean isParty(String partyName) {
|
||||
return partyPlayers.containsKey(partyName);
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a party is empty.
|
||||
*
|
||||
* @param partyName The party to check
|
||||
* @return true if this party is empty, false otherwise
|
||||
*/
|
||||
public boolean isPartyEmpty(String partyName) {
|
||||
return partyPlayers.get(partyName).isEmpty();
|
||||
public void setLeader(String leader) {
|
||||
this.leader = leader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player is the party leader.
|
||||
*
|
||||
* @param playerName The player name to check
|
||||
* @param partyName The party name to check
|
||||
* @return true if the player is the party leader, false otherwise
|
||||
*/
|
||||
public boolean isPartyLeader(String playerName, String partyName) {
|
||||
HashMap<String, Boolean> partyMembers = partyPlayers.get(partyName);
|
||||
|
||||
if (partyMembers != null) {
|
||||
Boolean isLeader = partyMembers.get(playerName);
|
||||
|
||||
if (isLeader == null) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return isLeader;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this party is locked.
|
||||
*
|
||||
* @param partyName The party to check
|
||||
* @return true if this party is locked, false otherwise
|
||||
*/
|
||||
public boolean isPartyLocked(String partyName) {
|
||||
Boolean isLocked = partyLocks.get(partyName);
|
||||
|
||||
if (isLocked == null) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return isLocked;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this party is password protected.
|
||||
*
|
||||
* @param partyName The party to check
|
||||
* @return true if this party is password protected, false otherwise
|
||||
*/
|
||||
public boolean isPartyPasswordProtected(String partyName) {
|
||||
String password = partyPasswords.get(partyName);
|
||||
|
||||
if (password == null) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player is in the party reflected by their profile.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @param PP The profile of the player
|
||||
* @return true if this player is in the right party, false otherwise
|
||||
*/
|
||||
public boolean isInParty(Player player, PlayerProfile PP) {
|
||||
Map<String, Boolean> party = partyPlayers.get(PP.getParty());
|
||||
|
||||
if (party != null && party.containsKey(player.getName())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all party related files.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void loadParties() {
|
||||
if (new File(partyPlayersFile).exists()) {
|
||||
try {
|
||||
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyPlayersFile));
|
||||
partyPlayers = (HashMap<String, HashMap<String, Boolean>>) obj.readObject();
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (EOFException e) {
|
||||
plugin.getLogger().info("partyPlayersFile empty.");
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (new File(partyLocksFile).exists()) {
|
||||
try {
|
||||
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyLocksFile));
|
||||
partyLocks = (HashMap<String, Boolean>) obj.readObject();
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (EOFException e) {
|
||||
plugin.getLogger().info("partyLocksFile empty.");
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (new File(partyPasswordsFile).exists()) {
|
||||
try {
|
||||
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyPasswordsFile));
|
||||
this.partyPasswords = (HashMap<String, String>) obj.readObject();
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (EOFException e) {
|
||||
plugin.getLogger().info("partyPasswordsFile empty.");
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save all party-related files.
|
||||
*/
|
||||
private void saveParties() {
|
||||
savePartyFile(partyPlayersFile, partyPlayers);
|
||||
savePartyFile(partyLocksFile, partyLocks);
|
||||
savePartyFile(partyPasswordsFile, partyPasswords);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a party-related file.
|
||||
*
|
||||
* @param fileName The filename to save as
|
||||
* @param partyData The Hashmap with the party data
|
||||
*/
|
||||
private void savePartyFile(String fileName, Object partyData) {
|
||||
try {
|
||||
new File(fileName).createNewFile();
|
||||
ObjectOutputStream obj = new ObjectOutputStream(new FileOutputStream(fileName));
|
||||
obj.writeObject(partyData);
|
||||
obj.close();
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
public void setLocked(boolean locked) {
|
||||
this.locked = locked;
|
||||
}
|
||||
}
|
||||
|
||||
430
src/main/java/com/gmail/nossr50/party/PartyManager.java
Normal file
430
src/main/java/com/gmail/nossr50/party/PartyManager.java
Normal file
@@ -0,0 +1,430 @@
|
||||
package com.gmail.nossr50.party;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PartyManager {
|
||||
private static String partiesFilePath;
|
||||
private static List<Party> parties = new ArrayList<Party>();
|
||||
private static mcMMO plugin;
|
||||
private static PartyManager instance;
|
||||
|
||||
private PartyManager() {
|
||||
plugin = mcMMO.p;
|
||||
partiesFilePath = plugin.getDataFolder().getPath() + File.separator + "FlatFileStuff" + File.separator + "parties.yml";
|
||||
|
||||
loadParties();
|
||||
}
|
||||
|
||||
public static PartyManager getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new PartyManager();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two players are in the same party.
|
||||
*
|
||||
* @param firstPlayer The first player
|
||||
* @param secondPlayer The second player
|
||||
* @return true if they are in the same party, false otherwise
|
||||
*/
|
||||
public boolean inSameParty(Player firstPlayer, Player secondPlayer) {
|
||||
PlayerProfile firstProfile = Users.getProfile(firstPlayer);
|
||||
PlayerProfile secondProfile = Users.getProfile(secondPlayer);
|
||||
|
||||
if (firstProfile == null || secondProfile == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Party firstParty = firstProfile.getParty();
|
||||
Party secondParty = secondProfile.getParty();
|
||||
|
||||
if (firstParty == null || secondParty == null || firstParty != secondParty) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify party members when a player joins
|
||||
*
|
||||
* @param playerName The name of the player that joins
|
||||
* @param party The concerned party
|
||||
*/
|
||||
private void informPartyMembersJoin(String playerName, Party party) {
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
if (member.getName().equals(playerName)) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", new Object[] {playerName}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify party members when a party member quits.
|
||||
*
|
||||
* @param playerName The name of the player that quits
|
||||
* @param party The concerned party
|
||||
*/
|
||||
private void informPartyMembersQuit(String playerName, Party party) {
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
if (member.getName().equals(playerName)) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", new Object[] {playerName}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all players in this player's party.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return all the players in the player's party
|
||||
*/
|
||||
public List<String> getAllMembers(Player player) {
|
||||
Party party = Users.getProfile(player).getParty();
|
||||
|
||||
if (party == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return party.getMembers();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all online players in this party.
|
||||
*
|
||||
* @param partyName The party to check
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public List<Player> getOnlineMembers(String partyName) {
|
||||
Party party = getParty(partyName);
|
||||
|
||||
if (party == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return party.getOnlineMembers();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all online players in this party.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public List<Player> getOnlineMembers(Player player) {
|
||||
return getOnlineMembers(player.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a party by its name
|
||||
*
|
||||
* @param partyName The party name
|
||||
* @return the existing party, null otherwise
|
||||
*/
|
||||
public Party getParty(String partyName) {
|
||||
for (Party party : parties) {
|
||||
if (party.getName().equals(partyName)) {
|
||||
return party;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a party by a member name
|
||||
*
|
||||
* @param playerName The member name
|
||||
* @return the existing party, null otherwise
|
||||
*/
|
||||
public Party getPlayerParty(String playerName) {
|
||||
for (Party party : parties) {
|
||||
if (party.getMembers().contains(playerName)) {
|
||||
return party;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all current parties.
|
||||
*
|
||||
* @return the list of parties.
|
||||
*/
|
||||
public List<Party> getParties() {
|
||||
return parties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a player from a party.
|
||||
*
|
||||
* @param playerName The name of the player to remove
|
||||
* @param party The party
|
||||
*/
|
||||
public void removeFromParty(String playerName, Party party) {
|
||||
List<String> members = party.getMembers();
|
||||
|
||||
members.remove(playerName);
|
||||
|
||||
if (members.isEmpty()) {
|
||||
parties.remove(party);
|
||||
}
|
||||
else {
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
party.setLocked(false);
|
||||
}
|
||||
|
||||
informPartyMembersQuit(playerName, party);
|
||||
}
|
||||
|
||||
PlayerProfile playerProfile = Users.getProfile(playerName);
|
||||
|
||||
if (playerProfile != null) {
|
||||
playerProfile.removeParty();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a player to a party.
|
||||
*
|
||||
* @param player The player to add to the party
|
||||
* @param playerProfile The profile of the player to add to the party
|
||||
* @param partyName The party to add the player to
|
||||
* @param password the password for this party, null if there was no password
|
||||
*/
|
||||
public void joinParty(Player player, PlayerProfile playerProfile, String partyName, String password) {
|
||||
partyName = partyName.replace(".", "");
|
||||
Party party = getParty(partyName);
|
||||
String playerName = player.getName();
|
||||
|
||||
if (party == null) {
|
||||
party = new Party();
|
||||
|
||||
party.setName(partyName);
|
||||
party.setLeader(playerName);
|
||||
|
||||
if (password != null) {
|
||||
party.setPassword(password);
|
||||
party.setLocked(true);
|
||||
}
|
||||
|
||||
parties.add(party);
|
||||
}
|
||||
else if (!checkJoinability(player, playerProfile, party, password)) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", new Object[]{party.getName()}));
|
||||
addToParty(player.getName(), playerProfile, party);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player can join a party
|
||||
*
|
||||
* @param player The player trying to join a party
|
||||
* @param playerProfile The profile of the player
|
||||
* @param party The party
|
||||
* @param password The password provided by the player
|
||||
* @return true if the player can join the party
|
||||
*/
|
||||
private boolean checkJoinability(Player player, PlayerProfile playerProfile, Party party, String password) {
|
||||
//Don't care about passwords if it isn't locked
|
||||
if (party.isLocked()) {
|
||||
String partyPassword = party.getPassword();
|
||||
|
||||
if (partyPassword != null) {
|
||||
if (password == null) {
|
||||
player.sendMessage("This party requires a password. Use /party <party> <password> to join it."); //TODO: Needs more locale.
|
||||
return false;
|
||||
}
|
||||
else if (!password.equals(partyPassword)) {
|
||||
player.sendMessage("Party password incorrect."); //TODO: Needs more locale.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage("Party is locked."); //TODO: Needs more locale.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept a party invitation
|
||||
*
|
||||
* @param player The player to add to the party
|
||||
* @param playerProfile The profile of the player
|
||||
*/
|
||||
public void joinInvitedParty(Player player, PlayerProfile playerProfile) {
|
||||
Party invite = playerProfile.getInvite();
|
||||
|
||||
if (!parties.contains(invite)) {
|
||||
parties.add(invite);
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", new Object[]{invite.getName()}));
|
||||
playerProfile.removeInvite();
|
||||
addToParty(player.getName(), playerProfile, invite);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a player to a party
|
||||
*
|
||||
* @param playerName The name of the player to add to a party
|
||||
* @param playerProfile The profile of the player
|
||||
* @param party The party
|
||||
*/
|
||||
public void addToParty(String playerName, PlayerProfile playerProfile, Party party) {
|
||||
informPartyMembersJoin(playerName, party);
|
||||
playerProfile.setParty(party);
|
||||
party.getMembers().add(playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the leader of a party.
|
||||
*
|
||||
* @param partyName The party name
|
||||
* @return the leader of the party
|
||||
*/
|
||||
public String getPartyLeader(String partyName) {
|
||||
Party party = getParty(partyName);
|
||||
|
||||
if (party == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return party.getLeader();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the leader of a party.
|
||||
*
|
||||
* @param playerName The name of the player to set as leader
|
||||
* @param party The party
|
||||
*/
|
||||
public void setPartyLeader(String playerName, Party party) {
|
||||
String leaderName = party.getLeader();
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
if (member.getName().equals(playerName)) {
|
||||
member.sendMessage("You are now the party owner."); //TODO: Needs more locale.
|
||||
}
|
||||
else if (member.equals(leaderName)) {
|
||||
member.sendMessage("You are no longer party owner."); //TODO: Needs more locale.
|
||||
}
|
||||
else {
|
||||
member.sendMessage(playerName + " is the new party owner."); //TODO: Needs more Locale.
|
||||
}
|
||||
}
|
||||
|
||||
party.setLeader(playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player can invite others to their party.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @param playerProfile The profile of the given player
|
||||
* @return true if the player can invite
|
||||
*/
|
||||
public boolean canInvite(Player player, PlayerProfile playerProfile) {
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
if (party == null || (party.isLocked() && !party.getLeader().equals(player.getName()))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a string is a valid party name.
|
||||
*
|
||||
* @param partyName The party name to check
|
||||
* @return true if this is a valid party, false otherwise
|
||||
*/
|
||||
public boolean isParty(String partyName) {
|
||||
for (Party party : parties) {
|
||||
if (party.getName().equals(partyName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load party file.
|
||||
*/
|
||||
private void loadParties() {
|
||||
File file = new File(partiesFilePath);
|
||||
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
YamlConfiguration partiesFile = new YamlConfiguration();
|
||||
|
||||
try {
|
||||
partiesFile.load(file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) {
|
||||
Party party = new Party();
|
||||
|
||||
party.setName(partyName);
|
||||
party.setLeader(partiesFile.getString(partyName + ".Leader"));
|
||||
party.setPassword(partiesFile.getString(partyName + ".Password"));
|
||||
party.setLocked(partiesFile.getBoolean(partyName + ".Locked"));
|
||||
party.getMembers().addAll(partiesFile.getStringList(partyName + ".Members"));
|
||||
|
||||
parties.add(party);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save party file.
|
||||
*/
|
||||
public void saveParties() {
|
||||
File file = new File(partiesFilePath);
|
||||
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
|
||||
YamlConfiguration partiesFile = new YamlConfiguration();
|
||||
|
||||
for (Party party : parties) {
|
||||
String partyName = party.getName();
|
||||
|
||||
partiesFile.set(partyName + ".Leader", party.getLeader());
|
||||
partiesFile.set(partyName + ".Password", party.getPassword());
|
||||
partiesFile.set(partyName + ".Locked", party.isLocked());
|
||||
partiesFile.set(partyName + ".Members", party.getMembers());
|
||||
|
||||
try {
|
||||
partiesFile.save(new File(partiesFilePath));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import com.gmail.nossr50.util.Combat;
|
||||
|
||||
public class BleedTimer implements Runnable {
|
||||
private final static int MAX_BLEED_TICKS = 10;
|
||||
|
||||
|
||||
private static Map<LivingEntity, Integer> bleedList = new HashMap<LivingEntity, Integer>();
|
||||
private static Map<LivingEntity, Integer> bleedAddList = new HashMap<LivingEntity, Integer>();
|
||||
private static List<LivingEntity> bleedRemoveList = new ArrayList<LivingEntity>();
|
||||
@@ -34,7 +34,7 @@ public class BleedTimer implements Runnable {
|
||||
for (Entry<LivingEntity, Integer> entry : bleedList.entrySet()) {
|
||||
LivingEntity entity = entry.getKey();
|
||||
|
||||
if (entry.getValue() <= 0 || entity.isDead() || entity == null) {
|
||||
if (entry.getValue() <= 0 || entity.isDead()) {
|
||||
remove(entity);
|
||||
break;
|
||||
}
|
||||
@@ -48,13 +48,8 @@ public class BleedTimer implements Runnable {
|
||||
}
|
||||
|
||||
//Never kill with Bleeding
|
||||
if (player.getHealth() - 2 < 0) {
|
||||
if (player.getHealth() - 1 > 0) {
|
||||
Combat.dealDamage(player, 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Combat.dealDamage(player, 2);
|
||||
if (player.getHealth() - 1 > 0) {
|
||||
Combat.dealDamage(player, 1);
|
||||
}
|
||||
|
||||
entry.setValue(entry.getValue() - 1);
|
||||
@@ -89,7 +84,7 @@ public class BleedTimer implements Runnable {
|
||||
|
||||
/**
|
||||
* Instantly Bleed out a LivingEntity
|
||||
*
|
||||
*
|
||||
* @param entity LivingEntity to bleed out
|
||||
*/
|
||||
public static void bleedOut(LivingEntity entity) {
|
||||
@@ -101,7 +96,7 @@ public class BleedTimer implements Runnable {
|
||||
|
||||
/**
|
||||
* Remove a LivingEntity from the bleedList if it is in it
|
||||
*
|
||||
*
|
||||
* @param entity LivingEntity to remove
|
||||
*/
|
||||
public static void remove(LivingEntity entity) {
|
||||
@@ -121,6 +116,7 @@ public class BleedTimer implements Runnable {
|
||||
* Add a LivingEntity to the bleedList if it is not in it.
|
||||
*
|
||||
* @param entity LivingEntity to add
|
||||
* @param ticks Number of bleeding ticks
|
||||
*/
|
||||
public static void add(LivingEntity entity, int ticks) {
|
||||
int newTicks = ticks;
|
||||
@@ -128,7 +124,7 @@ public class BleedTimer implements Runnable {
|
||||
if (lock) {
|
||||
if (bleedAddList.containsKey(entity)) {
|
||||
newTicks += bleedAddList.get(entity);
|
||||
|
||||
|
||||
if (newTicks > MAX_BLEED_TICKS) {
|
||||
newTicks = MAX_BLEED_TICKS;
|
||||
}
|
||||
@@ -146,7 +142,7 @@ public class BleedTimer implements Runnable {
|
||||
else {
|
||||
if (bleedList.containsKey(entity)) {
|
||||
newTicks += bleedList.get(entity);
|
||||
|
||||
|
||||
if (newTicks > MAX_BLEED_TICKS) {
|
||||
newTicks = MAX_BLEED_TICKS;
|
||||
}
|
||||
@@ -172,7 +168,7 @@ public class BleedTimer implements Runnable {
|
||||
|
||||
/**
|
||||
* Check to see if a LivingEntity is in the bleedList
|
||||
*
|
||||
*
|
||||
* @param entity LivingEntity to check if in the bleedList
|
||||
* @return true if in the list, false if not
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class ChunkletUnloader implements Runnable {
|
||||
private static Map<Chunk, Integer> unloadedChunks = new HashMap<Chunk, Integer>();
|
||||
private static int minimumInactiveTime = 60; //Should be a multiple of RUN_INTERVAL for best performance
|
||||
public static final int RUN_INTERVAL = 20;
|
||||
|
||||
public static void addToList(Chunk chunk) {
|
||||
//Unfortunately we can't use Map.contains() because Chunks are always new objects
|
||||
//This method isn't efficient enough for me
|
||||
for (Chunk otherChunk : unloadedChunks.keySet()) {
|
||||
if (chunk.getX() == otherChunk.getX() && chunk.getZ() == otherChunk.getZ()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
unloadedChunks.put(chunk, 0);
|
||||
}
|
||||
|
||||
public static void addToList(int cx, int cz, World world) {
|
||||
addToList(world.getChunkAt(cx, cz));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Iterator<Entry<Chunk, Integer>> it = unloadedChunks.entrySet().iterator() ; it.hasNext() ; ) {
|
||||
Entry<Chunk, Integer> entry = it.next();
|
||||
Chunk chunk = entry.getKey();
|
||||
|
||||
if (!chunk.isLoaded()) {
|
||||
int inactiveTime = entry.getValue() + RUN_INTERVAL;
|
||||
|
||||
//Chunklets are unloaded only if their chunk has been unloaded for minimumInactiveTime
|
||||
if (inactiveTime >= minimumInactiveTime) {
|
||||
mcMMO.placeStore.unloadChunk(chunk.getX(), chunk.getZ(), chunk.getWorld());
|
||||
it.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
unloadedChunks.put(entry.getKey(), inactiveTime);
|
||||
}
|
||||
else {
|
||||
//Just remove the entry if the chunk has been reloaded.
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,19 +5,19 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class GainXp implements Runnable {
|
||||
private Player player = null;
|
||||
private PlayerProfile PP = null;
|
||||
private PlayerProfile profile = null;
|
||||
private double baseXp = 0;
|
||||
private SkillType skillType = null;
|
||||
private LivingEntity target = null;
|
||||
private int baseHealth = 0;
|
||||
|
||||
public GainXp(Player player, PlayerProfile PP, SkillType skillType, double baseXp, LivingEntity target) {
|
||||
public GainXp(Player player, PlayerProfile profile, SkillType skillType, double baseXp, LivingEntity target) {
|
||||
this.player = player;
|
||||
this.PP = PP;
|
||||
this.profile = profile;
|
||||
this.skillType = skillType;
|
||||
this.baseXp = baseXp;
|
||||
this.target = target;
|
||||
@@ -27,7 +27,7 @@ public class GainXp implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
int health = target.getHealth();
|
||||
int damage = baseHealth - health;
|
||||
int damage = baseHealth - health;
|
||||
|
||||
//May avoid negative xp, we don't know what other plugins do with the entity health
|
||||
if (damage <= 0) {
|
||||
@@ -39,7 +39,6 @@ public class GainXp implements Runnable {
|
||||
damage += health;
|
||||
}
|
||||
|
||||
PP.addXP(skillType, (int) (damage * baseXp));
|
||||
Skills.XpCheckSkill(skillType, player);
|
||||
Skills.xpProcessing(player, profile, skillType, (int) (damage * baseXp));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@ import com.gmail.nossr50.datatypes.SkillType;
|
||||
|
||||
public class GreenThumbTimer implements Runnable {
|
||||
private Block block;
|
||||
private PlayerProfile PP;
|
||||
private PlayerProfile profile;
|
||||
|
||||
public GreenThumbTimer(Block block, PlayerProfile PP) {
|
||||
public GreenThumbTimer(Block block, PlayerProfile profile) {
|
||||
this.block = block;
|
||||
this.PP = PP;
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -22,14 +22,14 @@ public class GreenThumbTimer implements Runnable {
|
||||
block.setType(Material.CROPS);
|
||||
|
||||
//This replants the wheat at a certain stage in development based on Herbalism Skill
|
||||
if (!PP.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
||||
if (PP.getSkillLevel(SkillType.HERBALISM) >= 600) {
|
||||
if (!profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
||||
if (profile.getSkillLevel(SkillType.HERBALISM) >= 600) {
|
||||
block.setData(CropState.MEDIUM.getData());
|
||||
}
|
||||
else if (PP.getSkillLevel(SkillType.HERBALISM) >= 400) {
|
||||
else if (profile.getSkillLevel(SkillType.HERBALISM) >= 400) {
|
||||
block.setData(CropState.SMALL.getData());
|
||||
}
|
||||
else if (PP.getSkillLevel(SkillType.HERBALISM) >= 200) {
|
||||
else if (profile.getSkillLevel(SkillType.HERBALISM) >= 200) {
|
||||
block.setData(CropState.VERY_SMALL.getData());
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class ProfileSaveTask implements Runnable {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private PlayerProfile playerProfile;
|
||||
|
||||
public ProfileSaveTask(McMMOPlayer mcMMOPlayer) {
|
||||
this.mcMMOPlayer = mcMMOPlayer;
|
||||
this.playerProfile = mcMMOPlayer.getProfile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
playerProfile.save();
|
||||
|
||||
if (!mcMMOPlayer.getPlayer().isOnline()) {
|
||||
Users.remove(playerProfile.getPlayerName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class RemoveProfileFromMemoryTask implements Runnable {
|
||||
private String playerName = null;
|
||||
|
||||
public RemoveProfileFromMemoryTask(String playerName) {
|
||||
this.playerName = playerName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
//Check if the profile still exists (stuff like MySQL reconnection removes profiles)
|
||||
if (Users.players.containsKey(playerName.toLowerCase())) {
|
||||
Users.getProfileByName(playerName.toLowerCase()).save(); //We save here so players don't quit/reconnect to cause lag
|
||||
Users.removeUserByName(playerName.toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ 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.util.Misc;
|
||||
|
||||
public class SQLConversionTask implements Runnable {
|
||||
@@ -17,7 +18,8 @@ public class SQLConversionTask implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String location = mcMMO.usersFile;
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
String location = mcMMO.getUsersFile();
|
||||
|
||||
try {
|
||||
FileReader file = new FileReader(location);
|
||||
@@ -164,7 +166,7 @@ public class SQLConversionTask implements Runnable {
|
||||
}
|
||||
|
||||
//Check to see if the user is in the DB
|
||||
id = mcMMO.database.getInt("SELECT id FROM "
|
||||
id = database.getInt("SELECT id FROM "
|
||||
+ tablePrefix
|
||||
+ "users WHERE user = '" + playerName + "'");
|
||||
|
||||
@@ -172,11 +174,11 @@ public class SQLConversionTask implements Runnable {
|
||||
theCount++;
|
||||
|
||||
//Update the skill values
|
||||
mcMMO.database.write("UPDATE "
|
||||
database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "users SET lastlogin = " + 0
|
||||
+ " WHERE id = " + id);
|
||||
mcMMO.database.write("UPDATE "
|
||||
database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "skills SET "
|
||||
+ " taming = taming+" + Misc.getInt(taming)
|
||||
@@ -192,7 +194,7 @@ public class SQLConversionTask implements Runnable {
|
||||
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
|
||||
+ ", fishing = fishing+" + Misc.getInt(fishing)
|
||||
+ " WHERE user_id = " + id);
|
||||
mcMMO.database.write("UPDATE "
|
||||
database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "experience SET "
|
||||
+ " taming = " + Misc.getInt(tamingXP)
|
||||
@@ -213,32 +215,32 @@ public class SQLConversionTask implements Runnable {
|
||||
theCount++;
|
||||
|
||||
//Create the user in the DB
|
||||
mcMMO.database.write("INSERT INTO "
|
||||
database.write("INSERT INTO "
|
||||
+ tablePrefix
|
||||
+ "users (user, lastlogin) VALUES ('"
|
||||
+ playerName + "',"
|
||||
+ System.currentTimeMillis() / 1000 + ")");
|
||||
id = mcMMO.database.getInt("SELECT id FROM "
|
||||
id = database.getInt("SELECT id FROM "
|
||||
+ tablePrefix
|
||||
+ "users WHERE user = '"
|
||||
+ playerName + "'");
|
||||
mcMMO.database.write("INSERT INTO "
|
||||
database.write("INSERT INTO "
|
||||
+ tablePrefix
|
||||
+ "skills (user_id) VALUES (" + id + ")");
|
||||
mcMMO.database.write("INSERT INTO "
|
||||
database.write("INSERT INTO "
|
||||
+ tablePrefix
|
||||
+ "experience (user_id) VALUES (" + id
|
||||
+ ")");
|
||||
//Update the skill values
|
||||
mcMMO.database.write("UPDATE "
|
||||
database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "users SET lastlogin = " + 0
|
||||
+ " WHERE id = " + id);
|
||||
mcMMO.database.write("UPDATE "
|
||||
database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "users SET party = '" + party
|
||||
+ "' WHERE id = " + id);
|
||||
mcMMO.database.write("UPDATE "
|
||||
database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "skills SET "
|
||||
+ " taming = taming+" + Misc.getInt(taming)
|
||||
@@ -254,7 +256,7 @@ public class SQLConversionTask implements Runnable {
|
||||
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
|
||||
+ ", fishing = fishing+" + Misc.getInt(fishing)
|
||||
+ " WHERE user_id = " + id);
|
||||
mcMMO.database.write("UPDATE "
|
||||
database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "experience SET "
|
||||
+ " taming = " + Misc.getInt(tamingXP)
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.gmail.nossr50.runnables;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
@@ -16,16 +15,14 @@ public class SQLReconnect implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (Database.isConnected()) {
|
||||
if (!Database.isConnected()) {
|
||||
Database.connect();
|
||||
if (Database.isConnected()) {
|
||||
for (PlayerProfile x : Users.players.values()) {
|
||||
x.save(); //Save all profiles
|
||||
}
|
||||
Users.saveAll(); //Save all profiles
|
||||
Users.clearAll(); //Clear the profiles
|
||||
|
||||
Users.players.clear(); //Clear the profiles
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
Users.addUser(x); //Add in new profiles, forcing them to 'load' again from MySQL
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
Users.addUser(player); //Add in new profiles, forcing them to 'load' again from MySQL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SaveTimer implements Runnable {
|
||||
@@ -15,8 +17,14 @@ public class SaveTimer implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
//All player data will be saved periodically through this
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
Users.getProfile(player).save();
|
||||
int count = 1;
|
||||
BukkitScheduler bukkitScheduler = plugin.getServer().getScheduler();
|
||||
|
||||
for (McMMOPlayer mcMMOPlayer : Users.getPlayers().values()) {
|
||||
bukkitScheduler.scheduleSyncDelayedTask(plugin, new ProfileSaveTask(mcMMOPlayer), count);
|
||||
count++;
|
||||
}
|
||||
|
||||
PartyManager.getInstance().saveParties();
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user