mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 09:43:00 +01:00
Compare commits
472 Commits
1.4.05
...
1.4.07-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0095f7f9c7 | ||
|
|
f53820e4de | ||
|
|
25e4700ef9 | ||
|
|
58c7dcb705 | ||
|
|
44626c36a9 | ||
|
|
cfd5bfe2c4 | ||
|
|
f7928787dc | ||
|
|
d6630a0eb5 | ||
|
|
af39e84aef | ||
|
|
93fe2ff504 | ||
|
|
b42f2d4073 | ||
|
|
c5c231920d | ||
|
|
89ddf8c4fa | ||
|
|
71ab678945 | ||
|
|
14daee3b1b | ||
|
|
d2bbbb0fe7 | ||
|
|
fd8d9b02a9 | ||
|
|
a639a37637 | ||
|
|
7eec53d621 | ||
|
|
7523afffb5 | ||
|
|
2c8b9334b6 | ||
|
|
d41ccf9072 | ||
|
|
c98d298cf1 | ||
|
|
73d0b377ae | ||
|
|
df29306a1f | ||
|
|
435522415d | ||
|
|
a17d1d3a2f | ||
|
|
94a5bef62c | ||
|
|
2cd9a5658e | ||
|
|
3c5bd3cedd | ||
|
|
8e02b57369 | ||
|
|
935b8b7bc4 | ||
|
|
9c54f8fd11 | ||
|
|
6bfc1b84de | ||
|
|
59f545d5ce | ||
|
|
23983422e0 | ||
|
|
956bf2d763 | ||
|
|
964b2636fb | ||
|
|
490bc195d8 | ||
|
|
0ce41150c6 | ||
|
|
0455416dec | ||
|
|
a6e7febf77 | ||
|
|
ede0757d83 | ||
|
|
8282d84b16 | ||
|
|
223649ec28 | ||
|
|
68e433b3b7 | ||
|
|
1a51b93ec9 | ||
|
|
c31ffa5ab4 | ||
|
|
ca6bee07ea | ||
|
|
9acaa7b126 | ||
|
|
2bae937b28 | ||
|
|
51bf989418 | ||
|
|
07dd460d78 | ||
|
|
045d74fb9d | ||
|
|
c8c76f4174 | ||
|
|
83c4d09093 | ||
|
|
50ef8d9610 | ||
|
|
98c6abad36 | ||
|
|
62146480db | ||
|
|
6518d192ec | ||
|
|
3fe9cfee74 | ||
|
|
d495054eb5 | ||
|
|
ce80636141 | ||
|
|
fe93be66ad | ||
|
|
1f712063bf | ||
|
|
560c3860b4 | ||
|
|
36f1a2d78a | ||
|
|
3ddd8d2056 | ||
|
|
5441fcc374 | ||
|
|
1d83784820 | ||
|
|
fb5bab6e92 | ||
|
|
90fcf35c34 | ||
|
|
4ff6b5fbc7 | ||
|
|
ead1398132 | ||
|
|
6330c4a69e | ||
|
|
dcc18049a1 | ||
|
|
fcb8909a54 | ||
|
|
37e3bfe7d9 | ||
|
|
d61b837dcf | ||
|
|
f079e22789 | ||
|
|
1f53c62ced | ||
|
|
9fb4e0988b | ||
|
|
d8bbe459b9 | ||
|
|
8bd7526b43 | ||
|
|
24b1485555 | ||
|
|
7683dfc436 | ||
|
|
ccbffca278 | ||
|
|
aeaab43f44 | ||
|
|
a2450d2d07 | ||
|
|
c85bd8ab70 | ||
|
|
3f6bce0fc6 | ||
|
|
e566b20e2b | ||
|
|
f37a7d759a | ||
|
|
d1341b0be0 | ||
|
|
4ea3d690db | ||
|
|
d5dc9895e4 | ||
|
|
b1fc72e8a9 | ||
|
|
7479a02220 | ||
|
|
d1bf48ad79 | ||
|
|
a345737b8b | ||
|
|
c501ebb357 | ||
|
|
15e0570a8c | ||
|
|
09e77c8c94 | ||
|
|
f5c58f3679 | ||
|
|
ddcbe64db6 | ||
|
|
c5137eb884 | ||
|
|
e073eca458 | ||
|
|
78f2e0a064 | ||
|
|
df2defe969 | ||
|
|
6d4a2feaae | ||
|
|
8939fc09b3 | ||
|
|
e0e574c19e | ||
|
|
02126c93b9 | ||
|
|
37671bad9a | ||
|
|
0e8ce005d7 | ||
|
|
584a225d6e | ||
|
|
736359056f | ||
|
|
bf2e527e72 | ||
|
|
be7992d541 | ||
|
|
435eb7f8b9 | ||
|
|
001f1dbd3c | ||
|
|
7b5372a985 | ||
|
|
1647ef4fae | ||
|
|
ee86f8244f | ||
|
|
e518b58b23 | ||
|
|
5af1164b5c | ||
|
|
c9aba059e2 | ||
|
|
dc9469c0cc | ||
|
|
696e82e622 | ||
|
|
18a5ec73d7 | ||
|
|
83ee8dd3f8 | ||
|
|
04224b309a | ||
|
|
01a1cf5765 | ||
|
|
8fdf4042bb | ||
|
|
621969459a | ||
|
|
6fe1c85592 | ||
|
|
79346d92d7 | ||
|
|
24ceeb626b | ||
|
|
68727496ad | ||
|
|
d07b67b5bf | ||
|
|
4dc9c97978 | ||
|
|
99916f99fd | ||
|
|
4a5307f47b | ||
|
|
69aead58a7 | ||
|
|
f0dcfb0346 | ||
|
|
c85d52e594 | ||
|
|
4342abca3d | ||
|
|
11e4ff34d6 | ||
|
|
f118ac14ca | ||
|
|
f5eb7a10de | ||
|
|
36b09421e8 | ||
|
|
d6b39a11e7 | ||
|
|
23729f45ee | ||
|
|
27d7b73e57 | ||
|
|
af60f08a8b | ||
|
|
c19d3fd068 | ||
|
|
0f8312dd5e | ||
|
|
1edb11cedf | ||
|
|
6fea7c8d74 | ||
|
|
a4a1ba4331 | ||
|
|
de46277bea | ||
|
|
6d7d811814 | ||
|
|
98b98256b7 | ||
|
|
abd389f4de | ||
|
|
602956a555 | ||
|
|
8d0601babc | ||
|
|
050be563bf | ||
|
|
965dbda101 | ||
|
|
f2b2cd9cc0 | ||
|
|
3a78e1b487 | ||
|
|
db637f0bc9 | ||
|
|
b15f1dde28 | ||
|
|
28a78d820a | ||
|
|
a1792fe125 | ||
|
|
3f7b17961f | ||
|
|
0ea07d4bc7 | ||
|
|
190b7ee1f5 | ||
|
|
4ff4271da2 | ||
|
|
8705974e08 | ||
|
|
de0487d16f | ||
|
|
fc0c386ecb | ||
|
|
86db4251a2 | ||
|
|
effe5ec305 | ||
|
|
8fb92292bd | ||
|
|
375fa4f75c | ||
|
|
da25b02e0a | ||
|
|
d43ae17bd2 | ||
|
|
f81a763d6c | ||
|
|
385f8ca0b3 | ||
|
|
0ba4bc25c7 | ||
|
|
b0eb4b93a8 | ||
|
|
54f135aebd | ||
|
|
10e369f9c5 | ||
|
|
1ae9b0f4d2 | ||
|
|
198ee6a7ed | ||
|
|
2414ddf485 | ||
|
|
2cd52db8c9 | ||
|
|
5e00636761 | ||
|
|
a82cc9609b | ||
|
|
45c6c20ccd | ||
|
|
7a61f55e49 | ||
|
|
aa0b77a64c | ||
|
|
030c8e59d7 | ||
|
|
f21fbe2d40 | ||
|
|
9a5f4b638f | ||
|
|
9aa49a09da | ||
|
|
bf8945ac59 | ||
|
|
d9926bab4e | ||
|
|
38ba2c21e5 | ||
|
|
a48fb30edf | ||
|
|
92ec04bd46 | ||
|
|
0b6372a6ea | ||
|
|
4f8b66f94d | ||
|
|
0c52b3016c | ||
|
|
a2f80569e3 | ||
|
|
87df536a1f | ||
|
|
12e70490d8 | ||
|
|
23b1518dc0 | ||
|
|
6dbf2e0d95 | ||
|
|
60304e9643 | ||
|
|
614557e2fa | ||
|
|
e312e95aed | ||
|
|
2ee919b51f | ||
|
|
22f6ae858b | ||
|
|
3c3b4af2c4 | ||
|
|
feb0d1fe5d | ||
|
|
2d66b8ed12 | ||
|
|
483f348403 | ||
|
|
a8a5100f58 | ||
|
|
1f9dc70bb1 | ||
|
|
7f1ef61657 | ||
|
|
2e74c079b0 | ||
|
|
ce4295289a | ||
|
|
7fde04851d | ||
|
|
71d030e5ad | ||
|
|
b08649d0a4 | ||
|
|
0a11a9a2c8 | ||
|
|
068f47b523 | ||
|
|
79aab57abc | ||
|
|
2cf58f1b5b | ||
|
|
9678875b4b | ||
|
|
d1a7ce827a | ||
|
|
9b2f4b7bde | ||
|
|
24e5147a2a | ||
|
|
0423a7831d | ||
|
|
feea22b3a4 | ||
|
|
7f40a9f284 | ||
|
|
bc706109e0 | ||
|
|
a25bddba5e | ||
|
|
ab897724d3 | ||
|
|
a7861fc54b | ||
|
|
936bec8ff5 | ||
|
|
01d10971a1 | ||
|
|
12e388a392 | ||
|
|
fb450671d6 | ||
|
|
fca5f9ec98 | ||
|
|
c9ae6436bd | ||
|
|
b6c4d2b4ad | ||
|
|
27ab2f5b12 | ||
|
|
9b08062a58 | ||
|
|
401bdfa9ac | ||
|
|
68d8d6dd30 | ||
|
|
2a57d7007d | ||
|
|
fd675ac291 | ||
|
|
41f020bbb7 | ||
|
|
00dee500e0 | ||
|
|
36bdb8a63e | ||
|
|
aa9eb0868c | ||
|
|
48aafa9834 | ||
|
|
78f53f294a | ||
|
|
3158c7e3eb | ||
|
|
47d27ebf31 | ||
|
|
bc3773ae75 | ||
|
|
d8ddd27d71 | ||
|
|
8d5696507a | ||
|
|
9ec376a228 | ||
|
|
a05a0da9fb | ||
|
|
5029ad9d93 | ||
|
|
1444be665c | ||
|
|
3dedb94bdc | ||
|
|
c0f6c15a80 | ||
|
|
00626a4893 | ||
|
|
b416a59bb7 | ||
|
|
bf96fb2214 | ||
|
|
2e79c8d770 | ||
|
|
6c9d1c4953 | ||
|
|
df8df192d3 | ||
|
|
e5f43462c8 | ||
|
|
1867a3e040 | ||
|
|
6818f98de3 | ||
|
|
f910c76248 | ||
|
|
975cbf0bf8 | ||
|
|
f10b3cef01 | ||
|
|
ad39c94773 | ||
|
|
f189ab30e5 | ||
|
|
0ad18ee971 | ||
|
|
501f5de55a | ||
|
|
0b18ae8ff2 | ||
|
|
de12970486 | ||
|
|
7550b99aaa | ||
|
|
ed5a43966d | ||
|
|
95ea6703f1 | ||
|
|
55f9092aa6 | ||
|
|
5f50a46603 | ||
|
|
c5e6704530 | ||
|
|
8552192894 | ||
|
|
0261d16140 | ||
|
|
2b414526e5 | ||
|
|
c0b7eb526a | ||
|
|
7b7196a8c4 | ||
|
|
f648289035 | ||
|
|
8a0b1d548d | ||
|
|
1f17d5d11e | ||
|
|
18efd09421 | ||
|
|
18d3b30647 | ||
|
|
7f0243b2df | ||
|
|
33610c8997 | ||
|
|
8e0a1f4f70 | ||
|
|
b07cf6bdde | ||
|
|
7ed218ee7f | ||
|
|
3aedeea220 | ||
|
|
4f9b7b2609 | ||
|
|
09abab1b5d | ||
|
|
499713c8e7 | ||
|
|
cb953a1619 | ||
|
|
3ab4938f3d | ||
|
|
f6e9fd9f3a | ||
|
|
8dab75f3cb | ||
|
|
b36096e54d | ||
|
|
0574de4a29 | ||
|
|
6d6bc3de76 | ||
|
|
5c4c3cf59c | ||
|
|
0033c8864e | ||
|
|
e7c749ee3a | ||
|
|
5c026be0cd | ||
|
|
c465546871 | ||
|
|
3322677d32 | ||
|
|
76cf0ebb01 | ||
|
|
d34a0cca30 | ||
|
|
a77a916fcc | ||
|
|
e1ebb96545 | ||
|
|
d85a6bec43 | ||
|
|
78eb7787e9 | ||
|
|
b55ce30b2d | ||
|
|
14050cf096 | ||
|
|
5930128b7f | ||
|
|
08be78fa35 | ||
|
|
88f43d9a91 | ||
|
|
6cbf960dea | ||
|
|
374d34f76d | ||
|
|
cc486c2dc7 | ||
|
|
724dce07a9 | ||
|
|
1486e2063b | ||
|
|
50c9649b23 | ||
|
|
339a54b0ac | ||
|
|
b97afb85a1 | ||
|
|
15da9d580b | ||
|
|
62aed496cc | ||
|
|
fba131936a | ||
|
|
70601a4560 | ||
|
|
83604ecb6d | ||
|
|
b912f7072c | ||
|
|
7e7e468408 | ||
|
|
748c97f6c1 | ||
|
|
a3aab57cf8 | ||
|
|
5548e26dd9 | ||
|
|
89d2f07c03 | ||
|
|
f42a28f34f | ||
|
|
bdc753f03c | ||
|
|
68a7b540c5 | ||
|
|
b2dd820507 | ||
|
|
612308eb9a | ||
|
|
98dc7b853a | ||
|
|
a2fefd6fb6 | ||
|
|
17a0382283 | ||
|
|
eea5784527 | ||
|
|
1aff2cf9eb | ||
|
|
4fc6349824 | ||
|
|
7a3921eace | ||
|
|
e99599c377 | ||
|
|
e1f6366a00 | ||
|
|
182b01ac2f | ||
|
|
18f3914428 | ||
|
|
bd0a045da3 | ||
|
|
9a4bed8c67 | ||
|
|
ae0cf692cd | ||
|
|
2ca7d139fe | ||
|
|
7e67505dfb | ||
|
|
21100de85d | ||
|
|
d8f799f8b4 | ||
|
|
cb03a98113 | ||
|
|
4b36a11dda | ||
|
|
8099490213 | ||
|
|
6cb2843707 | ||
|
|
e831f0561a | ||
|
|
d57c253b19 | ||
|
|
c8c68ea7d9 | ||
|
|
150fe730bd | ||
|
|
8af425d067 | ||
|
|
c3845abd2a | ||
|
|
eba6820ec6 | ||
|
|
822e40bc1f | ||
|
|
3ffcaae122 | ||
|
|
42a30b4521 | ||
|
|
377ed9e8e5 | ||
|
|
be76fe61d8 | ||
|
|
07ba7a8d9e | ||
|
|
2be3e3b43c | ||
|
|
49bf190895 | ||
|
|
c9a53bdaca | ||
|
|
3a76a111d3 | ||
|
|
e59c7ac34a | ||
|
|
f05b9ae365 | ||
|
|
c60e5a65d6 | ||
|
|
1b4eda713f | ||
|
|
cb133ced80 | ||
|
|
062a3028f4 | ||
|
|
682c2631f0 | ||
|
|
faecb9a439 | ||
|
|
5dc40f3c03 | ||
|
|
569e87847f | ||
|
|
b448315f20 | ||
|
|
2c87ce06eb | ||
|
|
875091a1ce | ||
|
|
5ad7716137 | ||
|
|
8c97399cec | ||
|
|
27e0a9d3b6 | ||
|
|
07f9b287e7 | ||
|
|
fbee4f1b37 | ||
|
|
26542f3d6e | ||
|
|
14630fe956 | ||
|
|
30f5c761d9 | ||
|
|
365abaaa8f | ||
|
|
f4681a282c | ||
|
|
8a14d9ac26 | ||
|
|
0ab1986202 | ||
|
|
e11dc680de | ||
|
|
71249334c3 | ||
|
|
fa41dbce16 | ||
|
|
4246e6c900 | ||
|
|
1b421a24b0 | ||
|
|
9cc9eead52 | ||
|
|
8b21aea9c7 | ||
|
|
4f87cb6446 | ||
|
|
7525de1a72 | ||
|
|
78d2fa7520 | ||
|
|
7fe8122499 | ||
|
|
532c2e7450 | ||
|
|
b391a53c6b | ||
|
|
f3c6346b95 | ||
|
|
dd8984314f | ||
|
|
b82c3f41d3 | ||
|
|
7d6eb65776 | ||
|
|
dc0800e7e1 | ||
|
|
c151366952 | ||
|
|
212137ec3e | ||
|
|
31f36935d3 | ||
|
|
a14fc3e3c9 | ||
|
|
158b3c43f8 | ||
|
|
e31c1e33d9 | ||
|
|
25dfa6d34d | ||
|
|
431429a29c | ||
|
|
d4c8cc28a1 | ||
|
|
ce08405c00 | ||
|
|
da29185b7d | ||
|
|
87feb8c250 | ||
|
|
12797893df | ||
|
|
6d47e43ba9 | ||
|
|
f6b1643378 | ||
|
|
f1c16df63b | ||
|
|
c16e5231f4 | ||
|
|
2365c253dd |
105
Changelog.txt
105
Changelog.txt
@@ -7,6 +7,111 @@ Key:
|
||||
! Change
|
||||
- Removal
|
||||
|
||||
Version 1.4.07-dev
|
||||
+ Added ability to summon horses via "Call of the Wild" using apples
|
||||
+ Added XP gain to Taming for horses
|
||||
+ Added new permission nodes to allow more control over Taming and "Call of the Wild"
|
||||
+ Added new experience.yml config file! Moved all experience related settings from config.yml to experience.yml
|
||||
+ Added support for EXPONENTIAL formula curves to experience.yml
|
||||
+ Added new /mcconvert command to convert players levels and experience from one formula curve to another.
|
||||
+ Added snow to Excavation blocks
|
||||
+ Added new experience curve option. Cumulative curve, calculates experience needed for next level using power level.
|
||||
+ Added extra settings to config.yml for "Call of the Wild" (Taming)
|
||||
+ Added a 5 second cooldown after teleporting before Acrobatics XP can be earned. Plus a config option to disable
|
||||
+ Added new API methods to ExperienceAPI to get a players rank on the leaderboards
|
||||
+ Added new McMMOPlayerDeathPenaltyEvent, fired when a player dies and would lose levels
|
||||
+ Added new McMMOPlayerLevelChangeEvent, fired when a players level changes
|
||||
+ Added new McMMOPlayerLevelDownEvent, fired when a player loses levels
|
||||
= Fixed bug which allowed players to bypass fishing's exploit prevention
|
||||
= Fixed bug where FakeEntityDamageByEntityEvent wasn't being fired
|
||||
= Fixed bug with "Skull Splitter" not finding the locale string
|
||||
= Fixed issue where locale strings could cause the scoreboard header to be longer than 16 characters.
|
||||
= Fixed a bug with "Beast Lore" when the entity had no owner but was tamed.
|
||||
= Fixed a bug where AbilityDeactivateEvent would throw an error if the player logged out before his ability ran out.
|
||||
= Fixed a bug where LevelUpEvent would be called for an offline player.
|
||||
= Fixed a bug where teleport location was never reset if warmup was set to 0 for "Chimaera Wing".
|
||||
= Fixed a bug where the "Dodge" DamageModifier wasn't being read from advanced.yml
|
||||
= Fixed a bug where squid were not awarding XP.
|
||||
! Changed various values to double in advanced.yml for the sake of consistency.
|
||||
! Nerfed Archery damage to eliminate constant one-hit kills.
|
||||
! Changed the way Repair hands out XP, also added config options to control Repair XP
|
||||
! Changed Swords "Counter Attack" ability from passive to active. Blocking is required to activate.
|
||||
! Hardcore mode can now be toggled for each skill individually
|
||||
! Vampirism can now be enabled without having Skill Death Penalty enabled
|
||||
! Admin and Party chat prefixes are now customizable
|
||||
! Changed the color of party leader names in Party chat
|
||||
! Improved profile saving
|
||||
! Improved partial name matcher
|
||||
! Slightly improved update checker feedback
|
||||
! Updated localization files
|
||||
! Party item share category states are now saved when the server shuts down.
|
||||
! When using "Super Breaker" or "Giga Driller" abilities extra tool durability is used (again)
|
||||
- The /mmoupdate command has been removed. It is replaced by /mcconvert database
|
||||
- Removed Abilities.Tools.Durability_Loss_Enabled, set Abilities.Tools.Durability_Loss to 0 to disable instead.
|
||||
|
||||
Version 1.4.06
|
||||
+ Added "Ice Fishing" ability to Fishing
|
||||
+ Added global scoreboards to track skill rankings (display using /mctop)
|
||||
+ Added per-player scoreboard displays for the /inspect, /mcrank, /mcstats, and /<skillname> commands
|
||||
+ Added tab-complete support for all commands
|
||||
+ Added ability to configure drops from Shake in treasures.yml
|
||||
+ Added "Master Angler" ability to Fishing.
|
||||
+ Added health display for mobs during combat.
|
||||
+ Added new API method to McMMOPlayerLevelUpEvent to set levels gained
|
||||
+ Added new permission node for /ptp; mcmmo.commands.ptp.send (enabled by default)
|
||||
+ Added configurable cooldown and warmup times when using /ptp
|
||||
+ Added a new Party item share category "Misc" which contains a list of configurable items. (By default all tools and armor)
|
||||
+ Added fishing exploit prevention
|
||||
+ Added permission node to bypass the fishing exploit prevention
|
||||
+ Added boosts to Fishing chance depending on conditions
|
||||
+ Added McMMOAbilityActivateEvent and McMMOAbilityDeactivateEvent
|
||||
+ Added config option to toggle the size of fireworks
|
||||
+ Added config option to multiply xp gains from mob spawner mobs
|
||||
+ Added multiplier to Archery XP based on bow force
|
||||
+ Added information about /party itemshare and /party expshare to the party help page
|
||||
+ Added option to use scoreboards for power level display instead of Spout.
|
||||
+ Added permission node to prevent inspecting hidden players
|
||||
+ Added SQL to Flatfile database conversion
|
||||
+ Added ability to use custom database managers and convert to/from them
|
||||
= Fixed bug which could cause the server to hang for a minute when checking for updates. (Thanks to Riking)
|
||||
= Fixed bug where spawned arrows could throw ArrayIndexOutOfBoundsException
|
||||
= Fixed bug where custom Spout titles were overwritten by mcMMO.
|
||||
= Fixed bug where Nether Quartz wasn't included in Smelting or item sharing
|
||||
= Fixed bug where players were able to join the same party multiple times
|
||||
= Fixed displaying partial names when trying to use /ptp
|
||||
= Fixed wolves from Call of the Wild only having 8 health
|
||||
= Fixed bug where /party chat was not working
|
||||
= Fixed bug where experience commands were adding levels to all skills when they shouldn't
|
||||
= Fixed mcmmo.commands.ptp.send not being set by default
|
||||
= Fixed NPE when trying to tab-complete /mctop
|
||||
= Fixed Fishing treasures always having the same enchants
|
||||
= Fixed Smelting returning ink sacs instead of Lapis when double-dropping
|
||||
= Fixed bug where players could remain in party chat after leaving or being kicked from a party.
|
||||
= Fixed bug where non-player arrows couldn't be deflected.
|
||||
= Fixed experience being applied even when the permission for a skill was denied
|
||||
= Fixed possible item duplication bug with infinity bows
|
||||
= Fixed bug with removing players from mySQL database
|
||||
= Fixed bug with empty metadata lists and Smelting
|
||||
= Fixed bug where Blast Mining would drop wrong items
|
||||
= Fixed bug with Blast Mining where the Ability refreshed message was being send too early
|
||||
= Fixed bug where the chance of a successful Gracefull Roll was twice as high as displayed
|
||||
= Fixed bug where lucky perks where not working
|
||||
= Fixed bug with Ice Fishing on a single block of ice
|
||||
= Fixed bug with Ice Fishing which allowed players to break ice in protected areas
|
||||
= Fixed a small bug with mob healthbars and bosses, such as EnderDragons and Withers
|
||||
! Changed Spout notification tiers to be stored in SpoutConfig instead of AdvancedConfig
|
||||
! Changed Berserk to add items to inventory rather than denying pickup
|
||||
! Changed Call of the Wild, newly summoned pet's will have a custom name. (added permission node to disable this)
|
||||
! Changed Chimaera Wing's recipe result to use the ingredient Material
|
||||
! Changed Repair to ask a confirmation of the player when he tries to repair an enchanted item
|
||||
! Players will no longer pickup items to their hotbar while using Unarmed
|
||||
! ExperienceAPI methods will now throw InvalidSkillException if the skill name passed in is invalid.
|
||||
! Changed default value for recently-hurt cooldown between teleports, this is also fully configurable now
|
||||
! Changed the amount of info messages in the console when enabling/disabling, enable Verbose_Logging to enable them again
|
||||
! Items dropped by players are now being tracked and are not being shared with party members
|
||||
! Optimized tracking of tool & ability cooldowns.
|
||||
! Updated the localization files
|
||||
|
||||
Version 1.4.05
|
||||
+ Added option to allow refreshing of chunks after block-breaking abilities. (Disabled by default)
|
||||
+ Added fireworks effects when a player levels-up, for every 100 levels (configurable)
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
Our latest development builds are available [here](http://ci.mcmmo.info).
|
||||
|
||||
### Brief Description
|
||||
mcMMO takes core Minecraft game mechanics and expands them to add an extensive RPG experience, the goal of the project has always been a quality RPG experience. Everything in mcMMO is carefully thought out and is constantly improving. mcMMO adds eleven skills to train in and level in, while also offering a high level of customization for server admins. There are countless features, including custom sounds, graphical elements, and more added when running mcMMO in conjunction with Spout. I carefully read feedback and evaluate the mechanics of mcMMO in every update to provide an ever-evolving experience.
|
||||
|
||||
If you want an original RPG experience like no other mod out there, mcMMO is for you.
|
||||
The goal of mcMMO is to take core Minecraft game mechanics and expand them into add an extensive and quality RPG experience. Everything in mcMMO has been carefully thought out and is constantly being improved upon. Currently, mcMMO adds thirteen unique skills to train and level in. Each of these skills is highly customizable through our configuration files, allowing server admins to tweak mcMMO to best suit the needs of his or her server. Additionally, when run in conjuction with SpoutPlugin, mcMMO also has a custom XP bar to allow for easy tracking of progress towards leveling up. Know that the mcMMO team is dedicated to providing an ever-evolving experience, and that we carefully read all feedback and bug reports in order to evaluate and balance the mechanics of mcMMO in every update.
|
||||
|
||||
## About the Team
|
||||
|
||||
@@ -29,7 +27,7 @@ mcMMO is currently developed by a team of individuals from all over the world.
|
||||
(https://github.com/shatteredbeam)
|
||||
[]
|
||||
(https://github.com/TfT-02)
|
||||
[]
|
||||
[]
|
||||
(https://github.com/t00thpick1)
|
||||
|
||||
## Compiling
|
||||
@@ -41,7 +39,7 @@ The typical command used to build mcMMO is: mvn clean package install
|
||||
Required Libraries:
|
||||
* Spout API
|
||||
* JUnit
|
||||
* Metrics
|
||||
* EMetrics
|
||||
* Bukkit
|
||||
|
||||
http://dev.bukkit.org/server-mods/mcmmo for more up to date information.
|
||||
|
||||
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.4.05</version>
|
||||
<version>1.4.07-beta1</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<issueManagement>
|
||||
@@ -165,7 +165,7 @@
|
||||
<dependency>
|
||||
<groupId>com.turt2live.metrics</groupId>
|
||||
<artifactId>MetricsExtension</artifactId>
|
||||
<version>0.0.4-SNAPSHOT</version>
|
||||
<version>0.0.5-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
@@ -177,4 +177,8 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<ciManagement>
|
||||
<system>Jenkins</system>
|
||||
<url>ci.mcmmo.org</url>
|
||||
</ciManagement>
|
||||
</project>
|
||||
|
||||
@@ -48,4 +48,36 @@ public final class AbilityAPI {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void resetCooldowns(Player player) {
|
||||
UserManager.getPlayer(player).getProfile().resetCooldowns();
|
||||
}
|
||||
|
||||
public static void setBerserkCooldown(Player player, long cooldown) {
|
||||
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.BERSERK, cooldown);
|
||||
}
|
||||
|
||||
public static void setGigaDrillBreakerCooldown(Player player, long cooldown) {
|
||||
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.GIGA_DRILL_BREAKER, cooldown);
|
||||
}
|
||||
|
||||
public static void setGreenTerraCooldown(Player player, long cooldown) {
|
||||
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.GREEN_TERRA, cooldown);
|
||||
}
|
||||
|
||||
public static void setSerratedStrikesCooldown(Player player, long cooldown) {
|
||||
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.SERRATED_STRIKES, cooldown);
|
||||
}
|
||||
|
||||
public static void setSkullSplitterCooldown(Player player, long cooldown) {
|
||||
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.SKULL_SPLITTER, cooldown);
|
||||
}
|
||||
|
||||
public static void setSuperBreakerCooldown(Player player, long cooldown) {
|
||||
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.SUPER_BREAKER, cooldown);
|
||||
}
|
||||
|
||||
public static void setTreeFellerCooldown(Player player, long cooldown) {
|
||||
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.TREE_FELLER, cooldown);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.chat.ChatManager;
|
||||
import com.gmail.nossr50.chat.ChatManagerFactory;
|
||||
import com.gmail.nossr50.chat.PartyChatManager;
|
||||
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
@@ -22,7 +25,7 @@ public final class ChatAPI {
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendPartyChat(Plugin plugin, String sender, String displayName, String party, String message) {
|
||||
ChatManager.handlePartyChat(plugin, PartyManager.getParty(party), sender, displayName, message);
|
||||
getPartyChatManager(plugin, party).handleChat(sender, displayName, message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,7 +39,7 @@ public final class ChatAPI {
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendPartyChat(Plugin plugin, String sender, String party, String message) {
|
||||
ChatManager.handlePartyChat(plugin, PartyManager.getParty(party), sender, sender, message);
|
||||
getPartyChatManager(plugin, party).handleChat(sender, message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,7 +53,7 @@ public final class ChatAPI {
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendAdminChat(Plugin plugin, String sender, String displayName, String message) {
|
||||
ChatManager.handleAdminChat(plugin, sender, displayName, message);
|
||||
ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN).handleChat(sender, displayName, message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +66,7 @@ public final class ChatAPI {
|
||||
* @param message The message to send
|
||||
*/
|
||||
public static void sendAdminChat(Plugin plugin, String sender, String message) {
|
||||
ChatManager.handleAdminChat(plugin, sender, sender, message);
|
||||
ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN).handleChat(sender, message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +76,7 @@ public final class ChatAPI {
|
||||
* @return true if the player is using party chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingPartyChat(Player player) {
|
||||
return isUsingPartyChat(player.getName());
|
||||
return UserManager.getPlayer(player).getPartyChatMode();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,7 +96,7 @@ public final class ChatAPI {
|
||||
* @return true if the player is using admin chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingAdminChat(Player player) {
|
||||
return isUsingAdminChat(player.getName());
|
||||
return UserManager.getPlayer(player).getAdminChatMode();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +115,7 @@ public final class ChatAPI {
|
||||
* @param player The player to toggle party chat on.
|
||||
*/
|
||||
public static void togglePartyChat(Player player) {
|
||||
togglePartyChat(player.getName());
|
||||
UserManager.getPlayer(player).togglePartyChat();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +124,7 @@ public final class ChatAPI {
|
||||
* @param playerName The name of the player to toggle party chat on.
|
||||
*/
|
||||
public static void togglePartyChat(String playerName) {
|
||||
UserManager.getPlayer(playerName).setPartyChat(!isUsingPartyChat(playerName));
|
||||
UserManager.getPlayer(playerName).togglePartyChat();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,7 +133,7 @@ public final class ChatAPI {
|
||||
* @param player The player to toggle admin chat on.
|
||||
*/
|
||||
public static void toggleAdminChat(Player player) {
|
||||
toggleAdminChat(player.getName());
|
||||
UserManager.getPlayer(player).toggleAdminChat();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,7 +141,14 @@ public final class ChatAPI {
|
||||
*
|
||||
* @param playerName The name of the player to toggle party chat on.
|
||||
*/
|
||||
public static void toggleAdminChat(String playerName){
|
||||
UserManager.getPlayer(playerName).setAdminChat(!isUsingAdminChat(playerName));
|
||||
public static void toggleAdminChat(String playerName) {
|
||||
UserManager.getPlayer(playerName).toggleAdminChat();
|
||||
}
|
||||
|
||||
private static ChatManager getPartyChatManager(Plugin plugin, String party) {
|
||||
ChatManager chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.PARTY);
|
||||
((PartyChatManager) chatManager).setParty(PartyManager.getParty(party));
|
||||
|
||||
return chatManager;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,11 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.api.exceptions.InvalidPlayerException;
|
||||
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
@@ -13,6 +17,37 @@ import com.gmail.nossr50.util.player.UserManager;
|
||||
public final class ExperienceAPI {
|
||||
private ExperienceAPI() {}
|
||||
|
||||
/**
|
||||
* Returns whether given string is a valid type of skill suitable for the
|
||||
* other API calls in this class.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param skillType A string that may or may not be a skill
|
||||
* @return true if this is a valid mcMMO skill
|
||||
*/
|
||||
public static boolean isValidSkillType(String skillType) {
|
||||
return SkillType.getSkill(skillType) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given skill type string is both valid and not a
|
||||
* child skill. (Child skills have no XP of their own, and their level is
|
||||
* derived from the parent(s).)
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param skillType the skill to check
|
||||
* @return true if this is a valid, non-child mcMMO skill
|
||||
*/
|
||||
public static boolean isNonChildSkill(String skillType) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) return false;
|
||||
|
||||
return !skill.isChildSkill();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds raw XP to the player.
|
||||
* </br>
|
||||
@@ -21,9 +56,11 @@ public final class ExperienceAPI {
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static void addRawXP(Player player, String skillType, int XP) {
|
||||
UserManager.getPlayer(player).applyXpGain(SkillType.getSkill(skillType), XP);
|
||||
UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), XP);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,10 +72,11 @@ public final class ExperienceAPI {
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static void addRawXPOffline(String playerName, String skillType, int XP) {
|
||||
addOfflineXP(playerName, skillType, XP);
|
||||
addOfflineXP(playerName, getSkillType(skillType), XP);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,9 +87,11 @@ public final class ExperienceAPI {
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static void addMultipliedXP(Player player, String skillType, int XP) {
|
||||
UserManager.getPlayer(player).applyXpGain(SkillType.getSkill(skillType), (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||
UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), (int) (XP * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,10 +103,11 @@ public final class ExperienceAPI {
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static void addMultipliedXPOffline(String playerName, String skillType, int XP) {
|
||||
addOfflineXP(playerName, skillType, (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||
addOfflineXP(playerName, getSkillType(skillType), (int) (XP * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,11 +118,13 @@ public final class ExperienceAPI {
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static void addModifiedXP(Player player, String skillType, int XP) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
SkillType skill = getSkillType(skillType);
|
||||
|
||||
UserManager.getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||
UserManager.getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,23 +136,29 @@ public final class ExperienceAPI {
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static void addModifiedXPOffline(String playerName, String skillType, int XP) {
|
||||
addOfflineXP(playerName, skillType, (int) (XP / SkillType.getSkill(skillType).getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||
SkillType skill = getSkillType(skillType);
|
||||
|
||||
addOfflineXP(playerName, skill, (int) (XP / skill.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, calculates for XP Rate, skill modifiers and perks. May be shared with the party.
|
||||
* Adds XP to the player, calculates for XP Rate, skill modifiers, perks, child skills,
|
||||
* and party sharing.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static void addXP(Player player, String skillType, int XP) {
|
||||
UserManager.getPlayer(player).beginXpGain(SkillType.getSkill(skillType), XP);
|
||||
UserManager.getPlayer(player).beginXpGain(getSkillType(skillType), XP);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,9 +169,12 @@ public final class ExperienceAPI {
|
||||
* @param player The player to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
* @return the amount of XP in a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static int getXP(Player player, String skillType) {
|
||||
return UserManager.getPlayer(player).getProfile().getSkillXpLevel(SkillType.getSkill(skillType));
|
||||
return UserManager.getPlayer(player).getProfile().getSkillXpLevel(getNonChildSkillType(skillType));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,23 +185,99 @@ public final class ExperienceAPI {
|
||||
* @param playerName The player to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
* @return the amount of XP in a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static int getOfflineXP(String playerName, String skillType) {
|
||||
return getOfflineProfile(playerName).getSkillXpLevel(SkillType.getSkill(skillType));
|
||||
return getOfflineProfile(playerName).getSkillXpLevel(getNonChildSkillType(skillType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of XP left before leveling up.
|
||||
* Get the raw amount of XP a player has in a specific skill.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
* @return the amount of XP in a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static float getXPRaw(Player player, String skillType) {
|
||||
return UserManager.getPlayer(player).getProfile().getSkillXpLevelRaw(getNonChildSkillType(skillType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw amount of XP an offline player has in a specific skill.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
* @return the amount of XP in a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static float getOfflineXPRaw(String playerName, String skillType) {
|
||||
return getOfflineProfile(playerName).getSkillXpLevelRaw(getNonChildSkillType(skillType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total amount of XP needed to reach the next level.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get the XP amount for
|
||||
* @param skillType The skill to get the XP amount for
|
||||
* @return the amount of XP left before leveling up a specifc skill
|
||||
* @return the total amount of XP needed to reach the next level
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static int getXPToNextLevel(Player player, String skillType) {
|
||||
return UserManager.getPlayer(player).getProfile().getXpToLevel(SkillType.getSkill(skillType));
|
||||
return UserManager.getPlayer(player).getProfile().getXpToLevel(getNonChildSkillType(skillType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total amount of XP an offline player needs to reach the next level.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
* @return the total amount of XP needed to reach the next level
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static int getOfflineXPToNextLevel(String playerName, String skillType) {
|
||||
return getOfflineProfile(playerName).getXpToLevel(getNonChildSkillType(skillType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of XP remaining until the next level.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get the XP amount for
|
||||
* @param skillType The skill to get the XP amount for
|
||||
* @return the amount of XP remaining until the next level
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static int getXPRemaining(Player player, String skillType) {
|
||||
SkillType skill = getNonChildSkillType(skillType);
|
||||
|
||||
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||
|
||||
return profile.getXpToLevel(skill) - profile.getSkillXpLevel(skill);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,11 +287,18 @@ public final class ExperienceAPI {
|
||||
*
|
||||
* @param playerName The player to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
* @return the amount of XP in a given skill
|
||||
* @return the amount of XP needed to reach the next level
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static int getOfflineXPToNextLevel(String playerName, String skillType) {
|
||||
return getOfflineProfile(playerName).getXpToLevel(SkillType.getSkill(skillType));
|
||||
public static int getOfflineXPRemaining(String playerName, String skillType) {
|
||||
SkillType skill = getNonChildSkillType(skillType);
|
||||
|
||||
PlayerProfile profile = getOfflineProfile(playerName);
|
||||
|
||||
return profile.getXpToLevel(skill) - profile.getSkillXpLevel(skill);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,9 +309,11 @@ public final class ExperienceAPI {
|
||||
* @param player The player to add levels to
|
||||
* @param skillType Type of skill to add levels to
|
||||
* @param levels Number of levels to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static void addLevel(Player player, String skillType, int levels) {
|
||||
UserManager.getPlayer(player).getProfile().addLevels(SkillType.getSkill(skillType), levels);
|
||||
UserManager.getPlayer(player).getProfile().addLevels(getSkillType(skillType), levels);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,12 +325,12 @@ public final class ExperienceAPI {
|
||||
* @param skillType Type of skill to add levels to
|
||||
* @param levels Number of levels to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static void addLevelOffline(String playerName, String skillType, int levels) {
|
||||
PlayerProfile profile = getOfflineProfile(playerName);
|
||||
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
SkillType skill = getSkillType(skillType);
|
||||
|
||||
if (skill.isChildSkill()) {
|
||||
Set<SkillType> parentSkills = FamilyTree.getParents(skill);
|
||||
@@ -218,9 +355,11 @@ public final class ExperienceAPI {
|
||||
* @param player The player to get the level for
|
||||
* @param skillType The skill to get the level for
|
||||
* @return the level of a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static int getLevel(Player player, String skillType) {
|
||||
return UserManager.getPlayer(player).getProfile().getSkillLevel(SkillType.getSkill(skillType));
|
||||
return UserManager.getPlayer(player).getProfile().getSkillLevel(getSkillType(skillType));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,10 +370,12 @@ public final class ExperienceAPI {
|
||||
* @param playerName The player to get the level for
|
||||
* @param skillType The skill to get the level for
|
||||
* @return the level of a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static int getLevelOffline(String playerName, String skillType) {
|
||||
return getOfflineProfile(playerName).getSkillLevel(SkillType.getSkill(skillType));
|
||||
return getOfflineProfile(playerName).getSkillLevel(getSkillType(skillType));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,17 +397,14 @@ public final class ExperienceAPI {
|
||||
*
|
||||
* @param playerName The player to get the power level for
|
||||
* @return the power level of the player
|
||||
*
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static int getPowerLevelOffline(String playerName) {
|
||||
int powerLevel = 0;
|
||||
PlayerProfile profile = getOfflineProfile(playerName);
|
||||
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (SkillType type : SkillType.nonChildSkills()) {
|
||||
powerLevel += profile.getSkillLevel(type);
|
||||
}
|
||||
|
||||
@@ -280,9 +418,11 @@ public final class ExperienceAPI {
|
||||
*
|
||||
* @param skillType The skill to get the level cap for
|
||||
* @return the level cap of a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static int getLevelCap(String skillType) {
|
||||
return Config.getInstance().getLevelCap(SkillType.getSkill(skillType));
|
||||
return Config.getInstance().getLevelCap(getSkillType(skillType));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,12 +430,46 @@ public final class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @return the power level cap of a given skill
|
||||
* @return the overall power level cap
|
||||
*/
|
||||
public static int getPowerLevelCap() {
|
||||
return Config.getInstance().getPowerLevelCap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the position on the leaderboard of a player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The name of the player to check
|
||||
* @param skillType The skill to check
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*
|
||||
* @return the position on the leaderboard
|
||||
*/
|
||||
public static int getPlayerRankSkill(String playerName, String skillType) {
|
||||
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(getNonChildSkillType(skillType).toString());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the position on the power level leaderboard of a player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The name of the player to check
|
||||
*
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*
|
||||
* @return the position on the power level leaderboard
|
||||
*/
|
||||
public static int getPlayerRankOverall(String playerName) {
|
||||
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get("ALL");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the level of a player in a specific skill type.
|
||||
* </br>
|
||||
@@ -304,9 +478,11 @@ public final class ExperienceAPI {
|
||||
* @param player The player to set the level of
|
||||
* @param skillType The skill to set the level for
|
||||
* @param skillLevel The value to set the level to
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static void setLevel(Player player, String skillType, int skillLevel) {
|
||||
UserManager.getPlayer(player).getProfile().modifySkill(SkillType.getSkill(skillType), skillLevel);
|
||||
UserManager.getPlayer(player).getProfile().modifySkill(getSkillType(skillType), skillLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -318,10 +494,11 @@ public final class ExperienceAPI {
|
||||
* @param skillType The skill to set the level for
|
||||
* @param skillLevel The value to set the level to
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static void setLevelOffline(String playerName, String skillType, int skillLevel) {
|
||||
getOfflineProfile(playerName).modifySkill(SkillType.getSkill(skillType), skillLevel);
|
||||
getOfflineProfile(playerName).modifySkill(getSkillType(skillType), skillLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -332,9 +509,12 @@ public final class ExperienceAPI {
|
||||
* @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
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static void setXP(Player player, String skillType, int newValue) {
|
||||
UserManager.getPlayer(player).getProfile().setSkillXpLevel(SkillType.getSkill(skillType), newValue);
|
||||
UserManager.getPlayer(player).getProfile().setSkillXpLevel(getNonChildSkillType(skillType), newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,10 +526,12 @@ public final class ExperienceAPI {
|
||||
* @param skillType The skill to set the XP for
|
||||
* @param newValue The value to set the XP to
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static void setXPOffline(String playerName, String skillType, int newValue) {
|
||||
getOfflineProfile(playerName).setSkillXpLevel(SkillType.getSkill(skillType), newValue);
|
||||
getOfflineProfile(playerName).setSkillXpLevel(getNonChildSkillType(skillType), newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -360,9 +542,12 @@ public final class ExperienceAPI {
|
||||
* @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
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static void removeXP(Player player, String skillType, int xp) {
|
||||
UserManager.getPlayer(player).getProfile().removeXp(SkillType.getSkill(skillType), xp);
|
||||
UserManager.getPlayer(player).getProfile().removeXp(getNonChildSkillType(skillType), xp);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -374,23 +559,18 @@ public final class ExperienceAPI {
|
||||
* @param skillType The skill to change the XP for
|
||||
* @param xp The amount of XP to remove
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||
*/
|
||||
public static void removeXPOffline(String playerName, String skillType, int xp) {
|
||||
getOfflineProfile(playerName).removeXp(SkillType.getSkill(skillType), xp);
|
||||
getOfflineProfile(playerName).removeXp(getNonChildSkillType(skillType), xp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add XP to an offline player.
|
||||
*
|
||||
* @param playerName The player to check
|
||||
* @param skillType The skill to check
|
||||
* @param XP The amount of XP to award.
|
||||
*/
|
||||
private static void addOfflineXP(String playerName, String skillType, int XP) {
|
||||
PlayerProfile profile = getOfflineProfile(playerName);
|
||||
// Utility methods follow.
|
||||
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
private static void addOfflineXP(String playerName, SkillType skill, int XP) {
|
||||
PlayerProfile profile = getOfflineProfile(playerName);
|
||||
|
||||
if (skill.isChildSkill()) {
|
||||
Set<SkillType> parentSkills = FamilyTree.getParents(skill);
|
||||
@@ -408,7 +588,7 @@ public final class ExperienceAPI {
|
||||
}
|
||||
|
||||
private static PlayerProfile getOfflineProfile(String playerName) {
|
||||
PlayerProfile profile = new PlayerProfile(playerName, false);
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
throw new InvalidPlayerException();
|
||||
@@ -416,4 +596,24 @@ public final class ExperienceAPI {
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
private static SkillType getSkillType(String skillType) throws InvalidSkillException {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
return skill;
|
||||
}
|
||||
|
||||
private static SkillType getNonChildSkillType(String skillType) throws InvalidSkillException, UnsupportedOperationException {
|
||||
SkillType skill = getSkillType(skillType);
|
||||
|
||||
if (skill.isChildSkill()) {
|
||||
throw new UnsupportedOperationException("Child skills do not have XP");
|
||||
}
|
||||
|
||||
return skill;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@@ -76,12 +79,10 @@ public final class PartyAPI {
|
||||
Party party = PartyManager.getParty(partyName);
|
||||
|
||||
if (party == null) {
|
||||
party = new Party();
|
||||
party.setName(partyName);
|
||||
party.setLeader(player.getName());
|
||||
party = new Party(player.getName(), partyName);
|
||||
}
|
||||
|
||||
PartyManager.addToParty(player, UserManager.getPlayer(player), party);
|
||||
PartyManager.addToParty(UserManager.getPlayer(player), party);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +93,7 @@ public final class PartyAPI {
|
||||
* @param player The player to remove
|
||||
*/
|
||||
public static void removeFromParty(Player player) {
|
||||
PartyManager.removeFromParty(player, UserManager.getPlayer(player).getParty());
|
||||
PartyManager.removeFromParty(UserManager.getPlayer(player));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +128,26 @@ public final class PartyAPI {
|
||||
* @param player The player to check
|
||||
* @return all the players in the player's party
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) {
|
||||
List<OfflinePlayer> members = new ArrayList<OfflinePlayer>();
|
||||
|
||||
for (String memberName : PartyManager.getAllMembers(player)) {
|
||||
OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberName);
|
||||
members.add(member);
|
||||
}
|
||||
return members;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all player names in this player's party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return all the player names in the player's party
|
||||
*/
|
||||
public static LinkedHashSet<String> getMembers(Player player) {
|
||||
return PartyManager.getAllMembers(player);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.api;
|
||||
package com.gmail.nossr50.api.exceptions;
|
||||
|
||||
public class InvalidPlayerException extends RuntimeException {
|
||||
private static final long serialVersionUID = 907213002618581385L;
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.gmail.nossr50.api.exceptions;
|
||||
|
||||
public class InvalidSkillException extends RuntimeException {
|
||||
private static final long serialVersionUID = 942705284195791157L;
|
||||
|
||||
public InvalidSkillException() {
|
||||
super("That is not a valid skill.");
|
||||
}
|
||||
}
|
||||
22
src/main/java/com/gmail/nossr50/chat/AdminChatManager.java
Normal file
22
src/main/java/com/gmail/nossr50/chat/AdminChatManager.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.gmail.nossr50.chat;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||
|
||||
public class AdminChatManager extends ChatManager {
|
||||
protected AdminChatManager(Plugin plugin) {
|
||||
super(plugin, Config.getInstance().getAdminDisplayNames(), Config.getInstance().getAdminChatPrefix());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleChat(String senderName, String displayName, String message, boolean isAsync) {
|
||||
handleChat(new McMMOAdminChatEvent(plugin, senderName, displayName, message, isAsync));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendMessage() {
|
||||
plugin.getServer().broadcast(message, "mcmmo.chat.adminchat");
|
||||
}
|
||||
}
|
||||
@@ -1,78 +1,53 @@
|
||||
package com.gmail.nossr50.chat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.events.chat.McMMOChatEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public final class ChatManager {
|
||||
public ChatManager () {}
|
||||
public abstract class ChatManager {
|
||||
protected Plugin plugin;
|
||||
protected boolean useDisplayNames;
|
||||
protected String chatPrefix;
|
||||
|
||||
public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message, boolean isAsync) {
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message, isAsync);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
protected String senderName;
|
||||
protected String displayName;
|
||||
protected String message;
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
protected ChatManager(Plugin plugin, boolean useDisplayNames, String chatPrefix) {
|
||||
this.plugin = plugin;
|
||||
this.useDisplayNames = useDisplayNames;
|
||||
this.chatPrefix = chatPrefix;
|
||||
}
|
||||
|
||||
protected void handleChat(McMMOChatEvent event) {
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getAdminDisplayNames()) {
|
||||
displayName = chatEvent.getDisplayName();
|
||||
}
|
||||
else {
|
||||
displayName = chatEvent.getSender();
|
||||
}
|
||||
senderName = event.getSender();
|
||||
displayName = useDisplayNames ? event.getDisplayName() : senderName;
|
||||
message = LocaleLoader.formatString(chatPrefix, displayName) + " " + event.getMessage();
|
||||
|
||||
String adminMessage = chatEvent.getMessage();
|
||||
|
||||
mcMMO.p.getServer().broadcast(LocaleLoader.getString("Commands.AdminChat.Prefix", displayName) + adminMessage, "mcmmo.chat.adminchat");
|
||||
sendMessage();
|
||||
}
|
||||
|
||||
public static void handleAdminChat(Plugin plugin, String senderName, String message) {
|
||||
handleAdminChat(plugin, senderName, senderName, message);
|
||||
public void handleChat(String senderName, String message) {
|
||||
handleChat(senderName, senderName, message, false);
|
||||
}
|
||||
|
||||
public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message) {
|
||||
handleAdminChat(plugin, playerName, displayName, message, false);
|
||||
public void handleChat(Player player, String message, boolean isAsync) {
|
||||
handleChat(player.getName(), player.getDisplayName(), message, isAsync);
|
||||
}
|
||||
|
||||
public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message, boolean isAsync) {
|
||||
String partyName = party.getName();
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(plugin, playerName, displayName, partyName, message, isAsync);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getPartyDisplayNames()) {
|
||||
displayName = chatEvent.getDisplayName();
|
||||
}
|
||||
else {
|
||||
displayName = chatEvent.getSender();
|
||||
}
|
||||
|
||||
String partyMessage = chatEvent.getMessage();
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
member.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Prefix", displayName) + partyMessage);
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("[P](" + partyName + ")" + "<" + ChatColor.stripColor(displayName) + "> " + partyMessage);
|
||||
public void handleChat(String senderName, String displayName, String message) {
|
||||
handleChat(senderName, displayName, message, false);
|
||||
}
|
||||
|
||||
public static void handlePartyChat(Plugin plugin, Party party, String senderName, String message) {
|
||||
handlePartyChat(plugin, party, senderName, senderName, message);
|
||||
}
|
||||
public abstract void handleChat(String senderName, String displayName, String message, boolean isAsync);
|
||||
|
||||
public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message) {
|
||||
handlePartyChat(plugin, party, playerName, displayName, message, false);
|
||||
}
|
||||
protected abstract void sendMessage();
|
||||
}
|
||||
|
||||
31
src/main/java/com/gmail/nossr50/chat/ChatManagerFactory.java
Normal file
31
src/main/java/com/gmail/nossr50/chat/ChatManagerFactory.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.gmail.nossr50.chat;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
||||
|
||||
public class ChatManagerFactory {
|
||||
private static final HashMap<Plugin, AdminChatManager> adminChatManagers = new HashMap<Plugin, AdminChatManager>();
|
||||
private static final HashMap<Plugin, PartyChatManager> partyChatManagers = new HashMap<Plugin, PartyChatManager>();
|
||||
|
||||
public static ChatManager getChatManager(Plugin plugin, ChatMode mode) {
|
||||
switch (mode) {
|
||||
case ADMIN:
|
||||
if (!adminChatManagers.containsKey(plugin)) {
|
||||
adminChatManagers.put(plugin, new AdminChatManager(plugin));
|
||||
}
|
||||
|
||||
return adminChatManagers.get(plugin);
|
||||
case PARTY:
|
||||
if (!partyChatManagers.containsKey(plugin)) {
|
||||
partyChatManagers.put(plugin, new PartyChatManager(plugin));
|
||||
}
|
||||
|
||||
return partyChatManagers.get(plugin);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
39
src/main/java/com/gmail/nossr50/chat/PartyChatManager.java
Normal file
39
src/main/java/com/gmail/nossr50/chat/PartyChatManager.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package com.gmail.nossr50.chat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
|
||||
public class PartyChatManager extends ChatManager {
|
||||
private Party party;
|
||||
|
||||
protected PartyChatManager(Plugin plugin) {
|
||||
super(plugin, Config.getInstance().getPartyDisplayNames(), Config.getInstance().getPartyChatPrefix());
|
||||
}
|
||||
|
||||
public void setParty(Party party) {
|
||||
this.party = party;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleChat(String senderName, String displayName, String message, boolean isAsync) {
|
||||
handleChat(new McMMOPartyChatEvent(plugin, senderName, displayName, party.getName(), message, isAsync));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendMessage() {
|
||||
if (Config.getInstance().getPartyChatColorLeaderName() && senderName.equalsIgnoreCase(party.getLeader())) {
|
||||
message = message.replaceAll(displayName, ChatColor.GOLD + displayName + ChatColor.RESET);
|
||||
}
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
member.sendMessage(message);
|
||||
}
|
||||
|
||||
plugin.getLogger().info("[P]<" + party.getName() + ">" + message);
|
||||
}
|
||||
}
|
||||
69
src/main/java/com/gmail/nossr50/commands/KrakenCommand.java
Normal file
69
src/main/java/com/gmail/nossr50/commands/KrakenCommand.java
Normal file
@@ -0,0 +1,69 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class KrakenCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Permissions.kraken(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
UserManager.getPlayer((Player) sender).getFishingManager().unleashTheKraken();
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (!Permissions.krakenOthers(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
String playerName = Misc.getMatchedPlayerName(args[0]);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer.getFishingManager().unleashTheKraken();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Set<String> playerNames = UserManager.getPlayerNames();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,74 +1,29 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class McabilityCommand implements CommandExecutor {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private Player player;
|
||||
public class McabilityCommand extends ToggleCommand {
|
||||
@Override
|
||||
protected boolean hasOtherPermission(CommandSender sender) {
|
||||
return Permissions.mcabilityOthers(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Permissions.mcability(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
toggleAbilityUse();
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (!Permissions.mcabilityOthers(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, args[0], mcMMOPlayer)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (CommandUtils.isOffline(sender, player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
toggleAbilityUse();
|
||||
sender.sendMessage("Ability use has been toggled for " + player.getName()); // TODO: Localize
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
protected boolean hasSelfPermission(CommandSender sender) {
|
||||
return Permissions.mcability(sender);
|
||||
}
|
||||
|
||||
private void toggleAbilityUse() {
|
||||
if (mcMMOPlayer.getAbilityUse()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyCommandAction() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Ability." + (mcMMOPlayer.getAbilityUse() ? "Off" : "On")));
|
||||
mcMMOPlayer.toggleAbilityUse();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendSuccessMessage(CommandSender sender) {
|
||||
sender.sendMessage("Ability use has been toggled for " + player.getName()); // TODO: Localize
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,74 +1,29 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class McgodCommand implements CommandExecutor {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private Player player;
|
||||
public class McgodCommand extends ToggleCommand {
|
||||
@Override
|
||||
protected boolean hasOtherPermission(CommandSender sender) {
|
||||
return Permissions.mcgodOthers(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Permissions.mcgod(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
toggleGodMode();
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (!Permissions.mcgodOthers(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, args[0], mcMMOPlayer)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (CommandUtils.isOffline(sender, player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
toggleGodMode();
|
||||
sender.sendMessage("God mode has been toggled for " + player.getName()); // TODO: Localize
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
protected boolean hasSelfPermission(CommandSender sender) {
|
||||
return Permissions.mcgod(sender);
|
||||
}
|
||||
|
||||
private void toggleGodMode() {
|
||||
if (mcMMOPlayer.getGodMode()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyCommandAction() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode." + (mcMMOPlayer.getGodMode() ? "Disabled" : "Enabled")));
|
||||
mcMMOPlayer.toggleGodMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendSuccessMessage(CommandSender sender) {
|
||||
sender.sendMessage("God mode has been toggled for " + player.getName()); // TODO: Localize
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.party.PartySubcommandType;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.spout.SpoutUtils;
|
||||
|
||||
public class McmmoCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -28,13 +28,13 @@ public class McmmoCommand implements CommandExecutor {
|
||||
sender.sendMessage(mcSplit);
|
||||
|
||||
if (Config.getInstance().getDonateMessageEnabled()) {
|
||||
if (mcMMO.spoutEnabled && sender instanceof SpoutPlayer) {
|
||||
SpoutPlayer spoutPlayer = (SpoutPlayer) sender;
|
||||
spoutPlayer.sendNotification(LocaleLoader.getString("Spout.Donate"), ChatColor.GREEN + "gjmcferrin@gmail.com", Material.DIAMOND);
|
||||
if (mcMMO.isSpoutEnabled() && sender instanceof Player) {
|
||||
SpoutUtils.sendDonationNotification((Player) sender);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
|
||||
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
|
||||
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
|
||||
@@ -62,52 +62,52 @@ public class McmmoCommand implements CommandExecutor {
|
||||
private void displayPartyCommands(CommandSender sender) {
|
||||
if (Permissions.party(sender)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.Commands"));
|
||||
sender.sendMessage("/party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1"));
|
||||
sender.sendMessage("/party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2"));
|
||||
sender.sendMessage("/party quit " + LocaleLoader.getString("Commands.Party.Quit"));
|
||||
sender.sendMessage(" /party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1"));
|
||||
sender.sendMessage(" /party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2"));
|
||||
sender.sendMessage(" /party quit " + LocaleLoader.getString("Commands.Party.Quit"));
|
||||
|
||||
if (Permissions.partyChat(sender)) {
|
||||
sender.sendMessage("/party chat " + LocaleLoader.getString("Commands.Party.Toggle"));
|
||||
sender.sendMessage(" /party chat " + LocaleLoader.getString("Commands.Party.Toggle"));
|
||||
}
|
||||
|
||||
sender.sendMessage("/party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite"));
|
||||
sender.sendMessage("/party accept " + LocaleLoader.getString("Commands.Party.Accept"));
|
||||
sender.sendMessage(" /party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite"));
|
||||
sender.sendMessage(" /party accept " + LocaleLoader.getString("Commands.Party.Accept"));
|
||||
|
||||
if (Permissions.partySubcommand(sender, PartySubcommandType.TELEPORT)) {
|
||||
sender.sendMessage("/party teleport " + LocaleLoader.getString("Commands.Party.Teleport"));
|
||||
sender.sendMessage(" /party teleport " + LocaleLoader.getString("Commands.Party.Teleport"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void displayOtherCommands(CommandSender sender) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Other"));
|
||||
sender.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
|
||||
sender.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards"));
|
||||
sender.sendMessage(" /mcstats " + LocaleLoader.getString("Commands.Stats"));
|
||||
sender.sendMessage(" /mctop " + LocaleLoader.getString("Commands.Leaderboards"));
|
||||
|
||||
if (Permissions.skillreset(sender)) {
|
||||
sender.sendMessage("/skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
|
||||
sender.sendMessage(" /skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
|
||||
}
|
||||
|
||||
if (Permissions.mcability(sender)) {
|
||||
sender.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
|
||||
sender.sendMessage(" /mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
|
||||
}
|
||||
|
||||
if (Permissions.adminChat(sender)) {
|
||||
sender.sendMessage("/adminchat " + LocaleLoader.getString("Commands.AdminToggle"));
|
||||
sender.sendMessage(" /adminchat " + LocaleLoader.getString("Commands.AdminToggle"));
|
||||
}
|
||||
|
||||
if (Permissions.inspect(sender)) {
|
||||
sender.sendMessage("/inspect " + LocaleLoader.getString("Commands.Inspect"));
|
||||
sender.sendMessage(" /inspect " + LocaleLoader.getString("Commands.Inspect"));
|
||||
}
|
||||
|
||||
if (Permissions.mmoedit(sender)) {
|
||||
sender.sendMessage("/mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
|
||||
sender.sendMessage(" /mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
|
||||
}
|
||||
|
||||
if (Permissions.mcgod(sender)) {
|
||||
sender.sendMessage("/mcgod " + LocaleLoader.getString("Commands.mcgod"));
|
||||
sender.sendMessage(" /mcgod " + LocaleLoader.getString("Commands.mcgod"));
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.SkillInfo"));
|
||||
sender.sendMessage(" /<skill>" + LocaleLoader.getString("Commands.SkillInfo"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class McnotifyCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McnotifyCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
|
||||
if (mcMMOPlayer.useChatNotifications()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Notifications.Off"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Notifications.On"));
|
||||
}
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Notifications." + (mcMMOPlayer.useChatNotifications() ? "Off" : "On")));
|
||||
mcMMOPlayer.toggleChatNotifications();
|
||||
return true;
|
||||
|
||||
@@ -29,4 +28,9 @@ public class McnotifyCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,74 +1,33 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class McrefreshCommand implements CommandExecutor {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private Player player;
|
||||
|
||||
public class McrefreshCommand extends ToggleCommand {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Permissions.mcrefresh(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
refreshPlayer();
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (!Permissions.mcrefreshOthers(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, args[0], mcMMOPlayer)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (CommandUtils.isOffline(sender, player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
refreshPlayer();
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", player.getName()));
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
protected boolean hasOtherPermission(CommandSender sender) {
|
||||
return Permissions.mcrefreshOthers(sender);
|
||||
}
|
||||
|
||||
private void refreshPlayer() {
|
||||
@Override
|
||||
protected boolean hasSelfPermission(CommandSender sender) {
|
||||
return Permissions.mcrefresh(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyCommandAction() {
|
||||
mcMMOPlayer.setRecentlyHurt(0);
|
||||
mcMMOPlayer.getProfile().resetCooldowns();
|
||||
mcMMOPlayer.resetToolPrepMode();
|
||||
mcMMOPlayer.resetAbilityMode();
|
||||
|
||||
player.setCanPickupItems(true);
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendSuccessMessage(CommandSender sender) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McscoreboardCommand implements TabExecutor {
|
||||
private static final List<String> SCOREBOARD_TYPES = ImmutableList.of("clear", "rank", "stats", "top");
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
clearScoreboard(player);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("clear")) {
|
||||
clearScoreboard(player);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("rank")) {
|
||||
if (!Config.getInstance().getMcrankScoreboardEnabled()) {
|
||||
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||
return true;
|
||||
}
|
||||
|
||||
ScoreboardManager.setupPlayerScoreboard(player.getName());
|
||||
ScoreboardManager.enablePlayerRankScoreboard(player);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("stats")) {
|
||||
if (!Config.getInstance().getMcstatsScoreboardsEnabled()) {
|
||||
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||
return true;
|
||||
}
|
||||
|
||||
ScoreboardManager.setupPlayerScoreboard(player.getName());
|
||||
ScoreboardManager.enablePlayerStatsScoreboard(UserManager.getPlayer(player));
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("top")) {
|
||||
if (!Config.getInstance().getMctopScoreboardEnabled()) {
|
||||
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||
return true;
|
||||
}
|
||||
|
||||
ScoreboardManager.enableGlobalStatsScoreboard(player, "all", 1);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (!args[0].equalsIgnoreCase("top")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Config.getInstance().getMctopScoreboardEnabled()) {
|
||||
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||
return true;
|
||||
}
|
||||
|
||||
if (StringUtils.isInt(args[1])) {
|
||||
ScoreboardManager.enableGlobalStatsScoreboard(player, "all", Math.abs(Integer.parseInt(args[1])));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandUtils.isInvalidSkill(sender, args[1])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ScoreboardManager.enableGlobalStatsScoreboard(player, args[1], 1);
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
if (!args[0].equalsIgnoreCase("top")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Config.getInstance().getMctopScoreboardEnabled()) {
|
||||
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandUtils.isInvalidSkill(sender, args[1])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandUtils.isInvalidInteger(sender, args[2])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ScoreboardManager.enableGlobalStatsScoreboard(player, args[1], Math.abs(Integer.parseInt(args[2])));
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[0], SCOREBOARD_TYPES, new ArrayList<String>(SCOREBOARD_TYPES.size()));
|
||||
case 2:
|
||||
if (args[0].equalsIgnoreCase("top")) {
|
||||
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
||||
}
|
||||
// Fallthrough
|
||||
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
private void clearScoreboard(Player player) {
|
||||
player.setScoreboard(mcMMO.p.getServer().getScoreboardManager().getMainScoreboard());
|
||||
player.sendMessage("Your scoreboard has been cleared!"); //TODO: Locale
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class MobhealthCommand implements TabExecutor {
|
||||
private static final List<String> MOB_HEALTHBAR_TYPES;
|
||||
|
||||
static {
|
||||
ArrayList<String> types = new ArrayList<String>();
|
||||
|
||||
for (MobHealthbarType type : MobHealthbarType.values()) {
|
||||
types.add(type.toString());
|
||||
}
|
||||
|
||||
Collections.sort(types);
|
||||
MOB_HEALTHBAR_TYPES = ImmutableList.copyOf(types);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
PlayerProfile playerProfile = UserManager.getPlayer((Player) sender).getProfile();
|
||||
|
||||
try {
|
||||
MobHealthbarType type = MobHealthbarType.valueOf(args[0].toUpperCase().trim());
|
||||
playerProfile.setMobHealthbarType(type);
|
||||
sender.sendMessage("Display type changed to: " + type); //TODO: Localize
|
||||
return true;
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
sender.sendMessage("Invalid type!"); //TODO: Localize
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[0], MOB_HEALTHBAR_TYPES, new ArrayList<String>(MOB_HEALTHBAR_TYPES.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
}
|
||||
86
src/main/java/com/gmail/nossr50/commands/ToggleCommand.java
Normal file
86
src/main/java/com/gmail/nossr50/commands/ToggleCommand.java
Normal file
@@ -0,0 +1,86 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public abstract class ToggleCommand implements TabExecutor {
|
||||
protected McMMOPlayer mcMMOPlayer;
|
||||
protected Player player;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!hasSelfPermission(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
player = (Player) sender;
|
||||
mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
applyCommandAction();
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (!hasOtherPermission(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
String playerName = Misc.getMatchedPlayerName(args[0]);
|
||||
mcMMOPlayer = UserManager.getPlayer(playerName);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (CommandUtils.isOffline(sender, player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
applyCommandAction();
|
||||
sendSuccessMessage(sender);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Set<String> playerNames = UserManager.getPlayerNames();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean hasOtherPermission(CommandSender sender);
|
||||
protected abstract boolean hasSelfPermission(CommandSender sender);
|
||||
protected abstract void applyCommandAction();
|
||||
protected abstract void sendSuccessMessage(CommandSender sender);
|
||||
}
|
||||
@@ -1,20 +1,27 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
|
||||
public class XprateCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class XprateCommand implements TabExecutor {
|
||||
private double originalRate;
|
||||
|
||||
public XprateCommand() {
|
||||
originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
|
||||
originalRate = ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -35,7 +42,7 @@ public class XprateCommand implements CommandExecutor {
|
||||
mcMMO.p.toggleXpEventEnabled();
|
||||
}
|
||||
|
||||
Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
|
||||
ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
@@ -59,7 +66,7 @@ public class XprateCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
int newXpRate = Integer.parseInt(args[0]);
|
||||
Config.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
|
||||
ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
|
||||
|
||||
if (mcMMO.p.isXPEventEnabled()) {
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.0"));
|
||||
@@ -75,4 +82,20 @@ public class XprateCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (StringUtils.isInt(args[0])) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
return StringUtil.copyPartialMatches(args[0], CommandUtils.RESET_OPTIONS, new ArrayList<String>(CommandUtils.RESET_OPTIONS.size()));
|
||||
case 2:
|
||||
return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
package com.gmail.nossr50.commands.chat;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.chat.ChatManager;
|
||||
import com.gmail.nossr50.chat.ChatMode;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
||||
|
||||
public class AdminChatCommand extends ChatCommand {
|
||||
public AdminChatCommand() {
|
||||
@@ -15,12 +11,6 @@ public class AdminChatCommand extends ChatCommand {
|
||||
|
||||
@Override
|
||||
protected void handleChatSending(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
ChatManager.handleAdminChat(mcMMO.p, player.getName(), player.getDisplayName(), buildChatMessage(args, 0));
|
||||
}
|
||||
else {
|
||||
ChatManager.handleAdminChat(mcMMO.p, LocaleLoader.getString("Commands.Chat.Console"), buildChatMessage(args, 0));
|
||||
}
|
||||
chatManager.handleChat(sender.getName(), getDisplayName(sender), buildChatMessage(args, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,33 @@
|
||||
package com.gmail.nossr50.commands.chat;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.gmail.nossr50.chat.ChatMode;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.chat.ChatManager;
|
||||
import com.gmail.nossr50.chat.ChatManagerFactory;
|
||||
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public abstract class ChatCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public abstract class ChatCommand implements TabExecutor {
|
||||
protected ChatMode chatMode;
|
||||
protected ChatManager chatManager;
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
|
||||
public ChatCommand(ChatMode chatMode) {
|
||||
this.chatMode = chatMode;
|
||||
this.chatManager = ChatManagerFactory.getChatManager(mcMMO.p, chatMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -26,7 +38,7 @@ public abstract class ChatCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||
|
||||
if (chatMode.isEnabled(mcMMOPlayer)) {
|
||||
disableChatMode(sender);
|
||||
@@ -43,7 +55,7 @@ public abstract class ChatCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||
|
||||
enableChatMode(sender);
|
||||
return true;
|
||||
@@ -54,7 +66,7 @@ public abstract class ChatCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||
|
||||
disableChatMode(sender);
|
||||
return true;
|
||||
@@ -68,6 +80,16 @@ public abstract class ChatCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
protected String buildChatMessage(String[] args, int index) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(args[index]);
|
||||
@@ -80,6 +102,10 @@ public abstract class ChatCommand implements CommandExecutor {
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
protected String getDisplayName(CommandSender sender) {
|
||||
return (sender instanceof Player) ? ((Player) sender).getDisplayName() : LocaleLoader.getString("Commands.Chat.Console");
|
||||
}
|
||||
|
||||
protected abstract void handleChatSending(CommandSender sender, String[] args);
|
||||
|
||||
private void enableChatMode(CommandSender sender) {
|
||||
|
||||
@@ -3,9 +3,8 @@ package com.gmail.nossr50.commands.chat;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.chat.ChatManager;
|
||||
import com.gmail.nossr50.chat.ChatMode;
|
||||
import com.gmail.nossr50.chat.PartyChatManager;
|
||||
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
@@ -18,16 +17,18 @@ public class PartyChatCommand extends ChatCommand {
|
||||
|
||||
@Override
|
||||
protected void handleChatSending(CommandSender sender, String[] args) {
|
||||
Party party;
|
||||
String message;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
Party party = UserManager.getPlayer(player).getParty();
|
||||
party = UserManager.getPlayer((Player) sender).getParty();
|
||||
|
||||
if (party == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
return;
|
||||
}
|
||||
|
||||
ChatManager.handlePartyChat(mcMMO.p, party, player.getName(), player.getDisplayName(), buildChatMessage(args, 0));
|
||||
message = buildChatMessage(args, 0);
|
||||
}
|
||||
else {
|
||||
if (args.length < 2) {
|
||||
@@ -35,14 +36,17 @@ public class PartyChatCommand extends ChatCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
Party party = PartyManager.getParty(args[0]);
|
||||
party = PartyManager.getParty(args[0]);
|
||||
|
||||
if (party == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
|
||||
return;
|
||||
}
|
||||
|
||||
ChatManager.handlePartyChat(mcMMO.p, party, LocaleLoader.getString("Commands.Chat.Console"), buildChatMessage(args, 1));
|
||||
message = buildChatMessage(args, 1);
|
||||
}
|
||||
|
||||
((PartyChatManager) chatManager).setParty(party);
|
||||
chatManager.handleChat(sender.getName(), getDisplayName(sender), message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.gmail.nossr50.commands.database;
|
||||
|
||||
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.database.DatabaseManager;
|
||||
import com.gmail.nossr50.database.DatabaseManagerFactory;
|
||||
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.database.DatabaseConversionTask;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class ConvertDatabaseCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
DatabaseType previousType = DatabaseType.getDatabaseType(args[1]);
|
||||
DatabaseType newType = mcMMO.getDatabaseManager().getDatabaseType();
|
||||
|
||||
if ((newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1])) || previousType == newType) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Same", newType.toString()));
|
||||
return true;
|
||||
}
|
||||
|
||||
DatabaseManager oldDatabase = DatabaseManagerFactory.createDatabaseManager(previousType);
|
||||
|
||||
if (previousType == DatabaseType.CUSTOM) {
|
||||
Class<?> clazz;
|
||||
|
||||
try {
|
||||
clazz = Class.forName(args[1]);
|
||||
|
||||
if (!DatabaseManager.class.isAssignableFrom(clazz)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
oldDatabase = DatabaseManagerFactory.createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
sender.sendMessage("An error occurred during the conversion process."); // TODO: Localize
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Start", previousType.toString(), newType.toString()));
|
||||
|
||||
UserManager.saveAll();
|
||||
UserManager.clearAll();
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
PlayerProfile profile = oldDatabase.loadPlayerProfile(player.getName(), false);
|
||||
|
||||
if (profile.isLoaded()) {
|
||||
mcMMO.getDatabaseManager().saveUser(profile);
|
||||
}
|
||||
|
||||
UserManager.addUser(player);
|
||||
}
|
||||
|
||||
new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(mcMMO.p);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.gmail.nossr50.commands.database;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.experience.ConvertExperienceCommand;
|
||||
import com.gmail.nossr50.database.DatabaseManagerFactory;
|
||||
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McconvertCommand implements TabExecutor {
|
||||
private static final List<String> FORMULA_TYPES;
|
||||
private static final List<String> DATABASE_TYPES;
|
||||
private static final List<String> SUBCOMMANDS = ImmutableList.of("database", "experience");
|
||||
|
||||
private CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand();
|
||||
private CommandExecutor experienceConvertCommand = new ConvertExperienceCommand();
|
||||
|
||||
static {
|
||||
ArrayList<String> formulaTypes = new ArrayList<String>();
|
||||
|
||||
for (FormulaType type : FormulaType.values()) {
|
||||
formulaTypes.add(type.toString());
|
||||
}
|
||||
|
||||
Collections.sort(formulaTypes);
|
||||
FORMULA_TYPES = ImmutableList.copyOf(formulaTypes);
|
||||
}
|
||||
|
||||
static {
|
||||
ArrayList<String> databaseTypes = new ArrayList<String>();
|
||||
|
||||
for (DatabaseType type : DatabaseType.values()) {
|
||||
databaseTypes.add(type.toString());
|
||||
}
|
||||
|
||||
// Custom stuff
|
||||
databaseTypes.remove(DatabaseType.CUSTOM);
|
||||
|
||||
if (mcMMO.getDatabaseManager().getDatabaseType() == DatabaseType.CUSTOM) {
|
||||
databaseTypes.add(DatabaseManagerFactory.getCustomDatabaseManagerClass().getName());
|
||||
}
|
||||
|
||||
Collections.sort(databaseTypes);
|
||||
DATABASE_TYPES = ImmutableList.copyOf(databaseTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) {
|
||||
return databaseConvertCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[1].equalsIgnoreCase("exp")) {
|
||||
return experienceConvertCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[0], SUBCOMMANDS, new ArrayList<String>(SUBCOMMANDS.size()));
|
||||
case 2:
|
||||
if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) {
|
||||
return StringUtil.copyPartialMatches(args[0], DATABASE_TYPES, new ArrayList<String>(DATABASE_TYPES.size()));
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[0].equalsIgnoreCase("exp")) {
|
||||
return StringUtil.copyPartialMatches(args[0], FORMULA_TYPES, new ArrayList<String>(FORMULA_TYPES.size()));
|
||||
}
|
||||
|
||||
return ImmutableList.of();
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +1,26 @@
|
||||
package com.gmail.nossr50.commands.database;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.database.LeaderboardManager;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class McpurgeCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McpurgeCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!Permissions.mcpurge(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
DatabaseManager.purgePowerlessSQL();
|
||||
mcMMO.getDatabaseManager().purgePowerlessUsers();
|
||||
|
||||
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
||||
DatabaseManager.purgeOldSQL();
|
||||
}
|
||||
}
|
||||
else {
|
||||
LeaderboardManager.purgePowerlessFlatfile();
|
||||
|
||||
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
||||
LeaderboardManager.purgeOldFlatfile();
|
||||
}
|
||||
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
||||
mcMMO.getDatabaseManager().purgeOldUsers();
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success"));
|
||||
@@ -42,4 +30,9 @@ public class McpurgeCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +1,38 @@
|
||||
package com.gmail.nossr50.commands.database;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.database.LeaderboardManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class McremoveCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McremoveCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!Permissions.mcremove(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
/* MySQL */
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
String playerName = Misc.getMatchedPlayerName(args[0]);
|
||||
|
||||
if (DatabaseManager.update("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.user = '" + args[0] + "'") != 0) {
|
||||
Misc.profileCleanup(args[0]);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0]));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
}
|
||||
if (UserManager.getPlayer(playerName, true) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mcMMO.getDatabaseManager().removeUser(playerName)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", playerName));
|
||||
}
|
||||
else {
|
||||
if (LeaderboardManager.removeFlatFileUser(args[0])) {
|
||||
Misc.profileCleanup(args[0]);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0]));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
}
|
||||
sender.sendMessage(playerName + " could not be removed from the database."); // Pretty sure this should NEVER happen.
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -49,4 +41,15 @@ public class McremoveCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Set<String> playerNames = UserManager.getPlayerNames();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gmail.nossr50.commands.database;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.DatabaseManagerFactory;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class MmoshowdbCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (args.length != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Class<?> clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass();
|
||||
|
||||
if (clazz != null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", clazz.getName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (Config.getInstance().getUseMySQL() ? "sql" : "flatfile")));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.gmail.nossr50.commands.database;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.database.SQLConversionTask;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class MmoupdateCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!Permissions.mmoupdate(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Start"));
|
||||
UserManager.saveAll();
|
||||
UserManager.clearAll();
|
||||
convertToMySQL();
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
UserManager.addUser(player);
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Finish"));
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert FlatFile data to MySQL data.
|
||||
*/
|
||||
private void convertToMySQL() {
|
||||
if (!Config.getInstance().getUseMySQL()) {
|
||||
return;
|
||||
}
|
||||
|
||||
new SQLConversionTask().runTaskLaterAsynchronously(mcMMO.p, 1);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,9 @@ package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
@@ -21,6 +23,10 @@ public class AddlevelsCommand extends ExperienceCommand {
|
||||
@Override
|
||||
protected void handleCommand(SkillType skill) {
|
||||
profile.addLevels(skill, value);
|
||||
|
||||
if (player != null) {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -31,6 +37,5 @@ public class AddlevelsCommand extends ExperienceCommand {
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, SkillUtils.getSkillName(skill)));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.gmail.nossr50.commands.experience;
|
||||
|
||||
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.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.database.FormulaConversionTask;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class ConvertExperienceCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
FormulaType previousType = mcMMO.getFormulaManager().getPreviousFormulaType();
|
||||
FormulaType newType = FormulaType.getFormulaType(args[1].toUpperCase());
|
||||
|
||||
if (newType == FormulaType.UNKNOWN) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (previousType == newType) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Same", newType.toString()));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Start", previousType.toString(), newType.toString()));
|
||||
|
||||
UserManager.saveAll();
|
||||
UserManager.clearAll();
|
||||
|
||||
new FormulaConversionTask(sender, newType).runTaskLater(mcMMO.p, 1);
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
UserManager.addUser(player);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,28 @@
|
||||
package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public abstract class ExperienceCommand implements CommandExecutor {
|
||||
public abstract class ExperienceCommand implements TabExecutor {
|
||||
protected McMMOPlayer mcMMOPlayer;
|
||||
protected Player player;
|
||||
protected PlayerProfile profile;
|
||||
@@ -40,11 +48,12 @@ public abstract class ExperienceCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
player = (Player) sender;
|
||||
mcMMOPlayer = UserManager.getPlayer(player);
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
|
||||
editValues();
|
||||
cleanUp();
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
@@ -57,12 +66,12 @@ public abstract class ExperienceCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
String playerName = Misc.getMatchedPlayerName(args[0]);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false);
|
||||
|
||||
if (CommandUtils.unloadedProfile(sender, profile)) {
|
||||
return true;
|
||||
@@ -73,10 +82,12 @@ public abstract class ExperienceCommand implements CommandExecutor {
|
||||
}
|
||||
else {
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
editValues();
|
||||
}
|
||||
|
||||
handleSenderMessage(sender, args[0]);
|
||||
handleSenderMessage(sender, playerName);
|
||||
cleanUp();
|
||||
return true;
|
||||
|
||||
default:
|
||||
@@ -84,6 +95,19 @@ public abstract class ExperienceCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Set<String> playerNames = UserManager.getPlayerNames();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
case 2:
|
||||
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean permissionsCheckSelf(CommandSender sender);
|
||||
protected abstract boolean permissionsCheckOthers(CommandSender sender);
|
||||
protected abstract void handleCommand(SkillType skill);
|
||||
@@ -147,4 +171,9 @@ public abstract class ExperienceCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanUp() {
|
||||
allSkills = false;
|
||||
player = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,10 @@ package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
@@ -21,6 +24,19 @@ public class MmoeditCommand extends ExperienceCommand {
|
||||
@Override
|
||||
protected void handleCommand(SkillType skill) {
|
||||
profile.modifySkill(skill, value);
|
||||
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int skillLevel = profile.getSkillLevel(skill);
|
||||
|
||||
if (value > skillLevel) {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value - skillLevel));
|
||||
}
|
||||
else if (value < skillLevel) {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelDownEvent(player, skill, skillLevel - value));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,10 +2,13 @@ package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@@ -37,8 +40,8 @@ public class SkillresetCommand extends ExperienceCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
player = (Player) sender;
|
||||
mcMMOPlayer = UserManager.getPlayer(player);
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
|
||||
editValues();
|
||||
@@ -54,11 +57,12 @@ public class SkillresetCommand extends ExperienceCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||
String playerName = Misc.getMatchedPlayerName(args[0]);
|
||||
mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false);
|
||||
|
||||
if (CommandUtils.unloadedProfile(sender, profile)) {
|
||||
return true;
|
||||
@@ -74,7 +78,7 @@ public class SkillresetCommand extends ExperienceCommand {
|
||||
editValues();
|
||||
}
|
||||
|
||||
handleSenderMessage(sender, args[0]);
|
||||
handleSenderMessage(sender, playerName);
|
||||
return true;
|
||||
|
||||
default:
|
||||
@@ -84,13 +88,11 @@ public class SkillresetCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected boolean permissionsCheckSelf(CommandSender sender) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean permissionsCheckOthers(CommandSender sender) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -102,6 +104,10 @@ public class SkillresetCommand extends ExperienceCommand {
|
||||
}
|
||||
|
||||
profile.modifySkill(skill, 0);
|
||||
|
||||
if (player != null) {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelDownEvent(player, skill, profile.getSkillLevel(skill)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,22 +2,11 @@ package com.gmail.nossr50.commands.hardcore;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class HardcoreCommand extends HardcoreModeCommand {
|
||||
@Override
|
||||
protected void disable() {
|
||||
Config.getInstance().setHardcoreEnabled(false);
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Disabled"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void enable() {
|
||||
Config.getInstance().setHardcoreEnabled(true);
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Enabled"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkTogglePermissions() {
|
||||
return Permissions.hardcoreToggle(sender);
|
||||
@@ -29,13 +18,46 @@ public class HardcoreCommand extends HardcoreModeCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkEnabled() {
|
||||
return Config.getInstance().getHardcoreEnabled();
|
||||
protected boolean checkEnabled(String skill) {
|
||||
if (skill.equalsIgnoreCase("ALL")) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (!skillType.getHardcoreStatLossEnabled()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return SkillType.getSkill(skill).getHardcoreStatLossEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void enable(String skill) {
|
||||
toggle(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void disable(String skill) {
|
||||
toggle(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void modify() {
|
||||
Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercent);
|
||||
sender.sendMessage(LocaleLoader.getString("Hardcore.PercentageChanged", percent.format(newPercent / 100D)));
|
||||
sender.sendMessage(LocaleLoader.getString("Hardcore.DeathStatLoss.PercentageChanged", percent.format(newPercent / 100D)));
|
||||
}
|
||||
|
||||
private void toggle(boolean enable) {
|
||||
if (skill.equalsIgnoreCase("ALL")) {
|
||||
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||
Config.getInstance().setHardcoreStatLossEnabled(skillType, enable);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Config.getInstance().setHardcoreStatLossEnabled(SkillType.getSkill(skill), enable);
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.DeathStatLoss.Name"), skill));
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,26 @@
|
||||
package com.gmail.nossr50.commands.hardcore;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
|
||||
public abstract class HardcoreModeCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public abstract class HardcoreModeCommand implements TabExecutor {
|
||||
protected CommandSender sender;
|
||||
protected double newPercent;
|
||||
protected DecimalFormat percent;
|
||||
protected String skill;
|
||||
|
||||
public HardcoreModeCommand() {
|
||||
percent = new DecimalFormat("##0.00%");
|
||||
@@ -29,11 +37,11 @@ public abstract class HardcoreModeCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkEnabled()) {
|
||||
disable();
|
||||
if (checkEnabled("ALL")) {
|
||||
disable("ALL");
|
||||
}
|
||||
else {
|
||||
enable();
|
||||
enable("ALL");
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -45,7 +53,7 @@ public abstract class HardcoreModeCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
enable();
|
||||
enable("ALL");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -55,7 +63,7 @@ public abstract class HardcoreModeCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
disable();
|
||||
disable("ALL");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -71,16 +79,60 @@ public abstract class HardcoreModeCommand implements CommandExecutor {
|
||||
modify();
|
||||
return true;
|
||||
|
||||
|
||||
case 2:
|
||||
if (!args[0].equalsIgnoreCase("ALL") && CommandUtils.isChildSkill(sender, SkillType.getSkill(args[0]))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
skill = args[0];
|
||||
|
||||
if (CommandUtils.shouldEnableToggle(args[1])) {
|
||||
if (!Permissions.hardcoreToggle(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
enable(skill);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandUtils.shouldDisableToggle(args[1])) {
|
||||
if (!Permissions.hardcoreToggle(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
disable(skill);
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (StringUtils.isDouble(args[0])) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean checkTogglePermissions();
|
||||
protected abstract boolean checkModifyPermissions();
|
||||
protected abstract boolean checkEnabled();
|
||||
protected abstract void enable();
|
||||
protected abstract void disable();
|
||||
protected abstract boolean checkEnabled(String skill);
|
||||
protected abstract void enable(String skill);
|
||||
protected abstract void disable(String skill);
|
||||
protected abstract void modify();
|
||||
|
||||
private boolean isInvalidPercentage(CommandSender sender, String value) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.gmail.nossr50.commands.hardcore;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
@@ -17,25 +18,46 @@ public class VampirismCommand extends HardcoreModeCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkEnabled() {
|
||||
return Config.getInstance().getHardcoreVampirismEnabled();
|
||||
protected boolean checkEnabled(String skill) {
|
||||
if (skill.equalsIgnoreCase("ALL")) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (!skillType.getHardcoreVampirismEnabled()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return SkillType.getSkill(skill).getHardcoreVampirismEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void enable() {
|
||||
Config.getInstance().setHardcoreVampirismEnabled(true);
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Enabled"));
|
||||
protected void enable(String skill) {
|
||||
toggle(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void disable() {
|
||||
Config.getInstance().setHardcoreVampirismEnabled(false);
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Disabled"));
|
||||
protected void disable(String skill) {
|
||||
toggle(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void modify() {
|
||||
Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercent);
|
||||
sender.sendMessage(LocaleLoader.getString("Vampirism.PercentageChanged", percent.format(newPercent / 100D)));
|
||||
sender.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.PercentageChanged", percent.format(newPercent / 100D)));
|
||||
}
|
||||
|
||||
private void toggle(boolean enabled) {
|
||||
if (skill.equalsIgnoreCase("ALL")) {
|
||||
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||
Config.getInstance().setHardcoreVampirismEnabled(skillType, enabled);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Config.getInstance().setHardcoreVampirismEnabled(SkillType.getSkill(skill), enabled);
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enabled ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), skill));
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,8 @@ public class PartyAcceptCommand implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (!mcMMOPlayer.hasPartyInvite()) {
|
||||
sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
|
||||
@@ -24,11 +24,11 @@ public class PartyAcceptCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
// Changing parties
|
||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), mcMMOPlayer.getPartyInvite().getName())) {
|
||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.joinInvitedParty(player, mcMMOPlayer);
|
||||
PartyManager.joinInvitedParty(mcMMOPlayer);
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
||||
@@ -3,11 +3,12 @@ package com.gmail.nossr50.commands.party;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PartyChangeOwnerCommand implements CommandExecutor {
|
||||
@@ -15,14 +16,15 @@ public class PartyChangeOwnerCommand implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
Party playerParty = UserManager.getPlayer(sender.getName()).getParty();
|
||||
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||
String targetName = Misc.getMatchedPlayerName(args[1]);
|
||||
|
||||
if (!playerParty.getMembers().contains(mcMMO.p.getServer().getOfflinePlayer(args[1]))) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
|
||||
if (!playerParty.getMembers().contains(targetName)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.setPartyLeader(args[1], playerParty);
|
||||
PartyManager.setPartyLeader(targetName, playerParty);
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.gmail.nossr50.commands.party;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@@ -13,7 +14,7 @@ public class PartyChangePasswordCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
playerParty = UserManager.getPlayer(sender.getName()).getParty();
|
||||
playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
|
||||
@@ -1,21 +1,47 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.chat.PartyChatCommand;
|
||||
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PartyCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class PartyCommand implements TabExecutor {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private Player player;
|
||||
|
||||
private static final List<String> PARTY_SUBCOMMANDS;
|
||||
private static final List<String> EXPSHARE_COMPLETIONS = ImmutableList.of("none", "equal");
|
||||
private static final List<String> ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc");
|
||||
|
||||
static {
|
||||
ArrayList<String> subcommands = new ArrayList<String>();
|
||||
|
||||
for (PartySubcommandType subcommand : PartySubcommandType.values()) {
|
||||
subcommands.add(subcommand.toString());
|
||||
}
|
||||
|
||||
Collections.sort(subcommands);
|
||||
PARTY_SUBCOMMANDS = ImmutableList.copyOf(subcommands);
|
||||
}
|
||||
|
||||
private CommandExecutor partyJoinCommand = new PartyJoinCommand();
|
||||
private CommandExecutor partyAcceptCommand = new PartyAcceptCommand();
|
||||
private CommandExecutor partyCreateCommand = new PartyCreateCommand();
|
||||
@@ -32,7 +58,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
private CommandExecutor partyInfoCommand = new PartyInfoCommand();
|
||||
private CommandExecutor partyHelpCommand = new PartyHelpCommand();
|
||||
private CommandExecutor partyTeleportCommand = mcMMO.p.getCommand("ptp").getExecutor();
|
||||
private CommandExecutor partyChatCommand = mcMMO.p.getCommand("partychat").getExecutor();
|
||||
private CommandExecutor partyChatCommand = new PartyChatCommand();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
@@ -45,8 +71,8 @@ public class PartyCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
player = (Player) sender;
|
||||
mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (args.length < 1) {
|
||||
if (!mcMMOPlayer.inParty()) {
|
||||
@@ -134,6 +160,57 @@ public class PartyCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[0], PARTY_SUBCOMMANDS, new ArrayList<String>(PARTY_SUBCOMMANDS.size()));
|
||||
case 2:
|
||||
PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]);
|
||||
|
||||
if (subcommand == null) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
switch (subcommand) {
|
||||
case JOIN:
|
||||
case INVITE:
|
||||
case KICK:
|
||||
case OWNER:
|
||||
Set<String> playerNames = UserManager.getPlayerNames();
|
||||
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
case EXPSHARE:
|
||||
return StringUtil.copyPartialMatches(args[1], EXPSHARE_COMPLETIONS, new ArrayList<String>(EXPSHARE_COMPLETIONS.size()));
|
||||
case ITEMSHARE:
|
||||
return StringUtil.copyPartialMatches(args[1], ITEMSHARE_COMPLETIONS, new ArrayList<String>(ITEMSHARE_COMPLETIONS.size()));
|
||||
case LOCK:
|
||||
case CHAT:
|
||||
return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
|
||||
case PASSWORD:
|
||||
return StringUtil.copyPartialMatches(args[1], CommandUtils.RESET_OPTIONS, new ArrayList<String>(CommandUtils.RESET_OPTIONS.size()));
|
||||
case TELEPORT:
|
||||
List<String> matches = StringUtil.copyPartialMatches(args[1], PtpCommand.TELEPORT_SUBCOMMANDS, new ArrayList<String>(PtpCommand.TELEPORT_SUBCOMMANDS.size()));
|
||||
|
||||
if (matches.size() == 0) {
|
||||
playerNames = UserManager.getPlayerNames();
|
||||
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
}
|
||||
|
||||
return matches;
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
case 3:
|
||||
if (PartySubcommandType.getSubcommand(args[0]) == PartySubcommandType.ITEMSHARE && isItemShareCategory(args[1])) {
|
||||
return StringUtil.copyPartialMatches(args[2], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
|
||||
}
|
||||
|
||||
return ImmutableList.of();
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean printUsage() {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.0", "/party join"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create"));
|
||||
@@ -150,4 +227,9 @@ public class PartyCommand implements CommandExecutor {
|
||||
|
||||
return newArgs;
|
||||
}
|
||||
|
||||
private boolean isItemShareCategory(String category) {
|
||||
return category.equalsIgnoreCase("loot") || category.equalsIgnoreCase("mining") || category.equalsIgnoreCase("herbalism") || category.equalsIgnoreCase("woodcutting") || category.equalsIgnoreCase("misc");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
@@ -17,22 +16,20 @@ public class PartyCreateCommand implements CommandExecutor {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
case 3:
|
||||
Party newParty = PartyManager.getParty(args[1]);
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
// Check to see if the party exists, and if it does cancel creating a new party
|
||||
if (PartyManager.checkPartyExistence(player, newParty, args[1])) {
|
||||
if (PartyManager.checkPartyExistence(player, args[1])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Changing parties
|
||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), args[1])) {
|
||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, args[1])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.createParty(player, mcMMOPlayer, args[1], getPassword(args));
|
||||
PartyManager.createParty(mcMMOPlayer, args[1], getPassword(args));
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
||||
@@ -16,7 +16,7 @@ public class PartyDisbandCommand implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Party playerParty = UserManager.getPlayer(sender.getName()).getParty();
|
||||
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||
String partyName = playerParty.getName();
|
||||
|
||||
for (Player member : playerParty.getOnlineMembers()) {
|
||||
|
||||
@@ -7,9 +7,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
import com.gmail.nossr50.party.ShareHandler.ShareMode;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@@ -26,7 +25,7 @@ public class PartyExpShareCommand implements CommandExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
playerParty = UserManager.getPlayer(sender.getName()).getParty();
|
||||
playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||
|
||||
if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) {
|
||||
handleChangingShareMode(ShareMode.NONE);
|
||||
@@ -35,7 +34,7 @@ public class PartyExpShareCommand implements CommandExecutor {
|
||||
handleChangingShareMode(ShareMode.EQUAL);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "[NONE | EQUAL]"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "<NONE | EQUAL>"));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -46,7 +45,7 @@ public class PartyExpShareCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
private void handleChangingShareMode(ShareHandler.ShareMode mode) {
|
||||
private void handleChangingShareMode(ShareMode mode) {
|
||||
playerParty.setXpShareMode(mode);
|
||||
|
||||
String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
|
||||
|
||||
@@ -19,6 +19,8 @@ public class PartyHelpCommand implements CommandExecutor {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.6", "/party kick"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party leader"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.9", "/party itemshare"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.10", "/party expshare"));
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
||||
@@ -1,46 +1,54 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
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.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PartyInfoCommand implements CommandExecutor {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private Player player;
|
||||
private Party playerParty;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
playerParty = mcMMOPlayer.getParty();
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
case 1:
|
||||
player = (Player) sender;
|
||||
mcMMOPlayer = UserManager.getPlayer(player);
|
||||
playerParty = mcMMOPlayer.getParty();
|
||||
|
||||
displayPartyHeader();
|
||||
displayShareModeInfo();
|
||||
displayMemberInfo();
|
||||
return true;
|
||||
displayPartyHeader();
|
||||
displayShareModeInfo();
|
||||
displayMemberInfo();
|
||||
return true;
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "info"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private String createMembersList() {
|
||||
StringBuilder memberList = new StringBuilder();
|
||||
|
||||
for (OfflinePlayer member : playerParty.getMembers()) {
|
||||
String memberName = member.getName();
|
||||
for (String memberName : playerParty.getMembers()) {
|
||||
Player member = mcMMO.p.getServer().getPlayerExact(memberName);
|
||||
|
||||
if (playerParty.getLeader().equalsIgnoreCase(memberName)) {
|
||||
memberList.append(ChatColor.GOLD);
|
||||
}
|
||||
else if (member.isOnline()) {
|
||||
else if (member != null) {
|
||||
memberList.append(ChatColor.WHITE);
|
||||
}
|
||||
else {
|
||||
@@ -56,7 +64,7 @@ public class PartyInfoCommand implements CommandExecutor {
|
||||
private void displayShareModeInfo() {
|
||||
boolean xpShareEnabled = Config.getInstance().getExpShareEnabled();
|
||||
boolean itemShareEnabled = Config.getInstance().getItemShareEnabled();
|
||||
boolean itemSharingActive = (playerParty.getItemShareMode() != ShareHandler.ShareMode.NONE);
|
||||
boolean itemSharingActive = (playerParty.getItemShareMode() != ShareMode.NONE);
|
||||
|
||||
if (!xpShareEnabled && !itemShareEnabled) {
|
||||
return;
|
||||
@@ -96,7 +104,7 @@ public class PartyInfoCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void displayMemberInfo() {
|
||||
int membersNear = PartyManager.getNearMembers(player, playerParty, Config.getInstance().getPartyShareRange()).size();
|
||||
int membersNear = PartyManager.getNearMembers(mcMMOPlayer).size();
|
||||
int membersOnline = playerParty.getOnlineMembers().size() - 1;
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
@@ -17,15 +18,17 @@ public class PartyInviteCommand implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
McMMOPlayer mcMMOTarget = UserManager.getPlayer(args[1]);
|
||||
String targetName = Misc.getMatchedPlayerName(args[1]);
|
||||
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, args[1], mcMMOTarget)) {
|
||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Player target = mcMMOTarget.getPlayer();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
String playerName = player.getName();
|
||||
|
||||
if (player.equals(target)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
|
||||
@@ -33,21 +36,20 @@ public class PartyInviteCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (PartyManager.inSameParty(player, target)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", target.getName()));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
|
||||
return true;
|
||||
}
|
||||
|
||||
Party playerParty = mcMMOPlayer.getParty();
|
||||
|
||||
if (!PartyManager.canInvite(player, playerParty)) {
|
||||
if (!PartyManager.canInvite(mcMMOPlayer)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Party playerParty = mcMMOPlayer.getParty();
|
||||
mcMMOTarget.setPartyInvite(playerParty);
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getName(), player.getName()));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getName(), playerName));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
|
||||
return true;
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.ItemShareType;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
import com.gmail.nossr50.party.ShareHandler.ShareMode;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@@ -26,25 +26,19 @@ public class PartyItemShareCommand implements CommandExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
playerParty = UserManager.getPlayer(sender.getName()).getParty();
|
||||
playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||
ShareMode mode = ShareMode.getShareMode(args[1].toUpperCase());
|
||||
|
||||
if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) {
|
||||
handleChangingShareMode(ShareMode.NONE);
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even")) {
|
||||
handleChangingShareMode(ShareMode.EQUAL);
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("random")) {
|
||||
handleChangingShareMode(ShareMode.RANDOM);
|
||||
}
|
||||
else {
|
||||
if (mode == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
|
||||
return true;
|
||||
}
|
||||
|
||||
handleChangingShareMode(mode);
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
playerParty = UserManager.getPlayer(sender.getName()).getParty();
|
||||
playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||
boolean toggle = false;
|
||||
|
||||
if (CommandUtils.shouldEnableToggle(args[2])) {
|
||||
@@ -54,37 +48,27 @@ public class PartyItemShareCommand implements CommandExecutor {
|
||||
toggle = false;
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting> <true | false>"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("loot")) {
|
||||
playerParty.setSharingLootDrops(toggle);
|
||||
try {
|
||||
handleToggleItemShareCategory(ItemShareType.valueOf(args[1].toUpperCase()), toggle);
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("mining")) {
|
||||
playerParty.setSharingMiningDrops(toggle);
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("herbalism")) {
|
||||
playerParty.setSharingHerbalismDrops(toggle);
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("woodcutting")) {
|
||||
playerParty.setSharingWoodcuttingDrops(toggle);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting> <true | false>"));
|
||||
catch (IllegalArgumentException ex) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
|
||||
}
|
||||
|
||||
notifyToggleItemShareCategory(args[1], toggle);
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting> <true | false>"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleChangingShareMode(ShareHandler.ShareMode mode) {
|
||||
private void handleChangingShareMode(ShareMode mode) {
|
||||
playerParty.setItemShareMode(mode);
|
||||
|
||||
String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
|
||||
@@ -94,10 +78,10 @@ public class PartyItemShareCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyToggleItemShareCategory(String category, boolean toggle) {
|
||||
String state = toggle ? "enabled" : "disabled";
|
||||
private void handleToggleItemShareCategory(ItemShareType type, boolean toggle) {
|
||||
playerParty.setSharingDrops(type, toggle);
|
||||
|
||||
String toggleMessage = LocaleLoader.getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(category), state);
|
||||
String toggleMessage = LocaleLoader.getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(type.toString()), toggle ? "enabled" : "disabled");
|
||||
|
||||
for (Player member : playerParty.getOnlineMembers()) {
|
||||
member.sendMessage(toggleMessage);
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
@@ -19,7 +20,6 @@ public class PartyJoinCommand implements CommandExecutor {
|
||||
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private Player player;
|
||||
private Party playerParty;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
@@ -41,12 +41,15 @@ public class PartyJoinCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
String partyName = targetParty.getName();
|
||||
|
||||
// Changing parties
|
||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, playerParty, targetParty.getName())) {
|
||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, partyName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.joinParty(player, mcMMOPlayer, targetParty, password);
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", partyName));
|
||||
PartyManager.addToParty(mcMMOPlayer, targetParty);
|
||||
return true;
|
||||
|
||||
default:
|
||||
@@ -64,6 +67,7 @@ public class PartyJoinCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private boolean canJoinParty(CommandSender sender, String targetName) {
|
||||
targetName = Misc.getMatchedPlayerName(targetName);
|
||||
mcMMOTarget = UserManager.getPlayer(targetName);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||
@@ -77,13 +81,11 @@ public class PartyJoinCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
playerParty = mcMMOPlayer.getParty();
|
||||
player = (Player) sender;
|
||||
mcMMOPlayer = UserManager.getPlayer(player);
|
||||
targetParty = mcMMOTarget.getParty();
|
||||
|
||||
if (player.equals(target) || (mcMMOPlayer.inParty() && playerParty.equals(targetParty))) {
|
||||
if (player.equals(target) || (mcMMOPlayer.inParty() && mcMMOPlayer.getParty().equals(targetParty))) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Join.Self"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ public class PartyKickCommand implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
Party playerParty = UserManager.getPlayer(sender.getName()).getParty();
|
||||
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]);
|
||||
|
||||
if (!playerParty.getMembers().contains(target)) {
|
||||
if (!playerParty.getMembers().contains(target.getName())) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.gmail.nossr50.commands.party;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@@ -15,7 +16,7 @@ public class PartyLockCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
playerParty = UserManager.getPlayer(sender.getName()).getParty();
|
||||
playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
@@ -72,8 +73,6 @@ public class PartyLockCommand implements CommandExecutor {
|
||||
|
||||
/**
|
||||
* Handle unlocking a party.
|
||||
*
|
||||
* @return true if party is successfully unlocked, false otherwise.
|
||||
*/
|
||||
private void unlockParty(CommandSender sender, String permissionMessage) {
|
||||
if (!Permissions.partySubcommand(sender, PartySubcommandType.UNLOCK)) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
@@ -17,13 +18,14 @@ public class PartyQuitCommand implements CommandExecutor {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Player player = (Player) sender;
|
||||
Party playerParty = UserManager.getPlayer(player).getParty();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
Party playerParty = mcMMOPlayer.getParty();
|
||||
|
||||
if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.removeFromParty(player, playerParty);
|
||||
PartyManager.removeFromParty(mcMMOPlayer);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
|
||||
return true;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class PartyRenameCommand implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||
Party playerParty = mcMMOPlayer.getParty();
|
||||
|
||||
String oldPartyName = playerParty.getName();
|
||||
@@ -30,10 +30,9 @@ public class PartyRenameCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
Party newParty = PartyManager.getParty(newPartyName);
|
||||
|
||||
// Check to see if the party exists, and if it does cancel renaming the party
|
||||
if (PartyManager.checkPartyExistence(player, newParty, newPartyName)) {
|
||||
if (PartyManager.checkPartyExistence(player, newPartyName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ public class PtpAcceptAnyCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (mcMMOPlayer.getPtpConfirmRequired()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled"));
|
||||
|
||||
@@ -21,8 +21,8 @@ public class PtpAcceptCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (!mcMMOPlayer.hasPtpRequest()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.NoRequests"));
|
||||
@@ -58,7 +58,7 @@ public class PtpAcceptCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
PtpCommand.handlePartyTeleportEvent(target, player);
|
||||
PtpCommand.handleTeleportWarmup(target, player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
package com.gmail.nossr50.commands.party.teleport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
@@ -11,14 +17,21 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.items.TeleportationWarmup;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class PtpCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class PtpCommand implements TabExecutor {
|
||||
private static Player target;
|
||||
private static McMMOPlayer mcMMOTarget;
|
||||
|
||||
public static final List<String> TELEPORT_SUBCOMMANDS = ImmutableList.of("toggle", "accept", "acceptany", "acceptall");
|
||||
|
||||
private CommandExecutor ptpToggleCommand = new PtpToggleCommand();
|
||||
private CommandExecutor ptpAcceptAnyCommand = new PtpAcceptAnyCommand();
|
||||
private CommandExecutor ptpAcceptCommand = new PtpAcceptCommand();
|
||||
@@ -39,22 +52,43 @@ public class PtpCommand implements CommandExecutor {
|
||||
return ptpAcceptAnyCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
|
||||
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
|
||||
int hurtCooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown();
|
||||
|
||||
if (((recentlyHurt * Misc.TIME_CONVERSION_FACTOR) + (ptpCooldown * Misc.TIME_CONVERSION_FACTOR)) > System.currentTimeMillis()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", ptpCooldown));
|
||||
return true;
|
||||
if (hurtCooldown > 0) {
|
||||
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player);
|
||||
|
||||
if (timeRemaining > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("accept")) {
|
||||
return ptpAcceptCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
sendTeleportRequest(sender, player, args[0]);
|
||||
if (!Permissions.partyTeleportSend(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
|
||||
long ptpLastUse = mcMMOPlayer.getPtpLastUse();
|
||||
|
||||
if (ptpCooldown > 0) {
|
||||
int timeRemaining = SkillUtils.calculateTimeLeft(ptpLastUse * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player);
|
||||
|
||||
if (timeRemaining > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", timeRemaining));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
sendTeleportRequest(sender, player, Misc.getMatchedPlayerName(args[0]));
|
||||
return true;
|
||||
|
||||
default:
|
||||
@@ -62,13 +96,30 @@ public class PtpCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
List<String> matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<String>(TELEPORT_SUBCOMMANDS.size()));
|
||||
|
||||
if (matches.size() == 0) {
|
||||
Set<String> playerNames = UserManager.getPlayerNames();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
}
|
||||
|
||||
return matches;
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
private void sendTeleportRequest(CommandSender sender, Player player, String targetName) {
|
||||
if (!canTeleport(sender, player, targetName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mcMMOTarget.getPtpConfirmRequired()) {
|
||||
handlePartyTeleportEvent(player, target);
|
||||
handleTeleportWarmup(player, target);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -113,7 +164,24 @@ public class PtpCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected static void handlePartyTeleportEvent(Player teleportingPlayer, Player targetPlayer) {
|
||||
protected static void handleTeleportWarmup(Player teleportingPlayer, Player targetPlayer) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
|
||||
mcMMOTarget = UserManager.getPlayer(targetPlayer);
|
||||
|
||||
long warmup = Config.getInstance().getPTPCommandWarmup();
|
||||
|
||||
mcMMOPlayer.actualizeTeleportCommenceLocation(teleportingPlayer);
|
||||
|
||||
if (warmup > 0) {
|
||||
teleportingPlayer.sendMessage(LocaleLoader.getString("Teleport.Commencing", warmup));
|
||||
new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup);
|
||||
}
|
||||
else {
|
||||
handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
public static void handlePartyTeleportEvent(Player teleportingPlayer, Player targetPlayer) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(teleportingPlayer, targetPlayer, mcMMOPlayer.getParty().getName());
|
||||
|
||||
@@ -128,6 +196,6 @@ public class PtpCommand implements CommandExecutor {
|
||||
teleportingPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Player", targetPlayer.getName()));
|
||||
targetPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Target", teleportingPlayer.getName()));
|
||||
|
||||
mcMMOPlayer.actualizeRecentlyHurt();
|
||||
mcMMOPlayer.actualizePtpLastUse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ public class PtpToggleCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (mcMMOPlayer.getPtpEnabled()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled"));
|
||||
|
||||
@@ -1,34 +1,55 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
|
||||
public class InspectCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class InspectCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
|
||||
ScoreboardManager.setupPlayerScoreboard(sender.getName());
|
||||
}
|
||||
|
||||
String playerName = Misc.getMatchedPlayerName(args[0]);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||
if (mcMMOPlayer == null) {
|
||||
PlayerProfile profile = new PlayerProfile(args[0], false); // Temporary Profile
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); // Temporary Profile
|
||||
|
||||
if (CommandUtils.inspectOffline(sender, profile, Permissions.inspectOffline(sender))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", args[0]));
|
||||
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
|
||||
ScoreboardManager.enablePlayerInspectScoreboardOffline((Player) sender, profile);
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.EXCAVATION);
|
||||
@@ -51,7 +72,18 @@ public class InspectCommand implements CommandExecutor {
|
||||
else {
|
||||
Player target = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) {
|
||||
if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) {
|
||||
if (!Permissions.inspectOffline(sender)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
|
||||
ScoreboardManager.enablePlayerInspectScoreboardOnline((Player) sender, mcMMOPlayer);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -68,4 +100,15 @@ public class InspectCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Set<String> playerNames = UserManager.getPlayerNames();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,28 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.LeaderboardManager;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
|
||||
public class McrankCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McrankCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
@@ -31,11 +36,12 @@ public class McrankCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
sqlDisplay(sender, sender.getName());
|
||||
if (Config.getInstance().getMcrankScoreboardEnabled()) {
|
||||
ScoreboardManager.setupPlayerScoreboard(sender.getName());
|
||||
ScoreboardManager.enablePlayerRankScoreboard((Player) sender);
|
||||
}
|
||||
else {
|
||||
flatfileDisplay(sender, sender.getName());
|
||||
display(sender, sender.getName());
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -46,8 +52,8 @@ public class McrankCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
String playerName = args[0];
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
|
||||
String playerName = Misc.getMatchedPlayerName(args[0]);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||
|
||||
if (mcMMOPlayer != null) {
|
||||
playerName = mcMMOPlayer.getPlayer().getName();
|
||||
@@ -55,18 +61,18 @@ public class McrankCommand implements CommandExecutor {
|
||||
if (CommandUtils.tooFar(sender, mcMMOPlayer.getPlayer(), Permissions.mcrankFar(sender))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
} else if (CommandUtils.inspectOffline(sender, new PlayerProfile(playerName, false), Permissions.mcrankOffline(sender))) {
|
||||
}
|
||||
else if (CommandUtils.inspectOffline(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false), Permissions.mcrankOffline(sender))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
sqlDisplay(sender, playerName);
|
||||
if (sender instanceof Player && Config.getInstance().getMcrankScoreboardEnabled()) {
|
||||
ScoreboardManager.setupPlayerScoreboard(sender.getName());
|
||||
ScoreboardManager.enablePlayerRankScoreboardOthers((Player) sender, playerName);
|
||||
}
|
||||
else {
|
||||
flatfileDisplay(sender, playerName);
|
||||
display(sender, playerName);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
@@ -74,39 +80,18 @@ public class McrankCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
private void flatfileDisplay(CommandSender sender, String playerName) {
|
||||
LeaderboardManager.updateLeaderboards(); // Make sure the information is up to date
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
|
||||
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
int[] rankInts = LeaderboardManager.getPlayerRank(playerName, skillType);
|
||||
|
||||
if (!Permissions.skillEnabled(sender, skillType) || skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rankInts[1] == 0) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skillType), rankInts[0]));
|
||||
}
|
||||
}
|
||||
|
||||
// Show the powerlevel ranking
|
||||
int[] rankInts = LeaderboardManager.getPlayerRank(playerName);
|
||||
|
||||
if (rankInts[1] == 0) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", rankInts[0]));
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Set<String> playerNames = UserManager.getPlayerNames();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
private void sqlDisplay(CommandSender sender, String playerName) {
|
||||
private void display(CommandSender sender, String playerName) {
|
||||
new McrankCommandAsyncTask(playerName, sender).runTaskAsynchronously(mcMMO.p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
@@ -10,8 +12,11 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
|
||||
public class McstatsCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McstatsCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
@@ -20,23 +25,29 @@ public class McstatsCommand implements CommandExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
||||
|
||||
CommandUtils.printGatheringSkills(player);
|
||||
CommandUtils.printCombatSkills(player);
|
||||
CommandUtils.printMiscSkills(player);
|
||||
|
||||
int powerLevelCap = Config.getInstance().getPowerLevelCap();
|
||||
|
||||
if (powerLevelCap != Integer.MAX_VALUE) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap));
|
||||
if (Config.getInstance().getMcstatsScoreboardsEnabled()) {
|
||||
ScoreboardManager.setupPlayerScoreboard(player.getName());
|
||||
ScoreboardManager.enablePlayerStatsScoreboard(mcMMOPlayer);
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
|
||||
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
||||
|
||||
CommandUtils.printGatheringSkills(player);
|
||||
CommandUtils.printCombatSkills(player);
|
||||
CommandUtils.printMiscSkills(player);
|
||||
|
||||
int powerLevelCap = Config.getInstance().getPowerLevelCap();
|
||||
|
||||
if (powerLevelCap != Integer.MAX_VALUE) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -45,4 +56,9 @@ public class McstatsCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +1,38 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.LeaderboardManager;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
|
||||
public class MctopCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class MctopCommand implements TabExecutor {
|
||||
private SkillType skill;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
boolean useMySQL = Config.getInstance().getUseMySQL();
|
||||
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
display(1, "ALL", sender, useMySQL, command);
|
||||
display(1, "ALL", sender, command);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (StringUtils.isInt(args[0])) {
|
||||
display(Math.abs(Integer.parseInt(args[0])), "ALL", sender, useMySQL, command);
|
||||
display(Math.abs(Integer.parseInt(args[0])), "ALL", sender, command);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -38,7 +40,7 @@ public class MctopCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
display(1, skill.toString(), sender, useMySQL, command);
|
||||
display(1, skill.toString(), sender, command);
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
@@ -50,7 +52,7 @@ public class MctopCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
display(Math.abs(Integer.parseInt(args[1])), skill.toString(), sender, useMySQL, command);
|
||||
display(Math.abs(Integer.parseInt(args[1])), skill.toString(), sender, command);
|
||||
return true;
|
||||
|
||||
default:
|
||||
@@ -58,59 +60,31 @@ public class MctopCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
private void display(int page, String skill, CommandSender sender, boolean sql, Command command) {
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[0], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
private void display(int page, String skill, CommandSender sender, Command command) {
|
||||
if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, this.skill)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (sql) {
|
||||
if (skill.equalsIgnoreCase("all")) {
|
||||
sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender);
|
||||
}
|
||||
else {
|
||||
sqlDisplay(page, skill, sender);
|
||||
}
|
||||
if (sender instanceof Player && Config.getInstance().getMctopScoreboardEnabled()) {
|
||||
ScoreboardManager.enableGlobalStatsScoreboard((Player) sender, skill, page);
|
||||
}
|
||||
else {
|
||||
flatfileDisplay(page, skill, sender);
|
||||
display(page, skill, sender);
|
||||
}
|
||||
}
|
||||
|
||||
private void flatfileDisplay(int page, String skill, CommandSender sender) {
|
||||
LeaderboardManager.updateLeaderboards(); // Make sure we have the latest information
|
||||
|
||||
if (skill.equalsIgnoreCase("all")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(skill)));
|
||||
}
|
||||
|
||||
int position = (page * 10) - 9;
|
||||
|
||||
for (String playerStat : LeaderboardManager.retrieveInfo(skill, page)) {
|
||||
if (playerStat == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String digit = String.valueOf(position);
|
||||
|
||||
if (position < 10) {
|
||||
digit = "0" + digit;
|
||||
}
|
||||
|
||||
String[] splitStat = playerStat.split(":");
|
||||
|
||||
// Format: 1. Playername - skill value
|
||||
sender.sendMessage(digit + ". " + ChatColor.GREEN + splitStat[1] + " - " + ChatColor.WHITE + splitStat[0]);
|
||||
position++;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
||||
}
|
||||
|
||||
private void sqlDisplay(int page, String query, CommandSender sender) {
|
||||
private void display(int page, String query, CommandSender sender) {
|
||||
new MctopCommandAsyncTask(page, query, sender).runTaskAsynchronously(mcMMO.p);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ import com.gmail.nossr50.util.Permissions;
|
||||
public class AxesCommand extends SkillCommand {
|
||||
private String critChance;
|
||||
private String critChanceLucky;
|
||||
private float bonusDamage;
|
||||
private float impactDamage;
|
||||
private double bonusDamage;
|
||||
private double impactDamage;
|
||||
private String skullSplitterLength;
|
||||
private String skullSplitterLengthEndurance;
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@@ -15,11 +18,14 @@ public class FishingCommand extends SkillCommand {
|
||||
private String shakeChance;
|
||||
private String shakeChanceLucky;
|
||||
private int fishermansDietRank;
|
||||
private String biteChance;
|
||||
|
||||
private boolean canTreasureHunt;
|
||||
private boolean canMagicHunt;
|
||||
private boolean canShake;
|
||||
private boolean canFishermansDiet;
|
||||
private boolean canMasterAngler;
|
||||
private boolean canIceFish;
|
||||
|
||||
public FishingCommand() {
|
||||
super(SkillType.FISHING);
|
||||
@@ -27,12 +33,14 @@ public class FishingCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
boolean isStorming = player.getWorld().hasStorm();
|
||||
|
||||
// TREASURE HUNTER
|
||||
if (canTreasureHunt) {
|
||||
lootTier = mcMMOPlayer.getFishingManager().getLootTier();
|
||||
double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier();
|
||||
|
||||
if (player.getWorld().hasStorm()) {
|
||||
if (isStorming) {
|
||||
chanceRaining = LocaleLoader.getString("Fishing.Chance.Raining");
|
||||
enchantChance *= 1.1D;
|
||||
}
|
||||
@@ -53,6 +61,22 @@ public class FishingCommand extends SkillCommand {
|
||||
if (canFishermansDiet) {
|
||||
fishermansDietRank = calculateRank(Fishing.fishermansDietMaxLevel, Fishing.fishermansDietRankLevel1);
|
||||
}
|
||||
|
||||
// MASTER ANGLER
|
||||
if (canMasterAngler) {
|
||||
double rawBiteChance = ((Math.max((skillValue / 200.0), 1.0)) / (isStorming ? 300 : 500));
|
||||
Biome biome = player.getLocation().getBlock().getBiome();
|
||||
|
||||
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
|
||||
rawBiteChance = rawBiteChance * 2.0;
|
||||
}
|
||||
|
||||
if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) {
|
||||
rawBiteChance = rawBiteChance * 2.0;
|
||||
}
|
||||
|
||||
biteChance = calculateAbilityDisplayValues(rawBiteChance * 100.0)[0];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -61,11 +85,13 @@ public class FishingCommand extends SkillCommand {
|
||||
canMagicHunt = Permissions.magicHunter(player);
|
||||
canShake = Permissions.shake(player);
|
||||
canFishermansDiet = Permissions.fishermansDiet(player);
|
||||
canMasterAngler = Permissions.masterAngler(player);
|
||||
canIceFish = Permissions.iceFishing(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canTreasureHunt || canMagicHunt || canShake;
|
||||
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet || canIceFish;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,15 +113,27 @@ public class FishingCommand extends SkillCommand {
|
||||
if (canFishermansDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7")));
|
||||
}
|
||||
|
||||
if (canMasterAngler) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9")));
|
||||
}
|
||||
|
||||
if (canIceFish) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.10"), LocaleLoader.getString("Fishing.Effect.11")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canTreasureHunt || canMagicHunt || canShake;
|
||||
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet || canIceFish;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canMasterAngler) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Chance", biteChance));
|
||||
}
|
||||
|
||||
if (canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", lootTier));
|
||||
}
|
||||
@@ -118,5 +156,16 @@ public class FishingCommand extends SkillCommand {
|
||||
if (canFishermansDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
|
||||
}
|
||||
|
||||
if (canIceFish) {
|
||||
int unlockLevel = AdvancedConfig.getInstance().getIceFishingUnlockLevel();
|
||||
|
||||
if (skillValue < unlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.1", unlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.IceFishing"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,10 +41,10 @@ public class RepairCommand extends SkillCommand {
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
// We're using pickaxes here, not the best but it works
|
||||
Repairable diamondRepairable = mcMMO.repairableManager.getRepairable(Material.DIAMOND_PICKAXE.getId());
|
||||
Repairable goldRepairable = mcMMO.repairableManager.getRepairable(Material.GOLD_PICKAXE.getId());
|
||||
Repairable ironRepairable = mcMMO.repairableManager.getRepairable(Material.IRON_PICKAXE.getId());
|
||||
Repairable stoneRepairable = mcMMO.repairableManager.getRepairable(Material.STONE_PICKAXE.getId());
|
||||
Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE.getId());
|
||||
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLD_PICKAXE.getId());
|
||||
Repairable ironRepairable = mcMMO.getRepairableManager().getRepairable(Material.IRON_PICKAXE.getId());
|
||||
Repairable stoneRepairable = mcMMO.getRepairableManager().getRepairable(Material.STONE_PICKAXE.getId());
|
||||
|
||||
// TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0
|
||||
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
@@ -18,10 +21,13 @@ import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public abstract class SkillCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public abstract class SkillCommand implements TabExecutor {
|
||||
protected SkillType skill;
|
||||
protected String skillName;
|
||||
|
||||
@@ -50,8 +56,8 @@ public abstract class SkillCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
player = (Player) sender;
|
||||
mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
@@ -67,7 +73,14 @@ public abstract class SkillCommand implements CommandExecutor {
|
||||
if (!skill.isChildSkill()) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, profile.getSkillXpLevel(skill), profile.getXpToLevel(skill)));
|
||||
|
||||
if (Config.getInstance().getSkillScoreboardEnabled()) {
|
||||
ScoreboardManager.setupPlayerScoreboard(player.getName());
|
||||
ScoreboardManager.enablePlayerSkillScoreboard(mcMMOPlayer, skill);
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, profile.getSkillXpLevel(skill), profile.getXpToLevel(skill)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child")));
|
||||
@@ -102,6 +115,16 @@ public abstract class SkillCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return ImmutableList.of("?");
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
protected int calculateRank(int maxLevel, int rankChangeLevel) {
|
||||
return Math.min((int) skillValue, maxLevel) / rankChangeLevel;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@@ -36,7 +38,7 @@ public class TamingCommand extends SkillCommand {
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canBeastLore = Permissions.beastLore(player);
|
||||
canCallWild = Permissions.callOfTheWild(player);
|
||||
canCallWild = Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT);
|
||||
canEnvironmentallyAware = Permissions.environmentallyAware(player);
|
||||
canFastFood = Permissions.fastFoodService(player);
|
||||
canGore = Permissions.gore(player);
|
||||
|
||||
@@ -14,7 +14,7 @@ public class UnarmedCommand extends SkillCommand {
|
||||
private String disarmChanceLucky;
|
||||
private String ironGripChance;
|
||||
private String ironGripChanceLucky;
|
||||
private int ironArmBonus;
|
||||
private double ironArmBonus;
|
||||
|
||||
private boolean canBerserk;
|
||||
private boolean canDisarm;
|
||||
|
||||
@@ -1,12 +1,42 @@
|
||||
package com.gmail.nossr50.commands.spout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class MchudCommand extends SpoutCommand {
|
||||
private static final List<String> HUD_TYPES;
|
||||
|
||||
static {
|
||||
ArrayList<String> types = new ArrayList<String>();
|
||||
|
||||
for (HudType type : HudType.values()) {
|
||||
types.add(type.toString());
|
||||
}
|
||||
|
||||
Collections.sort(types);
|
||||
HUD_TYPES = ImmutableList.copyOf(types);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[0], HUD_TYPES, new ArrayList<String>(HUD_TYPES.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean noArguments(Command command, CommandSender sender, String[] args) {
|
||||
return false;
|
||||
@@ -14,16 +44,15 @@ public class MchudCommand extends SpoutCommand {
|
||||
|
||||
@Override
|
||||
protected boolean oneArgument(Command command, CommandSender sender, String[] args) {
|
||||
for (HudType hudType : HudType.values()) {
|
||||
if (hudType.toString().equalsIgnoreCase(args[0])) {
|
||||
playerProfile.setHudType(hudType);
|
||||
spoutHud.initializeXpBar();
|
||||
spoutHud.updateXpBar();
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
playerProfile.setHudType(HudType.valueOf(args[0].toUpperCase().trim()));
|
||||
spoutHud.initializeXpBar();
|
||||
spoutHud.updateXpBar();
|
||||
return true;
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mchud.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mchud.Invalid"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.gmail.nossr50.commands.spout;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||
@@ -12,7 +13,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public abstract class SpoutCommand implements CommandExecutor {
|
||||
public abstract class SpoutCommand implements TabExecutor {
|
||||
protected PlayerProfile playerProfile;
|
||||
protected McMMOHud spoutHud;
|
||||
|
||||
@@ -22,12 +23,12 @@ public abstract class SpoutCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mcMMO.spoutEnabled || !SpoutConfig.getInstance().getXPBarEnabled()) {
|
||||
if (!mcMMO.isSpoutEnabled() || !SpoutConfig.getInstance().getXPBarEnabled()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
playerProfile = UserManager.getPlayer(sender.getName()).getProfile();
|
||||
playerProfile = UserManager.getPlayer((Player) sender).getProfile();
|
||||
spoutHud = playerProfile.getSpoutHud();
|
||||
|
||||
if (spoutHud == null) {
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package com.gmail.nossr50.commands.spout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@@ -9,7 +13,25 @@ import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class XplockCommand extends SpoutCommand {
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
List<String> matches = StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
|
||||
|
||||
if (matches.size() == 0) {
|
||||
return StringUtil.copyPartialMatches(args[0], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
||||
}
|
||||
|
||||
return matches;
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean noArguments(Command command, CommandSender sender, String[] args) {
|
||||
if (spoutHud.getXpBarLocked()) {
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
private static AdvancedConfig instance;
|
||||
|
||||
private AdvancedConfig() {
|
||||
super("advanced.yml");
|
||||
validate();
|
||||
}
|
||||
|
||||
public static AdvancedConfig getInstance() {
|
||||
@@ -15,6 +19,766 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean validateKeys() {
|
||||
// Validate all the settings!
|
||||
List<String> reason = new ArrayList<String>();
|
||||
|
||||
/* GENERAL */
|
||||
if (getAbilityLength() < 1) {
|
||||
reason.add("Skills.General.Ability_IncreaseLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getEnchantBuff() < 1) {
|
||||
reason.add("Skills.General.Ability_EnchantBuff should be at least 1!");
|
||||
}
|
||||
|
||||
/* ACROBATICS */
|
||||
if (getDodgeChanceMax() < 1) {
|
||||
reason.add("Skills.Acrobatics.Dodge_ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getDodgeMaxBonusLevel() < 1) {
|
||||
reason.add("Skills.Acrobatics.Dodge_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getDodgeDamageModifier() <= 1) {
|
||||
reason.add("Skills.Acrobatics.Dodge_DamageModifier should be greater than 1!");
|
||||
}
|
||||
|
||||
if (getRollChanceMax() < 1) {
|
||||
reason.add("Skills.Acrobatics.Roll_ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getRollMaxBonusLevel() < 1) {
|
||||
reason.add("Skills.Acrobatics.Roll_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getRollDamageThreshold() < 0) {
|
||||
reason.add("Skills.Acrobatics.Roll_DamageThreshold should be at least 0!");
|
||||
}
|
||||
|
||||
if (getGracefulRollChanceMax() < 1) {
|
||||
reason.add("Skills.Acrobatics.GracefulRoll_ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getGracefulRollMaxBonusLevel() < 1) {
|
||||
reason.add("Skills.Acrobatics.GracefulRoll_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getGracefulRollDamageThreshold() < 0) {
|
||||
reason.add("Skills.Acrobatics.GracefulRoll_DamageThreshold should be at least 0!");
|
||||
}
|
||||
|
||||
if (getDodgeXPModifier() < 0) {
|
||||
reason.add("Skills.Acrobatics.Dodge_XP_Modifier should be at least 0!");
|
||||
}
|
||||
|
||||
if (getRollXPModifier() < 0) {
|
||||
reason.add("Skills.Acrobatics.Roll_XP_Modifier should be at least 0!");
|
||||
}
|
||||
|
||||
if (getFallXPModifier() < 0) {
|
||||
reason.add("Skills.Acrobatics.Fall_XP_Modifier should be at least 0!");
|
||||
}
|
||||
|
||||
/* ARCHERY */
|
||||
if (getSkillShotIncreaseLevel() < 1) {
|
||||
reason.add("Skills.Archery.SkillShot_IncreaseLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSkillShotIncreasePercentage() <= 0) {
|
||||
reason.add("Skills.Archery.SkillShot_IncreasePercentage should be greater than 0!");
|
||||
}
|
||||
|
||||
if (getSkillShotBonusMax() < 0) {
|
||||
reason.add("Skills.Archery.SkillShot_MaxBonus should be at least 0!");
|
||||
}
|
||||
|
||||
if (getDazeBonusMax() < 1) {
|
||||
reason.add("Skills.Acrobatics.Daze_MaxChance should be at least 1!");
|
||||
}
|
||||
|
||||
if (getDazeMaxBonusLevel() < 1) {
|
||||
reason.add("Skills.Acrobatics.Daze_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getDazeModifier() < 0) {
|
||||
reason.add("Skills.Acrobatics.Daze_BonusDamage should be at least 0!");
|
||||
}
|
||||
|
||||
if (getRetrieveChanceMax() < 1) {
|
||||
reason.add("Skills.Acrobatics.Retrieve_MaxBonus should be at least 1!");
|
||||
}
|
||||
|
||||
if (getRetrieveMaxBonusLevel() < 1) {
|
||||
reason.add("Skills.Acrobatics.Retrieve_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getForceMultiplier() < 0) {
|
||||
reason.add("Skills.Acrobatics.Force_Multiplier should be at least 0!");
|
||||
}
|
||||
|
||||
/* AXES */
|
||||
if (getBonusDamageAxesBonusMax() < 1) {
|
||||
reason.add("Skills.Axes.DamageIncrease_MaxBonus should be at least 1!");
|
||||
}
|
||||
|
||||
if (getBonusDamageAxesMaxBonusLevel() < 1) {
|
||||
reason.add("Skills.Axes.DamageIncrease_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getAxesCriticalChance() < 1) {
|
||||
reason.add("Skills.Axes.AxesCritical_MaxChance should be at least 1!");
|
||||
}
|
||||
|
||||
if (getAxesCriticalMaxBonusLevel() < 1) {
|
||||
reason.add("Skills.Axes.AxesCritical_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getAxesCriticalPVPModifier() < 1) {
|
||||
reason.add("Skills.Axes.AxesCritical_PVP_Modifier should be at least 1!");
|
||||
}
|
||||
|
||||
if (getAxesCriticalPVEModifier() < 1) {
|
||||
reason.add("Skills.Axes.AxesCritical_PVE_Modifier should be at least 1!");
|
||||
}
|
||||
|
||||
if (getGreaterImpactChance() < 1) {
|
||||
reason.add("Skills.Axes.GreaterImpact_Chance should be at least 1!");
|
||||
}
|
||||
|
||||
if (getGreaterImpactModifier() < 1) {
|
||||
reason.add("Skills.Axes.GreaterImpact_KnockbackModifier should be at least 1!");
|
||||
}
|
||||
|
||||
if (getGreaterImpactBonusDamage() < 1) {
|
||||
reason.add("Skills.Axes.GreaterImpact_BonusDamage should be at least 1!");
|
||||
}
|
||||
|
||||
if (getArmorImpactIncreaseLevel() < 1) {
|
||||
reason.add("Skills.Axes.ArmorImpact_IncreaseLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getImpactChance() < 1) {
|
||||
reason.add("Skills.Axes.ArmorImpact_Chance should be at least 1!");
|
||||
}
|
||||
|
||||
if (getArmorImpactMaxDurabilityDamage() < 1) {
|
||||
reason.add("Skills.Axes.ArmorImpact_MaxPercentageDurabilityDamage should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSkullSplitterModifier() < 1) {
|
||||
reason.add("Skills.Axes.SkullSplitter_DamagerModifier should be at least 1!");
|
||||
}
|
||||
|
||||
/* FISHING */
|
||||
if (getFishingTierLevelsTier1() >= getFishingTierLevelsTier2()) {
|
||||
reason.add("Skills.Fishing.Tier_Levels.Tier1 should be less than Skills.Fishing.Tier_Levels.Tier2!");
|
||||
}
|
||||
|
||||
if (getFishingTierLevelsTier2() >= getFishingTierLevelsTier3()) {
|
||||
reason.add("Skills.Fishing.Tier_Levels.Tier2 should be less than Skills.Fishing.Tier_Levels.Tier3!");
|
||||
}
|
||||
|
||||
if (getFishingTierLevelsTier3() >= getFishingTierLevelsTier4()) {
|
||||
reason.add("Skills.Fishing.Tier_Levels.Tier3 should be less than Skills.Fishing.Tier_Levels.Tier4!");
|
||||
}
|
||||
|
||||
if (getFishingTierLevelsTier4() >= getFishingTierLevelsTier5()) {
|
||||
reason.add("Skills.Fishing.Tier_Levels.Tier4 should be less than Skills.Fishing.Tier_Levels.Tier5!");
|
||||
}
|
||||
|
||||
if (getFishingMagicMultiplier() <= 0) {
|
||||
reason.add("Skills.Fishing.MagicHunter_Multiplier should be greater than 0!");
|
||||
}
|
||||
|
||||
if (getFishermanDietRankChange() < 1) {
|
||||
reason.add("Skills.Fishing.Fisherman_Diet_RankChange should be at least 1!");
|
||||
}
|
||||
|
||||
if (getIceFishingUnlockLevel() < 1) {
|
||||
reason.add("Skills.Fishing.Ice_Fishing_UnlockLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getShakeUnlockLevel() < 1) {
|
||||
reason.add("Skills.Fishing.Shake_UnlockLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getShakeChanceRank1() > getShakeChanceRank2()) {
|
||||
reason.add("Skills.Fishing.Shake_Chance.Rank_1 should be less or equal to Skills.Fishing.Shake_Chance.Rank_2!");
|
||||
}
|
||||
|
||||
if (getShakeChanceRank2() > getShakeChanceRank3()) {
|
||||
reason.add("Skills.Fishing.Shake_Chance.Rank_2 should be less or equal to Skills.Fishing.Shake_Chance.Rank_3!");
|
||||
}
|
||||
|
||||
if (getShakeChanceRank3() > getShakeChanceRank4()) {
|
||||
reason.add("Skills.Fishing.Shake_Chance.Rank_3 should be less or equal to Skills.Fishing.Shake_Chance.Rank_4!");
|
||||
}
|
||||
|
||||
if (getShakeChanceRank4() > getShakeChanceRank5()) {
|
||||
reason.add("Skills.Fishing.Shake_Chance.Rank_4 should be less or equal to Skills.Fishing.Shake_Chance.Rank_5!");
|
||||
}
|
||||
|
||||
if (getFishingVanillaXPModifierRank1() > getFishingVanillaXPModifierRank2()) {
|
||||
reason.add("Skills.Fishing.VanillaXPBoost.Rank_1 should be less or equal to Skills.Fishing.VanillaXPBoost.Rank_2!");
|
||||
}
|
||||
|
||||
if (getFishingVanillaXPModifierRank2() > getFishingVanillaXPModifierRank3()) {
|
||||
reason.add("Skills.Fishing.VanillaXPBoost.Rank_2 should be less or equal to Skills.Fishing.VanillaXPBoost.Rank_3!");
|
||||
}
|
||||
|
||||
if (getFishingVanillaXPModifierRank3() > getFishingVanillaXPModifierRank4()) {
|
||||
reason.add("Skills.Fishing.VanillaXPBoost.Rank_3 should be less or equal to Skills.Fishing.VanillaXPBoost.Rank_4!");
|
||||
}
|
||||
|
||||
if (getFishingVanillaXPModifierRank4() > getFishingVanillaXPModifierRank5()) {
|
||||
reason.add("Skills.Fishing.VanillaXPBoost.Rank_4 should be less or equal to Skills.Fishing.VanillaXPBoost.Rank_5!");
|
||||
}
|
||||
|
||||
if (getFishingVanillaXPModifierRank1() < 0) {
|
||||
reason.add("Skills.Fishing.VanillaXPBoost.Rank_1 should be at least 0!");
|
||||
}
|
||||
|
||||
if (getFishingVanillaXPModifierRank2() < 0) {
|
||||
reason.add("Skills.Fishing.VanillaXPBoost.Rank_2 should be at least 0!");
|
||||
}
|
||||
|
||||
if (getFishingVanillaXPModifierRank3() < 0) {
|
||||
reason.add("Skills.Fishing.VanillaXPBoost.Rank_3 should be at least 0!");
|
||||
}
|
||||
|
||||
if (getFishingVanillaXPModifierRank4() < 0) {
|
||||
reason.add("Skills.Fishing.VanillaXPBoost.Rank_4 should be at least 0!");
|
||||
}
|
||||
|
||||
if (getFishingVanillaXPModifierRank5() < 0) {
|
||||
reason.add("Skills.Fishing.VanillaXPBoost.Rank_5 should be at least 0!");
|
||||
}
|
||||
|
||||
/* HERBALISM */
|
||||
if (getFarmerDietRankChange() < 1) {
|
||||
reason.add("Skills.Herbalism.Farmer_Diet_RankChange should be at least 1!");
|
||||
}
|
||||
|
||||
if (getGreenThumbStageChange() < 1) {
|
||||
reason.add("Skills.Herbalism.GreenThumb_StageChange should be at least 1!");
|
||||
}
|
||||
|
||||
if (getGreenThumbChanceMax() < 1) {
|
||||
reason.add("Skills.Herbalism.GreenThumb_ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getGreenThumbMaxLevel() < 1) {
|
||||
reason.add("Skills.Herbalism.GreenThumb_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getHerbalismDoubleDropsChanceMax() < 1) {
|
||||
reason.add("Skills.Herbalism.DoubleDrops_ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getHerbalismDoubleDropsMaxLevel() < 1) {
|
||||
reason.add("Skills.Herbalism.DoubleDrops_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getHylianLuckChanceMax() < 1) {
|
||||
reason.add("Skills.Herbalism.HylianLuck_ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getHylianLuckMaxLevel() < 1) {
|
||||
reason.add("Skills.Herbalism.HylianLuck_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getShroomThumbChanceMax() < 1) {
|
||||
reason.add("Skills.Herbalism.ShroomThumb_ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getShroomThumbMaxLevel() < 1) {
|
||||
reason.add("Skills.Herbalism.ShroomThumb_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
/* MINING */
|
||||
if (getMiningDoubleDropChance() < 1) {
|
||||
reason.add("Skills.Mining.DoubleDrops_ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getMiningDoubleDropMaxLevel() < 1) {
|
||||
reason.add("Skills.Mining.DoubleDrops_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getBlastMiningRank1() > getBlastMiningRank2()) {
|
||||
reason.add("Skills.Mining.BlastMining_Rank1 should be less or equal to Skills.Mining.BlastMining_Rank2!");
|
||||
}
|
||||
|
||||
if (getBlastMiningRank2() > getBlastMiningRank3()) {
|
||||
reason.add("Skills.Mining.BlastMining_Rank2 should be less or equal to Skills.Mining.BlastMining_Rank3!");
|
||||
}
|
||||
|
||||
if (getBlastMiningRank3() > getBlastMiningRank4()) {
|
||||
reason.add("Skills.Mining.BlastMining_Rank3 should be less or equal to Skills.Mining.BlastMining_Rank4!");
|
||||
}
|
||||
|
||||
if (getBlastMiningRank4() > getBlastMiningRank5()) {
|
||||
reason.add("Skills.Mining.BlastMining_Rank4 should be less or equal to Skills.Mining.BlastMining_Rank5!");
|
||||
}
|
||||
|
||||
if (getBlastMiningRank5() > getBlastMiningRank6()) {
|
||||
reason.add("Skills.Mining.BlastMining_Rank5 should be less or equal to Skills.Mining.BlastMining_Rank6!");
|
||||
}
|
||||
|
||||
if (getBlastMiningRank6() > getBlastMiningRank7()) {
|
||||
reason.add("Skills.Mining.BlastMining_Rank6 should be less or equal to Skills.Mining.BlastMining_Rank7!");
|
||||
}
|
||||
|
||||
if (getBlastMiningRank7() > getBlastMiningRank8()) {
|
||||
reason.add("Skills.Mining.BlastMining_Rank7 should be less or equal to Skills.Mining.BlastMining_Rank8!");
|
||||
}
|
||||
|
||||
if (getBlastDamageDecreaseRank1() > getBlastDamageDecreaseRank2()) {
|
||||
reason.add("Skills.Mining.BlastDamageDecrease_Rank1 should be less or equal to Skills.Mining.BlastDamageDecrease_Rank2!");
|
||||
}
|
||||
|
||||
if (getBlastDamageDecreaseRank2() > getBlastDamageDecreaseRank3()) {
|
||||
reason.add("Skills.Mining.BlastDamageDecrease_Rank2 should be less or equal to Skills.Mining.BlastDamageDecrease_Rank3!");
|
||||
}
|
||||
|
||||
if (getBlastDamageDecreaseRank3() > getBlastDamageDecreaseRank4()) {
|
||||
reason.add("Skills.Mining.BlastDamageDecrease_Rank3 should be less or equal to Skills.Mining.BlastDamageDecrease_Rank4!");
|
||||
}
|
||||
|
||||
if (getBlastDamageDecreaseRank4() > getBlastDamageDecreaseRank5()) {
|
||||
reason.add("Skills.Mining.BlastDamageDecrease_Rank4 should be less or equal to Skills.Mining.BlastDamageDecrease_Rank5!");
|
||||
}
|
||||
|
||||
if (getBlastDamageDecreaseRank5() > getBlastDamageDecreaseRank6()) {
|
||||
reason.add("Skills.Mining.BlastDamageDecrease_Rank5 should be less or equal to Skills.Mining.BlastDamageDecrease_Rank6!");
|
||||
}
|
||||
|
||||
if (getBlastDamageDecreaseRank6() > getBlastDamageDecreaseRank7()) {
|
||||
reason.add("Skills.Mining.BlastDamageDecrease_Rank6 should be less or equal to Skills.Mining.BlastDamageDecrease_Rank7!");
|
||||
}
|
||||
|
||||
if (getBlastDamageDecreaseRank7() > getBlastDamageDecreaseRank8()) {
|
||||
reason.add("Skills.Mining.BlastDamageDecrease_Rank7 should be less or equal to Skills.Mining.BlastDamageDecrease_Rank8!");
|
||||
}
|
||||
|
||||
if (getOreBonusRank1() > getOreBonusRank2()) {
|
||||
reason.add("Skills.Mining.OreBonus_Rank1 should be less or equal to Skills.Mining.OreBonus_Rank2!");
|
||||
}
|
||||
|
||||
if (getOreBonusRank2() > getOreBonusRank3()) {
|
||||
reason.add("Skills.Mining.OreBonus_Rank2 should be less or equal to Skills.Mining.OreBonus_Rank3!");
|
||||
}
|
||||
|
||||
if (getOreBonusRank3() > getOreBonusRank4()) {
|
||||
reason.add("Skills.Mining.OreBonus_Rank3 should be less or equal to Skills.Mining.OreBonus_Rank4!");
|
||||
}
|
||||
|
||||
if (getOreBonusRank4() > getOreBonusRank5()) {
|
||||
reason.add("Skills.Mining.OreBonus_Rank4 should be less or equal to Skills.Mining.OreBonus_Rank5!");
|
||||
}
|
||||
|
||||
if (getOreBonusRank5() > getOreBonusRank6()) {
|
||||
reason.add("Skills.Mining.OreBonus_Rank5 should be less or equal to Skills.Mining.OreBonus_Rank6!");
|
||||
}
|
||||
|
||||
if (getOreBonusRank6() > getOreBonusRank7()) {
|
||||
reason.add("Skills.Mining.OreBonus_Rank6 should be less or equal to Skills.Mining.OreBonus_Rank7!");
|
||||
}
|
||||
|
||||
if (getOreBonusRank7() > getOreBonusRank8()) {
|
||||
reason.add("Skills.Mining.OreBonus_Rank7 should be less or equal to Skills.Mining.OreBonus_Rank8!");
|
||||
}
|
||||
|
||||
if (getDebrisReductionRank1() > getDebrisReductionRank2()) {
|
||||
reason.add("Skills.Mining.DebrisReduction_Rank1 should be less or equal to Skills.Mining.DebrisReduction_Rank2!");
|
||||
}
|
||||
|
||||
if (getDebrisReductionRank2() > getDebrisReductionRank3()) {
|
||||
reason.add("Skills.Mining.DebrisReduction_Rank2 should be less or equal to Skills.Mining.DebrisReduction_Rank3!");
|
||||
}
|
||||
|
||||
if (getDebrisReductionRank3() > getDebrisReductionRank4()) {
|
||||
reason.add("Skills.Mining.DebrisReduction_Rank3 should be less or equal to Skills.Mining.DebrisReduction_Rank4!");
|
||||
}
|
||||
|
||||
if (getDebrisReductionRank4() > getDebrisReductionRank5()) {
|
||||
reason.add("Skills.Mining.DebrisReduction_Rank4 should be less or equal to Skills.Mining.DebrisReduction_Rank5!");
|
||||
}
|
||||
|
||||
if (getDebrisReductionRank5() > getDebrisReductionRank6()) {
|
||||
reason.add("Skills.Mining.DebrisReduction_Rank5 should be less or equal to Skills.Mining.DebrisReduction_Rank6!");
|
||||
}
|
||||
|
||||
if (getDebrisReductionRank6() > getDebrisReductionRank7()) {
|
||||
reason.add("Skills.Mining.DebrisReduction_Rank6 should be less or equal to Skills.Mining.DebrisReduction_Rank7!");
|
||||
}
|
||||
|
||||
if (getDebrisReductionRank7() > getDebrisReductionRank8()) {
|
||||
reason.add("Skills.Mining.DebrisReduction_Rank7 should be less or equal to Skills.Mining.DebrisReduction_Rank8!");
|
||||
}
|
||||
|
||||
if (getDropMultiplierRank1() > getDropMultiplierRank2()) {
|
||||
reason.add("Skills.Mining.DropMultiplier_Rank1 should be less or equal to Skills.Mining.DropMultiplier_Rank2!");
|
||||
}
|
||||
|
||||
if (getDropMultiplierRank2() > getDropMultiplierRank3()) {
|
||||
reason.add("Skills.Mining.DropMultiplier_Rank2 should be less or equal to Skills.Mining.DropMultiplier_Rank3!");
|
||||
}
|
||||
|
||||
if (getDropMultiplierRank3() > getDropMultiplierRank4()) {
|
||||
reason.add("Skills.Mining.DropMultiplier_Rank3 should be less or equal to Skills.Mining.DropMultiplier_Rank4!");
|
||||
}
|
||||
|
||||
if (getDropMultiplierRank4() > getDropMultiplierRank5()) {
|
||||
reason.add("Skills.Mining.DropMultiplier_Rank4 should be less or equal to Skills.Mining.DropMultiplier_Rank5!");
|
||||
}
|
||||
|
||||
if (getDropMultiplierRank5() > getDropMultiplierRank6()) {
|
||||
reason.add("Skills.Mining.DropMultiplier_Rank5 should be less or equal to Skills.Mining.DropMultiplier_Rank6!");
|
||||
}
|
||||
|
||||
if (getDropMultiplierRank6() > getDropMultiplierRank7()) {
|
||||
reason.add("Skills.Mining.DropMultiplier_Rank6 should be less or equal to Skills.Mining.DropMultiplier_Rank7!");
|
||||
}
|
||||
|
||||
if (getDropMultiplierRank7() > getDropMultiplierRank8()) {
|
||||
reason.add("Skills.Mining.DropMultiplier_Rank7 should be less or equal to Skills.Mining.DropMultiplier_Rank8!");
|
||||
}
|
||||
|
||||
if (getBlastRadiusModifierRank1() > getBlastRadiusModifierRank2()) {
|
||||
reason.add("Skills.Mining.BlastRadiusModifier_Rank1 should be less or equal to Skills.Mining.BlastRadiusModifier_Rank2!");
|
||||
}
|
||||
|
||||
if (getBlastRadiusModifierRank2() > getBlastRadiusModifierRank3()) {
|
||||
reason.add("Skills.Mining.BlastRadiusModifier_Rank2 should be less or equal to Skills.Mining.BlastRadiusModifier_Rank3!");
|
||||
}
|
||||
|
||||
if (getBlastRadiusModifierRank3() > getBlastRadiusModifierRank4()) {
|
||||
reason.add("Skills.Mining.BlastRadiusModifier_Rank3 should be less or equal to Skills.Mining.BlastRadiusModifier_Rank4!");
|
||||
}
|
||||
|
||||
if (getBlastRadiusModifierRank4() > getBlastRadiusModifierRank5()) {
|
||||
reason.add("Skills.Mining.BlastRadiusModifier_Rank4 should be less or equal to Skills.Mining.BlastRadiusModifier_Rank5!");
|
||||
}
|
||||
|
||||
if (getBlastRadiusModifierRank5() > getBlastRadiusModifierRank6()) {
|
||||
reason.add("Skills.Mining.BlastRadiusModifier_Rank5 should be less or equal to Skills.Mining.BlastRadiusModifier_Rank6!");
|
||||
}
|
||||
|
||||
if (getBlastRadiusModifierRank6() > getBlastRadiusModifierRank7()) {
|
||||
reason.add("Skills.Mining.BlastRadiusModifier_Rank6 should be less or equal to Skills.Mining.BlastRadiusModifier_Rank7!");
|
||||
}
|
||||
|
||||
if (getBlastRadiusModifierRank7() > getBlastRadiusModifierRank8()) {
|
||||
reason.add("Skills.Mining.BlastRadiusModifier_Rank7 should be less or equal to Skills.Mining.BlastRadiusModifier_Rank8!");
|
||||
}
|
||||
|
||||
/* REPAIR */
|
||||
if (getRepairMasteryMaxBonus() < 1) {
|
||||
reason.add("Skills.Repair.RepairMastery_MaxBonusPercentage should be at least 1!");
|
||||
}
|
||||
|
||||
if (getRepairMasteryMaxLevel() < 1) {
|
||||
reason.add("Skills.Repair.RepairMastery_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSuperRepairChanceMax() < 1) {
|
||||
reason.add("Skills.Repair.SuperRepair_ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSuperRepairMaxLevel() < 1) {
|
||||
reason.add("Skills.Repair.SuperRepair_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSalvageUnlockLevel() < 1) {
|
||||
reason.add("Skills.Repair.Salvage_UnlockLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getArcaneForgingDowngradeChanceRank1() < 0 || getArcaneForgingDowngradeChanceRank1() > 100) {
|
||||
reason.add("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_1 only accepts values from 0 to 100!");
|
||||
}
|
||||
|
||||
if (getArcaneForgingDowngradeChanceRank2() < 0 || getArcaneForgingDowngradeChanceRank2() > 100) {
|
||||
reason.add("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_2 only accepts values from 0 to 100!");
|
||||
}
|
||||
|
||||
if (getArcaneForgingDowngradeChanceRank3() < 0 || getArcaneForgingDowngradeChanceRank3() > 100) {
|
||||
reason.add("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_3 only accepts values from 0 to 100!");
|
||||
}
|
||||
|
||||
if (getArcaneForgingDowngradeChanceRank4() < 0 || getArcaneForgingDowngradeChanceRank4() > 100) {
|
||||
reason.add("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_4 only accepts values from 0 to 100!");
|
||||
}
|
||||
|
||||
if (getArcaneForgingKeepEnchantsChanceRank1() < 0 || getArcaneForgingKeepEnchantsChanceRank1() > 100) {
|
||||
reason.add("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_1 only accepts values from 0 to 100!");
|
||||
}
|
||||
|
||||
if (getArcaneForgingKeepEnchantsChanceRank2() < 0 || getArcaneForgingKeepEnchantsChanceRank2() > 100) {
|
||||
reason.add("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_2 only accepts values from 0 to 100!");
|
||||
}
|
||||
|
||||
if (getArcaneForgingKeepEnchantsChanceRank3() < 0 || getArcaneForgingKeepEnchantsChanceRank3() > 100) {
|
||||
reason.add("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_3 only accepts values from 0 to 100!");
|
||||
}
|
||||
|
||||
if (getArcaneForgingKeepEnchantsChanceRank4() < 0 || getArcaneForgingKeepEnchantsChanceRank4() > 100) {
|
||||
reason.add("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_4 only accepts values from 0 to 100!");
|
||||
}
|
||||
|
||||
if (getArcaneForgingRankLevels1() < 0) {
|
||||
reason.add("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_1 should be at least 0!");
|
||||
}
|
||||
|
||||
if (getArcaneForgingRankLevels2() < 0) {
|
||||
reason.add("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_2 should be at least 0!");
|
||||
}
|
||||
|
||||
if (getArcaneForgingRankLevels3() < 0) {
|
||||
reason.add("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_3 should be at least 0!");
|
||||
}
|
||||
|
||||
if (getArcaneForgingRankLevels4() < 0) {
|
||||
reason.add("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_4 should be at least 0!");
|
||||
}
|
||||
|
||||
/* SMELTING */
|
||||
if (getBurnModifierMaxLevel() < 1) {
|
||||
reason.add("Skills.Smelting.FuelEfficiency_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getBurnTimeMultiplier() < 1) {
|
||||
reason.add("Skills.Smelting.FuelEfficiency_Multiplier should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSecondSmeltMaxLevel() < 1) {
|
||||
reason.add("Skills.Smelting.SecondSmelt_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSecondSmeltMaxChance() < 1) {
|
||||
reason.add("Skills.Smelting.SecondSmelt_MaxBonusChance should be at least 1!");
|
||||
}
|
||||
|
||||
if (getFluxMiningUnlockLevel() < 1) {
|
||||
reason.add("Skills.Smelting.FluxMining_UnlockLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getFluxMiningChance() < 1) {
|
||||
reason.add("Skills.Smelting.FluxMining_Chance should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSmeltingVanillaXPBoostRank1Level() > getSmeltingVanillaXPBoostRank2Level()) {
|
||||
reason.add("Skills.Smelting.VanillaXPBoost_Rank1Level should be less or equal to Skills.Smelting.VanillaXPBoost_Rank2Level!");
|
||||
}
|
||||
|
||||
if (getSmeltingVanillaXPBoostRank2Level() > getSmeltingVanillaXPBoostRank3Level()) {
|
||||
reason.add("Skills.Smelting.VanillaXPBoost_Rank2Level should be less or equal to Skills.Smelting.VanillaXPBoost_Rank3Level!");
|
||||
}
|
||||
|
||||
if (getSmeltingVanillaXPBoostRank3Level() > getSmeltingVanillaXPBoostRank4Level()) {
|
||||
reason.add("Skills.Smelting.VanillaXPBoost_Rank3Level should be less or equal to Skills.Smelting.VanillaXPBoost_Rank4Level!");
|
||||
}
|
||||
|
||||
if (getSmeltingVanillaXPBoostRank4Level() > getSmeltingVanillaXPBoostRank5Level()) {
|
||||
reason.add("Skills.Smelting.VanillaXPBoost_Rank4Level should be less or equal to Skills.Smelting.VanillaXPBoost_Rank5Level!");
|
||||
}
|
||||
|
||||
if (getSmeltingVanillaXPBoostRank1Multiplier() < 1) {
|
||||
reason.add("Skills.Smelting.VanillaXPBoost_Rank1Multiplier should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSmeltingVanillaXPBoostRank2Multiplier() < 1) {
|
||||
reason.add("Skills.Smelting.VanillaXPBoost_Rank2Multiplier should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSmeltingVanillaXPBoostRank3Multiplier() < 1) {
|
||||
reason.add("Skills.Smelting.VanillaXPBoost_Rank3Multiplier should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSmeltingVanillaXPBoostRank4Multiplier() < 1) {
|
||||
reason.add("Skills.Smelting.VanillaXPBoost_Rank4Multiplier should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSmeltingVanillaXPBoostRank5Multiplier() < 1) {
|
||||
reason.add("Skills.Smelting.VanillaXPBoost_Rank5Multiplier should be at least 1!");
|
||||
}
|
||||
|
||||
/* SWORDS */
|
||||
if (getBleedChanceMax() < 1) {
|
||||
reason.add("Skills.Swords.Bleed_ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getBleedMaxBonusLevel() < 1) {
|
||||
reason.add("Skills.Swords.Bleed_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getBleedMaxTicks() < 1) {
|
||||
reason.add("Skills.Swords.Bleed_MaxTicks should be at least 1!");
|
||||
}
|
||||
|
||||
if (getBleedMaxTicks() < getBleedBaseTicks()) {
|
||||
reason.add("Skills.Swords.Bleed_MaxTicks should be at least Skills.Swords.Bleed_BaseTicks!");
|
||||
}
|
||||
|
||||
if (getBleedBaseTicks() < 1) {
|
||||
reason.add("Skills.Swords.Bleed_BaseTicks should be at least 1!");
|
||||
}
|
||||
|
||||
if (getCounterChanceMax() < 1) {
|
||||
reason.add("Skills.Swords.Counter_ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getCounterMaxBonusLevel() < 1) {
|
||||
reason.add("Skills.Swords.Counter_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getCounterModifier() < 1) {
|
||||
reason.add("Skills.Swords.Counter_DamageModifier should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSerratedStrikesModifier() < 1) {
|
||||
reason.add("Skills.Swords.SerratedStrikes_DamageModifier should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSerratedStrikesTicks() < 1) {
|
||||
reason.add("Skills.Swords.SerratedStrikes_BleedTicks should be at least 1!");
|
||||
}
|
||||
|
||||
/* TAMING */
|
||||
|
||||
if (getGoreChanceMax() < 1) {
|
||||
reason.add("Skills.Taming.Gore_ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getGoreMaxBonusLevel() < 1) {
|
||||
reason.add("Skills.Taming.Gore_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getGoreBleedTicks() < 1) {
|
||||
reason.add("Skills.Taming.Gore_BleedTicks should be at least 1!");
|
||||
}
|
||||
|
||||
if (getGoreModifier() < 1) {
|
||||
reason.add("Skills.Taming.Gore_Modifier should be at least 1!");
|
||||
}
|
||||
|
||||
if (getFastFoodUnlock() < 1) {
|
||||
reason.add("Skills.Taming.FastFood_UnlockLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getFastFoodChance() < 1) {
|
||||
reason.add("Skills.Taming.FastFood_Chance should be at least 1!");
|
||||
}
|
||||
|
||||
if (getEnviromentallyAwareUnlock() < 1) {
|
||||
reason.add("Skills.Taming.EnvironmentallyAware_UnlockLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getThickFurUnlock() < 1) {
|
||||
reason.add("Skills.Taming.ThickFur_UnlockLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getThickFurModifier() < 1) {
|
||||
reason.add("Skills.Taming.ThickFur_Modifier should be at least 1!");
|
||||
}
|
||||
|
||||
if (getHolyHoundUnlock() < 1) {
|
||||
reason.add("Skills.Taming.HolyHound_UnlockLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getShockProofUnlock() < 1) {
|
||||
reason.add("Skills.Taming.ShockProof_UnlockLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getShockProofModifier() < 1) {
|
||||
reason.add("Skills.Taming.ShockProof_Modifier should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSharpenedClawsUnlock() < 1) {
|
||||
reason.add("Skills.Taming.SharpenedClaws_UnlockLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSharpenedClawsBonus() < 1) {
|
||||
reason.add("Skills.Taming.SharpenedClaws_Bonus should be at least 1!");
|
||||
}
|
||||
|
||||
|
||||
/* UNARMED */
|
||||
if (getDisarmChanceMax() < 1) {
|
||||
reason.add("Skills.Unarmed.Disarm_ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getDisarmMaxBonusLevel() < 1) {
|
||||
reason.add("Skills.Unarmed.Disarm_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getDeflectChanceMax() < 1) {
|
||||
reason.add("Skills.Unarmed.Deflect_ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getDeflectMaxBonusLevel() < 1) {
|
||||
reason.add("Skills.Unarmed.Deflect_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getIronGripChanceMax() < 1) {
|
||||
reason.add("Skills.Unarmed.IronGrip_ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getIronGripMaxBonusLevel() < 1) {
|
||||
reason.add("Skills.Unarmed.IronGrip_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getIronArmMinBonus() < 0) {
|
||||
reason.add("Skills.Unarmed.IronArm_BonusMin should be at least 0!");
|
||||
}
|
||||
|
||||
if (getIronArmMaxBonus() < 0) {
|
||||
reason.add("Skills.Unarmed.IronArm_BonusMax should be at least 0!");
|
||||
}
|
||||
|
||||
if (getIronArmMaxBonus() < getIronArmMinBonus()) {
|
||||
reason.add("Skills.Unarmed.IronArm_BonusMax should be greater than or equal to Skills.Unarmed.IronArm_BonusMin!");
|
||||
}
|
||||
|
||||
if (getIronArmIncreaseLevel() < 1) {
|
||||
reason.add("Skills.Unarmed.IronArm_IncreaseLevel should be at least 1!");
|
||||
}
|
||||
|
||||
/* WOODCUTTING */
|
||||
if (getLeafBlowUnlockLevel() < 1) {
|
||||
reason.add("Skills.Woodcutting.LeafBlower_UnlockLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getWoodcuttingDoubleDropChance() < 1) {
|
||||
reason.add("Skills.Woodcutting.DoubleDrops_ChanceMax should be at least 1!");
|
||||
}
|
||||
|
||||
if (getWoodcuttingDoubleDropMaxLevel() < 1) {
|
||||
reason.add("Skills.Woodcutting.DoubleDrops_MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
/* KRAKEN */
|
||||
if (getKrakenTriesBeforeRelease() < 1) {
|
||||
reason.add("Kraken.Tries_Before_Release should be at least 1!");
|
||||
}
|
||||
|
||||
if (getKrakenHealth() < 1) {
|
||||
reason.add("Kraken.Health should be at least 1!");
|
||||
}
|
||||
|
||||
if (getKrakenAttackInterval() < 1) {
|
||||
reason.add("Kraken.Attack_Interval_Seconds should be at least 1!");
|
||||
}
|
||||
|
||||
if (getKrakenAttackDamage() < 1) {
|
||||
reason.add("Kraken.Attack_Damage should be at least 1!");
|
||||
}
|
||||
|
||||
return noErrorsInConfig(reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {}
|
||||
|
||||
@@ -25,16 +789,15 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
/* ACROBATICS */
|
||||
public double getDodgeChanceMax() { return config.getDouble("Skills.Acrobatics.Dodge_ChanceMax", 20.0D); }
|
||||
public int getDodgeMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Dodge_MaxBonusLevel", 800); }
|
||||
public int getDodgeDamageModifier() { return config.getInt("Skills.Acrobatics.Dodge_DamageModifer", 2); }
|
||||
public double getDodgeDamageModifier() { return config.getDouble("Skills.Acrobatics.Dodge_DamageModifier", 2.0D); }
|
||||
|
||||
public double getRollChanceMax() { return config.getDouble("Skills.Acrobatics.Roll_ChanceMax", 100.0D); }
|
||||
public int getRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Roll_MaxBonusLevel", 1000); }
|
||||
public int getRollDamageThreshold() { return config.getInt("Skills.Acrobatics.Roll_DamageThreshold", 7); }
|
||||
public double getRollDamageThreshold() { return config.getDouble("Skills.Acrobatics.Roll_DamageThreshold", 7.0D); }
|
||||
|
||||
public double getGracefulRollChanceMax() { return config.getDouble("Skills.Acrobatics.GracefulRoll_ChanceMax", 100.0D); }
|
||||
public int getGracefulRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.GracefulRoll_MaxBonusLevel", 500); }
|
||||
public int getGracefulRollDamageThreshold() { return config.getInt("Skills.Acrobatics.GracefulRoll_DamageThreshold", 14); }
|
||||
public int getGracefulRollSuccessModifer() { return config.getInt("Skills.Acrobatics.GracefulRoll_SuccessModifier", 2); }
|
||||
public double getGracefulRollDamageThreshold() { return config.getDouble("Skills.Acrobatics.GracefulRoll_DamageThreshold", 14.0D); }
|
||||
|
||||
public int getDodgeXPModifier() { return config.getInt("Skills.Acrobatics.Dodge_XP_Modifier", 120); }
|
||||
public int getRollXPModifier() { return config.getInt("Skills.Acrobatics.Roll_XP_Modifier", 80); }
|
||||
@@ -44,16 +807,19 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
public int getSkillShotIncreaseLevel() { return config.getInt("Skills.Archery.SkillShot_IncreaseLevel", 50); }
|
||||
public double getSkillShotIncreasePercentage() { return config.getDouble("Skills.Archery.SkillShot_IncreasePercentage", 0.1D); }
|
||||
public double getSkillShotBonusMax() { return config.getDouble("Skills.Archery.SkillShot_MaxBonus", 2.0D); }
|
||||
public double getSkillShotDamageMax() { return config.getDouble("Skills.Archery.SkillShot_MaxDamage", 9.0D); }
|
||||
|
||||
public double getDazeBonusMax() { return config.getDouble("Skills.Archery.Daze_MaxChance", 50.0D); }
|
||||
public int getDazeMaxBonusLevel() { return config.getInt("Skills.Archery.Daze_MaxBonusLevel", 1000); }
|
||||
public int getDazeModifier() { return config.getInt("Skills.Archery.Daze_BonusDamage", 4); }
|
||||
public double getDazeModifier() { return config.getDouble("Skills.Archery.Daze_BonusDamage", 4.0D); }
|
||||
|
||||
public double getRetrieveChanceMax() { return config.getDouble("Skills.Archery.Retrieve_MaxBonus", 100.0D); }
|
||||
public int getRetrieveMaxBonusLevel() { return config.getInt("Skills.Archery.Retrieve_MaxBonusLevel", 1000); }
|
||||
|
||||
public double getForceMultiplier() { return config.getDouble("Skills.Archery.Force_Multiplier", 2.0D); }
|
||||
|
||||
/* AXES */
|
||||
public int getBonusDamageAxesBonusMax() { return config.getInt("Skills.Axes.DamageIncrease_MaxBonus", 4); }
|
||||
public double getBonusDamageAxesBonusMax() { return config.getDouble("Skills.Axes.DamageIncrease_MaxBonus", 4.0D); }
|
||||
public int getBonusDamageAxesMaxBonusLevel() { return config.getInt("Skills.Axes.DamageIncrease_MaxBonusLevel", 200); }
|
||||
|
||||
public double getAxesCriticalChance() { return config.getDouble("Skills.Axes.AxesCritical_MaxChance", 37.50D); }
|
||||
@@ -62,14 +828,14 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
public double getAxesCriticalPVEModifier() { return config.getDouble("Skills.Axes.AxesCritical_PVE_Modifier", 2.0D); }
|
||||
|
||||
public double getGreaterImpactChance() { return config.getDouble("Skills.Axes.GreaterImpact_Chance", 25.0D); }
|
||||
public double getGreaterImpactModifier() { return config.getDouble("Skills.Axes.GreaterImpact_KnockbackModifier", 1.5); }
|
||||
public int getGreaterImpactBonusDamage() { return config.getInt("Skills.Axes.GreaterImpact_BonusDamage", 2); }
|
||||
public double getGreaterImpactModifier() { return config.getDouble("Skills.Axes.GreaterImpact_KnockbackModifier", 1.5D); }
|
||||
public double getGreaterImpactBonusDamage() { return config.getDouble("Skills.Axes.GreaterImpact_BonusDamage", 2.0D); }
|
||||
|
||||
public int getArmorImpactIncreaseLevel() { return config.getInt("Skills.Axes.ArmorImpact_IncreaseLevel", 50); }
|
||||
public double getImpactChance() { return config.getDouble("Skills.Axes.ArmorImpact_Chance", 25.0D); }
|
||||
public double getArmorImpactMaxDurabilityDamage() { return config.getDouble("Skills.Axes.ArmorImpact_MaxPercentageDurabilityDamage", 20.0D); }
|
||||
|
||||
public int getSkullSplitterModifier() { return config.getInt("Skills.Axes.SkullSplitter_DamagerModifier", 2); }
|
||||
public double getSkullSplitterModifier() { return config.getDouble("Skills.Axes.SkullSplitter_DamagerModifier", 2.0D); }
|
||||
|
||||
/* EXCAVATION */
|
||||
//Nothing to configure, everything is already configurable in config.yml
|
||||
@@ -81,17 +847,19 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
public int getFishingTierLevelsTier4() { return config.getInt("Skills.Fishing.Tier_Levels.Tier4", 600); }
|
||||
public int getFishingTierLevelsTier5() { return config.getInt("Skills.Fishing.Tier_Levels.Tier5", 800); }
|
||||
|
||||
public int getFishingMagicMultiplier() { return config.getInt("Skills.Fishing.MagicHunter_Multiplier", 5); }
|
||||
public double getFishingMagicMultiplier() { return config.getDouble("Skills.Fishing.MagicHunter_Multiplier", 5.0D); }
|
||||
|
||||
public int getFishermanDietRankChange() { return config.getInt("Skills.Fishing.Fisherman_Diet_RankChange", 200); }
|
||||
|
||||
public int getIceFishingUnlockLevel() { return config.getInt("Skills.Fishing.Ice_Fishing_UnlockLevel", 50); }
|
||||
|
||||
/* Shake */
|
||||
public int getShakeUnlockLevel() { return config.getInt("Skills.Fishing.Shake_UnlockLevel", 150); }
|
||||
public int getShakeChanceRank1() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_1", 25); }
|
||||
public int getShakeChanceRank2() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_2", 40); }
|
||||
public int getShakeChanceRank3() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_3", 55); }
|
||||
public int getShakeChanceRank4() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_4", 60); }
|
||||
public int getShakeChanceRank5() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_5", 75); }
|
||||
public double getShakeChanceRank1() { return config.getDouble("Skills.Fishing.Shake_Chance.Rank_1", 25.0D); }
|
||||
public double getShakeChanceRank2() { return config.getDouble("Skills.Fishing.Shake_Chance.Rank_2", 40.0D); }
|
||||
public double getShakeChanceRank3() { return config.getDouble("Skills.Fishing.Shake_Chance.Rank_3", 55.0D); }
|
||||
public double getShakeChanceRank4() { return config.getDouble("Skills.Fishing.Shake_Chance.Rank_4", 60.0D); }
|
||||
public double getShakeChanceRank5() { return config.getDouble("Skills.Fishing.Shake_Chance.Rank_5", 75.0D); }
|
||||
|
||||
/* Vanilla XP Boost */
|
||||
public int getFishingVanillaXPModifierRank1() { return config.getInt("Skills.Fishing.VanillaXPBoost.Rank_1", 1); }
|
||||
@@ -183,15 +951,17 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
/* Arcane Forging */
|
||||
public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Skills.Repair.Arcane_Forging.Downgrades.Enabled", true); }
|
||||
public int getArcaneForgingDowngradeChanceRank1() { return config.getInt("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_1", 75); }
|
||||
public int getArcaneForgingDowngradeChanceRank2() { return config.getInt("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_2", 50); }
|
||||
public int getArcaneForgingDowngradeChanceRank3() { return config.getInt("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_3", 25); }
|
||||
public int getArcaneForgingDowngradeChanceRank4() { return config.getInt("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_4", 15); }
|
||||
public double getArcaneForgingDowngradeChanceRank1() { return config.getDouble("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_1", 75.0D); }
|
||||
public double getArcaneForgingDowngradeChanceRank2() { return config.getDouble("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_2", 50.0D); }
|
||||
public double getArcaneForgingDowngradeChanceRank3() { return config.getDouble("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_3", 25.0D); }
|
||||
public double getArcaneForgingDowngradeChanceRank4() { return config.getDouble("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_4", 15.0D); }
|
||||
|
||||
public boolean getArcaneForgingEnchantLossEnabled() { return config.getBoolean("Skills.Repair.Arcane_Forging.May_Lose_Enchants", true); }
|
||||
public int getArcaneForgingKeepEnchantsChanceRank1() { return config.getInt("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_1", 10); }
|
||||
public int getArcaneForgingKeepEnchantsChanceRank2() { return config.getInt("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_2", 20); }
|
||||
public int getArcaneForgingKeepEnchantsChanceRank3() { return config.getInt("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_3", 30); }
|
||||
public int getArcaneForgingKeepEnchantsChanceRank4() { return config.getInt("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_4", 40); }
|
||||
public double getArcaneForgingKeepEnchantsChanceRank1() { return config.getDouble("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_1", 10.0D); }
|
||||
public double getArcaneForgingKeepEnchantsChanceRank2() { return config.getDouble("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_2", 20.0D); }
|
||||
public double getArcaneForgingKeepEnchantsChanceRank3() { return config.getDouble("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_3", 30.0D); }
|
||||
public double getArcaneForgingKeepEnchantsChanceRank4() { return config.getDouble("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_4", 40.0D); }
|
||||
|
||||
public int getArcaneForgingRankLevels1() { return config.getInt("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_1", 100); }
|
||||
public int getArcaneForgingRankLevels2() { return config.getInt("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_2", 250); }
|
||||
public int getArcaneForgingRankLevels3() { return config.getInt("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_3", 500); }
|
||||
@@ -225,34 +995,35 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
public int getBleedMaxTicks() { return config.getInt("Skills.Swords.Bleed_MaxTicks", 3); }
|
||||
public int getBleedBaseTicks() { return config.getInt("Skills.Swords.Bleed_BaseTicks", 2); }
|
||||
|
||||
public boolean getCounterRequiresBlock() { return config.getBoolean("Skills.Swords.Counter_RequiresBlock"); }
|
||||
public double getCounterChanceMax() { return config.getDouble("Skills.Swords.Counter_ChanceMax", 30.0D); }
|
||||
public int getCounterMaxBonusLevel() { return config.getInt("Skills.Swords.Counter_MaxBonusLevel", 600); }
|
||||
public int getCounterModifier() { return config.getInt("Skills.Swords.Counter_DamageModifier", 2); }
|
||||
public double getCounterModifier() { return config.getDouble("Skills.Swords.Counter_DamageModifier", 2.0D); }
|
||||
|
||||
public int getSerratedStrikesModifier() { return config.getInt("Skills.Swords.SerratedStrikes_DamageModifier", 4); }
|
||||
public double getSerratedStrikesModifier() { return config.getDouble("Skills.Swords.SerratedStrikes_DamageModifier", 4.0D); }
|
||||
public int getSerratedStrikesTicks() { return config.getInt("Skills.Swords.SerratedStrikes_BleedTicks", 5); }
|
||||
|
||||
/* TAMING */
|
||||
public double getGoreChanceMax() { return config.getInt("Skills.Taming.Gore_ChanceMax", 100); }
|
||||
public double getGoreChanceMax() { return config.getDouble("Skills.Taming.Gore_ChanceMax", 100.0D); }
|
||||
public int getGoreMaxBonusLevel() { return config.getInt("Skills.Taming.Gore_MaxBonusLevel", 1000); }
|
||||
public int getGoreBleedTicks() { return config.getInt("Skills.Taming.Gore_BleedTicks", 2); }
|
||||
public int getGoreModifier() { return config.getInt("Skills.Taming.Gore_Modifier", 2); }
|
||||
public double getGoreModifier() { return config.getDouble("Skills.Taming.Gore_Modifier", 2.0D); }
|
||||
|
||||
public int getFastFoodUnlock() { return config.getInt("Skills.Taming.FastFood_UnlockLevel", 50); }
|
||||
public double getFastFoodChance() { return config.getInt("Skills.Taming.FastFood_Chance", 50); }
|
||||
public double getFastFoodChance() { return config.getDouble("Skills.Taming.FastFood_Chance", 50.0D); }
|
||||
|
||||
public int getEnviromentallyAwareUnlock() { return config.getInt("Skills.Taming.EnvironmentallyAware_UnlockLevel", 100); }
|
||||
|
||||
public int getThickFurUnlock() { return config.getInt("Skills.Taming.ThickFur_UnlockLevel", 250); }
|
||||
public int getThickFurModifier() { return config.getInt("Skills.Taming.ThickFur_Modifier", 2); }
|
||||
public double getThickFurModifier() { return config.getDouble("Skills.Taming.ThickFur_Modifier", 2.0D); }
|
||||
|
||||
public int getHolyHoundUnlock() {return config.getInt("Skills.Taming.HolyHound_UnlockLevel", 375); }
|
||||
|
||||
public int getShockProofUnlock() { return config.getInt("Skills.Taming.ShockProof_UnlockLevel", 500); }
|
||||
public int getShockProofModifier() { return config.getInt("Skills.Taming.ShockProof_Modifier", 6); }
|
||||
public double getShockProofModifier() { return config.getDouble("Skills.Taming.ShockProof_Modifier", 6.0D); }
|
||||
|
||||
public int getSharpenedClawsUnlock() { return config.getInt("Skills.Taming.SharpenedClaws_UnlockLevel", 750); }
|
||||
public int getSharpenedClawsBonus() { return config.getInt("Skills.Taming.SharpenedClaws_Bonus", 2); }
|
||||
public double getSharpenedClawsBonus() { return config.getDouble("Skills.Taming.SharpenedClaws_Bonus", 2.0D); }
|
||||
|
||||
/* UNARMED */
|
||||
public double getDisarmChanceMax() { return config.getDouble("Skills.Unarmed.Disarm_ChanceMax", 33.0D); }
|
||||
@@ -264,7 +1035,8 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
public double getIronGripChanceMax() { return config.getDouble("Skills.Unarmed.IronGrip_ChanceMax", 100.0D); }
|
||||
public int getIronGripMaxBonusLevel() { return config.getInt("Skills.Unarmed.IronGrip_MaxBonusLevel", 1000); }
|
||||
|
||||
public int getIronArmMaxBonus() { return config.getInt("Skills.Unarmed.IronArm_BonusMax", 8); }
|
||||
public double getIronArmMinBonus() { return config.getDouble("Skills.Unarmed.IronArm_BonusMin", 3.0D); }
|
||||
public double getIronArmMaxBonus() { return config.getDouble("Skills.Unarmed.IronArm_BonusMax", 8.0D); }
|
||||
public int getIronArmIncreaseLevel() { return config.getInt("Skills.Unarmed.IronArm_IncreaseLevel", 50); }
|
||||
|
||||
/* WOODCUTTING */
|
||||
@@ -273,9 +1045,17 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
public double getWoodcuttingDoubleDropChance() { return config.getDouble("Skills.Woodcutting.DoubleDrops_ChanceMax", 100.0D); }
|
||||
public int getWoodcuttingDoubleDropMaxLevel() { return config.getInt("Skills.Woodcutting.DoubleDrops_MaxBonusLevel", 1000); }
|
||||
|
||||
/* SPOUT STUFF*/
|
||||
public int getSpoutNotificationTier1() { return config.getInt("Spout.Notifications.Tier1", 200); }
|
||||
public int getSpoutNotificationTier2() { return config.getInt("Spout.Notifications.Tier2", 400); }
|
||||
public int getSpoutNotificationTier3() { return config.getInt("Spout.Notifications.Tier3", 600); }
|
||||
public int getSpoutNotificationTier4() { return config.getInt("Spout.Notifications.Tier4", 800); }
|
||||
/* KRAKEN STUFF */
|
||||
public boolean getKrakenEnabled() { return config.getBoolean("Kraken.Enabled", true); }
|
||||
public boolean getKrakenGlobalSoundsEnabled() { return config.getBoolean("Kraken.Global_Sounds", true); }
|
||||
public boolean getKrakenEscapeAllowed() { return config.getBoolean("Kraken.Allow_Escaping", false); }
|
||||
public int getKrakenTriesBeforeRelease() { return config.getInt("Kraken.Tries_Before_Release", 50); }
|
||||
public double getKrakenHealth() { return config.getDouble("Kraken.Health", 50.0D); }
|
||||
public String getKrakenName() { return config.getString("Kraken.Name", "The Kraken"); }
|
||||
public String getServerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Server", "(PLAYER) has unleashed the kraken!"); }
|
||||
public String getPlayerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Player", "THE KRAKEN HAS BEEN UNLEASHED!"); }
|
||||
public String getPlayerDefeatMessage() { return config.getString("Kraken.Defeated_Message.Killed", "You have slain the kraken!"); }
|
||||
public String getPlayerEscapeMessage() { return config.getString("Kraken.Defeated_Message.Escape", "You have escaped from the kraken!"); }
|
||||
public int getKrakenAttackInterval() { return config.getInt("Kraken.Attack_Interval_Seconds", 1); }
|
||||
public double getKrakenAttackDamage() { return config.getDouble("Kraken.Attack_Damage", 1.0D); }
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
@@ -15,6 +18,7 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
|
||||
private Config() {
|
||||
super("config.yml");
|
||||
validate();
|
||||
}
|
||||
|
||||
public static Config getInstance() {
|
||||
@@ -25,6 +29,148 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean validateKeys() {
|
||||
// Validate all the settings!
|
||||
List<String> reason = new ArrayList<String>();
|
||||
|
||||
/* General Settings */
|
||||
if (getSaveInterval() <= 0) {
|
||||
reason.add("General.Save_Interval should be greater than 0!");
|
||||
}
|
||||
|
||||
/* Mob Healthbar */
|
||||
if (getMobHealthbarTime() == 0) {
|
||||
reason.add("Mob_Healthbar.Display_Time cannot be 0! Set to -1 to disable or set a valid value.");
|
||||
}
|
||||
|
||||
/* Scoreboards */
|
||||
if (getMcrankScoreboardTime() != -1 && getMcrankScoreboardTime() <= 0) {
|
||||
reason.add("Scoreboards.Mcrank.Display_Time should be greater than 0 or -1!");
|
||||
}
|
||||
|
||||
if (getMcstatsScoreboardTime() != -1 && getMcstatsScoreboardTime() <= 0) {
|
||||
reason.add("Scoreboards.Mcstats.Display_Time should be greater than 0 or -1!");
|
||||
}
|
||||
|
||||
if (getMctopScoreboardTime() != -1 && getMctopScoreboardTime() <= 0) {
|
||||
reason.add("Scoreboards.Mctop.Display_Time should be greater than 0 or -1!");
|
||||
}
|
||||
|
||||
if (getInspectScoreboardTime() != -1 && getInspectScoreboardTime() <= 0) {
|
||||
reason.add("Scoreboards.Inspect.Display_Time should be greater than 0 or -1!");
|
||||
}
|
||||
|
||||
if (getSkillScoreboardTime() != -1 && getSkillScoreboardTime() <= 0) {
|
||||
reason.add("Scoreboards.Skillname.Display_Time should be greater than 0 or -1!");
|
||||
}
|
||||
|
||||
/* Database Purging */
|
||||
if (getPurgeInterval() < -1) {
|
||||
reason.add("Database_Purging.Purge_Interval should be greater than, or equal to -1!");
|
||||
}
|
||||
|
||||
if (getOldUsersCutoff() != -1 && getOldUsersCutoff() <= 0) {
|
||||
reason.add("Database_Purging.Old_User_Cutoff should be greater than 0 or -1!");
|
||||
}
|
||||
|
||||
/* Hardcore Mode */
|
||||
if (getHardcoreDeathStatPenaltyPercentage() < 1 || getHardcoreDeathStatPenaltyPercentage() > 100) {
|
||||
reason.add("Hardcore.Death_Stat_Loss.Penalty_Percentage only accepts values from 1 to 100!");
|
||||
}
|
||||
|
||||
if (getHardcoreVampirismStatLeechPercentage() < 1 || getHardcoreVampirismStatLeechPercentage() > 100) {
|
||||
reason.add("Hardcore.Vampirism.Leech_Percentage only accepts values from 1 to 100!");
|
||||
}
|
||||
|
||||
/* Items */
|
||||
if (getChimaeraUseCost() < 1 || getChimaeraUseCost() > 64) {
|
||||
reason.add("Items.Chimaera_Wing.Use_Cost only accepts values from 1 to 64!");
|
||||
}
|
||||
|
||||
if (getChimaeraRecipeCost() < 1 || getChimaeraRecipeCost() > 9) {
|
||||
reason.add("Items.Chimaera_Wing.Recipe_Cost only accepts values from 1 to 64!");
|
||||
}
|
||||
|
||||
if (getChimaeraItemId() < 1) {
|
||||
reason.add("Items.Chimaera_Wing.Item_ID should be at least 1!");
|
||||
}
|
||||
|
||||
/* Particles */
|
||||
if (getLevelUpEffectsTier() < 1) {
|
||||
reason.add("Particles.LevelUp_Tier should be at least 1!");
|
||||
}
|
||||
|
||||
/* PARTY SETTINGS */
|
||||
if (getAutoPartyKickInterval() < -1) {
|
||||
reason.add("Party.AutoKick_Interval should be at least -1!");
|
||||
}
|
||||
|
||||
if (getAutoPartyKickTime() < 0) {
|
||||
reason.add("Party.Old_Party_Member_Cutoff should be at least 0!");
|
||||
}
|
||||
|
||||
if (getPartyShareBonusBase() <= 0) {
|
||||
reason.add("Party.Sharing.ExpShare_bonus_base should be greater than 0!");
|
||||
}
|
||||
|
||||
if (getPartyShareBonusIncrease() < 0) {
|
||||
reason.add("Party.Sharing.ExpShare_bonus_increase should be at least 0!");
|
||||
}
|
||||
|
||||
if (getPartyShareBonusCap() <= 0) {
|
||||
reason.add("Party.Sharing.ExpShare_bonus_cap should be greater than 0!");
|
||||
}
|
||||
|
||||
if (getPartyShareRange() <= 0) {
|
||||
reason.add("Party.Sharing.Range should be greater than 0!");
|
||||
}
|
||||
|
||||
/* Inspect command distance */
|
||||
if (getInspectDistance() <= 0) {
|
||||
reason.add("Commands.inspect.Max_Distance should be greater than 0!");
|
||||
}
|
||||
|
||||
if (getTreeFellerThreshold() <= 0) {
|
||||
reason.add("Abilities.Limits.Tree_Feller_Threshold should be greater than 0!");
|
||||
}
|
||||
|
||||
|
||||
if (getDetonatorItemID() < 1) {
|
||||
reason.add("Skills.Mining.Detonator_ID should be at least 1!");
|
||||
}
|
||||
|
||||
if (getRepairAnvilId() < 1) {
|
||||
reason.add("Skills.Repair.Anvil_ID should be at least 1!");
|
||||
}
|
||||
|
||||
if (getSalvageAnvilId() < 1) {
|
||||
reason.add("Skills.Repair.Salvage_Anvil_ID should be at least 1!");
|
||||
}
|
||||
|
||||
if (getRepairAnvilId() == getSalvageAnvilId()) {
|
||||
reason.add("Cannot use the same item ID for Repair and Salvage anvils!");
|
||||
}
|
||||
|
||||
if (getTamingCOTWWolfCost() < 1) {
|
||||
reason.add("Skills.Taming.Call_Of_The_Wild.Bones_Required should be at least 1!");
|
||||
}
|
||||
|
||||
if (getTamingCOTWOcelotCost() < 1) {
|
||||
reason.add("Skills.Taming.Call_Of_The_Wild.Fish_Required should be at least 1!");
|
||||
}
|
||||
|
||||
if (getTamingCOTWAmount(EntityType.OCELOT) <= 0) {
|
||||
reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot_Amount should be greater than 0!");
|
||||
}
|
||||
|
||||
if (getTamingCOTWAmount(EntityType.WOLF) <= 0) {
|
||||
reason.add("Skills.Taming.Call_Of_The_Wild.Wolf_Amount should be greater than 0!");
|
||||
}
|
||||
|
||||
return noErrorsInConfig(reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {}
|
||||
|
||||
@@ -45,9 +191,43 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
|
||||
public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); }
|
||||
|
||||
public String getPartyChatPrefix() { return config.getString("Commands.p.Chat_Prefix_Format", "[[GREEN]]([[WHITE]]{0}[[GREEN]])"); }
|
||||
public boolean getPartyChatColorLeaderName() { return config.getBoolean("Commands.p.Gold_Leader_Name", true); }
|
||||
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); }
|
||||
|
||||
public String getAdminChatPrefix() { return config.getString("Commands.a.Chat_Prefix_Format", "[[AQUA]][[[WHITE]]{0}[[AQUA]]]"); }
|
||||
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); }
|
||||
|
||||
/* Mob Healthbar */
|
||||
public MobHealthbarType getMobHealthbarDefault() {
|
||||
try {
|
||||
return MobHealthbarType.valueOf(config.getString("Mob_Healthbar.Display_Type", "HEARTS").toUpperCase().trim());
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
return MobHealthbarType.HEARTS;
|
||||
}
|
||||
}
|
||||
|
||||
public int getMobHealthbarTime() { return config.getInt("Mob_Healthbar.Display_Time", 3); }
|
||||
|
||||
/* Scoreboards */
|
||||
public boolean getMcrankScoreboardEnabled() { return config.getBoolean("Scoreboards.Mcrank.Use", true); }
|
||||
public int getMcrankScoreboardTime() { return config.getInt("Scoreboards.Mcrank.Display_Time", 10); }
|
||||
|
||||
public boolean getMcstatsScoreboardsEnabled() { return config.getBoolean("Scoreboards.Mcstats.Use", true); }
|
||||
public int getMcstatsScoreboardTime() { return config.getInt("Scoreboards.Mcstats.Display_Time", 10); }
|
||||
|
||||
public boolean getMctopScoreboardEnabled() { return config.getBoolean("Scoreboards.Mctop.Use", true); }
|
||||
public int getMctopScoreboardTime() { return config.getInt("Scoreboards.Mctop.Display_Time", 10); }
|
||||
|
||||
public boolean getInspectScoreboardEnabled() { return config.getBoolean("Scoreboards.Inspect.Use", true); }
|
||||
public int getInspectScoreboardTime() { return config.getInt("Scoreboards.Inspect.Display_Time", 10); }
|
||||
|
||||
public boolean getSkillScoreboardEnabled() { return config.getBoolean("Scoreboards.Skillname.Use", true); }
|
||||
public int getSkillScoreboardTime() { return config.getInt("Scoreboards.Skillname.Display_Time", 10); }
|
||||
|
||||
public boolean getPowerLevelsEnabled() { return config.getBoolean("Scoreboards.Power_Level.Use", false); }
|
||||
|
||||
/* Database Purging */
|
||||
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
|
||||
public int getOldUsersCutoff() { return config.getInt("Database_Purging.Old_User_Cutoff", 6); }
|
||||
@@ -75,24 +255,24 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
str = String.valueOf(cfg.getInt(key));
|
||||
}
|
||||
|
||||
if (str == "0") {
|
||||
if (str.equals("0")) {
|
||||
str = "No value set for '" + key + "'";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/* Hardcore Mode */
|
||||
public boolean getHardcoreEnabled() { return config.getBoolean("Hardcore.Enabled", false); }
|
||||
public void setHardcoreEnabled(boolean enabled) { config.set("Hardcore.Enabled", enabled); }
|
||||
public boolean getHardcoreStatLossEnabled(SkillType skillType) { return config.getBoolean("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(skillType.toString()), false); }
|
||||
public void setHardcoreStatLossEnabled(SkillType skillType, boolean enabled) { config.set("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(skillType.toString()), enabled); }
|
||||
|
||||
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss_Penalty_Percentage", 75.0); }
|
||||
public void setHardcoreDeathStatPenaltyPercentage(double value) { config.set("Hardcore.Death_Stat_Loss_Penalty_Percentage", value); }
|
||||
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss.Penalty_Percentage", 75.0); }
|
||||
public void setHardcoreDeathStatPenaltyPercentage(double value) { config.set("Hardcore.Death_Stat_Loss.Penalty_Percentage", value); }
|
||||
|
||||
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism_Stat_Leech_Percentage", 5.0); }
|
||||
public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism_Stat_Leech_Percentage", value); }
|
||||
public boolean getHardcoreVampirismEnabled(SkillType skillType) { return config.getBoolean("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(skillType.toString()), false); }
|
||||
public void setHardcoreVampirismEnabled(SkillType skillType, boolean enabled) { config.set("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(skillType.toString()), enabled); }
|
||||
|
||||
public boolean getHardcoreVampirismEnabled() { return config.getBoolean("Hardcore.Vampirism", false); }
|
||||
public void setHardcoreVampirismEnabled(boolean enabled) { config.set("Hardcore.Vampirism", enabled); }
|
||||
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism.Leech_Percentage", 5.0); }
|
||||
public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism.Leech_Percentage", value); }
|
||||
|
||||
/* SMP Mods */
|
||||
public boolean getToolModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
|
||||
@@ -108,6 +288,7 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public boolean getChimaeraPreventUseUnderground() { return config.getBoolean("Items.Chimaera_Wing.Prevent_Use_Underground", true); }
|
||||
public int getChimaeraCooldown() { return config.getInt("Items.Chimaera_Wing.Cooldown", 240); }
|
||||
public int getChimaeraWarmup() { return config.getInt("Items.Chimaera_Wing.Warmup", 5); }
|
||||
public int getChimaeraRecentlyHurtCooldown() { return config.getInt("Items.Chimaera_Wing.RecentlyHurt_Cooldown", 60); }
|
||||
|
||||
/* Particles */
|
||||
public boolean getAbilityActivationEffectEnabled() { return config.getBoolean("Particles.Ability_Activation", true); }
|
||||
@@ -117,6 +298,7 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public boolean getGreaterImpactEffectEnabled() { return config.getBoolean("Particles.Greater_Impact", true); }
|
||||
public boolean getLevelUpEffectsEnabled() { return config.getBoolean("Particles.LevelUp_Enabled", true); }
|
||||
public int getLevelUpEffectsTier() { return config.getInt("Particles.LevelUp_Tier", 100); }
|
||||
public boolean getLargeFireworks() { return config.getBoolean("Particles.LargeFireworks", true); }
|
||||
|
||||
/* PARTY SETTINGS */
|
||||
public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); }
|
||||
@@ -129,11 +311,16 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public double getPartyShareRange() { return config.getDouble("Party.Sharing.Range", 75.0); }
|
||||
|
||||
/* Party Teleport Settings */
|
||||
public int getPTPCommandCooldown() { return config.getInt("Commands.ptp.Cooldown", 30); }
|
||||
public int getPTPCommandCooldown() { return config.getInt("Commands.ptp.Cooldown", 120); }
|
||||
public int getPTPCommandWarmup() { return config.getInt("Commands.ptp.Warmup", 5); }
|
||||
public int getPTPCommandRecentlyHurtCooldown() { return config.getInt("Commands.ptp.RecentlyHurt_Cooldown", 60); }
|
||||
public int getPTPCommandTimeout() { return config.getInt("Commands.ptp.Request_Timeout", 300); }
|
||||
public boolean getPTPCommandConfirmRequired() { return config.getBoolean("Commands.ptp.Confirm_Required", true); }
|
||||
public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); }
|
||||
|
||||
/* Inspect command distance */
|
||||
public double getInspectDistance() { return config.getDouble("Commands.inspect.Max_Distance", 30); }
|
||||
|
||||
/*
|
||||
* ABILITY SETTINGS
|
||||
*/
|
||||
@@ -147,7 +334,6 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public int getMaxTicks(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); }
|
||||
|
||||
/* Durability Settings */
|
||||
public boolean getAbilitiesDamageTools() { return config.getBoolean("Abilities.Tools.Durability_Loss_Enabled", true); }
|
||||
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 2); }
|
||||
|
||||
/* Thresholds */
|
||||
@@ -156,8 +342,6 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
/*
|
||||
* SKILL SETTINGS
|
||||
*/
|
||||
|
||||
public int getXp(SkillType skill, Material material) { return config.getInt("Experience." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
|
||||
public boolean getDoubleDropsEnabled(SkillType skill, Material material) { return config.getBoolean("Double_Drops." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
|
||||
|
||||
public boolean getDoubleDropsDisabled(SkillType skill) {
|
||||
@@ -178,9 +362,9 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
|
||||
/* Acrobatics */
|
||||
public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
|
||||
public boolean getPreventXPAfterTeleport() { return config.getBoolean("Skills.Acrobatics.Prevent_XP_After_Teleport", true); }
|
||||
|
||||
/* Fishing */
|
||||
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
|
||||
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
|
||||
|
||||
/* Mining */
|
||||
@@ -192,24 +376,19 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public int getSalvageAnvilId() { return config.getInt("Skills.Repair.Salvage_Anvil_ID", 41); }
|
||||
public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
|
||||
public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); }
|
||||
public boolean getRepairConfirmRequired() { return config.getBoolean("Skills.Repair.Confirm_Required", true); }
|
||||
|
||||
/* Unarmed */
|
||||
public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); }
|
||||
|
||||
/* Taming */
|
||||
public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); }
|
||||
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
|
||||
public int getTamingCOTWHorseCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Apples_Required", 10); }
|
||||
public int getTamingCOTWWolfCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Bones_Required", 10); }
|
||||
public int getTamingCOTWOcelotCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Fish_Required", 10); }
|
||||
public double getTamingCOTWRange() { return config.getDouble("Skills.Taming.Call_Of_The_Wild.Range", 40); }
|
||||
public int getTamingCOTWAmount(EntityType type) { return config.getInt("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type)+ "_Amount"); }
|
||||
|
||||
/* Woodcutting */
|
||||
public int getWoodcuttingXPOak() { return config.getInt("Experience.Woodcutting.Oak", 70); }
|
||||
public int getWoodcuttingXPBirch() { return config.getInt("Experience.Woodcutting.Birch", 90); }
|
||||
public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); }
|
||||
public int getWoodcuttingXPJungle() { return config.getInt("Experience.Woodcutting.Jungle", 100); }
|
||||
public int getWoodcuttingXPHugeBrownMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Brown", 70); }
|
||||
public int getWoodcuttingXPHugeRedMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Red", 70); }
|
||||
|
||||
public boolean getOakDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Oak", true); }
|
||||
public boolean getBirchDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Birch", true); }
|
||||
public boolean getSpruceDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Spruce", true); }
|
||||
@@ -233,27 +412,4 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
/* PVP & PVE Settings */
|
||||
public boolean getPVPEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVP", true); }
|
||||
public boolean getPVEEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVE", true); }
|
||||
|
||||
/*
|
||||
* XP SETTINGS
|
||||
*/
|
||||
|
||||
/* General Settings */
|
||||
public boolean getExperienceGainsMobspawnersEnabled() { return config.getBoolean("Experience.Gains.Mobspawners.Enabled", false); }
|
||||
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
|
||||
|
||||
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience.Gains.Multiplier.Global", 1.0); }
|
||||
public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience.Gains.Multiplier.Global", value); }
|
||||
|
||||
/* Combat XP Multipliers */
|
||||
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience.Gains.Multiplier.PVP", 1.0); }
|
||||
public double getCombatXP(EntityType entity) { return config.getDouble("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
|
||||
|
||||
public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); }
|
||||
public double getWitherSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Wither_Skeleton", 4.0); }
|
||||
|
||||
|
||||
/* XP Formula Multiplier */
|
||||
public int getFormulaMultiplierCurve() { return config.getInt("Experience.Formula.Curve_Modifier", 20); }
|
||||
public double getForumulaMultiplier(SkillType skill) { return config.getDouble("Experience.Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@@ -30,11 +33,11 @@ public abstract class ConfigLoader {
|
||||
|
||||
protected void loadFile() {
|
||||
if (!configFile.exists()) {
|
||||
plugin.getLogger().info("Creating mcMMO " + fileName + " File...");
|
||||
plugin.debug("Creating mcMMO " + fileName + " File...");
|
||||
createFile();
|
||||
}
|
||||
else {
|
||||
plugin.getLogger().info("Loading mcMMO " + fileName + " File...");
|
||||
plugin.debug("Loading mcMMO " + fileName + " File...");
|
||||
}
|
||||
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
@@ -43,38 +46,72 @@ public abstract class ConfigLoader {
|
||||
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);
|
||||
if (inputStream == null) {
|
||||
plugin.getLogger().severe("Missing resource file: '" + fileName + "' please notify the plugin authors");
|
||||
return;
|
||||
}
|
||||
|
||||
OutputStream outputStream = null;
|
||||
|
||||
try {
|
||||
outputStream = new FileOutputStream(configFile);
|
||||
|
||||
int read;
|
||||
byte[] bytes = new byte[1024];
|
||||
|
||||
while ((read = inputStream.read(bytes)) != -1) {
|
||||
outputStream.write(bytes, 0, read);
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
if (outputStream != null) {
|
||||
try {
|
||||
outputStream.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
inputStream.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
plugin.getLogger().severe("Missing resource file: '" + fileName + "' please notify the plugin authors");
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyStreamToFile(InputStream inputStream, File file) throws Exception {
|
||||
OutputStream outputStream = new FileOutputStream(file);
|
||||
protected boolean validateKeys() {
|
||||
return true;
|
||||
}
|
||||
|
||||
int read = 0;
|
||||
byte[] bytes = new byte[1024];
|
||||
|
||||
while ((read = inputStream.read(bytes)) != -1) {
|
||||
outputStream.write(bytes, 0, read);
|
||||
protected boolean noErrorsInConfig(List<String> issues) {
|
||||
for (String issue : issues) {
|
||||
plugin.getLogger().warning(issue);
|
||||
}
|
||||
|
||||
inputStream.close();
|
||||
outputStream.close();
|
||||
return issues.isEmpty();
|
||||
}
|
||||
|
||||
protected void validate() {
|
||||
if (validateKeys()) {
|
||||
plugin.debug("No errors found in " + fileName + "!");
|
||||
}
|
||||
else {
|
||||
plugin.getLogger().warning("Errors were found in " + fileName + "! mcMMO was disabled!");
|
||||
plugin.getServer().getPluginManager().disablePlugin(plugin);
|
||||
plugin.noErrorsInConfigFiles = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
package com.gmail.nossr50.config.experience;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.skills.repair.RepairMaterialType;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
private static ExperienceConfig instance;
|
||||
|
||||
private ExperienceConfig() {
|
||||
super("experience.yml");
|
||||
validate();
|
||||
}
|
||||
|
||||
public static ExperienceConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new ExperienceConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {}
|
||||
|
||||
@Override
|
||||
protected boolean validateKeys() {
|
||||
List<String> reason = new ArrayList<String>();
|
||||
|
||||
/*
|
||||
* FORMULA SETTINGS
|
||||
*/
|
||||
|
||||
/* Curve values */
|
||||
if (getMultiplier(FormulaType.EXPONENTIAL) <= 0) {
|
||||
reason.add("Experience_Formula.Exponential_Values.multiplier should be greater than 0!");
|
||||
}
|
||||
|
||||
if (getMultiplier(FormulaType.LINEAR) <= 0) {
|
||||
reason.add("Experience_Formula.Linear_Values.multiplier should be greater than 0!");
|
||||
}
|
||||
|
||||
if (getExponent(FormulaType.EXPONENTIAL) <= 0) {
|
||||
reason.add("Experience_Formula.Exponential_Values.exponent should be greater than 0!");
|
||||
}
|
||||
|
||||
/* Global modifier */
|
||||
if (getExperienceGainsGlobalMultiplier() <= 0) {
|
||||
reason.add("Experience_Formula.Multiplier.Global should be greater than 0!");
|
||||
}
|
||||
|
||||
/* PVP modifier */
|
||||
if (getPlayerVersusPlayerXP() < 0) {
|
||||
reason.add("Experience_Formula.Multiplier.PVP should be at least 0!");
|
||||
}
|
||||
|
||||
/* Spawned Mob modifier */
|
||||
if (getSpawnedMobXpMultiplier() < 0) {
|
||||
reason.add("Experience_Formula.Mobspawners.Multiplier should be at least 0!");
|
||||
}
|
||||
|
||||
/* Conversion */
|
||||
if (getExpModifier() <= 0) {
|
||||
reason.add("Conversion.Exp_Modifier should be greater than 0!");
|
||||
}
|
||||
|
||||
/*
|
||||
* XP SETTINGS
|
||||
*/
|
||||
|
||||
/* Combat XP Multipliers */
|
||||
if (getAnimalsXP() < 0) {
|
||||
reason.add("Experience.Combat.Multiplier.Animals should be at least 0!");
|
||||
}
|
||||
|
||||
if (getWitherSkeletonXP() < 0) {
|
||||
reason.add("Experience.Combat.Multiplier.Wither_Skeleton should be at least 0!");
|
||||
}
|
||||
|
||||
/* Fishing */
|
||||
if (getFishingBaseXP() <= 0) {
|
||||
reason.add("Experience.Fishing.Base should be greater than 0!");
|
||||
}
|
||||
|
||||
/* Repair */
|
||||
if (getRepairXPBase() <= 0) {
|
||||
reason.add("Experience.Repair.Base should be greater than 0!");
|
||||
}
|
||||
|
||||
/* Taming */
|
||||
if (getTamingXPWolf() <= 0) {
|
||||
reason.add("Experience.Taming.Animal_Taming.Wolf should be greater than 0!");
|
||||
}
|
||||
|
||||
if (getTamingXPOcelot() <= 0) {
|
||||
reason.add("Experience.Taming.Animal_Taming.Ocelot should be greater than 0!");
|
||||
}
|
||||
|
||||
/* Woodcutting */
|
||||
if (getWoodcuttingXPOak() <= 0) {
|
||||
reason.add("Experience.Woodcutting.Oak should be greater than 0!");
|
||||
}
|
||||
|
||||
if (getWoodcuttingXPBirch() <= 0) {
|
||||
reason.add("Experience.Woodcutting.Birch should be greater than 0!");
|
||||
}
|
||||
|
||||
if (getWoodcuttingXPSpruce() <= 0) {
|
||||
reason.add("Experience.Woodcutting.Spruce should be greater than 0!");
|
||||
}
|
||||
|
||||
if (getWoodcuttingXPJungle() <= 0) {
|
||||
reason.add("Experience.Woodcutting.Jungle should be greater than 0!");
|
||||
}
|
||||
|
||||
if (getWoodcuttingXPHugeBrownMushroom() <= 0) {
|
||||
reason.add("Experience.Woodcutting.Huge_Mushroom_Brown should be greater than 0!");
|
||||
}
|
||||
|
||||
if (getWoodcuttingXPHugeRedMushroom() <= 0) {
|
||||
reason.add("Experience.Woodcutting.Huge_Mushroom_Red should be greater than 0!");
|
||||
}
|
||||
|
||||
return noErrorsInConfig(reason);
|
||||
}
|
||||
|
||||
/*
|
||||
* FORMULA SETTINGS
|
||||
*/
|
||||
|
||||
/* Curve settings */
|
||||
public FormulaType getFormulaType() { return FormulaType.getFormulaType(config.getString("Experience_Formula.Curve")); }
|
||||
public boolean getCumulativeCurveEnabled() { return config.getBoolean("Experience_Formula.Cumulative_Curve", false); }
|
||||
|
||||
/* Curve values */
|
||||
public double getMultiplier(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.multiplier"); }
|
||||
public int getBase(FormulaType type) { return config.getInt("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.base"); }
|
||||
public double getExponent(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) +"_Values.exponent"); }
|
||||
|
||||
/* Global modifier */
|
||||
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience_Formula.Multiplier.Global", 1.0); }
|
||||
public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience_Formula.Multiplier.Global", value); }
|
||||
|
||||
/* PVP modifier */
|
||||
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience_Formula.Multiplier.PVP", 1.0); }
|
||||
|
||||
/* Spawned Mob modifier */
|
||||
public double getSpawnedMobXpMultiplier() { return config.getDouble("Experience_Formula.Mobspawners.Multiplier", 0.0); }
|
||||
|
||||
/* Skill modifiers */
|
||||
public double getFormulaSkillModifier(SkillType skill) { return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }
|
||||
|
||||
/* Conversion */
|
||||
public double getExpModifier() { return config.getDouble("Conversion.Exp_Modifier", 1); }
|
||||
|
||||
/*
|
||||
* XP SETTINGS
|
||||
*/
|
||||
|
||||
/* General Settings */
|
||||
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
|
||||
|
||||
/* Combat XP Multipliers */
|
||||
public double getCombatXP(EntityType entity) { return config.getDouble("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
|
||||
public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); }
|
||||
public double getWitherSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Wither_Skeleton", 4.0); }
|
||||
|
||||
/* Materials */
|
||||
public int getXp(SkillType skill, Material material) { return config.getInt("Experience." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
|
||||
|
||||
/* Fishing */
|
||||
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
|
||||
|
||||
/* Repair */
|
||||
public double getRepairXPBase() { return config.getDouble("Experience.Repair.Base", 1000.0); }
|
||||
public double getRepairXP(RepairMaterialType repairMaterialType) { return config.getDouble("Experience.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); }
|
||||
|
||||
/* Taming */
|
||||
public int getTamingXPHorse() { return config.getInt("Experience.Taming.Animal_Taming.Horse", 1000); }
|
||||
public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); }
|
||||
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
|
||||
|
||||
/* Woodcutting */
|
||||
public int getWoodcuttingXPOak() { return config.getInt("Experience.Woodcutting.Oak", 70); }
|
||||
public int getWoodcuttingXPBirch() { return config.getInt("Experience.Woodcutting.Birch", 90); }
|
||||
public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); }
|
||||
public int getWoodcuttingXPJungle() { return config.getInt("Experience.Woodcutting.Jungle", 100); }
|
||||
public int getWoodcuttingXPHugeBrownMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Brown", 70); }
|
||||
public int getWoodcuttingXPHugeRedMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Red", 70); }
|
||||
}
|
||||
@@ -15,13 +15,15 @@ import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
public class CustomToolConfig extends ConfigLoader {
|
||||
private static CustomToolConfig 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> 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<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>();
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.config.party;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
@@ -21,13 +23,20 @@ public class ItemWeightConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
public int getItemWeight(Material material) {
|
||||
String materialName = StringUtils.getPrettyItemString(material).replace(" ", "_");
|
||||
int itemWeight = config.getInt("Item_Weights.Default");
|
||||
return config.getInt("Item_Weights." + StringUtils.getPrettyItemString(material).replace(" ", "_"), config.getInt("Item_Weights.Default"));
|
||||
}
|
||||
|
||||
if (config.getInt("Item_Weights." + materialName) > 0) {
|
||||
itemWeight = config.getInt("Item_Weights." + materialName);
|
||||
public HashSet<Material> getMiscItems() {
|
||||
HashSet<Material> miscItems = new HashSet<Material>();
|
||||
|
||||
for (String item : config.getStringList("Party_Shareables.Misc_Items")) {
|
||||
Material material = Material.getMaterial(item.toUpperCase());
|
||||
|
||||
if (material != null) {
|
||||
miscItems.add(material);
|
||||
}
|
||||
}
|
||||
return itemWeight;
|
||||
return miscItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,13 +4,13 @@ import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||
|
||||
import org.getspout.spoutapi.keyboard.Keyboard;
|
||||
|
||||
public class SpoutConfig extends ConfigLoader {
|
||||
private static SpoutConfig instance;
|
||||
public HudType defaultHudType;
|
||||
|
||||
private SpoutConfig() {
|
||||
super("spout.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static SpoutConfig getInstance() {
|
||||
@@ -24,22 +24,26 @@ public class SpoutConfig extends ConfigLoader {
|
||||
@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)) {
|
||||
defaultHudType = hudType;
|
||||
break;
|
||||
}
|
||||
public HudType getDefaultHudType() {
|
||||
try {
|
||||
return HudType.valueOf(config.getString("Spout.HUD.Default", "STANDARD").toUpperCase().trim());
|
||||
}
|
||||
|
||||
if (defaultHudType == null) {
|
||||
defaultHudType = HudType.STANDARD;
|
||||
catch (IllegalArgumentException ex) {
|
||||
return HudType.STANDARD;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); }
|
||||
public String getMenuKey() { return config.getString("Menu.Key", "KEY_M"); }
|
||||
public Keyboard getMenuKey() {
|
||||
try {
|
||||
return Keyboard.valueOf(config.getString("Menu.Key", "KEY_M").toUpperCase().trim());
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
return Keyboard.KEY_M;
|
||||
}
|
||||
}
|
||||
|
||||
/* XP Bar */
|
||||
public boolean getXPBarEnabled() { return config.getBoolean("XP.Bar.Enabled", true); }
|
||||
@@ -62,4 +66,10 @@ public class SpoutConfig extends ConfigLoader {
|
||||
public double getRetroHUDRed(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
|
||||
public double getRetroHUDGreen(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
|
||||
public double getRetroHUDBlue(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
|
||||
|
||||
/* Notification Tiers */
|
||||
public int getNotificationTier1() { return config.getInt("Notifications.Tier1", 200); }
|
||||
public int getNotificationTier2() { return config.getInt("Notifications.Tier2", 400); }
|
||||
public int getNotificationTier3() { return config.getInt("Notifications.Tier3", 600); }
|
||||
public int getNotificationTier4() { return config.getInt("Notifications.Tier4", 800); }
|
||||
}
|
||||
|
||||
@@ -5,34 +5,59 @@ import java.util.HashMap;
|
||||
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.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.potion.Potion;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.Treasure;
|
||||
|
||||
public class TreasureConfig extends ConfigLoader {
|
||||
private static TreasureConfig instance;
|
||||
|
||||
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromGravel = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromGravel = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromSnow = new ArrayList<ExcavationTreasure>();
|
||||
|
||||
public List<HylianTreasure> hylianFromBushes = new ArrayList<HylianTreasure>();
|
||||
public List<HylianTreasure> hylianFromFlowers = new ArrayList<HylianTreasure>();
|
||||
public List<HylianTreasure> hylianFromPots = new ArrayList<HylianTreasure>();
|
||||
|
||||
public List<ShakeTreasure> shakeFromBlaze = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromCaveSpider = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromSpider = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromChicken = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromCow = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromCreeper = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromEnderman = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromGhast = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromIronGolem = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromMagmaCube = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromMushroomCow = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromPig = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromPigZombie = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromSheep = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromSkeleton = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromSlime = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromSnowman = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromSquid = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromWitch = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromZombie = new ArrayList<ShakeTreasure>();
|
||||
|
||||
public List<FishingTreasure> fishingRewards = new ArrayList<FishingTreasure>();
|
||||
|
||||
private TreasureConfig() {
|
||||
@@ -57,9 +82,7 @@ public class TreasureConfig extends ConfigLoader {
|
||||
return;
|
||||
}
|
||||
|
||||
Set<String> treasureConfigSet = treasureSection.getKeys(false);
|
||||
|
||||
for (String treasureName : treasureConfigSet) {
|
||||
for (String treasureName : treasureSection.getKeys(false)) {
|
||||
|
||||
// Validate all the things!
|
||||
List<String> reason = new ArrayList<String>();
|
||||
@@ -92,7 +115,7 @@ public class TreasureConfig extends ConfigLoader {
|
||||
reason.add("Invalid amount: " + amount);
|
||||
}
|
||||
|
||||
if (data > 127 || data < -128) {
|
||||
if (id < 256 && (data > 127 || data < -128)) {
|
||||
reason.add("Invalid data: " + data);
|
||||
}
|
||||
|
||||
@@ -128,15 +151,32 @@ public class TreasureConfig extends ConfigLoader {
|
||||
reason.add("Invalid Drop_Level: " + dropLevel);
|
||||
}
|
||||
|
||||
/*
|
||||
* Potions
|
||||
*/
|
||||
|
||||
ItemStack item = null;
|
||||
|
||||
if (config.contains("Treasures." + treasureName + ".Potion_Type")) {
|
||||
String potionType = config.getString("Treasures." + treasureName + ".Potion_Type");
|
||||
try {
|
||||
item = new Potion(PotionType.valueOf(potionType.toUpperCase())).toItemStack(amount);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
reason.add("Invalid Potion_Type: " + potionType);
|
||||
}
|
||||
}
|
||||
else {
|
||||
item = (new MaterialData(id, (byte) data)).toItemStack(amount);
|
||||
}
|
||||
|
||||
/*
|
||||
* Drops From & Max Level
|
||||
*/
|
||||
|
||||
ItemStack item = (new MaterialData(id, (byte) data)).toItemStack(amount);
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
|
||||
if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) {
|
||||
reason.add("Fishing drops cannot also be excavation drops");
|
||||
reason.add("This can only be a fishing drop.");
|
||||
}
|
||||
|
||||
if (!config.contains("Treasures." + treasureName + ".Max_Level")) {
|
||||
@@ -145,11 +185,35 @@ public class TreasureConfig extends ConfigLoader {
|
||||
|
||||
int maxLevel = config.getInt("Treasures." + treasureName + ".Max_Level");
|
||||
|
||||
if (noErrorsInTreasure(reason)) {
|
||||
if (noErrorsInConfig(reason)) {
|
||||
FishingTreasure fTreasure = new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel);
|
||||
treasures.put(treasureName, fTreasure);
|
||||
}
|
||||
}
|
||||
else if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Shake", false)) {
|
||||
if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) {
|
||||
reason.add("This can only be a shake drop.");
|
||||
}
|
||||
|
||||
if (!config.contains("Treasures." + treasureName + ".Mob")) {
|
||||
reason.add("Missing Mob");
|
||||
}
|
||||
|
||||
String mobType = config.getString("Treasures." + treasureName + ".Mob");
|
||||
EntityType mob = null;
|
||||
|
||||
try {
|
||||
mob = EntityType.valueOf(mobType.toUpperCase().trim());
|
||||
}
|
||||
catch (IllegalArgumentException ex){
|
||||
reason.add("Invalid Mob: " + mobType);
|
||||
}
|
||||
|
||||
if (noErrorsInConfig(reason)) {
|
||||
ShakeTreasure sTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel, mob);
|
||||
treasures.put(treasureName, sTreasure);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ExcavationTreasure eTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
|
||||
HylianTreasure hTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
|
||||
@@ -182,6 +246,10 @@ public class TreasureConfig extends ConfigLoader {
|
||||
eTreasure.setDropsFromSoulSand();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Snow", false)) {
|
||||
eTreasure.setDropsFromSnow();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Bushes", false)) {
|
||||
hTreasure.setDropsFromBushes();
|
||||
}
|
||||
@@ -195,13 +263,17 @@ public class TreasureConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
|
||||
reason.add("Excavation drops cannot also be fishing drops");
|
||||
reason.add("This cannot also be a fishing drop.");
|
||||
}
|
||||
|
||||
if (noErrorsInTreasure(reason) && hTreasure.getDropsFrom() == (byte) 0x0) {
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Shake", false)) {
|
||||
reason.add("This cannot also be a shake drop.");
|
||||
}
|
||||
|
||||
if (noErrorsInConfig(reason) && hTreasure.getDropsFrom() == (byte) 0x0) {
|
||||
treasures.put(treasureName, eTreasure);
|
||||
}
|
||||
else if (noErrorsInTreasure(reason) && eTreasure.getDropsFrom() == (byte) 0x0) {
|
||||
else if (noErrorsInConfig(reason) && eTreasure.getDropsFrom() == (byte) 0x0) {
|
||||
treasures.put(treasureName, hTreasure);
|
||||
}
|
||||
}
|
||||
@@ -210,6 +282,7 @@ public class TreasureConfig extends ConfigLoader {
|
||||
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
|
||||
List<String> fishingTreasures = config.getStringList("Fishing.Treasure");
|
||||
List<String> hylianTreasures = config.getStringList("Hylian_Luck.Treasure");
|
||||
List<String> shakeTreasures = config.getStringList("Shake.Treasure");
|
||||
|
||||
for (Entry<String, Treasure> nextEntry : treasures.entrySet()) {
|
||||
String treasureKey = nextEntry.getKey();
|
||||
@@ -222,6 +295,97 @@ public class TreasureConfig extends ConfigLoader {
|
||||
|
||||
fishingRewards.add((FishingTreasure) treasure);
|
||||
}
|
||||
else if (treasure instanceof ShakeTreasure) {
|
||||
if (shakeTreasures == null || !shakeTreasures.contains(treasureKey)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ShakeTreasure e = (ShakeTreasure) treasure;
|
||||
switch (e.getMob()) {
|
||||
case BLAZE:
|
||||
shakeFromBlaze.add(e);
|
||||
break;
|
||||
|
||||
case CAVE_SPIDER:
|
||||
shakeFromCaveSpider.add(e);
|
||||
break;
|
||||
|
||||
case CHICKEN:
|
||||
shakeFromChicken.add(e);
|
||||
break;
|
||||
|
||||
case COW:
|
||||
shakeFromCow.add(e);
|
||||
break;
|
||||
|
||||
case CREEPER:
|
||||
shakeFromCreeper.add(e);
|
||||
break;
|
||||
|
||||
case ENDERMAN:
|
||||
shakeFromEnderman.add(e);
|
||||
break;
|
||||
|
||||
case GHAST:
|
||||
shakeFromGhast.add(e);
|
||||
break;
|
||||
|
||||
case IRON_GOLEM:
|
||||
shakeFromIronGolem.add(e);
|
||||
break;
|
||||
|
||||
case MAGMA_CUBE:
|
||||
shakeFromMagmaCube.add(e);
|
||||
break;
|
||||
|
||||
case MUSHROOM_COW:
|
||||
shakeFromMushroomCow.add(e);
|
||||
break;
|
||||
|
||||
case PIG:
|
||||
shakeFromPig.add(e);
|
||||
break;
|
||||
|
||||
case PIG_ZOMBIE:
|
||||
shakeFromPigZombie.add(e);
|
||||
break;
|
||||
|
||||
case SHEEP:
|
||||
shakeFromSheep.add(e);
|
||||
break;
|
||||
|
||||
case SKELETON:
|
||||
shakeFromSkeleton.add(e);
|
||||
break;
|
||||
|
||||
case SLIME:
|
||||
shakeFromSlime.add(e);
|
||||
break;
|
||||
|
||||
case SPIDER:
|
||||
shakeFromSpider.add(e);
|
||||
break;
|
||||
|
||||
case SNOWMAN:
|
||||
shakeFromSnowman.add(e);
|
||||
break;
|
||||
|
||||
case SQUID:
|
||||
shakeFromSquid.add(e);
|
||||
break;
|
||||
|
||||
case WITCH:
|
||||
shakeFromWitch.add(e);
|
||||
break;
|
||||
|
||||
case ZOMBIE:
|
||||
shakeFromZombie.add(e);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (treasure instanceof HylianTreasure) {
|
||||
if (hylianTreasures == null || !hylianTreasures.contains(treasureKey)) {
|
||||
continue;
|
||||
@@ -275,18 +439,11 @@ public class TreasureConfig extends ConfigLoader {
|
||||
if (eTreasure.getDropsFromSoulSand()) {
|
||||
excavationFromSoulSand.add(eTreasure);
|
||||
}
|
||||
|
||||
if (eTreasure.getDropsFromSnow()) {
|
||||
excavationFromSnow.add(eTreasure);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean noErrorsInTreasure(List<String> issues) {
|
||||
if (issues.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (String issue : issues) {
|
||||
plugin.getLogger().warning(issue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,643 +1,97 @@
|
||||
package com.gmail.nossr50.database;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.database.DatabaseUpdateType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.runnables.database.SQLReconnectTask;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
|
||||
public final class DatabaseManager {
|
||||
private static String connectionString;
|
||||
|
||||
private static String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
private static Connection connection = null;
|
||||
|
||||
// Scale waiting time by this much per failed attempt
|
||||
private static final double SCALING_FACTOR = 40;
|
||||
|
||||
// Minimum wait in nanoseconds (default 500ms)
|
||||
private static final long MIN_WAIT = 500L * 1000000L;
|
||||
|
||||
// Maximum time to wait between reconnects (default 5 minutes)
|
||||
private static final long MAX_WAIT = 5L * 60L * 1000L * 1000000L;
|
||||
|
||||
// How long to wait when checking if connection is valid (default 3 seconds)
|
||||
private static final int VALID_TIMEOUT = 3;
|
||||
|
||||
// When next to try connecting to Database in nanoseconds
|
||||
private static long nextReconnectTimestamp = 0L;
|
||||
|
||||
// How many connection attempts have failed
|
||||
private static int reconnectAttempt = 0;
|
||||
|
||||
private static final long ONE_MONTH = 2630000000L;
|
||||
|
||||
private DatabaseManager() {}
|
||||
public interface DatabaseManager {
|
||||
// One month in milliseconds
|
||||
public final long PURGE_TIME = 2630000000L * Config.getInstance().getOldUsersCutoff();
|
||||
|
||||
/**
|
||||
* Attempt to connect to the mySQL database.
|
||||
* Purge users with 0 power level from the database.
|
||||
*/
|
||||
public static void connect() {
|
||||
Config configInstance = Config.getInstance();
|
||||
connectionString = "jdbc:mysql://" + configInstance.getMySQLServerName() + ":" + configInstance.getMySQLServerPort() + "/" + configInstance.getMySQLDatabaseName();
|
||||
|
||||
try {
|
||||
mcMMO.p.getLogger().info("Attempting connection to MySQL...");
|
||||
|
||||
// Force driver to load if not yet loaded
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
Properties connectionProperties = new Properties();
|
||||
connectionProperties.put("user", configInstance.getMySQLUserName());
|
||||
connectionProperties.put("password", configInstance.getMySQLUserPassword());
|
||||
connectionProperties.put("autoReconnect", "false");
|
||||
connectionProperties.put("maxReconnects", "0");
|
||||
connection = DriverManager.getConnection(connectionString, connectionProperties);
|
||||
|
||||
mcMMO.p.getLogger().info("Connection to MySQL was a success!");
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
connection = null;
|
||||
|
||||
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
|
||||
mcMMO.p.getLogger().info("Connection to MySQL failed!");
|
||||
}
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
connection = null;
|
||||
|
||||
if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
|
||||
mcMMO.p.getLogger().info("MySQL database driver not found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
public void purgePowerlessUsers();
|
||||
|
||||
/**
|
||||
* Attempt to create the database structure.
|
||||
* Purge users who haven't logged on in over a certain time frame from the database.
|
||||
*/
|
||||
public static void createStructure() {
|
||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "users` ("
|
||||
+ "`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
|
||||
+ "`user` varchar(40) NOT NULL,"
|
||||
+ "`lastlogin` int(32) unsigned NOT NULL,"
|
||||
+ "PRIMARY KEY (`id`),"
|
||||
+ "UNIQUE KEY `user` (`user`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
|
||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "huds` ("
|
||||
+ "`user_id` int(10) unsigned NOT NULL,"
|
||||
+ "`hudtype` varchar(50) NOT NULL DEFAULT 'STANDARD',"
|
||||
+ "PRIMARY KEY (`user_id`),"
|
||||
+ "FOREIGN KEY (`user_id`) REFERENCES `" + tablePrefix + "users` (`id`) "
|
||||
+ "ON DELETE CASCADE) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "cooldowns` ("
|
||||
+ "`user_id` int(10) unsigned NOT NULL,"
|
||||
+ "`taming` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`mining` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`woodcutting` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`repair` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`unarmed` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`herbalism` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`excavation` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`archery` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`swords` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`axes` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`acrobatics` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`blast_mining` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`),"
|
||||
+ "FOREIGN KEY (`user_id`) REFERENCES `" + tablePrefix + "users` (`id`) "
|
||||
+ "ON DELETE CASCADE) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "skills` ("
|
||||
+ "`user_id` int(10) unsigned NOT NULL,"
|
||||
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`mining` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`woodcutting` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`repair` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`unarmed` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`herbalism` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`excavation` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`archery` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`swords` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`),"
|
||||
+ "FOREIGN KEY (`user_id`) REFERENCES `" + tablePrefix + "users` (`id`) "
|
||||
+ "ON DELETE CASCADE) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "experience` ("
|
||||
+ "`user_id` int(10) unsigned NOT NULL,"
|
||||
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`mining` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`woodcutting` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`repair` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`unarmed` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`herbalism` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`excavation` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`archery` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`swords` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`),"
|
||||
+ "FOREIGN KEY (`user_id`) REFERENCES `" + tablePrefix + "users` (`id`) "
|
||||
+ "ON DELETE CASCADE) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
||||
|
||||
checkDatabaseStructure(DatabaseUpdateType.FISHING);
|
||||
checkDatabaseStructure(DatabaseUpdateType.BLAST_MINING);
|
||||
checkDatabaseStructure(DatabaseUpdateType.CASCADE_DELETE);
|
||||
checkDatabaseStructure(DatabaseUpdateType.INDEX);
|
||||
}
|
||||
public void purgeOldUsers();
|
||||
|
||||
/**
|
||||
* Attempt to write the SQL query.
|
||||
* Remove a user from the database.
|
||||
*
|
||||
* @param sql Query to write.
|
||||
* @return true if the query was successfully written, false otherwise.
|
||||
* @param playerName The name of the user to remove
|
||||
* @return true if the user was successfully removed, false otherwise
|
||||
*/
|
||||
public static boolean write(String sql) {
|
||||
if (!checkConnected()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
statement = connection.prepareStatement(sql);
|
||||
statement.executeUpdate();
|
||||
return true;
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
printErrors(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public boolean removeUser(String playerName);
|
||||
|
||||
/**
|
||||
* Returns the number of rows affected by either a DELETE or UPDATE query
|
||||
* Save a user to the database.
|
||||
*
|
||||
* @param sql SQL query to execute
|
||||
* @return the number of rows affected
|
||||
* @param profile The profile of the player to save
|
||||
*/
|
||||
public static int update(String sql) {
|
||||
int ret = 0;
|
||||
|
||||
if (checkConnected()) {
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
statement = connection.prepareStatement(sql);
|
||||
ret = statement.executeUpdate();
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
}
|
||||
finally {
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
printErrors(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
public void saveUser(PlayerProfile profile);
|
||||
|
||||
/**
|
||||
* Get the Integer. Only return first row / first field.
|
||||
*
|
||||
* @param sql SQL query to execute
|
||||
* @return the value in the first row / first field
|
||||
*/
|
||||
public static int getInt(String sql) {
|
||||
ResultSet resultSet = null;
|
||||
int result = 0;
|
||||
|
||||
if (checkConnected()) {
|
||||
PreparedStatement statement = null;
|
||||
|
||||
try {
|
||||
statement = connection.prepareStatement(sql);
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
if (resultSet.next()) {
|
||||
result = resultSet.getInt(1);
|
||||
}
|
||||
else {
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
}
|
||||
finally {
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
printErrors(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
* Retrieve leaderboard info.
|
||||
*
|
||||
* @param skillName The skill to retrieve info on
|
||||
* @param pageNumber Which page in the leaderboards to retrieve
|
||||
* @param statsPerPage The number of stats per page
|
||||
* @return the requested leaderboard information
|
||||
*/
|
||||
public List<PlayerStat> readLeaderboard(String skillName, int pageNumber, int statsPerPage);
|
||||
|
||||
/**
|
||||
* Check connection status and re-establish if dead or stale.
|
||||
* Retrieve rank info.
|
||||
*
|
||||
* If the very first immediate attempt fails, further attempts
|
||||
* will be made in progressively larger intervals up to MAX_WAIT
|
||||
* intervals.
|
||||
*
|
||||
* This allows for MySQL to time out idle connections as needed by
|
||||
* server operator, without affecting McMMO, while still providing
|
||||
* protection against a database outage taking down Bukkit's tick
|
||||
* processing loop due to attemping a database connection each
|
||||
* time McMMO needs the database.
|
||||
*
|
||||
* @return the boolean value for whether or not we are connected
|
||||
* @param playerName The name of the user to retrieve the rankings for
|
||||
* @return the requested rank information
|
||||
*/
|
||||
public static boolean checkConnected() {
|
||||
boolean isClosed = true;
|
||||
boolean isValid = false;
|
||||
boolean exists = (connection != null);
|
||||
|
||||
// If we're waiting for server to recover then leave early
|
||||
if (nextReconnectTimestamp > 0 && nextReconnectTimestamp > System.nanoTime()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (exists) {
|
||||
try {
|
||||
isClosed = connection.isClosed();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
isClosed = true;
|
||||
e.printStackTrace();
|
||||
printErrors(e);
|
||||
}
|
||||
|
||||
if (!isClosed) {
|
||||
try {
|
||||
isValid = connection.isValid(VALID_TIMEOUT);
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Don't print stack trace because it's valid to lose idle connections to the server and have to restart them.
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Leave if all ok
|
||||
if (exists && !isClosed && isValid) {
|
||||
// Housekeeping
|
||||
nextReconnectTimestamp = 0;
|
||||
reconnectAttempt = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Cleanup after ourselves for GC and MySQL's sake
|
||||
if (exists && !isClosed) {
|
||||
try {
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
// This is a housekeeping exercise, ignore errors
|
||||
}
|
||||
}
|
||||
|
||||
// Try to connect again
|
||||
connect();
|
||||
|
||||
// Leave if connection is good
|
||||
try {
|
||||
if (connection != null && !connection.isClosed()) {
|
||||
// Schedule a database save if we really had an outage
|
||||
if (reconnectAttempt > 1) {
|
||||
new SQLReconnectTask().runTaskLater(mcMMO.p, 5);
|
||||
}
|
||||
nextReconnectTimestamp = 0;
|
||||
reconnectAttempt = 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Failed to check isClosed, so presume connection is bad and attempt later
|
||||
e.printStackTrace();
|
||||
printErrors(e);
|
||||
}
|
||||
|
||||
reconnectAttempt++;
|
||||
nextReconnectTimestamp = (long)(System.nanoTime() + Math.min(MAX_WAIT, (reconnectAttempt * SCALING_FACTOR * MIN_WAIT)));
|
||||
return false;
|
||||
}
|
||||
public Map<String, Integer> readRank(String playerName);
|
||||
|
||||
/**
|
||||
* Read SQL query.
|
||||
* Add a new user to the database.
|
||||
*
|
||||
* @param sql SQL query to read
|
||||
* @return the rows in this SQL query
|
||||
* @param playerName The name of the player to be added to the database
|
||||
*/
|
||||
public static HashMap<Integer, ArrayList<String>> read(String sql) {
|
||||
ResultSet resultSet;
|
||||
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
||||
|
||||
if (checkConnected()) {
|
||||
PreparedStatement statement = null;
|
||||
|
||||
try {
|
||||
statement = connection.prepareStatement(sql);
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
while (resultSet.next()) {
|
||||
ArrayList<String> column = new ArrayList<String>();
|
||||
|
||||
for (int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) {
|
||||
column.add(resultSet.getString(i));
|
||||
}
|
||||
|
||||
rows.put(resultSet.getRow(), column);
|
||||
}
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
}
|
||||
finally {
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
printErrors(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
public static Map<String, Integer> readSQLRank(String playerName) {
|
||||
ResultSet resultSet;
|
||||
Map<String, Integer> skills = new HashMap<String, Integer>();
|
||||
|
||||
if (checkConnected()) {
|
||||
try {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String skillName = skillType.name().toLowerCase();
|
||||
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
|
||||
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
||||
"WHERE user = ?)";
|
||||
|
||||
PreparedStatement statement = connection.prepareStatement(sql);
|
||||
statement.setString(1, playerName);
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
resultSet.next();
|
||||
|
||||
int rank = resultSet.getInt("rank");
|
||||
|
||||
sql = "SELECT user, " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
|
||||
"AND " + skillName + " = (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
||||
"WHERE user = '" + playerName + "') ORDER BY user";
|
||||
|
||||
statement = connection.prepareStatement(sql);
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
while (resultSet.next()) {
|
||||
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
||||
skills.put(skillType.name(), rank + resultSet.getRow());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
statement.close();
|
||||
}
|
||||
|
||||
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
||||
"WHERE taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > 0 " +
|
||||
"AND taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > " +
|
||||
"(SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing " +
|
||||
"FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = ?)";
|
||||
|
||||
PreparedStatement statement = connection.prepareStatement(sql);
|
||||
statement.setString(1, playerName);
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
resultSet.next();
|
||||
|
||||
int rank = resultSet.getInt("rank");
|
||||
|
||||
sql = "SELECT user, taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing " +
|
||||
"FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
||||
"WHERE taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > 0 " +
|
||||
"AND taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing = " +
|
||||
"(SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing " +
|
||||
"FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = ?) ORDER BY user";
|
||||
|
||||
statement = connection.prepareStatement(sql);
|
||||
statement.setString(1, playerName);
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
while (resultSet.next()) {
|
||||
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
||||
skills.put("ALL", rank + resultSet.getRow());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
}
|
||||
}
|
||||
|
||||
return skills;
|
||||
}
|
||||
|
||||
public static void purgePowerlessSQL() {
|
||||
mcMMO.p.getLogger().info("Purging powerless users...");
|
||||
HashMap<Integer, ArrayList<String>> usernames;
|
||||
|
||||
usernames = read("SELECT u.user FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u " + "WHERE s.user_id = u.id AND " +
|
||||
"(s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0");
|
||||
|
||||
write("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.id IN (SELECT * FROM " +
|
||||
"(SELECT u.id FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u " + "WHERE s.user_id = u.id " +
|
||||
"AND (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0) AS p)");
|
||||
|
||||
int purgedUsers = 0;
|
||||
for (int i = 1; i <= usernames.size(); i++) {
|
||||
String playerName = usernames.get(i).get(0);
|
||||
|
||||
if (playerName == null || mcMMO.p.getServer().getOfflinePlayer(playerName).isOnline()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Misc.profileCleanup(playerName);
|
||||
purgedUsers++;
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
||||
}
|
||||
|
||||
public static void purgeOldSQL() {
|
||||
mcMMO.p.getLogger().info("Purging old users...");
|
||||
long currentTime = System.currentTimeMillis();
|
||||
long purgeTime = ONE_MONTH * Config.getInstance().getOldUsersCutoff();
|
||||
HashMap<Integer, ArrayList<String>> usernames = read("SELECT user FROM " + tablePrefix + "users WHERE ((" + currentTime + " - lastlogin*1000) > " + purgeTime + ")");
|
||||
write("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.id IN (SELECT * FROM (SELECT id FROM " + tablePrefix + "users WHERE ((" + currentTime + " - lastlogin*1000) > " + purgeTime + ")) AS p)");
|
||||
|
||||
int purgedUsers = 0;
|
||||
for (int i = 1; i <= usernames.size(); i++) {
|
||||
String playerName = usernames.get(i).get(0);
|
||||
|
||||
if (playerName == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Misc.profileCleanup(playerName);
|
||||
purgedUsers++;
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
||||
}
|
||||
public void newUser(String playerName);
|
||||
|
||||
/**
|
||||
* Check database structure for missing values.
|
||||
* Load a player from the database.
|
||||
*
|
||||
* @param update Type of data to check updates for
|
||||
* @param playerName The name of the player to load from the database
|
||||
* @param createNew Whether to create a new record if the player is not
|
||||
* found
|
||||
* @return The player's data, or an unloaded PlayerProfile if not found
|
||||
* and createNew is false
|
||||
*/
|
||||
private static void checkDatabaseStructure(DatabaseUpdateType update) {
|
||||
String sql = null;
|
||||
ResultSet resultSet = null;
|
||||
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
||||
public PlayerProfile loadPlayerProfile(String playerName, boolean createNew);
|
||||
|
||||
switch (update) {
|
||||
case BLAST_MINING:
|
||||
sql = "SELECT * FROM `" + tablePrefix + "cooldowns` ORDER BY `" + tablePrefix + "cooldowns`.`blast_mining` ASC LIMIT 0 , 30";
|
||||
break;
|
||||
/**
|
||||
* Get all users currently stored in the database.
|
||||
*
|
||||
* @return list of playernames
|
||||
*/
|
||||
public List<String> getStoredUsers();
|
||||
|
||||
case CASCADE_DELETE:
|
||||
write("ALTER TABLE `" + tablePrefix + "huds` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
|
||||
write("ALTER TABLE `" + tablePrefix + "experience` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
|
||||
write("ALTER TABLE `" + tablePrefix + "cooldowns` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
|
||||
write("ALTER TABLE `" + tablePrefix + "skills` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
|
||||
break;
|
||||
/**
|
||||
* Convert all users from this database to the provided database using
|
||||
* {@link #saveUser(PlayerProfile)}.
|
||||
*
|
||||
* @param destination The DatabaseManager to save to
|
||||
*/
|
||||
public void convertUsers(DatabaseManager destination);
|
||||
|
||||
case FISHING:
|
||||
sql = "SELECT * FROM `" + tablePrefix + "experience` ORDER BY `" + tablePrefix + "experience`.`fishing` ASC LIMIT 0 , 30";
|
||||
break;
|
||||
|
||||
case INDEX:
|
||||
if (read("SHOW INDEX FROM " + tablePrefix + "skills").size() != 13 && checkConnected()) {
|
||||
mcMMO.p.getLogger().info("Indexing tables, this may take a while on larger databases");
|
||||
write("ALTER TABLE `" + tablePrefix + "skills` ADD INDEX `idx_taming` (`taming`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_mining` (`mining`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_woodcutting` (`woodcutting`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_repair` (`repair`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_unarmed` (`unarmed`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_herbalism` (`herbalism`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_excavation` (`excavation`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_archery` (`archery`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_swords` (`swords`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_axes` (`axes`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_acrobatics` (`acrobatics`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_fishing` (`fishing`) USING BTREE;");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
if (!checkConnected()) {
|
||||
return;
|
||||
}
|
||||
|
||||
statement = connection.prepareStatement(sql);
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
while (resultSet.next()) {
|
||||
ArrayList<String> column = new ArrayList<String>();
|
||||
|
||||
for (int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) {
|
||||
column.add(resultSet.getString(i));
|
||||
}
|
||||
|
||||
rows.put(resultSet.getRow(), column);
|
||||
}
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
switch (update) {
|
||||
case BLAST_MINING:
|
||||
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Blast Mining...");
|
||||
write("ALTER TABLE `"+tablePrefix + "cooldowns` ADD `blast_mining` int(32) NOT NULL DEFAULT '0' ;");
|
||||
break;
|
||||
|
||||
case FISHING:
|
||||
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Fishing...");
|
||||
write("ALTER TABLE `"+tablePrefix + "skills` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
|
||||
write("ALTER TABLE `"+tablePrefix + "experience` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore the error, we're leaving
|
||||
}
|
||||
}
|
||||
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore the error, we're leaving
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void printErrors(SQLException ex) {
|
||||
mcMMO.p.getLogger().severe("SQLException: " + ex.getMessage());
|
||||
mcMMO.p.getLogger().severe("SQLState: " + ex.getSQLState());
|
||||
mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode());
|
||||
}
|
||||
/**
|
||||
* Retrieve the type of database in use. Custom databases should return CUSTOM.
|
||||
*
|
||||
* @return The type of database
|
||||
*/
|
||||
public DatabaseType getDatabaseType();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.gmail.nossr50.database;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
||||
|
||||
public class DatabaseManagerFactory {
|
||||
private static Class<? extends DatabaseManager> customManager = null;
|
||||
|
||||
public static DatabaseManager getDatabaseManager() {
|
||||
if (customManager != null) {
|
||||
try {
|
||||
return createCustomDatabaseManager(customManager);
|
||||
}
|
||||
catch (Exception e) {
|
||||
mcMMO.p.debug("Could not create custom database manager");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (Throwable e) {
|
||||
mcMMO.p.debug("Failed to create custom database manager");
|
||||
e.printStackTrace();
|
||||
}
|
||||
mcMMO.p.debug("Falling back on " + (Config.getInstance().getUseMySQL() ? "SQL" : "Flatfile") + " database");
|
||||
}
|
||||
|
||||
return Config.getInstance().getUseMySQL() ? new SQLDatabaseManager() : new FlatfileDatabaseManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the custom DatabaseManager class for mcMMO to use. This should be
|
||||
* called prior to mcMMO enabling.
|
||||
* <p>
|
||||
* The provided class must have an empty constructor, which is the one
|
||||
* that will be used.
|
||||
* <p>
|
||||
* This method is intended for API use, but it should not be considered
|
||||
* stable. This method is subject to change and/or removal in future
|
||||
* versions.
|
||||
*
|
||||
* @param clazz the DatabaseManager class to use
|
||||
* @throws IllegalArgumentException if the provided class does not have
|
||||
* an empty constructor
|
||||
*/
|
||||
public static void setCustomDatabaseManagerClass(Class<? extends DatabaseManager> clazz) {
|
||||
try {
|
||||
clazz.getConstructor((Class<?>) null);
|
||||
customManager = clazz;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
throw new IllegalArgumentException("Provided database manager class must have an empty constructor", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Class<? extends DatabaseManager> getCustomDatabaseManagerClass() {
|
||||
return customManager;
|
||||
}
|
||||
|
||||
public static DatabaseManager createDatabaseManager(DatabaseType type) {
|
||||
switch (type) {
|
||||
case FLATFILE:
|
||||
return new FlatfileDatabaseManager();
|
||||
|
||||
case SQL:
|
||||
return new SQLDatabaseManager();
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Why is clazz never used here?
|
||||
public static DatabaseManager createCustomDatabaseManager(Class<? extends DatabaseManager> clazz) throws Throwable {
|
||||
return customManager.getConstructor((Class<?>) clazz).newInstance((Object[]) null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,801 @@
|
||||
package com.gmail.nossr50.database;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
private final HashMap<SkillType, List<PlayerStat>> playerStatHash = new HashMap<SkillType, List<PlayerStat>>();
|
||||
private final List<PlayerStat> powerLevels = new ArrayList<PlayerStat>();
|
||||
private long lastUpdate = 0;
|
||||
|
||||
private final long UPDATE_WAIT_TIME = 600000L; // 10 minutes
|
||||
private final File usersFile;
|
||||
private static final Object fileWritingLock = new Object();
|
||||
|
||||
protected FlatfileDatabaseManager() {
|
||||
usersFile = new File(mcMMO.getUsersFilePath());
|
||||
checkStructure();
|
||||
updateLeaderboards();
|
||||
}
|
||||
|
||||
public void purgePowerlessUsers() {
|
||||
int purgedUsers = 0;
|
||||
|
||||
mcMMO.p.getLogger().info("Purging powerless users...");
|
||||
|
||||
BufferedReader in = null;
|
||||
FileWriter out = null;
|
||||
String usersFilePath = mcMMO.getUsersFilePath();
|
||||
|
||||
// This code is O(n) instead of O(n²)
|
||||
synchronized (fileWritingLock) {
|
||||
try {
|
||||
in = new BufferedReader(new FileReader(usersFilePath));
|
||||
StringBuilder writer = new StringBuilder();
|
||||
String line = "";
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
String[] character = line.split(":");
|
||||
Map<SkillType, Integer> skills = getSkillMapFromLine(character);
|
||||
|
||||
boolean powerless = true;
|
||||
for (int skill : skills.values()) {
|
||||
if (skill != 0) {
|
||||
powerless = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If they're still around, rewrite them to the file.
|
||||
if (!powerless) {
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
else {
|
||||
purgedUsers++;
|
||||
Misc.profileCleanup(character[0]);
|
||||
}
|
||||
}
|
||||
|
||||
// Write the new file
|
||||
out = new FileWriter(usersFilePath);
|
||||
out.write(writer.toString());
|
||||
}
|
||||
catch (IOException e) {
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
finally {
|
||||
tryClose(in);
|
||||
tryClose(out);
|
||||
}
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
||||
}
|
||||
|
||||
public void purgeOldUsers() {
|
||||
int removedPlayers = 0;
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
mcMMO.p.getLogger().info("Purging old users...");
|
||||
|
||||
BufferedReader in = null;
|
||||
FileWriter out = null;
|
||||
String usersFilePath = mcMMO.getUsersFilePath();
|
||||
|
||||
// This code is O(n) instead of O(n²)
|
||||
synchronized (fileWritingLock) {
|
||||
try {
|
||||
in = new BufferedReader(new FileReader(usersFilePath));
|
||||
StringBuilder writer = new StringBuilder();
|
||||
String line = "";
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
String[] character = line.split(":");
|
||||
String name = character[0];
|
||||
long lastPlayed = 0;
|
||||
boolean rewrite = false;
|
||||
try {
|
||||
lastPlayed = Long.parseLong(character[37]) * Misc.TIME_CONVERSION_FACTOR;
|
||||
}
|
||||
catch (NumberFormatException e) {}
|
||||
if (lastPlayed == 0) {
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
||||
lastPlayed = player.getLastPlayed();
|
||||
rewrite = true;
|
||||
}
|
||||
|
||||
if (currentTime - lastPlayed > PURGE_TIME) {
|
||||
removedPlayers++;
|
||||
Misc.profileCleanup(name);
|
||||
}
|
||||
else {
|
||||
if (rewrite) {
|
||||
// Rewrite their data with a valid time
|
||||
character[37] = Long.toString(lastPlayed);
|
||||
String newLine = org.apache.commons.lang.StringUtils.join(character, ":");
|
||||
writer.append(newLine).append("\r\n");
|
||||
}
|
||||
else {
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Write the new file
|
||||
out = new FileWriter(usersFilePath);
|
||||
out.write(writer.toString());
|
||||
}
|
||||
catch (IOException e) {
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
finally {
|
||||
tryClose(in);
|
||||
tryClose(out);
|
||||
}
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("Purged " + removedPlayers + " users from the database.");
|
||||
}
|
||||
|
||||
public boolean removeUser(String playerName) {
|
||||
boolean worked = false;
|
||||
|
||||
BufferedReader in = null;
|
||||
FileWriter out = null;
|
||||
String usersFilePath = mcMMO.getUsersFilePath();
|
||||
|
||||
synchronized (fileWritingLock) {
|
||||
try {
|
||||
in = new BufferedReader(new FileReader(usersFilePath));
|
||||
StringBuilder writer = new StringBuilder();
|
||||
String line = "";
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
// Write out the same file but when we get to the player we want to remove, we skip his line.
|
||||
if (!worked && line.split(":")[0].equalsIgnoreCase(playerName)) {
|
||||
mcMMO.p.getLogger().info("User found, removing...");
|
||||
worked = true;
|
||||
continue; // Skip the player
|
||||
}
|
||||
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
|
||||
out = new FileWriter(usersFilePath); // Write out the new file
|
||||
out.write(writer.toString());
|
||||
}
|
||||
catch (Exception e) {
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
finally {
|
||||
tryClose(in);
|
||||
tryClose(out);
|
||||
}
|
||||
}
|
||||
|
||||
Misc.profileCleanup(playerName);
|
||||
|
||||
return worked;
|
||||
}
|
||||
|
||||
public void saveUser(PlayerProfile profile) {
|
||||
String playerName = profile.getPlayerName();
|
||||
|
||||
BufferedReader in = null;
|
||||
FileWriter out = null;
|
||||
String usersFilePath = mcMMO.getUsersFilePath();
|
||||
|
||||
synchronized (fileWritingLock) {
|
||||
try {
|
||||
// Open the file
|
||||
in = new BufferedReader(new FileReader(usersFilePath));
|
||||
StringBuilder writer = new StringBuilder();
|
||||
String line;
|
||||
|
||||
// While not at the end of the file
|
||||
while ((line = in.readLine()) != null) {
|
||||
// Read the line in and copy it to the output it's not the player we want to edit
|
||||
if (!line.split(":")[0].equalsIgnoreCase(playerName)) {
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
else {
|
||||
// Otherwise write the new player information
|
||||
writer.append(playerName).append(":");
|
||||
writer.append(profile.getSkillLevel(SkillType.MINING)).append(":");
|
||||
writer.append(":");
|
||||
writer.append(":");
|
||||
writer.append(profile.getSkillXpLevel(SkillType.MINING)).append(":");
|
||||
writer.append(profile.getSkillLevel(SkillType.WOODCUTTING)).append(":");
|
||||
writer.append(profile.getSkillXpLevel(SkillType.WOODCUTTING)).append(":");
|
||||
writer.append(profile.getSkillLevel(SkillType.REPAIR)).append(":");
|
||||
writer.append(profile.getSkillLevel(SkillType.UNARMED)).append(":");
|
||||
writer.append(profile.getSkillLevel(SkillType.HERBALISM)).append(":");
|
||||
writer.append(profile.getSkillLevel(SkillType.EXCAVATION)).append(":");
|
||||
writer.append(profile.getSkillLevel(SkillType.ARCHERY)).append(":");
|
||||
writer.append(profile.getSkillLevel(SkillType.SWORDS)).append(":");
|
||||
writer.append(profile.getSkillLevel(SkillType.AXES)).append(":");
|
||||
writer.append(profile.getSkillLevel(SkillType.ACROBATICS)).append(":");
|
||||
writer.append(profile.getSkillXpLevel(SkillType.REPAIR)).append(":");
|
||||
writer.append(profile.getSkillXpLevel(SkillType.UNARMED)).append(":");
|
||||
writer.append(profile.getSkillXpLevel(SkillType.HERBALISM)).append(":");
|
||||
writer.append(profile.getSkillXpLevel(SkillType.EXCAVATION)).append(":");
|
||||
writer.append(profile.getSkillXpLevel(SkillType.ARCHERY)).append(":");
|
||||
writer.append(profile.getSkillXpLevel(SkillType.SWORDS)).append(":");
|
||||
writer.append(profile.getSkillXpLevel(SkillType.AXES)).append(":");
|
||||
writer.append(profile.getSkillXpLevel(SkillType.ACROBATICS)).append(":");
|
||||
writer.append(":");
|
||||
writer.append(profile.getSkillLevel(SkillType.TAMING)).append(":");
|
||||
writer.append(profile.getSkillXpLevel(SkillType.TAMING)).append(":");
|
||||
writer.append((int) profile.getSkillDATS(AbilityType.BERSERK)).append(":");
|
||||
writer.append((int) profile.getSkillDATS(AbilityType.GIGA_DRILL_BREAKER)).append(":");
|
||||
writer.append((int) profile.getSkillDATS(AbilityType.TREE_FELLER)).append(":");
|
||||
writer.append((int) profile.getSkillDATS(AbilityType.GREEN_TERRA)).append(":");
|
||||
writer.append((int) profile.getSkillDATS(AbilityType.SERRATED_STRIKES)).append(":");
|
||||
writer.append((int) profile.getSkillDATS(AbilityType.SKULL_SPLITTER)).append(":");
|
||||
writer.append((int) profile.getSkillDATS(AbilityType.SUPER_BREAKER)).append(":");
|
||||
HudType hudType = profile.getHudType();
|
||||
writer.append(hudType == null ? "STANDARD" : hudType.toString()).append(":");
|
||||
writer.append(profile.getSkillLevel(SkillType.FISHING)).append(":");
|
||||
writer.append(profile.getSkillXpLevel(SkillType.FISHING)).append(":");
|
||||
writer.append((int) profile.getSkillDATS(AbilityType.BLAST_MINING)).append(":");
|
||||
writer.append(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR).append(":");
|
||||
MobHealthbarType mobHealthbarType = profile.getMobHealthbarType();
|
||||
writer.append(mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()).append(":");
|
||||
writer.append("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Write the new file
|
||||
out = new FileWriter(usersFilePath);
|
||||
out.write(writer.toString());
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
tryClose(in);
|
||||
tryClose(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<PlayerStat> readLeaderboard(String skillName, int pageNumber, int statsPerPage) {
|
||||
updateLeaderboards();
|
||||
List<PlayerStat> statsList = skillName.equalsIgnoreCase("all") ? powerLevels : playerStatHash.get(SkillType.getSkill(skillName));
|
||||
int fromIndex = (Math.max(pageNumber, 1) - 1) * statsPerPage;
|
||||
|
||||
return statsList.subList(Math.min(fromIndex, statsList.size()), Math.min(fromIndex + statsPerPage, statsList.size()));
|
||||
}
|
||||
|
||||
public Map<String, Integer> readRank(String playerName) {
|
||||
updateLeaderboards();
|
||||
|
||||
Map<String, Integer> skills = new HashMap<String, Integer>();
|
||||
|
||||
for (SkillType skill : SkillType.nonChildSkills()) {
|
||||
skills.put(skill.name(), getPlayerRank(playerName, playerStatHash.get(skill)));
|
||||
}
|
||||
|
||||
skills.put("ALL", getPlayerRank(playerName, powerLevels));
|
||||
|
||||
return skills;
|
||||
}
|
||||
|
||||
public void newUser(String playerName) {
|
||||
BufferedWriter out = null;
|
||||
synchronized (fileWritingLock) {
|
||||
try {
|
||||
// Open the file to write the player
|
||||
out = new BufferedWriter(new FileWriter(mcMMO.getUsersFilePath(), true));
|
||||
|
||||
// Add the player to the end
|
||||
out.append(playerName).append(":");
|
||||
out.append("0:"); // Mining
|
||||
out.append(":");
|
||||
out.append(":");
|
||||
out.append("0:"); // Xp
|
||||
out.append("0:"); // Woodcutting
|
||||
out.append("0:"); // WoodCuttingXp
|
||||
out.append("0:"); // Repair
|
||||
out.append("0:"); // Unarmed
|
||||
out.append("0:"); // Herbalism
|
||||
out.append("0:"); // Excavation
|
||||
out.append("0:"); // Archery
|
||||
out.append("0:"); // Swords
|
||||
out.append("0:"); // Axes
|
||||
out.append("0:"); // Acrobatics
|
||||
out.append("0:"); // RepairXp
|
||||
out.append("0:"); // UnarmedXp
|
||||
out.append("0:"); // HerbalismXp
|
||||
out.append("0:"); // ExcavationXp
|
||||
out.append("0:"); // ArcheryXp
|
||||
out.append("0:"); // SwordsXp
|
||||
out.append("0:"); // AxesXp
|
||||
out.append("0:"); // AcrobaticsXp
|
||||
out.append(":");
|
||||
out.append("0:"); // Taming
|
||||
out.append("0:"); // TamingXp
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("STANDARD").append(":"); // HUD
|
||||
out.append("0:"); // Fishing
|
||||
out.append("0:"); // FishingXp
|
||||
out.append("0:"); // Blast Mining
|
||||
out.append(String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)).append(":"); // LastLogin
|
||||
out.append(Config.getInstance().getMobHealthbarDefault().toString()).append(":"); // Mob Healthbar HUD
|
||||
|
||||
// Add more in the same format as the line above
|
||||
|
||||
out.newLine();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
tryClose(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerProfile loadPlayerProfile(String playerName, boolean create) {
|
||||
BufferedReader in = null;
|
||||
String usersFilePath = mcMMO.getUsersFilePath();
|
||||
|
||||
synchronized (fileWritingLock) {
|
||||
try {
|
||||
// Open the user file
|
||||
in = new BufferedReader(new FileReader(usersFilePath));
|
||||
String line;
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
// Find if the line contains the player we want.
|
||||
String[] character = line.split(":");
|
||||
|
||||
if (!character[0].equalsIgnoreCase(playerName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PlayerProfile p = loadFromLine(character);
|
||||
in.close();
|
||||
return p;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
tryClose(in);
|
||||
}
|
||||
}
|
||||
|
||||
if (create) {
|
||||
newUser(playerName);
|
||||
return new PlayerProfile(playerName, true);
|
||||
}
|
||||
return new PlayerProfile(playerName);
|
||||
}
|
||||
|
||||
public void convertUsers(DatabaseManager destination) {
|
||||
BufferedReader in = null;
|
||||
String usersFilePath = mcMMO.getUsersFilePath();
|
||||
|
||||
synchronized (fileWritingLock) {
|
||||
try {
|
||||
// Open the user file
|
||||
in = new BufferedReader(new FileReader(usersFilePath));
|
||||
String line;
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
String[] character = line.split(":");
|
||||
|
||||
try {
|
||||
destination.saveUser(loadFromLine(character));
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
tryClose(in);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkConnected() {
|
||||
// Not implemented
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> getStoredUsers() {
|
||||
ArrayList<String> users = new ArrayList<String>();
|
||||
BufferedReader in = null;
|
||||
String usersFilePath = mcMMO.getUsersFilePath();
|
||||
|
||||
synchronized (fileWritingLock) {
|
||||
try {
|
||||
// Open the user file
|
||||
in = new BufferedReader(new FileReader(usersFilePath));
|
||||
String line;
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
String[] character = line.split(":");
|
||||
users.add(character[0]);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
tryClose(in);
|
||||
}
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the leader boards.
|
||||
*/
|
||||
private void updateLeaderboards() {
|
||||
// Only update FFS leaderboards every 10 minutes.. this puts a lot of strain on the server (depending on the size of the database) and should not be done frequently
|
||||
if (System.currentTimeMillis() < lastUpdate + UPDATE_WAIT_TIME) {
|
||||
return;
|
||||
}
|
||||
|
||||
String usersFilePath = mcMMO.getUsersFilePath();
|
||||
lastUpdate = System.currentTimeMillis(); // Log when the last update was run
|
||||
powerLevels.clear(); // Clear old values from the power levels
|
||||
|
||||
// Initialize lists
|
||||
List<PlayerStat> mining = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> woodcutting = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> herbalism = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> excavation = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> acrobatics = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> repair = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> swords = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> axes = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> archery = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> unarmed = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> taming = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> fishing = new ArrayList<PlayerStat>();
|
||||
|
||||
BufferedReader in = null;
|
||||
// Read from the FlatFile database and fill our arrays with information
|
||||
synchronized (fileWritingLock) {
|
||||
try {
|
||||
in = new BufferedReader(new FileReader(usersFilePath));
|
||||
String line = "";
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
String[] data = line.split(":");
|
||||
String playerName = data[0];
|
||||
int powerLevel = 0;
|
||||
|
||||
Map<SkillType, Integer> skills = getSkillMapFromLine(data);
|
||||
|
||||
powerLevel += putStat(acrobatics, playerName, skills.get(SkillType.ACROBATICS));
|
||||
powerLevel += putStat(archery, playerName, skills.get(SkillType.ARCHERY));
|
||||
powerLevel += putStat(axes, playerName, skills.get(SkillType.AXES));
|
||||
powerLevel += putStat(excavation, playerName, skills.get(SkillType.EXCAVATION));
|
||||
powerLevel += putStat(fishing, playerName, skills.get(SkillType.FISHING));
|
||||
powerLevel += putStat(herbalism, playerName, skills.get(SkillType.HERBALISM));
|
||||
powerLevel += putStat(mining, playerName, skills.get(SkillType.MINING));
|
||||
powerLevel += putStat(repair, playerName, skills.get(SkillType.REPAIR));
|
||||
powerLevel += putStat(swords, playerName, skills.get(SkillType.SWORDS));
|
||||
powerLevel += putStat(taming, playerName, skills.get(SkillType.TAMING));
|
||||
powerLevel += putStat(unarmed, playerName, skills.get(SkillType.UNARMED));
|
||||
powerLevel += putStat(woodcutting, playerName, skills.get(SkillType.WOODCUTTING));
|
||||
|
||||
putStat(powerLevels, playerName, powerLevel);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
finally {
|
||||
tryClose(in);
|
||||
}
|
||||
}
|
||||
|
||||
SkillComparator c = new SkillComparator();
|
||||
|
||||
Collections.sort(mining, c);
|
||||
Collections.sort(woodcutting, c);
|
||||
Collections.sort(repair, c);
|
||||
Collections.sort(unarmed, c);
|
||||
Collections.sort(herbalism, c);
|
||||
Collections.sort(excavation, c);
|
||||
Collections.sort(archery, c);
|
||||
Collections.sort(swords, c);
|
||||
Collections.sort(axes, c);
|
||||
Collections.sort(acrobatics, c);
|
||||
Collections.sort(taming, c);
|
||||
Collections.sort(fishing, c);
|
||||
Collections.sort(powerLevels, c);
|
||||
|
||||
playerStatHash.put(SkillType.MINING, mining);
|
||||
playerStatHash.put(SkillType.WOODCUTTING, woodcutting);
|
||||
playerStatHash.put(SkillType.REPAIR, repair);
|
||||
playerStatHash.put(SkillType.UNARMED, unarmed);
|
||||
playerStatHash.put(SkillType.HERBALISM, herbalism);
|
||||
playerStatHash.put(SkillType.EXCAVATION, excavation);
|
||||
playerStatHash.put(SkillType.ARCHERY, archery);
|
||||
playerStatHash.put(SkillType.SWORDS, swords);
|
||||
playerStatHash.put(SkillType.AXES, axes);
|
||||
playerStatHash.put(SkillType.ACROBATICS, acrobatics);
|
||||
playerStatHash.put(SkillType.TAMING, taming);
|
||||
playerStatHash.put(SkillType.FISHING, fishing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the file is present and valid
|
||||
*/
|
||||
private void checkStructure() {
|
||||
if (usersFile.exists()) {
|
||||
BufferedReader in = null;
|
||||
FileWriter out = null;
|
||||
String usersFilePath = mcMMO.getUsersFilePath();
|
||||
|
||||
synchronized (fileWritingLock) {
|
||||
try {
|
||||
in = new BufferedReader(new FileReader(usersFilePath));
|
||||
StringBuilder writer = new StringBuilder();
|
||||
String line = "";
|
||||
HashSet<String> players = new HashSet<String>();
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
// Length checks depend on last character being ':'
|
||||
if (line.charAt(line.length() - 1) != ':') {
|
||||
line = line + ":";
|
||||
}
|
||||
String[] character = line.split(":");
|
||||
|
||||
// Prevent the same player from being present multiple times
|
||||
if (!players.add(character[0])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If they're valid, rewrite them to the file.
|
||||
if (character.length > 38) {
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
else if (character.length < 33) {
|
||||
// Before Version 1.0 - Drop
|
||||
mcMMO.p.getLogger().warning("Dropping malformed or before version 1.0 line from database - " + line);
|
||||
}
|
||||
else {
|
||||
String oldVersion = null;
|
||||
StringBuilder newLine = new StringBuilder(line);
|
||||
boolean announce = false;
|
||||
if (character.length <= 33) {
|
||||
// Introduction of HUDType
|
||||
// Version 1.1.06
|
||||
// commit 78f79213cdd7190cd11ae54526f3b4ea42078e8a
|
||||
newLine.append("STANDARD").append(":");
|
||||
oldVersion = "1.1.06";
|
||||
}
|
||||
if (character.length <= 35) {
|
||||
// Introduction of Fishing
|
||||
// Version 1.2.00
|
||||
// commit a814b57311bc7734661109f0e77fc8bab3a0bd29
|
||||
newLine.append(0).append(":");
|
||||
newLine.append(0).append(":");
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.2.00";
|
||||
}
|
||||
}
|
||||
if (character.length <= 36) {
|
||||
// Introduction of Blast Mining cooldowns
|
||||
// Version 1.3.00-dev
|
||||
// commit fadbaf429d6b4764b8f1ad0efaa524a090e82ef5
|
||||
newLine.append(0).append(":");
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.3.00";
|
||||
}
|
||||
}
|
||||
if (character.length <= 37) {
|
||||
// Making old-purge work with flatfile
|
||||
// Version 1.4.00-dev
|
||||
// commmit 3f6c07ba6aaf44e388cc3b882cac3d8f51d0ac28
|
||||
// XXX Cannot create an OfflinePlayer at startup, use 0 and fix in purge
|
||||
newLine.append("0").append(":");
|
||||
announce = true; // TODO move this down
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.4.00";
|
||||
}
|
||||
}
|
||||
if (character.length <= 38) {
|
||||
// Addition of mob healthbars
|
||||
// Version 1.4.06
|
||||
// commit da29185b7dc7e0d992754bba555576d48fa08aa6
|
||||
newLine.append(Config.getInstance().getMobHealthbarDefault().toString()).append(":");
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.4.06";
|
||||
}
|
||||
}
|
||||
|
||||
if (announce) {
|
||||
mcMMO.p.debug("Updating database line for player " + character[0] + " from before version " + oldVersion);
|
||||
}
|
||||
writer.append(newLine).append("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Write the new file
|
||||
out = new FileWriter(usersFilePath);
|
||||
out.write(writer.toString());
|
||||
}
|
||||
catch (IOException e) {
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
finally {
|
||||
tryClose(in);
|
||||
tryClose(out);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
usersFile.getParentFile().mkdir();
|
||||
|
||||
try {
|
||||
mcMMO.p.debug("Creating mcmmo.users file...");
|
||||
new File(mcMMO.getUsersFilePath()).createNewFile();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void tryClose(Closeable c) {
|
||||
if (c == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
c.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private Integer getPlayerRank(String playerName, List<PlayerStat> statsList) {
|
||||
if (statsList == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int currentPos = 1;
|
||||
|
||||
for (PlayerStat stat : statsList) {
|
||||
if (stat.name.equalsIgnoreCase(playerName)) {
|
||||
return currentPos;
|
||||
}
|
||||
|
||||
currentPos++;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private int putStat(List<PlayerStat> statList, String playerName, int statValue) {
|
||||
statList.add(new PlayerStat(playerName, statValue));
|
||||
return statValue;
|
||||
}
|
||||
|
||||
private class SkillComparator implements Comparator<PlayerStat> {
|
||||
@Override
|
||||
public int compare(PlayerStat o1, PlayerStat o2) {
|
||||
return (o2.statVal - o1.statVal);
|
||||
}
|
||||
}
|
||||
|
||||
private PlayerProfile loadFromLine(String[] character) throws Exception {
|
||||
Map<SkillType, Integer> skills = getSkillMapFromLine(character); // Skill levels
|
||||
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
|
||||
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
|
||||
HudType hudType;
|
||||
MobHealthbarType mobHealthbarType;
|
||||
|
||||
// TODO on updates, put new values in a try{} ?
|
||||
|
||||
skillsXp.put(SkillType.TAMING, (float) Integer.valueOf(character[25]));
|
||||
skillsXp.put(SkillType.MINING, (float) Integer.valueOf(character[4]));
|
||||
skillsXp.put(SkillType.REPAIR, (float) Integer.valueOf(character[15]));
|
||||
skillsXp.put(SkillType.WOODCUTTING, (float) Integer.valueOf(character[6]));
|
||||
skillsXp.put(SkillType.UNARMED, (float) Integer.valueOf(character[16]));
|
||||
skillsXp.put(SkillType.HERBALISM, (float) Integer.valueOf(character[17]));
|
||||
skillsXp.put(SkillType.EXCAVATION, (float) Integer.valueOf(character[18]));
|
||||
skillsXp.put(SkillType.ARCHERY, (float) Integer.valueOf(character[19]));
|
||||
skillsXp.put(SkillType.SWORDS, (float) Integer.valueOf(character[20]));
|
||||
skillsXp.put(SkillType.AXES, (float) Integer.valueOf(character[21]));
|
||||
skillsXp.put(SkillType.ACROBATICS, (float) Integer.valueOf(character[22]));
|
||||
skillsXp.put(SkillType.FISHING, (float) Integer.valueOf(character[35]));
|
||||
|
||||
// Taming - Unused
|
||||
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(character[32]));
|
||||
// Repair - Unused
|
||||
skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(character[28]));
|
||||
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(character[26]));
|
||||
skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(character[29]));
|
||||
skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(character[27]));
|
||||
// Archery - Unused
|
||||
skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(character[30]));
|
||||
skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(character[31]));
|
||||
// Acrobatics - Unused
|
||||
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[36]));
|
||||
|
||||
try {
|
||||
hudType = HudType.valueOf(character[33]);
|
||||
}
|
||||
catch (Exception e) {
|
||||
hudType = HudType.STANDARD; // Shouldn't happen unless database is being tampered with
|
||||
}
|
||||
|
||||
try {
|
||||
mobHealthbarType = MobHealthbarType.valueOf(character[38]);
|
||||
}
|
||||
catch (Exception e) {
|
||||
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
||||
}
|
||||
|
||||
return new PlayerProfile(character[0], skills, skillsXp, skillsDATS, hudType, mobHealthbarType);
|
||||
}
|
||||
|
||||
private Map<SkillType, Integer> getSkillMapFromLine(String[] character) {
|
||||
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skill & Level
|
||||
|
||||
skills.put(SkillType.TAMING, Integer.valueOf(character[24]));
|
||||
skills.put(SkillType.MINING, Integer.valueOf(character[1]));
|
||||
skills.put(SkillType.REPAIR, Integer.valueOf(character[7]));
|
||||
skills.put(SkillType.WOODCUTTING, Integer.valueOf(character[5]));
|
||||
skills.put(SkillType.UNARMED, Integer.valueOf(character[8]));
|
||||
skills.put(SkillType.HERBALISM, Integer.valueOf(character[9]));
|
||||
skills.put(SkillType.EXCAVATION, Integer.valueOf(character[10]));
|
||||
skills.put(SkillType.ARCHERY, Integer.valueOf(character[11]));
|
||||
skills.put(SkillType.SWORDS, Integer.valueOf(character[12]));
|
||||
skills.put(SkillType.AXES, Integer.valueOf(character[13]));
|
||||
skills.put(SkillType.ACROBATICS, Integer.valueOf(character[14]));
|
||||
skills.put(SkillType.FISHING, Integer.valueOf(character[34]));
|
||||
|
||||
return skills;
|
||||
}
|
||||
|
||||
public DatabaseType getDatabaseType() {
|
||||
return DatabaseType.FLATFILE;
|
||||
}
|
||||
}
|
||||
@@ -1,377 +0,0 @@
|
||||
package com.gmail.nossr50.database;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public final class LeaderboardManager {
|
||||
private static HashMap<SkillType, List<PlayerStat>> playerStatHash = new HashMap<SkillType, List<PlayerStat>>();
|
||||
private static List<PlayerStat> powerLevels = new ArrayList<PlayerStat>();
|
||||
private static long lastUpdate = 0;
|
||||
|
||||
private static final long UPDATE_WAIT_TIME = 600000L; // 10 minutes
|
||||
private static final long ONE_MONTH = 2630000000L;
|
||||
|
||||
private LeaderboardManager() {}
|
||||
|
||||
/**
|
||||
* Update the leader boards.
|
||||
*/
|
||||
public static void updateLeaderboards() {
|
||||
// Only update FFS leaderboards every 10 minutes.. this puts a lot of strain on the server (depending on the size of the database) and should not be done frequently
|
||||
if (System.currentTimeMillis() < lastUpdate + UPDATE_WAIT_TIME) {
|
||||
return;
|
||||
}
|
||||
|
||||
lastUpdate = System.currentTimeMillis(); // Log when the last update was run
|
||||
powerLevels.clear(); // Clear old values from the power levels
|
||||
|
||||
// Initialize lists
|
||||
List<PlayerStat> mining = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> woodcutting = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> herbalism = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> excavation = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> acrobatics = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> repair = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> swords = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> axes = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> archery = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> unarmed = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> taming = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> fishing = new ArrayList<PlayerStat>();
|
||||
|
||||
// Read from the FlatFile database and fill our arrays with information
|
||||
try {
|
||||
FileReader file = new FileReader(mcMMO.getUsersFilePath());
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
String line = "";
|
||||
ArrayList<String> players = new ArrayList<String>();
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
String[] data = line.split(":");
|
||||
|
||||
String playerName = data[0];
|
||||
int powerLevel = 0;
|
||||
|
||||
// Prevent the same player from being added multiple times (I'd like to note that this shouldn't happen...)
|
||||
if (players.contains(playerName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
players.add(playerName);
|
||||
|
||||
if (data.length > 1 && StringUtils.isInt(data[1])) {
|
||||
mining.add(new PlayerStat(playerName, Integer.parseInt(data[1])));
|
||||
powerLevel += Integer.parseInt(data[1]);
|
||||
}
|
||||
|
||||
if (data.length > 5 && StringUtils.isInt(data[5])) {
|
||||
woodcutting.add(new PlayerStat(playerName, Integer.parseInt(data[5])));
|
||||
powerLevel += Integer.parseInt(data[5]);
|
||||
}
|
||||
|
||||
if (data.length > 7 && StringUtils.isInt(data[7])) {
|
||||
repair.add(new PlayerStat(playerName, Integer.parseInt(data[7])));
|
||||
powerLevel += Integer.parseInt(data[7]);
|
||||
}
|
||||
|
||||
if (data.length > 8 && StringUtils.isInt(data[8])) {
|
||||
unarmed.add(new PlayerStat(playerName, Integer.parseInt(data[8])));
|
||||
powerLevel += Integer.parseInt(data[8]);
|
||||
}
|
||||
|
||||
if (data.length > 9 && StringUtils.isInt(data[9])) {
|
||||
herbalism.add(new PlayerStat(playerName, Integer.parseInt(data[9])));
|
||||
powerLevel += Integer.parseInt(data[9]);
|
||||
}
|
||||
|
||||
if (data.length > 10 && StringUtils.isInt(data[10])) {
|
||||
excavation.add(new PlayerStat(playerName, Integer.parseInt(data[10])));
|
||||
powerLevel += Integer.parseInt(data[10]);
|
||||
}
|
||||
|
||||
if (data.length > 11 && StringUtils.isInt(data[11])) {
|
||||
archery.add(new PlayerStat(playerName, Integer.parseInt(data[11])));
|
||||
powerLevel += Integer.parseInt(data[11]);
|
||||
}
|
||||
|
||||
if (data.length > 12 && StringUtils.isInt(data[12])) {
|
||||
swords.add(new PlayerStat(playerName, Integer.parseInt(data[12])));
|
||||
powerLevel += Integer.parseInt(data[12]);
|
||||
}
|
||||
|
||||
if (data.length > 13 && StringUtils.isInt(data[13])) {
|
||||
axes.add(new PlayerStat(playerName, Integer.parseInt(data[13])));
|
||||
powerLevel += Integer.parseInt(data[13]);
|
||||
}
|
||||
|
||||
if (data.length > 14 && StringUtils.isInt(data[14])) {
|
||||
acrobatics.add(new PlayerStat(playerName, Integer.parseInt(data[14])));
|
||||
powerLevel += Integer.parseInt(data[14]);
|
||||
}
|
||||
|
||||
if (data.length > 24 && StringUtils.isInt(data[24])) {
|
||||
taming.add(new PlayerStat(playerName, Integer.parseInt(data[24])));
|
||||
powerLevel += Integer.parseInt(data[24]);
|
||||
}
|
||||
|
||||
if (data.length > 34 && StringUtils.isInt(data[34])) {
|
||||
fishing.add(new PlayerStat(playerName, Integer.parseInt(data[34])));
|
||||
powerLevel += Integer.parseInt(data[34]);
|
||||
}
|
||||
|
||||
powerLevels.add(new PlayerStat(playerName, powerLevel));
|
||||
}
|
||||
in.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + mcMMO.getUsersFilePath() + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
|
||||
SkillComparator c = new SkillComparator();
|
||||
|
||||
Collections.sort(mining, c);
|
||||
Collections.sort(woodcutting, c);
|
||||
Collections.sort(repair, c);
|
||||
Collections.sort(unarmed, c);
|
||||
Collections.sort(herbalism, c);
|
||||
Collections.sort(excavation, c);
|
||||
Collections.sort(archery, c);
|
||||
Collections.sort(swords, c);
|
||||
Collections.sort(axes, c);
|
||||
Collections.sort(acrobatics, c);
|
||||
Collections.sort(taming, c);
|
||||
Collections.sort(fishing, c);
|
||||
Collections.sort(powerLevels, c);
|
||||
|
||||
playerStatHash.put(SkillType.MINING, mining);
|
||||
playerStatHash.put(SkillType.WOODCUTTING, woodcutting);
|
||||
playerStatHash.put(SkillType.REPAIR, repair);
|
||||
playerStatHash.put(SkillType.UNARMED, unarmed);
|
||||
playerStatHash.put(SkillType.HERBALISM, herbalism);
|
||||
playerStatHash.put(SkillType.EXCAVATION, excavation);
|
||||
playerStatHash.put(SkillType.ARCHERY, archery);
|
||||
playerStatHash.put(SkillType.SWORDS, swords);
|
||||
playerStatHash.put(SkillType.AXES, axes);
|
||||
playerStatHash.put(SkillType.ACROBATICS, acrobatics);
|
||||
playerStatHash.put(SkillType.TAMING, taming);
|
||||
playerStatHash.put(SkillType.FISHING, fishing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve leaderboard info.
|
||||
*
|
||||
* @param skillType Skill to retrieve info on.
|
||||
* @param pageNumber Which page in the leaderboards to retrieve
|
||||
* @return the requested leaderboard information
|
||||
*/
|
||||
public static String[] retrieveInfo(String skillType, int pageNumber) {
|
||||
String[] info = new String[10];
|
||||
List<PlayerStat> statsList;
|
||||
|
||||
if (skillType.equalsIgnoreCase("all")) {
|
||||
statsList = powerLevels;
|
||||
}
|
||||
else {
|
||||
statsList = playerStatHash.get(SkillType.getSkill(skillType));
|
||||
}
|
||||
|
||||
if (pageNumber < 1) {
|
||||
pageNumber = 1;
|
||||
}
|
||||
int destination = (pageNumber - 1) * 10;
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
if (destination + i < statsList.size()) {
|
||||
PlayerStat ps = statsList.get(destination + i);
|
||||
info[i] = ps.name + ":" + ps.statVal;
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
public static int[] getPlayerRank(String playerName) {
|
||||
return getPlayerRank(playerName, powerLevels);
|
||||
}
|
||||
|
||||
public static int[] getPlayerRank(String playerName, SkillType skillType) {
|
||||
return getPlayerRank(playerName, playerStatHash.get(skillType));
|
||||
}
|
||||
|
||||
public static boolean removeFlatFileUser(String playerName) {
|
||||
boolean worked = false;
|
||||
|
||||
BufferedReader in = null;
|
||||
FileWriter out = null;
|
||||
String usersFilePath = mcMMO.getUsersFilePath();
|
||||
|
||||
try {
|
||||
FileReader file = new FileReader(usersFilePath);
|
||||
in = new BufferedReader(file);
|
||||
StringBuilder writer = new StringBuilder();
|
||||
String line = "";
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
|
||||
// Write out the same file but when we get to the player we want to remove, we skip his line.
|
||||
if (!line.split(":")[0].equalsIgnoreCase(playerName)) {
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
else {
|
||||
mcMMO.p.getLogger().info("User found, removing...");
|
||||
worked = true;
|
||||
continue; // Skip the player
|
||||
}
|
||||
}
|
||||
|
||||
out = new FileWriter(usersFilePath); // Write out the new file
|
||||
out.write(writer.toString());
|
||||
}
|
||||
catch (Exception e) {
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return worked;
|
||||
}
|
||||
|
||||
public static void purgePowerlessFlatfile() {
|
||||
mcMMO.p.getLogger().info("Purging powerless users...");
|
||||
|
||||
int purgedUsers = 0;
|
||||
|
||||
for (PlayerStat stat : powerLevels) {
|
||||
if (stat.statVal == 0 && !mcMMO.p.getServer().getOfflinePlayer(stat.name).isOnline() && removeFlatFileUser(stat.name)) {
|
||||
purgedUsers++;
|
||||
}
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
||||
}
|
||||
|
||||
public static void purgeOldFlatfile() {
|
||||
mcMMO.p.getLogger().info("Purging old users...");
|
||||
int purgedUsers = removeOldFlatfileUsers();
|
||||
mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
||||
}
|
||||
|
||||
private static int removeOldFlatfileUsers() {
|
||||
int removedPlayers = 0;
|
||||
long currentTime = System.currentTimeMillis();
|
||||
long purgeTime = ONE_MONTH * Config.getInstance().getOldUsersCutoff();
|
||||
|
||||
BufferedReader in = null;
|
||||
FileWriter out = null;
|
||||
String usersFilePath = mcMMO.getUsersFilePath();
|
||||
|
||||
try {
|
||||
FileReader file = new FileReader(usersFilePath);
|
||||
in = new BufferedReader(file);
|
||||
StringBuilder writer = new StringBuilder();
|
||||
String line = "";
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
|
||||
// Write out the same file but when we get to the player we want to remove, we skip his line.
|
||||
String[] splitLine = line.split(":");
|
||||
|
||||
if (splitLine.length > 37) {
|
||||
if (currentTime - (StringUtils.getLong(line.split(":")[37]) * 1000) <= purgeTime) {
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
else {
|
||||
mcMMO.p.getLogger().info("User found, removing...");
|
||||
removedPlayers++;
|
||||
continue; // Skip the player
|
||||
}
|
||||
}
|
||||
else {
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
out = new FileWriter(usersFilePath); // Write out the new file
|
||||
out.write(writer.toString());
|
||||
}
|
||||
catch (Exception e) {
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return removedPlayers;
|
||||
}
|
||||
|
||||
private static int[] getPlayerRank(String playerName, List<PlayerStat> statsList) {
|
||||
int currentPos = 1;
|
||||
|
||||
if (statsList == null) {
|
||||
return new int[] {0, 0};
|
||||
}
|
||||
|
||||
for (PlayerStat stat : statsList) {
|
||||
if (stat.name.equalsIgnoreCase(playerName)) {
|
||||
return new int[] {currentPos, stat.statVal};
|
||||
}
|
||||
|
||||
currentPos++;
|
||||
}
|
||||
|
||||
return new int[] {0, 0};
|
||||
}
|
||||
|
||||
private static class SkillComparator implements Comparator<PlayerStat> {
|
||||
@Override
|
||||
public int compare(PlayerStat o1, PlayerStat o2) {
|
||||
return (o2.statVal - o1.statVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
1226
src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java
Normal file
1226
src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
public enum MobHealthbarType {
|
||||
HEARTS,
|
||||
BAR,
|
||||
DISABLED;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.chat;
|
||||
package com.gmail.nossr50.datatypes.chat;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.gmail.nossr50.datatypes.database;
|
||||
|
||||
public enum DatabaseType {
|
||||
FLATFILE,
|
||||
SQL,
|
||||
CUSTOM;
|
||||
|
||||
public static DatabaseType getDatabaseType(String typeName) {
|
||||
for (DatabaseType type : values()) {
|
||||
if (type.name().equalsIgnoreCase(typeName)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeName.equalsIgnoreCase("file")) {
|
||||
return FLATFILE;
|
||||
}
|
||||
else if (typeName.equalsIgnoreCase("mysql")) {
|
||||
return SQL;
|
||||
}
|
||||
|
||||
return CUSTOM;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,9 @@ package com.gmail.nossr50.datatypes.database;
|
||||
public enum DatabaseUpdateType {
|
||||
FISHING,
|
||||
BLAST_MINING,
|
||||
CASCADE_DELETE,
|
||||
INDEX;
|
||||
INDEX,
|
||||
MOB_HEALTHBARS,
|
||||
PARTY_NAMES,
|
||||
KILL_ORPHANS,
|
||||
;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.gmail.nossr50.datatypes.experience;
|
||||
|
||||
public enum FormulaType {
|
||||
LINEAR,
|
||||
EXPONENTIAL,
|
||||
UNKNOWN;
|
||||
|
||||
public static FormulaType getFormulaType(String string) {
|
||||
try {
|
||||
return valueOf(string);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public enum ItemShareType {
|
||||
LOOT,
|
||||
MINING,
|
||||
HERBALISM,
|
||||
WOODCUTTING,
|
||||
MISC;
|
||||
|
||||
public static ItemShareType getShareType(ItemStack itemStack) {
|
||||
if (ItemUtils.isMobDrop(itemStack)) {
|
||||
return LOOT;
|
||||
}
|
||||
else if (ItemUtils.isMiningDrop(itemStack)) {
|
||||
return MINING;
|
||||
}
|
||||
else if (ItemUtils.isHerbalismDrop(itemStack)) {
|
||||
return HERBALISM;
|
||||
}
|
||||
else if (ItemUtils.isWoodcuttingDrop(itemStack)) {
|
||||
return WOODCUTTING;
|
||||
}
|
||||
else if (ItemUtils.isMiscDrop(itemStack)) {
|
||||
return MISC;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getLocaleString() {
|
||||
return LocaleLoader.getString("Party.ItemShare.Category." + StringUtils.getCapitalized(this.toString()));
|
||||
}
|
||||
}
|
||||
@@ -1,38 +1,66 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class Party {
|
||||
private List<OfflinePlayer> members = new ArrayList<OfflinePlayer>();
|
||||
private final LinkedHashSet<String> members = new LinkedHashSet<String>();
|
||||
|
||||
private String leader;
|
||||
private String name;
|
||||
private String password;
|
||||
private boolean locked;
|
||||
|
||||
private ShareHandler.ShareMode xpShareMode = ShareHandler.ShareMode.NONE;
|
||||
private ShareHandler.ShareMode itemShareMode = ShareHandler.ShareMode.NONE;
|
||||
private ShareMode xpShareMode = ShareMode.NONE;
|
||||
private ShareMode itemShareMode = ShareMode.NONE;
|
||||
|
||||
private boolean shareLootDrops = true;
|
||||
private boolean shareMiningDrops = true;
|
||||
private boolean shareHerbalismDrops = true;
|
||||
private boolean shareWoodcuttingDrops = true;
|
||||
private boolean shareMiscDrops = true;
|
||||
|
||||
public List<OfflinePlayer> getMembers() {
|
||||
public Party(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Party(String leader, String name) {
|
||||
this.leader = leader;
|
||||
this.name = name;
|
||||
this.locked = true;
|
||||
}
|
||||
|
||||
public Party(String leader, String name, String password) {
|
||||
this.leader = leader;
|
||||
this.name = name;
|
||||
this.password = password;
|
||||
this.locked = true;
|
||||
}
|
||||
|
||||
public Party(String leader, String name, String password, boolean locked) {
|
||||
this.leader = leader;
|
||||
this.name = name;
|
||||
this.password = password;
|
||||
this.locked = locked;
|
||||
}
|
||||
|
||||
public LinkedHashSet<String> getMembers() {
|
||||
return members;
|
||||
}
|
||||
|
||||
public List<Player> getOnlineMembers() {
|
||||
List<Player> onlineMembers = new ArrayList<Player>();
|
||||
|
||||
for (OfflinePlayer member : members) {
|
||||
if (member.isOnline()) {
|
||||
onlineMembers.add(member.getPlayer());
|
||||
for (String memberName : members) {
|
||||
Player member = mcMMO.p.getServer().getPlayerExact(memberName);
|
||||
|
||||
if (member != null) {
|
||||
onlineMembers.add(member);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,40 +83,13 @@ public class Party {
|
||||
return locked;
|
||||
}
|
||||
|
||||
public boolean sharingLootDrops() {
|
||||
return shareLootDrops;
|
||||
}
|
||||
|
||||
public boolean sharingMiningDrops() {
|
||||
return shareMiningDrops;
|
||||
}
|
||||
|
||||
public boolean sharingHerbalismDrops() {
|
||||
return shareHerbalismDrops;
|
||||
}
|
||||
|
||||
public boolean sharingWoodcuttingDrops() {
|
||||
return shareWoodcuttingDrops;
|
||||
}
|
||||
|
||||
public List<String> getItemShareCategories() {
|
||||
List<String> shareCategories = new ArrayList<String>();
|
||||
|
||||
// TODO Locale the category names!
|
||||
if (sharingLootDrops()) {
|
||||
shareCategories.add("Loot");
|
||||
}
|
||||
|
||||
if (sharingMiningDrops()) {
|
||||
shareCategories.add("Mining");
|
||||
}
|
||||
|
||||
if (sharingHerbalismDrops()) {
|
||||
shareCategories.add("Herbalism");
|
||||
}
|
||||
|
||||
if (sharingWoodcuttingDrops()) {
|
||||
shareCategories.add("Woodcutting");
|
||||
for (ItemShareType shareType : ItemShareType.values()) {
|
||||
if (sharingDrops(shareType)) {
|
||||
shareCategories.add(shareType.getLocaleString());
|
||||
}
|
||||
}
|
||||
|
||||
return shareCategories;
|
||||
@@ -110,35 +111,92 @@ public class Party {
|
||||
this.locked = locked;
|
||||
}
|
||||
|
||||
public void setXpShareMode(ShareHandler.ShareMode xpShareMode) {
|
||||
public void setXpShareMode(ShareMode xpShareMode) {
|
||||
this.xpShareMode = xpShareMode;
|
||||
}
|
||||
|
||||
public ShareHandler.ShareMode getXpShareMode() {
|
||||
public ShareMode getXpShareMode() {
|
||||
return xpShareMode;
|
||||
}
|
||||
|
||||
public void setItemShareMode(ShareHandler.ShareMode itemShareMode) {
|
||||
public void setItemShareMode(ShareMode itemShareMode) {
|
||||
this.itemShareMode = itemShareMode;
|
||||
}
|
||||
|
||||
public ShareHandler.ShareMode getItemShareMode() {
|
||||
public ShareMode getItemShareMode() {
|
||||
return itemShareMode;
|
||||
}
|
||||
|
||||
public void setSharingLootDrops(boolean enabled) {
|
||||
shareLootDrops = enabled;
|
||||
public boolean sharingDrops(ItemShareType shareType) {
|
||||
switch (shareType) {
|
||||
case HERBALISM:
|
||||
return shareHerbalismDrops;
|
||||
|
||||
case LOOT:
|
||||
return shareLootDrops;
|
||||
|
||||
case MINING:
|
||||
return shareMiningDrops;
|
||||
|
||||
case MISC:
|
||||
return shareMiscDrops;
|
||||
|
||||
case WOODCUTTING:
|
||||
return shareWoodcuttingDrops;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setSharingMiningDrops(boolean enabled) {
|
||||
shareMiningDrops = enabled;
|
||||
public void setSharingDrops(ItemShareType shareType, boolean enabled) {
|
||||
switch (shareType) {
|
||||
case HERBALISM:
|
||||
shareHerbalismDrops = enabled;
|
||||
break;
|
||||
|
||||
case LOOT:
|
||||
shareLootDrops = enabled;
|
||||
break;
|
||||
|
||||
case MINING:
|
||||
shareMiningDrops = enabled;
|
||||
break;
|
||||
|
||||
case MISC:
|
||||
shareMiscDrops = enabled;
|
||||
break;
|
||||
|
||||
case WOODCUTTING:
|
||||
shareWoodcuttingDrops = enabled;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void setSharingHerbalismDrops(boolean enabled) {
|
||||
shareHerbalismDrops = enabled;
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(obj instanceof Party)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Party other = (Party) obj;
|
||||
|
||||
if ((this.getName() == null) || (other.getName() == null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.getName().equals(other.getName());
|
||||
}
|
||||
|
||||
public void setSharingWoodcuttingDrops(boolean enabled) {
|
||||
shareWoodcuttingDrops = enabled;
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
|
||||
public enum ShareMode {
|
||||
NONE,
|
||||
EQUAL,
|
||||
RANDOM;
|
||||
|
||||
public static ShareMode getShareMode(String string) {
|
||||
try {
|
||||
return valueOf(string);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
if (string.equalsIgnoreCase("even")) {
|
||||
return EQUAL;
|
||||
}
|
||||
else if (CommandUtils.shouldDisableToggle(string)) {
|
||||
return NONE;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -7,10 +7,10 @@ import java.util.Set;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
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.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
@@ -18,8 +18,10 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
import com.gmail.nossr50.runnables.skills.AbilityDisableTask;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||
import com.gmail.nossr50.skills.archery.ArcheryManager;
|
||||
@@ -53,7 +55,7 @@ public class McMMOPlayer {
|
||||
* we make sure that all class inheriting from SkillManager are instanced.
|
||||
* Which solution is better, I let you decide. - bm01
|
||||
*/
|
||||
private Map<SkillType, SkillManager> skillManagers = new HashMap<SkillType, SkillManager>();
|
||||
private final Map<SkillType, SkillManager> skillManagers = new HashMap<SkillType, SkillManager>();
|
||||
|
||||
private Party party;
|
||||
private Party invite;
|
||||
@@ -63,6 +65,7 @@ public class McMMOPlayer {
|
||||
private boolean ptpEnabled = true;
|
||||
private boolean ptpConfirmRequired = Config.getInstance().getPTPCommandConfirmRequired();
|
||||
private long ptpTimeout;
|
||||
private int ptpLastUse;
|
||||
|
||||
private boolean partyChatMode;
|
||||
private boolean adminChatMode;
|
||||
@@ -70,29 +73,33 @@ public class McMMOPlayer {
|
||||
|
||||
private boolean abilityUse = true;
|
||||
private boolean placedRepairAnvil;
|
||||
private int lastRepairClick;
|
||||
private boolean placedSalvageAnvil;
|
||||
private int lastSalvageClick;
|
||||
private boolean godMode;
|
||||
|
||||
private Map<AbilityType, Boolean> abilityMode = new HashMap<AbilityType, Boolean>();
|
||||
private Map<AbilityType, Boolean> abilityInformed = new HashMap<AbilityType, Boolean>();
|
||||
private final Map<AbilityType, Boolean> abilityMode = new HashMap<AbilityType, Boolean>();
|
||||
private final Map<AbilityType, Boolean> abilityInformed = new HashMap<AbilityType, Boolean>();
|
||||
|
||||
private Map<ToolType, Boolean> toolMode = new HashMap<ToolType, Boolean>();
|
||||
private Map<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
|
||||
|
||||
private int chimaeraWing;
|
||||
private Location chimaeraWingCommence;
|
||||
private final Map<ToolType, Boolean> toolMode = new HashMap<ToolType, Boolean>();
|
||||
private final Map<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
|
||||
|
||||
private int recentlyHurt;
|
||||
private int respawnATS;
|
||||
private int teleportATS;
|
||||
private int chimeraWingLastUse;
|
||||
private Location teleportCommence;
|
||||
|
||||
private boolean isUsingUnarmed;
|
||||
|
||||
public McMMOPlayer(Player player) {
|
||||
String playerName = player.getName();
|
||||
|
||||
this.player = player;
|
||||
profile = new PlayerProfile(playerName, true);
|
||||
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, true);
|
||||
party = PartyManager.getPlayerParty(playerName);
|
||||
|
||||
/*
|
||||
/*
|
||||
* I'm using this method because it makes code shorter and safer (we don't have to add all SkillTypes manually),
|
||||
* but I actually have no idea about the performance impact, if there is any.
|
||||
* If in the future someone wants to remove this, don't forget to also remove what is in the SkillType enum. - bm01
|
||||
@@ -179,7 +186,8 @@ public class McMMOPlayer {
|
||||
*/
|
||||
public void resetAbilityMode() {
|
||||
for (AbilityType ability : AbilityType.values()) {
|
||||
setAbilityMode(ability, false);
|
||||
// Correctly disable and handle any special deactivate code
|
||||
new AbilityDisableTask(this, ability).run();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,10 +205,10 @@ public class McMMOPlayer {
|
||||
* Set the mode of an ability.
|
||||
*
|
||||
* @param ability The ability to check
|
||||
* @param bool True if the ability is active, false otherwise
|
||||
* @param isActive True if the ability is active, false otherwise
|
||||
*/
|
||||
public void setAbilityMode(AbilityType ability, boolean bool) {
|
||||
abilityMode.put(ability, bool);
|
||||
public void setAbilityMode(AbilityType ability, boolean isActive) {
|
||||
abilityMode.put(ability, isActive);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,10 +225,10 @@ public class McMMOPlayer {
|
||||
* Set the informed state of an ability.
|
||||
*
|
||||
* @param ability The ability to check
|
||||
* @param bool True if the ability is informed, false otherwise
|
||||
* @param isInformed True if the ability is informed, false otherwise
|
||||
*/
|
||||
public void setAbilityInformed(AbilityType ability, boolean bool) {
|
||||
abilityInformed.put(ability, bool);
|
||||
public void setAbilityInformed(AbilityType ability, boolean isInformed) {
|
||||
abilityInformed.put(ability, isInformed);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,10 +266,10 @@ public class McMMOPlayer {
|
||||
* Set the current prep mode of a tool.
|
||||
*
|
||||
* @param tool Tool to set the mode for
|
||||
* @param bool true if the tool should be prepped, false otherwise
|
||||
* @param isPrepared true if the tool should be prepped, false otherwise
|
||||
*/
|
||||
public void setToolPreparationMode(ToolType tool, boolean bool) {
|
||||
toolMode.put(tool, bool);
|
||||
public void setToolPreparationMode(ToolType tool, boolean isPrepared) {
|
||||
toolMode.put(tool, isPrepared);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -303,31 +311,27 @@ public class McMMOPlayer {
|
||||
}
|
||||
|
||||
/*
|
||||
* Chimaera Wing
|
||||
* Teleportation cooldown & warmup
|
||||
*/
|
||||
|
||||
public int getLastChimaeraTeleport() {
|
||||
return chimaeraWing;
|
||||
public int getChimeraWingLastUse() {
|
||||
return chimeraWingLastUse;
|
||||
}
|
||||
|
||||
public void setLastChimaeraTeleport(int value) {
|
||||
chimaeraWing = value;
|
||||
public void actualizeChimeraWingLastUse() {
|
||||
chimeraWingLastUse = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
public void actualizeLastChimaeraTeleport() {
|
||||
chimaeraWing = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
public Location getTeleportCommenceLocation() {
|
||||
return teleportCommence;
|
||||
}
|
||||
|
||||
public Location getChimaeraCommenceLocation() {
|
||||
return chimaeraWingCommence;
|
||||
public void setTeleportCommenceLocation(Location location) {
|
||||
teleportCommence = location;
|
||||
}
|
||||
|
||||
public void setChimaeraCommenceLocation(Location location) {
|
||||
chimaeraWingCommence = location;
|
||||
}
|
||||
|
||||
public void actualizeChimaeraCommenceLocation(Player player) {
|
||||
setChimaeraCommenceLocation(player.getLocation());
|
||||
public void actualizeTeleportCommenceLocation(Player player) {
|
||||
teleportCommence = player.getLocation();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -342,6 +346,14 @@ public class McMMOPlayer {
|
||||
respawnATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
public int getTeleportATS() {
|
||||
return teleportATS;
|
||||
}
|
||||
|
||||
public void actualizeTeleportATS() {
|
||||
teleportATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Repair Anvil Placement
|
||||
*/
|
||||
@@ -368,6 +380,42 @@ public class McMMOPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Repair Anvil Usage
|
||||
*/
|
||||
|
||||
public int getLastAnvilUse(int anvilId) {
|
||||
if (anvilId == Repair.repairAnvilId) {
|
||||
return lastRepairClick;
|
||||
}
|
||||
|
||||
if (anvilId == Repair.salvageAnvilId) {
|
||||
return lastSalvageClick;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setLastAnvilUse(int anvilId, int value) {
|
||||
if (anvilId == Repair.repairAnvilId) {
|
||||
lastRepairClick = value;
|
||||
}
|
||||
|
||||
if (anvilId == Repair.salvageAnvilId) {
|
||||
lastSalvageClick = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void actualizeLastAnvilUse(int anvilId) {
|
||||
if (anvilId == Repair.repairAnvilId) {
|
||||
lastRepairClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
if (anvilId == Repair.salvageAnvilId) {
|
||||
lastSalvageClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* God Mode
|
||||
*/
|
||||
@@ -400,11 +448,7 @@ public class McMMOPlayer {
|
||||
public int getPowerLevel() {
|
||||
int powerLevel = 0;
|
||||
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (SkillType type : SkillType.nonChildSkills()) {
|
||||
if (Permissions.skillEnabled(player, type)) {
|
||||
powerLevel += profile.getSkillLevel(type);
|
||||
}
|
||||
@@ -419,7 +463,7 @@ public class McMMOPlayer {
|
||||
* @param skillType Skill being used
|
||||
* @param xp Experience amount to process
|
||||
*/
|
||||
public void beginXpGain(SkillType skillType, int xp) {
|
||||
public void beginXpGain(SkillType skillType, float xp) {
|
||||
if (xp == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -450,7 +494,7 @@ public class McMMOPlayer {
|
||||
* @param skillType Skill being used
|
||||
* @param xp Experience amount to process
|
||||
*/
|
||||
public void beginUnsharedXpGain(SkillType skillType, int xp) {
|
||||
public void beginUnsharedXpGain(SkillType skillType, float xp) {
|
||||
xp = modifyXpGain(skillType, xp);
|
||||
|
||||
applyXpGain(skillType, xp);
|
||||
@@ -462,20 +506,21 @@ public class McMMOPlayer {
|
||||
* @param skillType Skill being used
|
||||
* @param xp Experience amount to add
|
||||
*/
|
||||
public void applyXpGain(SkillType skillType, int xp) {
|
||||
public void applyXpGain(SkillType skillType, float xp) {
|
||||
if (!Permissions.skillEnabled(player, skillType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (skillType.isChildSkill()) {
|
||||
Set<SkillType> parentSkills = FamilyTree.getParents(skillType);
|
||||
|
||||
for (SkillType parentSkill : parentSkills) {
|
||||
if (Permissions.skillEnabled(player, parentSkill)) {
|
||||
applyXpGain(parentSkill, xp / parentSkills.size());
|
||||
}
|
||||
applyXpGain(parentSkill, xp / parentSkills.size());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skillType, xp);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
@@ -483,7 +528,7 @@ public class McMMOPlayer {
|
||||
return;
|
||||
}
|
||||
|
||||
profile.setSkillXpLevel(skillType, profile.getSkillXpLevel(skillType) + event.getXpGained());
|
||||
profile.setSkillXpLevel(skillType, profile.getSkillXpLevelRaw(skillType) + event.getRawXpGained());
|
||||
|
||||
McMMOHud spoutHud = profile.getSpoutHud();
|
||||
|
||||
@@ -491,6 +536,7 @@ public class McMMOPlayer {
|
||||
spoutHud.setLastGained(skillType);
|
||||
}
|
||||
|
||||
isUsingUnarmed = (skillType == SkillType.UNARMED);
|
||||
SkillUtils.xpCheckSkill(skillType, player, profile);
|
||||
}
|
||||
|
||||
@@ -523,11 +569,7 @@ public class McMMOPlayer {
|
||||
}
|
||||
|
||||
public boolean hasPartyInvite() {
|
||||
if (invite != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return (invite != null);
|
||||
}
|
||||
|
||||
public void setParty(Party party) {
|
||||
@@ -539,11 +581,7 @@ public class McMMOPlayer {
|
||||
}
|
||||
|
||||
public boolean inParty() {
|
||||
if (party != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return (party != null);
|
||||
}
|
||||
|
||||
public void removeParty() {
|
||||
@@ -571,11 +609,7 @@ public class McMMOPlayer {
|
||||
}
|
||||
|
||||
public boolean hasPtpRequest() {
|
||||
if (ptpRequest != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return (ptpRequest != null);
|
||||
}
|
||||
|
||||
public void removePtpRequest() {
|
||||
@@ -590,6 +624,14 @@ public class McMMOPlayer {
|
||||
ptpConfirmRequired = !ptpConfirmRequired;
|
||||
}
|
||||
|
||||
public int getPtpLastUse() {
|
||||
return ptpLastUse;
|
||||
}
|
||||
|
||||
public void actualizePtpLastUse() {
|
||||
ptpLastUse = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
public long getPtpTimeout() {
|
||||
return ptpTimeout;
|
||||
}
|
||||
@@ -607,11 +649,7 @@ public class McMMOPlayer {
|
||||
}
|
||||
|
||||
public void setItemShareModifier(int modifier) {
|
||||
if (modifier < 10) {
|
||||
modifier = 10;
|
||||
}
|
||||
|
||||
itemShareModifier = modifier;
|
||||
itemShareModifier = Math.max(10, modifier);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -642,6 +680,10 @@ public class McMMOPlayer {
|
||||
partyChatMode = !partyChatMode;
|
||||
}
|
||||
|
||||
public boolean isUsingUnarmed() {
|
||||
return isUsingUnarmed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies an experience gain using skill modifiers, global rate and perks
|
||||
*
|
||||
@@ -649,22 +691,35 @@ public class McMMOPlayer {
|
||||
* @param xp Experience amount to process
|
||||
* @return Modified experience
|
||||
*/
|
||||
private int modifyXpGain(SkillType skillType, int xp) {
|
||||
if (player.getGameMode() == GameMode.CREATIVE || (skillType.getMaxLevel() < profile.getSkillLevel(skillType) + 1) || (Config.getInstance().getPowerLevelCap() < getPowerLevel() + 1)) {
|
||||
private float modifyXpGain(SkillType skillType, float xp) {
|
||||
if (player.getGameMode() == GameMode.CREATIVE || (skillType.getMaxLevel() <= profile.getSkillLevel(skillType)) || (Config.getInstance().getPowerLevelCap() <= getPowerLevel())) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
xp = (int) (xp / skillType.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier());
|
||||
xp = (float) (xp / skillType.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier());
|
||||
|
||||
if (Config.getInstance().getToolModsEnabled()) {
|
||||
ItemStack item = player.getItemInHand();
|
||||
CustomTool tool = ModUtils.getToolFromItemStack(item);
|
||||
CustomTool tool = ModUtils.getToolFromItemStack(player.getItemInHand());
|
||||
|
||||
if (tool != null) {
|
||||
xp *= tool.getXpMultiplier();
|
||||
}
|
||||
}
|
||||
|
||||
return PerksUtils.handleXpPerks(player, xp);
|
||||
return PerksUtils.handleXpPerks(player, xp, skillType);
|
||||
}
|
||||
|
||||
public void checkGodMode() {
|
||||
if (godMode && !Permissions.mcgod(player)) {
|
||||
toggleGodMode();
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Forbidden"));
|
||||
}
|
||||
}
|
||||
|
||||
public void checkParty() {
|
||||
if (inParty() && !Permissions.party(player)) {
|
||||
removeParty();
|
||||
player.sendMessage(LocaleLoader.getString("Party.Forbidden"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,530 +1,90 @@
|
||||
package com.gmail.nossr50.datatypes.player;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PlayerProfile {
|
||||
private String playerName;
|
||||
|
||||
// HUD
|
||||
private McMMOHud spoutHud;
|
||||
private HudType hudType;
|
||||
|
||||
// mySQL Stuff
|
||||
private int userId;
|
||||
|
||||
private final String playerName;
|
||||
private boolean loaded;
|
||||
private boolean changed;
|
||||
|
||||
private Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skills and Levels
|
||||
private Map<SkillType, Integer> skillsXp = new HashMap<SkillType, Integer>(); // Skills and Xp
|
||||
private Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>();
|
||||
/* HUDs */
|
||||
private HudType hudType;
|
||||
private MobHealthbarType mobHealthbarType;
|
||||
private McMMOHud spoutHud;
|
||||
private Scoreboard playerStatsScoreboard;
|
||||
|
||||
private final static String location = mcMMO.getUsersFilePath();
|
||||
/* Skill Data */
|
||||
private final Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skill & Level
|
||||
private final Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
|
||||
private final Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
|
||||
|
||||
public PlayerProfile(String playerName, boolean addNew) {
|
||||
public PlayerProfile(String playerName) {
|
||||
this.playerName = playerName;
|
||||
|
||||
if (mcMMO.spoutEnabled) {
|
||||
hudType = SpoutConfig.getInstance().defaultHudType;
|
||||
}
|
||||
else {
|
||||
hudType = HudType.DISABLED;
|
||||
}
|
||||
hudType = mcMMO.isSpoutEnabled() ? SpoutConfig.getInstance().getDefaultHudType() : HudType.DISABLED;
|
||||
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
||||
|
||||
for (AbilityType abilityType : AbilityType.values()) {
|
||||
skillsDATS.put(abilityType, 0);
|
||||
}
|
||||
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (!skillType.isChildSkill()) {
|
||||
skills.put(skillType, 0);
|
||||
skillsXp.put(skillType, 0);
|
||||
}
|
||||
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||
skills.put(skillType, 0);
|
||||
skillsXp.put(skillType, 0F);
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerProfile(String playerName, boolean isLoaded) {
|
||||
this(playerName);
|
||||
this.loaded = isLoaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calling this constructor is considered loading the profile.
|
||||
*/
|
||||
public PlayerProfile(String playerName, Map<SkillType, Integer> argSkills, Map<SkillType, Float> argSkillsXp, Map<AbilityType, Integer> argSkillsDats, HudType hudType, MobHealthbarType mobHealthbarType) {
|
||||
this(playerName, true);
|
||||
|
||||
this.hudType = hudType;
|
||||
this.mobHealthbarType = mobHealthbarType;
|
||||
|
||||
this.skills.putAll(argSkills);
|
||||
this.skillsXp.putAll(argSkillsXp);
|
||||
this.skillsDATS.putAll(argSkillsDats);
|
||||
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
if (!changed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
if (!loadMySQL() && addNew) {
|
||||
addMySQLPlayer();
|
||||
loaded = true;
|
||||
}
|
||||
}
|
||||
else if (!load() && addNew) {
|
||||
addPlayer();
|
||||
loaded = true;
|
||||
}
|
||||
mcMMO.getDatabaseManager().saveUser(this);
|
||||
changed = false;
|
||||
}
|
||||
|
||||
public String getPlayerName() {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
public boolean loadMySQL() {
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
|
||||
userId = DatabaseManager.getInt("SELECT id FROM " + tablePrefix + "users WHERE user = '" + playerName + "'");
|
||||
|
||||
if (userId == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HashMap<Integer, ArrayList<String>> huds = DatabaseManager.read("SELECT hudtype FROM " + tablePrefix + "huds WHERE user_id = " + userId);
|
||||
|
||||
if (huds.get(1) == null) {
|
||||
DatabaseManager.write("INSERT INTO " + tablePrefix + "huds (user_id) VALUES (" + userId + ")");
|
||||
}
|
||||
else {
|
||||
for (HudType type : HudType.values()) {
|
||||
if (type.toString().equalsIgnoreCase(huds.get(1).get(0))) {
|
||||
hudType = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<Integer, ArrayList<String>> cooldowns = DatabaseManager.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM " + tablePrefix + "cooldowns WHERE user_id = " + userId);
|
||||
ArrayList<String> cooldownValues = cooldowns.get(1);
|
||||
|
||||
if (cooldownValues == null) {
|
||||
DatabaseManager.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")");
|
||||
mcMMO.p.getLogger().warning(playerName + "does not exist in the cooldown table. Their cooldowns will be reset.");
|
||||
}
|
||||
else {
|
||||
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(cooldownValues.get(0)));
|
||||
skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(cooldownValues.get(1)));
|
||||
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(cooldownValues.get(2)));
|
||||
skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(cooldownValues.get(3)));
|
||||
skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(cooldownValues.get(4)));
|
||||
skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(cooldownValues.get(5)));
|
||||
skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(cooldownValues.get(6)));
|
||||
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(cooldownValues.get(7)));
|
||||
}
|
||||
|
||||
HashMap<Integer, ArrayList<String>> stats = DatabaseManager.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "skills WHERE user_id = " + userId);
|
||||
ArrayList<String> statValues = stats.get(1);
|
||||
|
||||
if (statValues == null) {
|
||||
DatabaseManager.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")");
|
||||
mcMMO.p.getLogger().warning(playerName + "does not exist in the skills table. Their stats will be reset.");
|
||||
}
|
||||
else {
|
||||
skills.put(SkillType.TAMING, Integer.valueOf(statValues.get(0)));
|
||||
skills.put(SkillType.MINING, Integer.valueOf(statValues.get(1)));
|
||||
skills.put(SkillType.REPAIR, Integer.valueOf(statValues.get(2)));
|
||||
skills.put(SkillType.WOODCUTTING, Integer.valueOf(statValues.get(3)));
|
||||
skills.put(SkillType.UNARMED, Integer.valueOf(statValues.get(4)));
|
||||
skills.put(SkillType.HERBALISM, Integer.valueOf(statValues.get(5)));
|
||||
skills.put(SkillType.EXCAVATION, Integer.valueOf(statValues.get(6)));
|
||||
skills.put(SkillType.ARCHERY, Integer.valueOf(statValues.get(7)));
|
||||
skills.put(SkillType.SWORDS, Integer.valueOf(statValues.get(8)));
|
||||
skills.put(SkillType.AXES, Integer.valueOf(statValues.get(9)));
|
||||
skills.put(SkillType.ACROBATICS, Integer.valueOf(statValues.get(10)));
|
||||
skills.put(SkillType.FISHING, Integer.valueOf(statValues.get(11)));
|
||||
}
|
||||
|
||||
HashMap<Integer, ArrayList<String>> experience = DatabaseManager.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "experience WHERE user_id = " + userId);
|
||||
ArrayList<String> experienceValues = experience.get(1);
|
||||
|
||||
if (experienceValues == null) {
|
||||
DatabaseManager.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")");
|
||||
mcMMO.p.getLogger().warning(playerName + "does not exist in the experience table. Their experience will be reset.");
|
||||
}
|
||||
else {
|
||||
skillsXp.put(SkillType.TAMING, Integer.valueOf(experienceValues.get(0)));
|
||||
skillsXp.put(SkillType.MINING, Integer.valueOf(experienceValues.get(1)));
|
||||
skillsXp.put(SkillType.REPAIR, Integer.valueOf(experienceValues.get(2)));
|
||||
skillsXp.put(SkillType.WOODCUTTING, Integer.valueOf(experienceValues.get(3)));
|
||||
skillsXp.put(SkillType.UNARMED, Integer.valueOf(experienceValues.get(4)));
|
||||
skillsXp.put(SkillType.HERBALISM, Integer.valueOf(experienceValues.get(5)));
|
||||
skillsXp.put(SkillType.EXCAVATION, Integer.valueOf(experienceValues.get(6)));
|
||||
skillsXp.put(SkillType.ARCHERY, Integer.valueOf(experienceValues.get(7)));
|
||||
skillsXp.put(SkillType.SWORDS, Integer.valueOf(experienceValues.get(8)));
|
||||
skillsXp.put(SkillType.AXES, Integer.valueOf(experienceValues.get(9)));
|
||||
skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(experienceValues.get(10)));
|
||||
skillsXp.put(SkillType.FISHING, Integer.valueOf(experienceValues.get(11)));
|
||||
}
|
||||
|
||||
loaded = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addMySQLPlayer() {
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
|
||||
DatabaseManager.write("INSERT INTO " + tablePrefix + "users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR + ")");
|
||||
userId = DatabaseManager.getInt("SELECT id FROM " + tablePrefix + "users WHERE user = '" + playerName + "'");
|
||||
|
||||
DatabaseManager.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")");
|
||||
DatabaseManager.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")");
|
||||
DatabaseManager.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")");
|
||||
}
|
||||
|
||||
public boolean load() {
|
||||
try {
|
||||
// Open the user file
|
||||
FileReader file = new FileReader(location);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
String line;
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
// Find if the line contains the player we want.
|
||||
String[] character = line.split(":");
|
||||
|
||||
if (!character[0].equalsIgnoreCase(playerName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (character.length > 1 && StringUtils.isInt(character[1])) {
|
||||
skills.put(SkillType.MINING, Integer.valueOf(character[1]));
|
||||
}
|
||||
|
||||
if (character.length > 4 && StringUtils.isInt(character[4])) {
|
||||
skillsXp.put(SkillType.MINING, Integer.valueOf(character[4]));
|
||||
}
|
||||
|
||||
if (character.length > 5 && StringUtils.isInt(character[5])) {
|
||||
skills.put(SkillType.WOODCUTTING, Integer.valueOf(character[5]));
|
||||
}
|
||||
|
||||
if (character.length > 6 && StringUtils.isInt(character[6])) {
|
||||
skillsXp.put(SkillType.WOODCUTTING, Integer.valueOf(character[6]));
|
||||
}
|
||||
|
||||
if (character.length > 7 && StringUtils.isInt(character[7])) {
|
||||
skills.put(SkillType.REPAIR, Integer.valueOf(character[7]));
|
||||
}
|
||||
|
||||
if (character.length > 8 && StringUtils.isInt(character[8])) {
|
||||
skills.put(SkillType.UNARMED, Integer.valueOf(character[8]));
|
||||
}
|
||||
|
||||
if (character.length > 9 && StringUtils.isInt(character[9])) {
|
||||
skills.put(SkillType.HERBALISM, Integer.valueOf(character[9]));
|
||||
}
|
||||
|
||||
if (character.length > 10 && StringUtils.isInt(character[10])) {
|
||||
skills.put(SkillType.EXCAVATION, Integer.valueOf(character[10]));
|
||||
}
|
||||
|
||||
if (character.length > 11 && StringUtils.isInt(character[11])) {
|
||||
skills.put(SkillType.ARCHERY, Integer.valueOf(character[11]));
|
||||
}
|
||||
|
||||
if (character.length > 12 && StringUtils.isInt(character[12])) {
|
||||
skills.put(SkillType.SWORDS, Integer.valueOf(character[12]));
|
||||
}
|
||||
|
||||
if (character.length > 13 && StringUtils.isInt(character[13])) {
|
||||
skills.put(SkillType.AXES, Integer.valueOf(character[13]));
|
||||
}
|
||||
|
||||
if (character.length > 14 && StringUtils.isInt(character[14])) {
|
||||
skills.put(SkillType.ACROBATICS, Integer.valueOf(character[14]));
|
||||
}
|
||||
|
||||
if (character.length > 15 && StringUtils.isInt(character[15])) {
|
||||
skillsXp.put(SkillType.REPAIR, Integer.valueOf(character[15]));
|
||||
}
|
||||
|
||||
if (character.length > 16 && StringUtils.isInt(character[16])) {
|
||||
skillsXp.put(SkillType.UNARMED, Integer.valueOf(character[16]));
|
||||
}
|
||||
|
||||
if (character.length > 17 && StringUtils.isInt(character[17])) {
|
||||
skillsXp.put(SkillType.HERBALISM, Integer.valueOf(character[17]));
|
||||
}
|
||||
|
||||
if (character.length > 18 && StringUtils.isInt(character[18])) {
|
||||
skillsXp.put(SkillType.EXCAVATION, Integer.valueOf(character[18]));
|
||||
}
|
||||
|
||||
if (character.length > 19 && StringUtils.isInt(character[19])) {
|
||||
skillsXp.put(SkillType.ARCHERY, Integer.valueOf(character[19]));
|
||||
}
|
||||
|
||||
if (character.length > 20 && StringUtils.isInt(character[20])) {
|
||||
skillsXp.put(SkillType.SWORDS, Integer.valueOf(character[20]));
|
||||
}
|
||||
|
||||
if (character.length > 21 && StringUtils.isInt(character[21])) {
|
||||
skillsXp.put(SkillType.AXES, Integer.valueOf(character[21]));
|
||||
}
|
||||
|
||||
if (character.length > 22 && StringUtils.isInt(character[22])) {
|
||||
skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(character[22]));
|
||||
}
|
||||
|
||||
if (character.length > 24 && StringUtils.isInt(character[24])) {
|
||||
skills.put(SkillType.TAMING, Integer.valueOf(character[24]));
|
||||
}
|
||||
|
||||
if (character.length > 25 && StringUtils.isInt(character[25])) {
|
||||
skillsXp.put(SkillType.TAMING, Integer.valueOf(character[25]));
|
||||
}
|
||||
|
||||
if (character.length > 26) {
|
||||
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(character[26]));
|
||||
}
|
||||
|
||||
if (character.length > 27) {
|
||||
skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(character[27]));
|
||||
}
|
||||
|
||||
if (character.length > 28) {
|
||||
skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(character[28]));
|
||||
}
|
||||
|
||||
if (character.length > 29) {
|
||||
skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(character[29]));
|
||||
}
|
||||
|
||||
if (character.length > 30) {
|
||||
skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(character[30]));
|
||||
}
|
||||
|
||||
if (character.length > 31) {
|
||||
skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(character[31]));
|
||||
}
|
||||
|
||||
if (character.length > 32) {
|
||||
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(character[32]));
|
||||
}
|
||||
|
||||
if (character.length > 33) {
|
||||
for (HudType type : HudType.values()) {
|
||||
if (type.toString().equalsIgnoreCase(character[33])) {
|
||||
hudType = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (character.length > 34) {
|
||||
skills.put(SkillType.FISHING, Integer.valueOf(character[34]));
|
||||
}
|
||||
|
||||
if (character.length > 35) {
|
||||
skillsXp.put(SkillType.FISHING, Integer.valueOf(character[35]));
|
||||
}
|
||||
|
||||
if (character.length > 36) {
|
||||
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[36]));
|
||||
}
|
||||
|
||||
loaded = true;
|
||||
|
||||
in.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
in.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
Long timestamp = System.currentTimeMillis();
|
||||
|
||||
// If we are using mysql save to database
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
|
||||
DatabaseManager.write("UPDATE " + tablePrefix + "huds SET hudtype = '" + hudType.toString() + "' WHERE user_id = " + userId);
|
||||
DatabaseManager.write("UPDATE " + tablePrefix + "users SET lastlogin = " + ((int) (timestamp / Misc.TIME_CONVERSION_FACTOR)) + " WHERE id = " + userId);
|
||||
DatabaseManager.write("UPDATE " + tablePrefix + "cooldowns SET "
|
||||
+ " mining = " + skillsDATS.get(AbilityType.SUPER_BREAKER)
|
||||
+ ", woodcutting = " + skillsDATS.get(AbilityType.TREE_FELLER)
|
||||
+ ", unarmed = " + skillsDATS.get(AbilityType.BERSERK)
|
||||
+ ", herbalism = " + skillsDATS.get(AbilityType.GREEN_TERRA)
|
||||
+ ", excavation = " + skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER)
|
||||
+ ", swords = " + skillsDATS.get(AbilityType.SERRATED_STRIKES)
|
||||
+ ", axes = " + skillsDATS.get(AbilityType.SKULL_SPLITTER)
|
||||
+ ", blast_mining = " + skillsDATS.get(AbilityType.BLAST_MINING)
|
||||
+ " WHERE user_id = " + userId);
|
||||
DatabaseManager.write("UPDATE " + tablePrefix + "skills SET "
|
||||
+ " taming = " + skills.get(SkillType.TAMING)
|
||||
+ ", mining = " + skills.get(SkillType.MINING)
|
||||
+ ", repair = " + skills.get(SkillType.REPAIR)
|
||||
+ ", woodcutting = " + skills.get(SkillType.WOODCUTTING)
|
||||
+ ", unarmed = " + skills.get(SkillType.UNARMED)
|
||||
+ ", herbalism = " + skills.get(SkillType.HERBALISM)
|
||||
+ ", excavation = " + skills.get(SkillType.EXCAVATION)
|
||||
+ ", archery = " + skills.get(SkillType.ARCHERY)
|
||||
+ ", swords = " + skills.get(SkillType.SWORDS)
|
||||
+ ", axes = " + skills.get(SkillType.AXES)
|
||||
+ ", acrobatics = " + skills.get(SkillType.ACROBATICS)
|
||||
+ ", fishing = " + skills.get(SkillType.FISHING)
|
||||
+ " WHERE user_id = " + userId);
|
||||
DatabaseManager.write("UPDATE " + tablePrefix + "experience SET "
|
||||
+ " taming = " + skillsXp.get(SkillType.TAMING)
|
||||
+ ", mining = " + skillsXp.get(SkillType.MINING)
|
||||
+ ", repair = " + skillsXp.get(SkillType.REPAIR)
|
||||
+ ", woodcutting = " + skillsXp.get(SkillType.WOODCUTTING)
|
||||
+ ", unarmed = " + skillsXp.get(SkillType.UNARMED)
|
||||
+ ", herbalism = " + skillsXp.get(SkillType.HERBALISM)
|
||||
+ ", excavation = " + skillsXp.get(SkillType.EXCAVATION)
|
||||
+ ", archery = " + skillsXp.get(SkillType.ARCHERY)
|
||||
+ ", swords = " + skillsXp.get(SkillType.SWORDS)
|
||||
+ ", axes = " + skillsXp.get(SkillType.AXES)
|
||||
+ ", acrobatics = " + skillsXp.get(SkillType.ACROBATICS)
|
||||
+ ", fishing = " + skillsXp.get(SkillType.FISHING)
|
||||
+ " WHERE user_id = " + userId);
|
||||
}
|
||||
else {
|
||||
// Otherwise save to flatfile
|
||||
try {
|
||||
// Open the file
|
||||
FileReader file = new FileReader(location);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
StringBuilder writer = new StringBuilder();
|
||||
String line;
|
||||
|
||||
// While not at the end of the file
|
||||
while ((line = in.readLine()) != null) {
|
||||
// Read the line in and copy it to the output it's not the player we want to edit
|
||||
if (!line.split(":")[0].equalsIgnoreCase(playerName)) {
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
else {
|
||||
// Otherwise write the new player information
|
||||
writer.append(playerName).append(":");
|
||||
writer.append(skills.get(SkillType.MINING)).append(":");
|
||||
writer.append(":");
|
||||
writer.append(":");
|
||||
writer.append(skillsXp.get(SkillType.MINING)).append(":");
|
||||
writer.append(skills.get(SkillType.WOODCUTTING)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.WOODCUTTING)).append(":");
|
||||
writer.append(skills.get(SkillType.REPAIR)).append(":");
|
||||
writer.append(skills.get(SkillType.UNARMED)).append(":");
|
||||
writer.append(skills.get(SkillType.HERBALISM)).append(":");
|
||||
writer.append(skills.get(SkillType.EXCAVATION)).append(":");
|
||||
writer.append(skills.get(SkillType.ARCHERY)).append(":");
|
||||
writer.append(skills.get(SkillType.SWORDS)).append(":");
|
||||
writer.append(skills.get(SkillType.AXES)).append(":");
|
||||
writer.append(skills.get(SkillType.ACROBATICS)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.REPAIR)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.UNARMED)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.HERBALISM)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.EXCAVATION)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.ARCHERY)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.SWORDS)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.AXES)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.ACROBATICS)).append(":");
|
||||
writer.append(":");
|
||||
writer.append(skills.get(SkillType.TAMING)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.TAMING)).append(":");
|
||||
writer.append(skillsDATS.get(AbilityType.BERSERK)).append(":");
|
||||
writer.append(skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER)).append(":");
|
||||
writer.append(skillsDATS.get(AbilityType.TREE_FELLER)).append(":");
|
||||
writer.append(skillsDATS.get(AbilityType.GREEN_TERRA)).append(":");
|
||||
writer.append(skillsDATS.get(AbilityType.SERRATED_STRIKES)).append(":");
|
||||
writer.append(skillsDATS.get(AbilityType.SKULL_SPLITTER)).append(":");
|
||||
writer.append(skillsDATS.get(AbilityType.SUPER_BREAKER)).append(":");
|
||||
writer.append(hudType.toString()).append(":");
|
||||
writer.append(skills.get(SkillType.FISHING)).append(":");
|
||||
writer.append(skillsXp.get(SkillType.FISHING)).append(":");
|
||||
writer.append(skillsDATS.get(AbilityType.BLAST_MINING)).append(":");
|
||||
writer.append(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR).append(":");
|
||||
writer.append("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
in.close();
|
||||
|
||||
// Write the new file
|
||||
FileWriter out = new FileWriter(location);
|
||||
out.write(writer.toString());
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addPlayer() {
|
||||
try {
|
||||
// Open the file to write the player
|
||||
FileWriter file = new FileWriter(location, true);
|
||||
BufferedWriter out = new BufferedWriter(file);
|
||||
|
||||
// Add the player to the end
|
||||
out.append(playerName).append(":");
|
||||
out.append("0:"); // Mining
|
||||
out.append(":");
|
||||
out.append(":");
|
||||
out.append("0:"); // Xp
|
||||
out.append("0:"); // Woodcutting
|
||||
out.append("0:"); // WoodCuttingXp
|
||||
out.append("0:"); // Repair
|
||||
out.append("0:"); // Unarmed
|
||||
out.append("0:"); // Herbalism
|
||||
out.append("0:"); // Excavation
|
||||
out.append("0:"); // Archery
|
||||
out.append("0:"); // Swords
|
||||
out.append("0:"); // Axes
|
||||
out.append("0:"); // Acrobatics
|
||||
out.append("0:"); // RepairXp
|
||||
out.append("0:"); // UnarmedXp
|
||||
out.append("0:"); // HerbalismXp
|
||||
out.append("0:"); // ExcavationXp
|
||||
out.append("0:"); // ArcheryXp
|
||||
out.append("0:"); // SwordsXp
|
||||
out.append("0:"); // AxesXp
|
||||
out.append("0:"); // AcrobaticsXp
|
||||
out.append(":");
|
||||
out.append("0:"); // Taming
|
||||
out.append("0:"); // TamingXp
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append("0:"); // DATS
|
||||
out.append(hudType.toString()).append(":"); // HUD
|
||||
out.append("0:"); // Fishing
|
||||
out.append("0:"); // FishingXp
|
||||
out.append("0:"); // Blast Mining
|
||||
out.append(String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)).append(":"); // LastLogin
|
||||
|
||||
// Add more in the same format as the line above
|
||||
|
||||
out.newLine();
|
||||
out.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* mySQL Stuff
|
||||
*/
|
||||
|
||||
public int getMySQLuserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public boolean isLoaded() {
|
||||
return loaded;
|
||||
}
|
||||
@@ -549,6 +109,30 @@ public class PlayerProfile {
|
||||
this.hudType = hudType;
|
||||
}
|
||||
|
||||
/*
|
||||
* Mob Healthbars
|
||||
*/
|
||||
|
||||
public MobHealthbarType getMobHealthbarType() {
|
||||
return mobHealthbarType;
|
||||
}
|
||||
|
||||
public void setMobHealthbarType(MobHealthbarType mobHealthbarType) {
|
||||
this.mobHealthbarType = mobHealthbarType;
|
||||
}
|
||||
|
||||
/*
|
||||
* Scoreboards
|
||||
*/
|
||||
|
||||
public Scoreboard getPlayerStatsScoreboard() {
|
||||
return playerStatsScoreboard;
|
||||
}
|
||||
|
||||
public void setPlayerStatsScoreboard(Scoreboard statsScoreboard) {
|
||||
this.playerStatsScoreboard = statsScoreboard;
|
||||
}
|
||||
|
||||
/*
|
||||
* Cooldowns
|
||||
*/
|
||||
@@ -566,12 +150,14 @@ public class PlayerProfile {
|
||||
/**
|
||||
* Set the current DATS of a skill.
|
||||
*
|
||||
* @param abilityType Ability to set the DATS for
|
||||
* @param abilityType Ability to set the DATS for
|
||||
* @param DATS the DATS of the ability
|
||||
*/
|
||||
public void setSkillDATS(AbilityType abilityType, long DATS) {
|
||||
int wearsOff = (int) (DATS * .001D);
|
||||
|
||||
changed = true;
|
||||
|
||||
skillsDATS.put(abilityType, wearsOff);
|
||||
}
|
||||
|
||||
@@ -579,8 +165,10 @@ public class PlayerProfile {
|
||||
* Reset all skill cooldowns.
|
||||
*/
|
||||
public void resetCooldowns() {
|
||||
for (AbilityType x : skillsDATS.keySet()) {
|
||||
skillsDATS.put(x, 0);
|
||||
changed = true;
|
||||
|
||||
for (AbilityType ability : skillsDATS.keySet()) {
|
||||
skillsDATS.put(ability, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -596,26 +184,21 @@ public class PlayerProfile {
|
||||
return skills.get(skillType);
|
||||
}
|
||||
|
||||
public int getChildSkillLevel(SkillType skillType) {
|
||||
Set<SkillType> parents = FamilyTree.getParents(skillType);
|
||||
int sum = 0;
|
||||
|
||||
for (SkillType parent : parents) {
|
||||
sum += Math.min(getSkillLevel(parent), 1000);
|
||||
}
|
||||
|
||||
return sum / parents.size();
|
||||
}
|
||||
|
||||
public int getSkillXpLevel(SkillType skillType) {
|
||||
public float getSkillXpLevelRaw(SkillType skillType) {
|
||||
return skillsXp.get(skillType);
|
||||
}
|
||||
|
||||
public void setSkillXpLevel(SkillType skillType, int newValue) {
|
||||
public int getSkillXpLevel(SkillType skillType) {
|
||||
return (int) Math.floor(getSkillXpLevelRaw(skillType));
|
||||
}
|
||||
|
||||
public void setSkillXpLevel(SkillType skillType, float newValue) {
|
||||
if (skillType.isChildSkill()) {
|
||||
return;
|
||||
}
|
||||
|
||||
changed = true;
|
||||
|
||||
skillsXp.put(skillType, newValue);
|
||||
}
|
||||
|
||||
@@ -634,6 +217,8 @@ public class PlayerProfile {
|
||||
return;
|
||||
}
|
||||
|
||||
changed = true;
|
||||
|
||||
skillsXp.put(skillType, skillsXp.get(skillType) - xp);
|
||||
}
|
||||
|
||||
@@ -648,8 +233,10 @@ public class PlayerProfile {
|
||||
return;
|
||||
}
|
||||
|
||||
changed = true;
|
||||
|
||||
skills.put(skillType, newValue);
|
||||
skillsXp.put(skillType, 0);
|
||||
skillsXp.put(skillType, 0F);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -663,8 +250,10 @@ public class PlayerProfile {
|
||||
return;
|
||||
}
|
||||
|
||||
changed = true;
|
||||
|
||||
skills.put(skillType, skills.get(skillType) + levels);
|
||||
skillsXp.put(skillType, 0);
|
||||
skillsXp.put(skillType, 0F);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -678,16 +267,32 @@ public class PlayerProfile {
|
||||
return;
|
||||
}
|
||||
|
||||
changed = true;
|
||||
|
||||
skillsXp.put(skillType, skillsXp.get(skillType) + experience);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of Xp remaining before the next level.
|
||||
* Get the total amount of Xp before the next level.
|
||||
*
|
||||
* @param skillType Type of skill to check
|
||||
* @return the Xp remaining until next level
|
||||
* @return the total amount of Xp until next level
|
||||
*/
|
||||
public int getXpToLevel(SkillType skillType) {
|
||||
return 1020 + (skills.get(skillType) * Config.getInstance().getFormulaMultiplierCurve());
|
||||
int level = (ExperienceConfig.getInstance().getCumulativeCurveEnabled()) ? UserManager.getPlayer(playerName).getPowerLevel() : skills.get(skillType);
|
||||
FormulaType formulaType = ExperienceConfig.getInstance().getFormulaType();
|
||||
|
||||
return mcMMO.getFormulaManager().getCachedXpToLevel(level, formulaType);
|
||||
}
|
||||
|
||||
private int getChildSkillLevel(SkillType skillType) {
|
||||
Set<SkillType> parents = FamilyTree.getParents(skillType);
|
||||
int sum = 0;
|
||||
|
||||
for (SkillType parent : parents) {
|
||||
sum += Math.min(getSkillLevel(parent), 1000);
|
||||
}
|
||||
|
||||
return sum / parents.size();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,13 @@ public enum AbilityType {
|
||||
null),
|
||||
|
||||
LEAF_BLOWER(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null),
|
||||
|
||||
BLOCK_CRACKER(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
@@ -144,7 +151,6 @@ public enum AbilityType {
|
||||
* @return true if the player has permissions, false otherwise
|
||||
*/
|
||||
public boolean getPermissions(Player player) {
|
||||
|
||||
switch (this) {
|
||||
case BERSERK:
|
||||
return Permissions.berserk(player);
|
||||
@@ -152,6 +158,9 @@ public enum AbilityType {
|
||||
case BLAST_MINING:
|
||||
return Permissions.remoteDetonation(player);
|
||||
|
||||
case BLOCK_CRACKER:
|
||||
return Permissions.blockCracker(player);
|
||||
|
||||
case GIGA_DRILL_BREAKER:
|
||||
return Permissions.gigaDrillBreaker(player);
|
||||
|
||||
@@ -189,6 +198,9 @@ public enum AbilityType {
|
||||
case BERSERK:
|
||||
return (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW);
|
||||
|
||||
case BLOCK_CRACKER:
|
||||
return BlockUtils.affectedByBlockCracker(blockState);
|
||||
|
||||
case GIGA_DRILL_BREAKER:
|
||||
return BlockUtils.affectedByGigaDrillBreaker(blockState);
|
||||
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package com.gmail.nossr50.datatypes.skills;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Color;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||
@@ -20,6 +25,9 @@ import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public enum SkillType {
|
||||
ACROBATICS(AcrobaticsManager.class, Color.WHITE),
|
||||
@@ -41,6 +49,19 @@ public enum SkillType {
|
||||
private AbilityType ability;
|
||||
private ToolType tool;
|
||||
|
||||
public static final List<String> SKILL_NAMES;
|
||||
|
||||
static {
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
|
||||
for (SkillType skill : values()) {
|
||||
names.add(SkillUtils.getSkillName(skill));
|
||||
}
|
||||
|
||||
Collections.sort(names);
|
||||
SKILL_NAMES = ImmutableList.copyOf(names);
|
||||
}
|
||||
|
||||
private SkillType(Class<? extends SkillManager> managerClass, Color runescapeColor) {
|
||||
this.managerClass = managerClass;
|
||||
this.runescapeColor = runescapeColor;
|
||||
@@ -84,12 +105,20 @@ public enum SkillType {
|
||||
return Config.getInstance().getDoubleDropsDisabled(this);
|
||||
}
|
||||
|
||||
public boolean getHardcoreStatLossEnabled() {
|
||||
return Config.getInstance().getHardcoreStatLossEnabled(this);
|
||||
}
|
||||
|
||||
public boolean getHardcoreVampirismEnabled() {
|
||||
return Config.getInstance().getHardcoreVampirismEnabled(this);
|
||||
}
|
||||
|
||||
public ToolType getTool() {
|
||||
return tool;
|
||||
}
|
||||
|
||||
public double getXpModifier() {
|
||||
return Config.getInstance().getForumulaMultiplier(this);
|
||||
return ExperienceConfig.getInstance().getFormulaSkillModifier(this);
|
||||
}
|
||||
|
||||
public static SkillType getSkill(String skillName) {
|
||||
@@ -122,7 +151,36 @@ public enum SkillType {
|
||||
}
|
||||
}
|
||||
|
||||
public static SkillType[] nonChildSkills() {
|
||||
return new SkillType[] {SkillType.ACROBATICS,
|
||||
SkillType.ARCHERY,
|
||||
SkillType.AXES,
|
||||
SkillType.EXCAVATION,
|
||||
SkillType.FISHING,
|
||||
SkillType.HERBALISM,
|
||||
SkillType.MINING,
|
||||
SkillType.REPAIR,
|
||||
SkillType.SWORDS,
|
||||
SkillType.TAMING,
|
||||
SkillType.UNARMED,
|
||||
SkillType.WOODCUTTING };
|
||||
}
|
||||
|
||||
public static SkillType[] childSkills() {
|
||||
return new SkillType[] { SkillType.SMELTING };
|
||||
}
|
||||
|
||||
public Color getRunescapeModeColor() {
|
||||
return runescapeColor;
|
||||
}
|
||||
|
||||
public static SkillType byAbility(AbilityType ability) {
|
||||
for (SkillType type : values()) {
|
||||
if (type.getAbility() == ability) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.datatypes.spout.huds;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||
@@ -11,6 +10,8 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.spout.popups.McMMOMenu;
|
||||
import com.gmail.nossr50.datatypes.spout.popups.McMMOXpBar;
|
||||
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
|
||||
public class McMMOHud {
|
||||
private Player player;
|
||||
private PlayerProfile profile;
|
||||
@@ -56,11 +57,7 @@ public class McMMOHud {
|
||||
}
|
||||
|
||||
public boolean isMenuOpened() {
|
||||
if (menu != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return (menu != null);
|
||||
}
|
||||
|
||||
public void openMenu() {
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
package com.gmail.nossr50.datatypes.spout.popups;
|
||||
|
||||
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.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.spout.buttons.McMMOButton;
|
||||
@@ -13,6 +8,11 @@ import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
import org.getspout.spoutapi.gui.GenericLabel;
|
||||
import org.getspout.spoutapi.gui.GenericPopup;
|
||||
import org.getspout.spoutapi.gui.InGameHUD;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
public class McMMOMenu extends GenericPopup {
|
||||
private McMMOButton hudButton;
|
||||
private McMMOButton escapeButton;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user