1
0
mirror of https://github.com/mcMMO-Dev/mcMMO.git synced 2026-02-18 17:53:00 +01:00

Compare commits

...

899 Commits

Author SHA1 Message Date
NuclearW
09eabe98c4 1.3.13 Release 2013-01-18 20:44:00 -05:00
TfT_02
173cb001cb Update the changelog 2013-01-19 02:27:42 +01:00
TfT_02
7d6a4d11fd They came pretty soon! Right? 2013-01-19 01:48:20 +01:00
GJ
11ea6b269e Fix issues with properties files & formatting. 2013-01-18 19:34:19 -05:00
Glitchfinder
372950071a Merge pull request #532 from Glitchfinder/master
Removing detritus left over from recent commits.
2013-01-18 15:47:38 -08:00
Glitchfinder
b424ecfd3e Removing ChunkletUnloader and dependents, since they are no longer necessary. 2013-01-18 15:39:02 -08:00
Glitchfinder
fc38bbd179 Merge pull request #530 from Glitchfinder/master
Updating entity tracking and such.
2013-01-18 14:57:52 -08:00
Glitchfinder
00f24fd5bd Reducing CPU usage on chunk load. 2013-01-18 14:55:29 -08:00
Glitchfinder
50de88a0a0 Fixing minor spacing issue. 2013-01-18 14:47:55 -08:00
Glitchfinder
ca2673f258 Condensing entity tracking into a single set of storage, to reduce CPU use. Also handily causes invalid falling blocks to be removed. (Fell out of the world, etc) 2013-01-18 14:43:14 -08:00
T00thpick1
7d416a90de Redundant as they are caught in finally 2013-01-18 16:18:44 -05:00
Glitchfinder
d09526e470 Changing chunk unloading to patch logic hole for entity tracking. 2013-01-18 12:39:57 -08:00
GJ
ed68f227ac Not closing the objectStream here is BAD. 2013-01-18 15:28:42 -05:00
NuclearW
f72b1e7eec Unsetting up Travis CI. 2013-01-18 14:25:06 -05:00
GJ
bbd756f0d3 Because I don't know how to format our chat properly. 2013-01-18 14:16:18 -05:00
GJ
87a9c12827 Remove my nonworking debug code so mcMMO will actually start. 2013-01-18 14:01:20 -05:00
NuclearW
ebd83e1f19 Support some new stuff in our locale files 2013-01-18 13:59:20 -05:00
GJ
5b4b99f44e Fix party/admin chat changing colors. 2013-01-18 13:22:51 -05:00
GJ
d153e3e25c Go on and remove the placed flag when it first falls. 2013-01-18 11:52:38 -05:00
GJ
e3b3b7cfdb Useless check for air.
The block will always be replacing either air, water, or lava. The check
for whether or not it's being tracked is sufficient.
2013-01-18 09:41:46 -05:00
GJ
2c78bac8f7 We only care about sand & gravel.
Technically this was already addressed because no other blocks would
have their place store set to true, but this eliminates unnecessary
overhead caused by the checking of other falling blocks - anvils, dragon
eggs, and TNT.
2013-01-18 09:37:03 -05:00
GJ
db1c0647ed Fix issue with tracking falling sand & gravel. 2013-01-17 23:26:18 -05:00
T00thpick1
2f16dbc9b5 Explicitely state desired order 2013-01-17 21:35:35 -05:00
T00thpick1
7e7ab249c2 Order correctly to match mcrank 2013-01-17 21:31:50 -05:00
T00thpick1
1d2298e5f6 Join tables in query 2013-01-17 20:57:06 -05:00
T00thpick1
b53b5bbc6c Update Changelog.txt 2013-01-17 18:37:58 -05:00
GJ
0dfd2fe9ef ACTUALLY fix issue with fishing enchantments. Also updated the
changelog.
2013-01-17 18:25:26 -05:00
T00thpick1
c0b3a4e929 Index tables 2013-01-17 18:11:28 -05:00
GJ
5830bf461d Fix fishing not handling enchants right. 2013-01-17 15:32:28 -05:00
GJ
857bb00c8a Because this way is easier. 2013-01-17 15:20:20 -05:00
GJ
c5ae4ca615 Update issue tracker in pom.xml 2013-01-17 14:48:51 -05:00
nossr50
abb0184e49 Fixed a bug where Triple Drops wouldn't happen. 2013-01-17 11:23:52 -08:00
nossr50
b11762da99 Absolutely no reason to do it that way 2013-01-17 10:28:31 -08:00
GJ
946d00cce6 Change admin chat prefix to use "[" instead of "{" due to issues with
loading properties files.
2013-01-17 12:28:16 -05:00
GJ
0262255bea Fixed bug where Skull Splitter would be applied twice. 2013-01-17 12:04:56 -05:00
GJ
38a8a6f2ff Fix possible NPE when using the PartyAPI to add a player to a party that
doesn't exist.
2013-01-17 11:26:55 -05:00
GJ
a6446563d8 Sync the rest of the localization changes. Fixes #464 2013-01-17 11:11:38 -05:00
GJ
225adb5cce Rearranged a few things in the changelog. 2013-01-17 11:03:58 -05:00
GJ
a9c722de67 Wrapping up the localizations... though I'm sure there are probably
still some that got missed.
2013-01-17 11:02:55 -05:00
GJ
49610e372f Localizing more commands. 2013-01-17 01:36:56 -05:00
GJ
a33768de1b Add missing locale strings to our two weird locale files. 2013-01-17 00:46:38 -05:00
GJ
790b31c60e Looks like we've got to escape those. Fixes #526 2013-01-17 00:05:11 -05:00
GJ
37c92b8d7c Localize /addlevels and /addxp commands 2013-01-16 23:58:12 -05:00
GJ
07211611a6 Missed one. 2013-01-16 23:36:00 -05:00
GJ
ea7fee2a53 Localize /mmoedit, /mmoupdate, and /mcpurge 2013-01-16 23:31:28 -05:00
GJ
89da8b832f Localize chat commands and /invite 2013-01-16 22:13:30 -05:00
GJ
5f4c83b6a1 Localize /mchud & /ptp 2013-01-16 18:09:02 -05:00
GJ
2e751b1438 Localize XpLock command. 2013-01-16 17:38:00 -05:00
GJ
1a888d3116 Formatting, and reminding myself to come back and fix this even further. 2013-01-16 17:37:35 -05:00
GJ
2a4fe4aa48 Because lowercase class names are just wrong... 2013-01-16 17:13:56 -05:00
GJ
4c81eb3058 Localizing, and removing a duplicate line. 2013-01-16 17:13:04 -05:00
GJ
64c20d0e24 Because toothplck1 doesn't know how to locale, apparently. 2013-01-16 16:58:00 -05:00
GJ
ff186d5d9d Make our StructureGrowEvent only care about player-planted trees. 2013-01-16 16:47:04 -05:00
GJ
734d691e00 Fix issue where Tree Feller wouldn't work on the base of a
player-planted tree. Fixes #524
2013-01-16 16:16:11 -05:00
T00thpick1
51777dbe85 Import chatColor 2013-01-16 16:15:03 -05:00
T00thpick1
fb1d48fcae Output Header along with info for mcRank 2013-01-16 16:13:31 -05:00
GJ
41ae8cbbf3 Sync all current locale changes across languages.
Also fixes the missing % signs in some locale strings.
2013-01-16 15:45:12 -05:00
nossr50
9717be3da8 Minor cleanup 2013-01-16 12:09:03 -08:00
nossr50
67a4efa03e FFS Leaderboards will only update every 10 minutes 2013-01-16 12:02:41 -08:00
nossr50
fd4f0f4096 mcrank FFS output is now consistent with SQL 2013-01-16 11:58:14 -08:00
GJ
957605d46b More localization updates. 2013-01-16 14:28:59 -05:00
GJ
55f824e0c8 More work on localization update 2013-01-16 14:03:32 -05:00
GJ
faa22002e3 Start of major localization update. 2013-01-16 14:03:31 -05:00
t00thpick1
5d0e85452a Update Changelog.txt 2013-01-16 14:03:31 -05:00
t00thpick1
8c61e35fde Update Changelog.txt 2013-01-16 14:03:30 -05:00
TfT_02
bdfdc61e7f Fixing accidental merge of Mining and Repair guides. 2013-01-16 14:03:30 -05:00
TfT_02
b333916f56 Adding Archery & Axes guides to all the other language files.
It's better to have atleast an English guide than no guide at all.
2013-01-16 14:03:30 -05:00
TfT_02
737d4e2d65 We're sorry for giving the phrase "Coming soon..." a whole new meaning.
More guides coming soon! (This time with soon, we actually mean soon)
2013-01-16 14:03:29 -05:00
T00thpick1
c0dfcfd9f6 More changes 2013-01-16 13:28:14 -05:00
T00thpick1
c073c7ed3a Make mcRank Async in SQL 2013-01-16 02:50:18 -05:00
GJ
7fa1a8c6c7 Make /mctop [skillname] work for localized skillnames 2013-01-16 00:06:14 -05:00
GJ
037fd890dc Use localized skill name in skill guide string.
Still need to localize the REST of the strings relating to the skill
guides, though.
2013-01-15 23:40:34 -05:00
GJ
d673676a8a Add localized skill names to Perks.Lucky.Desc in skill commands. 2013-01-15 23:30:58 -05:00
nossr50
793538d4ef Fixing mcrank reading from FFS when on SQL 2013-01-15 20:09:49 -08:00
GJ
92fc00bb0a Merge pull request #521 from t00thpick1/patch-2
We have to stop meeting like this, database.java
2013-01-15 20:02:20 -08:00
t00thpick1
9d70a2a9a6 We have to stop meeting like this, database.java 2013-01-15 22:42:56 -05:00
Glitchfinder
46a5245a1d Merge pull request #520 from t00thpick1/patch-2
SQL stuff
2013-01-15 19:35:06 -08:00
t00thpick1
9b94fba3a6 The final frontier 2013-01-15 22:27:47 -05:00
t00thpick1
a6144f6dee Hehe no silly hat for me 2013-01-15 22:24:46 -05:00
NuclearW
615eb9666e Add repo 2013-01-15 22:19:03 -05:00
t00thpick1
94a4f628c7 Fix mcremove for sql 2013-01-15 22:14:05 -05:00
t00thpick1
d440876bbb Close statements correctly, add update function 2013-01-15 22:08:59 -05:00
t00thpick1
32c62fd7eb Actually fix discrepencies between mcrank + mctop 2013-01-15 22:00:28 -05:00
Glitchfinder
65f78ba447 Merge pull request #519 from t00thpick1/patch-2
Fix discrepencies between mctop and mcrank in sql
2013-01-15 18:37:34 -08:00
t00thpick1
9c9a097ff3 Fix discrepencies between mctop and mcrank 2013-01-15 21:20:33 -05:00
Glitchfinder
ff6cdc3e9d Merge pull request #516 from t00thpick1/patch-2
One more change
2013-01-15 17:00:42 -08:00
t00thpick1
24367b350d One more change 2013-01-15 19:40:17 -05:00
nossr50
e0da44b34a Merge pull request #515 from t00thpick1/patch-2
Fix mcRank command for SQL
2013-01-15 16:30:35 -08:00
t00thpick1
ea13ce09c9 Apostrophe's are important 2013-01-15 19:24:10 -05:00
nossr50
ef69217b81 Merge pull request #514 from t00thpick1/patch-2
SQL for mcRank command
2013-01-15 16:16:53 -08:00
t00thpick1
7e297ac884 Name methods properly 2013-01-15 19:09:48 -05:00
t00thpick1
e6e8470851 Should be capitalized 2013-01-15 19:08:41 -05:00
t00thpick1
89a36ae47e Last change 2013-01-15 19:04:30 -05:00
t00thpick1
137c46b8ce Part two of sql mcRank 2013-01-15 19:03:13 -05:00
t00thpick1
5512bd7df6 Part one of sql for mcRank 2013-01-15 18:35:21 -05:00
nossr50
96e2cfaad6 Tip: Shoot the cyberdemon until it's dead. 2013-01-15 15:10:48 -08:00
nossr50
f7d482e7bc Sometimes I forget how to use git (all the time) 2013-01-15 14:55:41 -08:00
nossr50
6c67308a1f Merge branch 'master' of https://github.com/mcMMO-Dev/mcMMO 2013-01-15 14:49:55 -08:00
nossr50
6bbdbee669 FFS Leaderboard rewrites, and new mcrank command. 2013-01-15 14:49:20 -08:00
GJ
9204b23d51 Allow configuration of Skull Splitter damage modifier. 2013-01-15 17:00:56 -05:00
GJ
7203a0fcad Changelog update. 2013-01-15 16:42:20 -05:00
GJ
5bdf4b5dcc Finish Axe restructuring, modify a little bit of Swords stuff as well. 2013-01-15 16:38:44 -05:00
GJ
105f088576 Remove unused variable. 2013-01-15 16:36:39 -05:00
GJ
f40433fc99 Axe restructuring. 2013-01-15 16:16:46 -05:00
GJ
bbbd12d461 Fix issue where Tree Feller affected player-placed blocks. Fixes #507 2013-01-15 13:13:20 -05:00
GJ
81dae8c43d Fix NPE resulting from using /mcremove command on a Flatfile DB. Fixes
#509.
2013-01-15 10:51:06 -05:00
GJ
ec6a7e79d6 ACTUALLY fix issue with TNT damage - Fixes #510. 2013-01-15 10:34:13 -05:00
GJ
630b64462e Fixed a bug with Blast Mining incorrectly handling reduced TNT damage. 2013-01-15 10:01:15 -05:00
GJ
72b8eb85b0 NPEs are bad and I should feel bad. 2013-01-14 17:38:47 -05:00
Glitchfinder
a92843533b Merge pull request #506 from Glitchfinder/master
Further reducing lag when saving or unloading a world.
2013-01-14 14:25:18 -08:00
GJ
83855268d5 To keep me from accidentally deleting this again... 2013-01-14 17:23:39 -05:00
Glitchfinder
67e1defdb8 Further reducing lag when saving or unloading a world. 2013-01-14 14:18:01 -08:00
GJ
724aad8504 Allow for a chance at 3x drops from Super Breaker again - Addresses #456 2013-01-14 17:11:35 -05:00
Glitchfinder
5b1337ed07 Merge pull request #505 from Glitchfinder/master
Fixing some leaderboard-related NPEs.
2013-01-14 13:22:46 -08:00
Glitchfinder
a64e177c21 Fixing some NPEs related to having an empty leaderboard. 2013-01-14 13:09:11 -08:00
GJ
e7aafb7242 Merge pull request #504 from Glitchfinder/master
Making it impossible to attempt to drop air
2013-01-14 12:10:30 -08:00
Glitchfinder
75e52bbe66 Making it impossible to attempt to drop air. 2013-01-14 11:31:11 -08:00
GJ
348887f799 Refactoring, removing useless variables, changing ints to doubles, etc. 2013-01-14 12:41:39 -05:00
GJ
8915a535c6 No point casting from int to int. 2013-01-14 12:03:42 -05:00
GJ
0587741437 More Axe restructuring, changing some config values from int to double,
added function to duplicate code.
2013-01-14 11:55:43 -05:00
Glitchfinder
dd766d5363 Merge pull request #501 from t00thpick1/patch-1
Incorrect key on changelog entries
2013-01-13 21:53:25 -08:00
GJ
8e2707d33e Duplicate code is stupid. 2013-01-14 00:47:47 -05:00
t00thpick1
3390c2dbf2 Incorrect key on changelog entries 2013-01-14 00:35:47 -05:00
GJ
268db10361 Parameterize our ArrayLists. 2013-01-14 00:34:01 -05:00
GJ
ed5120eead This should be static access. 2013-01-14 00:27:30 -05:00
GJ
aab532f475 Remove useless else. 2013-01-14 00:27:16 -05:00
GJ
00ee75bb29 Remove unused imports. 2013-01-14 00:26:18 -05:00
GJ
e7e680fd8e Updating the SQL for the purge command, adding config options for
purging old users.
2013-01-14 00:25:31 -05:00
GJ
7b334601c6 Merge pull request #500 from t00thpick1/master
More SQL stuff
2013-01-13 21:09:40 -08:00
T00thpick1
050cb8c5f4 Speed up purgeOldUsers task 2013-01-14 00:06:01 -05:00
Glitchfinder
cb8af637e1 Merge pull request #498 from Glitchfinder/master
Reducing CPU usage as a result of unloading chunks.
2013-01-13 20:09:19 -08:00
Glitchfinder
c1bbc685e6 Fixing a minor spacing issue. 2013-01-13 20:05:20 -08:00
Glitchfinder
d5d6f7e860 Reducing CPU usage as a result of unloading chunks. 2013-01-13 20:02:11 -08:00
Glitchfinder
c2738d247a Merge pull request #495 from Glitchfinder/master
Converting the calls back to getDyeData().
2013-01-13 18:29:37 -08:00
Glitchfinder
f73d0dbc40 Missed one of the calls. 2013-01-13 18:24:43 -08:00
Glitchfinder
395e243730 Converting calls again. 2013-01-13 18:23:11 -08:00
Glitchfinder
4d1bcf1cc0 Merge pull request #494 from Glitchfinder/master
Renaming a call to patch new errors.
2013-01-13 18:01:23 -08:00
Glitchfinder
eb2c552316 Bukkit Devs renamed a method and didn't leave a mirror in the old name. 2013-01-13 17:56:05 -08:00
TfT_02
664239c567 Fixing a java.io.FileNotFoundException when using SQL 2013-01-14 00:20:48 +01:00
TfT_02
06df8e7f7b Formatting 2013-01-14 00:20:48 +01:00
GJ
21a0849a5b Fix t00thpick's mistake. :p 2013-01-13 16:22:56 -05:00
GJ
1f660c8c5b Merge pull request #492 from t00thpick1/master
Speed up powerless sql users purge
2013-01-13 13:20:50 -08:00
T00thpick1
14f5a25633 Speed up SQL powerless users purge 2013-01-13 16:09:47 -05:00
GJ
606195c78a Added option to disable gaining Acrobatics XP from dodging lightning
strikes. Fixes #481
2013-01-13 16:04:02 -05:00
TfT_02
6a7f92b4e2 Fixed missing spaces resulting in Arcane Forging Settings being ignored 2013-01-13 12:53:59 +01:00
TfT_02
0e1646e3a7 Fixed removing to many '%' from locale files 2013-01-13 12:53:59 +01:00
NuclearW
ea5af0397e Merge pull request #488 from t00thpick1/master
One more fix
2013-01-12 20:52:10 -08:00
T00thpick1
6ed0038b1e Result rows start at 1 not 0 2013-01-12 23:24:35 -05:00
Grant
00640fe39b Merge pull request #487 from t00thpick1/master
Should fix mcTop and reduce used queries from 11 to 1 - Fixes #483
2013-01-12 20:10:24 -08:00
T00thpick1
4fb7d60eee Java loop should work right now, forgot to order it earlier 2013-01-12 21:58:22 -05:00
T00thpick1
c54755b9c1 Forgot to format 2013-01-12 21:30:53 -05:00
T00thpick1
07c9b614bc Increment place for display 2013-01-12 21:29:28 -05:00
T00thpick1
7bea8f5120 Fix MctopCommand and make it more efficient 2013-01-12 21:26:48 -05:00
gmcferrin
ea97dcdb55 Fix missing Spout check. Will switch to Bukkit sounds soon. 2013-01-12 19:17:29 -05:00
TfT_02
931bafe962 Adding missing line to locale files
Forgot to add this in my previous commit
2013-01-13 00:33:54 +01:00
TfT_02
a3a6509410 Update the changelog 2013-01-13 00:26:18 +01:00
TfT_02
5e26f2e707 Fixing silly calculations by me. 2013-01-13 00:26:18 +01:00
TfT_02
54ef85e1a3 Fishing in the rain gives you a higher chance of getting magical items! 2013-01-13 00:26:18 +01:00
TfT_02
6f29e475ee Nothing to see here, just some boring patches and fixes! 2013-01-13 00:26:18 +01:00
gmcferrin
e6607783e9 One last time... 2013-01-12 01:43:40 -05:00
gmcferrin
2021a0b065 Finish fixing CASCADE_DELETE issues... I think. 2013-01-12 01:23:16 -05:00
gmcferrin
0871a96399 Fix SQL syntax issue. 2013-01-12 00:34:52 -05:00
gmcferrin
2ed5e8e717 Fixes issue #315 - Fishing will now properly respect min/max levels in
treasures.yml
2013-01-11 17:55:54 -05:00
gmcferrin
0c61cc8bdc More things can be enchanted now. 2013-01-11 17:35:28 -05:00
gmcferrin
c2bad4419b Make the purge task available as a command. 2013-01-11 16:33:49 -05:00
gmcferrin
d0e2358fab This is a much better way to delete things. 2013-01-11 15:26:56 -05:00
TfT_02
db95085b26 Use the DecimalFormatter from SkillCommand
Why didn't I do this in the first place..
2013-01-11 19:07:07 +01:00
gmcferrin
08592cbacf Hopefully speed up UserPergeTask 2013-01-11 12:12:19 -05:00
gmcferrin
487e67d208 Because NuclearW said I was wrong...
"Final is final unless it's not really final."
2013-01-10 23:15:53 -05:00
gmcferrin
a8abfdae5e Start Axe restructuring. 2013-01-10 22:39:08 -05:00
gmcferrin
6496816692 Fixed the null check I broke. 2013-01-10 22:06:50 -05:00
gmcferrin
364c18b842 Leave purge task disabled by default until we can speed it up. 2013-01-10 21:56:48 -05:00
gmcferrin
e20098d462 Fixed up the log messages. 2013-01-10 21:54:32 -05:00
gmcferrin
d25a314d3a Fix bug with UserPurgeTask... 2013-01-10 21:41:35 -05:00
gmcferrin
3dde331f9d Add some debug so we can find the problem... 2013-01-10 21:11:11 -05:00
gmcferrin
f7e56d9833 (Hopefully) Fix NPE, delay PurgeTask start for a few seconds just to be
safe.
2013-01-10 20:49:33 -05:00
gmcferrin
b554fb342a Helpful logging! 2013-01-10 20:33:48 -05:00
gmcferrin
6d9ef91315 Make purge task run options configurable. Also adds ability to disable
the task entirely.
2013-01-10 19:58:25 -05:00
gmcferrin
ce42da5806 Added task to prune old and powerless users from the SQL database.
*** WARNING: THIS WILL RUN AUTOMATICALLY ON YOUR DB. IF YOU ARE WORRIED
ABOUT DATA LOSS, BACK UP YOUR SQL DATA BEFORE INSTALLING THIS BUILD ***
2013-01-10 19:36:11 -05:00
TfT_02
5b5413c1a2 Merge pull request #475 from TfT-02/master
Moving Fishing and Arcance Forging settings to advanced.yml
2013-01-10 15:31:38 -08:00
TfT_02
6cdb27aef0 Moving Fishing and Arcance Forging settings to advanced.yml 2013-01-11 00:21:18 +01:00
Glitchfinder
2205ad0772 Merge pull request #474 from Glitchfinder/master
Added a cleanup task to remove inavlid spawned mobs.
2013-01-10 14:30:50 -08:00
Glitchfinder
637e826c1b Adding a cleanup task to remove invalid entities from the spawned mob storage. 2013-01-10 14:12:41 -08:00
TfT_02
b19395b40d Also display possible lucky perk for MagicHunter 2013-01-10 22:56:15 +01:00
TfT_02
085a25306c Make the MagicHunter Chance configurable 2013-01-10 22:54:57 +01:00
TfT_02
88c39dbb72 Now displays the new magic find chance 2013-01-10 22:11:49 +01:00
Glitchfinder
91670d3945 Merge pull request #473 from Glitchfinder/master
Alleviating hangtime on world save
2013-01-10 12:36:10 -08:00
TfT_02
bdfd7d9839 Display Endurance Perk stats in skill commands 2013-01-10 21:33:50 +01:00
TfT_02
e01b6f175c Use lucky variable; Don't use the actual permission node when not needed. 2013-01-10 21:33:50 +01:00
TfT_02
3f899380d9 Fixing two typos @Jobsti 2013-01-10 21:33:50 +01:00
Glitchfinder
2513b4ca23 Alleviating hangtime on world save. 2013-01-10 12:33:30 -08:00
gmcferrin
93180ccd06 Because 50% was too high. 2013-01-10 15:28:02 -05:00
gmcferrin
f43b4ebdc5 Clarify the way fishing enchantments work - need to fix command display
still.
2013-01-10 15:22:47 -05:00
Glitchfinder
ff4832a6a2 Merge pull request #472 from Glitchfinder/master
Alleviating excessive lag.
2013-01-10 11:25:59 -08:00
Glitchfinder
8267a10f41 Adding an explanation in the comments. 2013-01-10 11:23:58 -08:00
Glitchfinder
771ef6e16e Disabling the place store saveWorld call for when a world is saved due to excessive lag. 2013-01-10 11:13:18 -08:00
gmcferrin
f7ef2b768f Added permission nodes for using Green Thumb with cocoa. 2013-01-10 13:07:14 -05:00
gmcferrin
74c3ce0552 Support for auto-replanting cocoa. 2013-01-10 12:55:54 -05:00
Glitchfinder
67b63f84f1 Merge pull request #471 from Glitchfinder/master
Making errors during the chunk converion process silent.
2013-01-10 09:44:11 -08:00
Glitchfinder
f8c5c380b1 Merge branch 'master' of https://github.com/mcMMO-Dev/mcMMO 2013-01-10 09:27:05 -08:00
Glitchfinder
2708449089 Making errors during the chunk conversion process silent. 2013-01-10 09:26:54 -08:00
gmcferrin
bcfec56300 Because it's not just Citizens that uses NPCs. 2013-01-10 12:18:48 -05:00
gmcferrin
ec6b9d4387 Attempted fix for CombatTag dupe glitch - don't apply AoE damage to
NPCs.
2013-01-10 12:18:08 -05:00
gmcferrin
621f739831 Axes restructuring, part 1 2013-01-10 09:26:28 -05:00
gmcferrin
607d2b8bd7 Abstraction is good. 2013-01-10 09:26:01 -05:00
gmcferrin
c1463c3257 Because we don't need that many Random objects. 2013-01-09 23:46:35 -05:00
gmcferrin
e036b7ac70 We don't need that param. 2013-01-09 23:15:29 -05:00
gmcferrin
4a4db675f1 More OCD. 2013-01-09 23:07:32 -05:00
gmcferrin
e193da2cd7 My OCD made me do it. 2013-01-09 23:03:17 -05:00
gmcferrin
c60cbe824c Function even MORE things. 2013-01-09 22:53:26 -05:00
gmcferrin
8b9432d1d9 So many useless else statements... 2013-01-09 22:43:21 -05:00
gmcferrin
75a5ffcb10 Cleanup our iterators. 2013-01-09 22:18:41 -05:00
gmcferrin
6cc2fc7a6e Functions are still better than copy-pasted code. 2013-01-09 22:09:07 -05:00
gmcferrin
4bb6f68e6f No sense in repeating static variables. 2013-01-09 21:49:17 -05:00
gmcferrin
00e1521d46 Functions >> copy-paste code. 2013-01-09 21:47:03 -05:00
gmcferrin
1055186e86 Finished Mining restructuring. 2013-01-09 21:44:53 -05:00
gmcferrin
fc17448473 Changelog update. 2013-01-09 19:47:21 -05:00
gmcferrin
1839f6ce8c Restructuring Blast Mining. 2013-01-09 19:45:34 -05:00
TfT_02
39e9e426ef Fixing #465 /swords always displaying 5 seconds as SerratedStrikes length 2013-01-09 21:35:33 +01:00
TfT_02
7c2d590951 Finishing adding comments 2013-01-09 17:21:56 +01:00
TfT_02
551b73ea74 Another confusingly named config node 2013-01-09 17:18:20 +01:00
TfT_02
fca095689e Fixed wrongly named config node 2013-01-09 16:54:01 +01:00
TfT_02
e76078fc89 Updated German translation by @Jobsti #462 2013-01-09 15:54:20 +01:00
gmcferrin
2b6b7b899e Attempting to fix some possible memory leaks. Son't know if I'm actually
helping anything though.
2013-01-09 00:01:33 -05:00
gmcferrin
4e6086e8ed Fixed typo in PartyCommand that resulted in locale string not being
output.
2013-01-08 21:56:21 -05:00
gmcferrin
97a59cd21e Fix locale stuff again. 2013-01-08 21:53:18 -05:00
Glitchfinder
9ef0ed8516 Merge pull request #461 from Glitchfinder/master
Merging in TfT-02's changes.
2013-01-08 17:54:06 -08:00
Glitchfinder
3c919c3af7 Fixing new merge conflicts. 2013-01-08 17:45:53 -08:00
gmcferrin
fbe3c70b85 Locale file update! 2013-01-08 20:33:04 -05:00
Glitchfinder
46bf22e36b Merging TfT_02's branch in. 2013-01-08 17:28:09 -08:00
gmcferrin
003c89c3a4 Missed one. 2013-01-08 18:54:22 -05:00
gmcferrin
793bd04afe Fixing merge issues, again. 2013-01-08 18:52:50 -05:00
gmcferrin
0249ae2724 Handle potions better. 2013-01-08 18:46:26 -05:00
Glitchfinder
32e0be481a Merge pull request #458 from Glitchfinder/master
Adding a bit more in the way of Dye-related backwards compatibility.
2013-01-08 15:29:57 -08:00
Glitchfinder
e5592c5da8 Resolving minor merge conflict. 2013-01-08 15:27:59 -08:00
Glitchfinder
b0500332bc Finishing up backwards compatibility for dye colors. 2013-01-08 15:14:12 -08:00
gmcferrin
78b8ac663e A little more cleanup. 2013-01-08 18:09:13 -05:00
Glitchfinder
e41ab3ac18 Merge pull request #457 from Glitchfinder/master
Minor updates.
2013-01-08 14:50:39 -08:00
gmcferrin
36d97bbcaf Store the scheduler. 2013-01-08 17:45:52 -05:00
gmcferrin
f3c89fe48b Archery cleanup. 2013-01-08 17:44:05 -05:00
Glitchfinder
9b31520684 Basic error check for backwards compatibility with dye colors. 2013-01-08 14:39:08 -08:00
Glitchfinder
660e68b0a3 Merge branch 'master' of https://github.com/mcMMO-Dev/mcMMO 2013-01-08 14:32:30 -08:00
gmcferrin
08b46e1a7c Cover ALL the bases. 2013-01-08 17:26:11 -05:00
gmcferrin
b78299bbbd Metadata does nothing, apparently. 2013-01-08 17:24:09 -05:00
Glitchfinder
c8687bfc74 Setting up Travis CI. 2013-01-08 14:23:07 -08:00
Glitchfinder
a5219055ef Merge pull request #454 from Glitchfinder/master
Fixing a minor omission in the Permissions setup.
2013-01-08 14:07:22 -08:00
Glitchfinder
f79a9e5182 Fixing minor omission in permissions setup. 2013-01-08 14:05:41 -08:00
TfT_02
3904b172ad Better formatting for the comments 2013-01-08 22:19:03 +01:00
gmcferrin
e0da506d1a Protected, not public. 2013-01-08 16:10:19 -05:00
gmcferrin
d2f6191615 Starting on cleaning up null checks & type casting 2013-01-08 16:07:29 -05:00
gmcferrin
7c211fa50c Fix for Super Breaker & Giga Drill Breaker double/triple drops. 2013-01-08 14:56:31 -05:00
gmcferrin
fadec1a846 Remove unused import. 2013-01-08 14:27:09 -05:00
gmcferrin
d2aa19e31f Whoops, forgot to change a reference. 2013-01-08 14:23:21 -05:00
gmcferrin
ccfe1181be More mining restructuring. 2013-01-08 12:52:16 -05:00
gmcferrin
85fb12a4ec Use new Bukkit DyeColor data. 2013-01-08 11:31:07 -05:00
gmcferrin
84994c2b2f Remove a few unused imports & variables. 2013-01-08 10:50:37 -05:00
gmcferrin
1a2dfb9b19 Fixed parameterization issue. 2013-01-08 10:48:30 -05:00
gmcferrin
753652dcf9 More mining updates. 2013-01-08 10:46:19 -05:00
gmcferrin
b99d261084 Remove our workaround for NBT tag issues since Bukkit fixed it. 2013-01-08 10:45:49 -05:00
gmcferrin
aee4bcd65e More mining restructuring. 2013-01-08 09:42:37 -05:00
gmcferrin
159ec3f04d Pass location & type as params, rather than calling inside the function. 2013-01-08 09:35:41 -05:00
Glitchfinder
57ff84cd4d Merge pull request #452 from Glitchfinder/master
Fixing yet another concurrency error.
2013-01-08 01:34:31 -08:00
Glitchfinder
2933f80d69 Fixing yet another concurrency error. 2013-01-08 01:32:42 -08:00
gmcferrin
3d38892f7e Only call for an instance of Config once. 2013-01-07 17:40:33 -05:00
gmcferrin
1d990979ac Made the casting a little less complex.
No need to cast them BOTH to a double, only one is needed.
2013-01-07 17:27:52 -05:00
gmcferrin
d69cf09d4e Removed some unnecessary casting. 2013-01-07 17:08:53 -05:00
gmcferrin
b8d346d890 More work on Mining restructuring. 2013-01-07 12:51:39 -05:00
gmcferrin
5d58d85eae Remove unused import. 2013-01-07 11:39:59 -05:00
Glitchfinder
bc4d34f2fc Merge pull request #446 from Glitchfinder/master
Shutting down more concurrency errors.
2013-01-07 01:21:47 -08:00
Glitchfinder
6565d84cf9 Shutting down more concurrency errors. 2013-01-07 01:20:36 -08:00
Glitchfinder
95ed33b2ce Merge pull request #443 from Glitchfinder/master
Merge conflicts are fun.
2013-01-06 18:03:56 -08:00
Glitchfinder
e8f6d4107b Merge conflicts are fun. 2013-01-06 18:02:52 -08:00
Glitchfinder
deb0b211b4 Merge pull request #442 from Glitchfinder/master
Updating permissions to be more consistent.
2013-01-06 17:59:50 -08:00
Glitchfinder
83888f80d4 Fixing merge conflicts 2013-01-06 17:59:31 -08:00
Glitchfinder
974862a60a Updating permissions for consistency. 2013-01-06 17:52:31 -08:00
TfT_02
2965f35d6d Merge pull request #1 from WasBornForJustice/patch-1
Update src/main/resources/locale/locale_ru.properties
2013-01-06 10:30:32 -08:00
WasBornForJustice
6aa300dac0 Update src/main/resources/locale/locale_ru.properties
Little translation fixes
2013-01-06 20:58:31 +04:00
TfT_02
00020a9cbb Skill commands now show the perk effect, if any are active 2013-01-06 12:16:08 +01:00
TfT_02
99c6c46d54 Adding another missing line to all locale files 2013-01-05 11:53:35 +01:00
TfT_02
d183b1b940 Fishermans diet now uses the FoodChance value from advanced.yml 2013-01-05 00:52:11 +01:00
TfT_02
49fc2a93fa Adding missing line to locale files 2013-01-05 00:48:05 +01:00
TfT_02
1c3066aaf7 Fixing a small error pointed out by @sh4z 2013-01-04 12:16:31 +01:00
TfT_02
cdd9745341 Fixing formatting 2013-01-03 17:40:22 +01:00
Glitchfinder
d0c051a9c2 Merge pull request #419 from Glitchfinder/master
Patching two bugs.
2013-01-02 18:06:34 -08:00
Glitchfinder
d444e088c4 Patching a bug where mcMMO drops too few items, and yet another concurrent modification exception. 2013-01-02 18:03:52 -08:00
TfT_02
9ae74e0fba Began adding comments to advanced.yml
Hopefully there aren't too many spell / grammar errors in here.
2013-01-02 23:44:52 +01:00
TfT_02
447aafd106 Fishermans diet now uses the FoodChance value from advanced.yml 2013-01-02 23:20:48 +01:00
TfT_02
376b79cab3 This doesn't need to get added at any point, because users can replace the sound files inside the .jar 2013-01-02 23:20:25 +01:00
Glitchfinder
b95ac44a4c Merge pull request #409 from TfT-02/master
More fixes
2013-01-01 19:36:38 -08:00
Glitchfinder
4161952566 Merge pull request #410 from Glitchfinder/master
Fixing a concurrent modification error.
2013-01-01 19:26:39 -08:00
Glitchfinder
5b18abbea0 Fixing a concurrent modification error. 2013-01-01 19:25:35 -08:00
TfT_02
66cc9bc6db Fixed a bug where GreenThumb_StageChange wasn't read from advanced.yml 2013-01-02 02:10:16 +01:00
TfT_02
4f8337c11a Fixed a bug which caused advanced.yml not to respect every MaxChance node 2013-01-02 01:27:50 +01:00
TfT_02
3aee334fbd Fixed Arcobatics & Archery ignoring ChanceMax settings from advanced config 2013-01-02 00:34:32 +01:00
TfT_02
6d76a14ed0 Update the README
Added link to the mcMMO jenkins and removed the link to the dead forums
2013-01-02 00:18:41 +01:00
gmcferrin
48150e2002 Move permissions declaration to the constructor. 2013-01-01 17:54:58 -05:00
TfT_02
d741d9a11e Merge pull request #400 from TfT-02/master
Various fixed for issues in the issue tracker
2013-01-01 14:17:06 -08:00
gmcferrin
3194baffd7 Use finals rather than local variables. 2013-01-01 17:12:15 -05:00
TfT_02
7a49fbb0bb Update the changelog with recent changes by Glitchfinder 2013-01-01 22:42:27 +01:00
gmcferrin
1ff1704697 Fixed some parameterization issues. 2013-01-01 16:13:33 -05:00
gmcferrin
aeaad41c45 Fix static access issues. 2013-01-01 16:04:53 -05:00
gmcferrin
15cdf3bfd6 More unused imports 2013-01-01 16:03:33 -05:00
gmcferrin
146fa474a1 Removed unused import 2013-01-01 16:02:39 -05:00
gmcferrin
11468abc98 Fixed update for Mining refactoring 2013-01-01 16:01:51 -05:00
gmcferrin
ef6d47b801 Update for Mining refactoring. 2013-01-01 15:54:41 -05:00
Glitchfinder
bfdb825e0b Merge pull request #406 from Glitchfinder/master
Fixing a few issues in the Tracker
2012-12-31 20:00:29 -08:00
Glitchfinder
707a388c51 Fixed an issue where dropped items did not retain custom NBT data. 2012-12-31 19:57:21 -08:00
Glitchfinder
d33334708d Fixing recursion errors by switching from an unnecessary btree to a simple ArrayList. 2012-12-31 19:40:33 -08:00
Glitchfinder
0e853d44b7 Fixing a bug where repairing could leave items with the enchant effect but no enchantments. 2012-12-31 16:04:17 -08:00
TfT_02
c598f202f8 Updated the changelog 2012-12-31 19:09:10 +01:00
Glitchfinder
e607e04af4 Merge pull request #396 from Glitchfinder/master
Fixes and Patches
2012-12-31 10:03:19 -08:00
TfT_02
802d1dfa8e Fixed some mistakes with the path names #404 2012-12-31 18:40:15 +01:00
TfT_02
00279502e4 This does prevent using wood axes everytime you tree fell 2012-12-31 11:04:01 +01:00
TfT_02
cc18794a93 Don't damage the tool more than it's max durability 2012-12-31 11:00:27 +01:00
Glitchfinder
905e92fa4d Adding the ability to track spawned mobs when chunks unload. 2012-12-30 19:51:26 -08:00
TfT_02
7a503ea76c Updated the changelog
This hasen't got any major attention since the 14th of August, untill
now.
2012-12-31 02:24:07 +01:00
TfT_02
eed8a57ff9 Merge pull request #392 from TfT-02/master
Various fixed for issues in the issue tracker
2012-12-30 15:03:12 -08:00
TfT_02
2968803f29 Fixed formatting 2012-12-31 00:01:58 +01:00
TfT_02
6cf6e8ab54 This needs to be on this line. 2012-12-30 23:54:51 +01:00
TfT_02
3668249267 Iterate through the durability damage with Unbreaking check 2012-12-30 23:46:21 +01:00
Glitchfinder
28b092a4e3 Adding Bats, Giants, Withers, and Wither Skeletons to the combat experience list. 2012-12-30 12:33:38 -08:00
Glitchfinder
c0bba7dead Merge pull request #395 from Glitchfinder/master
Fixing an issue where players repaired items a hundred times better than they should be able to.
2012-12-30 09:39:05 -08:00
Glitchfinder
7fc8d432b5 Fixing an issue where players repaired items a hundred times better than they should be able to. 2012-12-30 09:37:38 -08:00
TfT_02
34027ee7c4 Ignore all Mac OSX filesystem dust 2012-12-30 13:37:34 +01:00
TfT_02
dc675162c9 Update the locale files 2012-12-30 13:37:07 +01:00
TfT_02
db370418f8 Add version number to /mcmmo command
Also used the logger in onEnable and onDisable
2012-12-30 00:02:39 +01:00
TfT_02
43de871392 Fixed enchantments being ignored + removed uneccesary code
Fixed Unbreaking enchantments being ignored when using Treefelling and
when hit by Armor Impact
2012-12-29 22:38:57 +01:00
TfT_02
5e9c483892 Merge pull request #387 from dualspiral/EventFix
Don't fire Party Change event if player can't change parties
2012-12-29 13:12:10 -08:00
Glitchfinder
17169903b4 Merge pull request #391 from Glitchfinder/master
Fixing Data Value issues caused by the patch to deprecated ItemStack use.
2012-12-29 13:02:07 -08:00
Glitchfinder
aa70c82824 Fixing issues caused by the patch to deprecated ItemStack changes. 2012-12-29 12:59:18 -08:00
Daniel Naylor
73a5143a17 Check to see if players are eligible to join a party before the mcMMOPartyChangeEvent is fired 2012-12-29 13:15:58 +00:00
Glitchfinder
d35e56fd37 Merge pull request #383 from Glitchfinder/master
Fixing a few more NPEs.
2012-12-28 21:11:58 -08:00
Glitchfinder
cafed2d98c Fixing remaining NPEs with custom blocks using vanilla IDs. 2012-12-28 21:11:22 -08:00
Glitchfinder
cd5df82d72 Fixing more NPEs with custom blocks. 2012-12-28 20:47:39 -08:00
Glitchfinder
5404371b35 Merge pull request #357 from TfT-02/master
Various fixes and patches
2012-12-28 12:19:44 -08:00
Glitchfinder
899bbfee40 Merge pull request #379 from Glitchfinder/master
Fixing an NPE
2012-12-28 12:16:01 -08:00
Glitchfinder
b9f2aa5eff Fixing an NPE involving custom blocks. More investigation needed to find the source of the issue. 2012-12-28 12:14:25 -08:00
TfT_02
0a028afe7f Update the changelog with recent commits 2012-12-28 12:11:54 +01:00
TfT_02
6f1ee88b78 Fixes issues #259 and #335 2012-12-28 11:40:15 +01:00
TfT_02
e5cc06e822 Fix for wrong datataypes 2012-12-28 02:12:34 +01:00
TfT_02
e13ba010bf Adresses issue #364 2012-12-28 00:41:56 +01:00
Glitchfinder
f6bc473eb4 Merge pull request #369 from Glitchfinder/master
Repairing the Repair skill.
2012-12-27 15:10:41 -08:00
Glitchfinder
b491090037 Repairing the Repair skill. 2012-12-27 15:08:10 -08:00
Glitchfinder
0416f5f4a8 Merge pull request #367 from Glitchfinder/master
Fixing level caps.
2012-12-27 13:46:37 -08:00
Glitchfinder
5177bf6c1f Fixing level caps so that 0 represents no cap rather than 0. 2012-12-27 13:45:27 -08:00
Glitchfinder
fcd2fb0f12 Merge pull request #366 from Glitchfinder/master
Fixes the broken /skillreset command.
2012-12-27 12:42:23 -08:00
Glitchfinder
37115d238b Fixing broken skillreset command. 2012-12-27 12:35:30 -08:00
TfT_02
2c8bfd6573 Implementing an durability cap for ArmorImpact 2012-12-27 17:45:10 +01:00
TfT_02
de3bae41ae Implementing an durability cap for ArmorImpact 2012-12-27 17:36:12 +01:00
Glitchfinder
bd1850db69 Merge pull request #353 from Glitchfinder/master
Reimplementing Skill Level and Power Level caps.
2012-12-26 19:56:44 -08:00
Glitchfinder
11b5c54c69 Reimplementing skill level and power level caps. 2012-12-26 19:54:20 -08:00
Glitchfinder
6f081eb1e4 Merge pull request #345 from Glitchfinder/master
Fixing issues with latest spout.
2012-12-25 21:27:50 -08:00
Glitchfinder
d367dbf767 Fixing compatibility with recent Spout updates. Why do people not understand the purpose of an API? 2012-12-25 21:22:38 -08:00
Glitchfinder
8237bd52b5 Merge branch 'master', remote-tracking branch 'mcmmo/master' 2012-12-25 21:00:44 -08:00
TfT_02
71471d3bbc Added Wooden button to list of blocks that should not trigger abilities 2012-12-25 15:35:12 +01:00
gmcferrin
34169aebaf Update POM.xml for proper version 2012-12-25 01:08:12 -05:00
gmcferrin
07e98ab79f Fixed Async deprecation issues 2012-12-25 01:06:21 -05:00
gmcferrin
9af66a8e69 Fixed ItemStack deprecation issues. 2012-12-25 01:01:10 -05:00
Glitchfinder
5e965aec2c Merge pull request #343 from Glitchfinder/fixes
Fixing conversions for a long to and int. for user data.
2012-12-24 14:58:31 -08:00
Glitchfinder
ecb38693db Fixing conversions for a long to and int. for user data. 2012-12-24 14:57:36 -08:00
Grant
36d5344ded Cleanup formatting. 2012-12-24 16:56:25 -05:00
Grant
6b3bde585d Fixed some issues with static access 2012-12-24 16:17:33 -05:00
Grant
f7ea25be61 Fixed issue with Mining using actual skill level rather than max skill
level
2012-12-24 16:17:33 -05:00
Grant
9136530618 Removed unused imports 2012-12-24 16:17:33 -05:00
Grant
f4e7e6c74a Added default cases to switch/case statements 2012-12-24 16:17:32 -05:00
Grant
c4766ad3fb Remove dead code relating to null profiles. 2012-12-24 16:17:32 -05:00
Glitchfinder
894a78c0f9 Merge pull request #342 from Glitchfinder/fixes
Fixing a few issues.
2012-12-24 13:04:21 -08:00
Glitchfinder
c082290cf1 Fixing minor typo involving a binary operation instead of a check. 2012-12-24 12:25:23 -08:00
Glitchfinder
4cac324e9f Fixing skill save timing and autosave features. 2012-12-24 12:19:19 -08:00
Glitchfinder
493353e774 Merge branches 'master' and 'fixes' into fixes 2012-12-24 12:05:41 -08:00
Grant
3289215e19 Merge pull request #340 from TfT-02/master
Small patch
2012-12-24 08:54:51 -08:00
TfT_02
cdb5fed5a5 Changed bonus to float
Fixes bug where only 1 diamond was needed to fully repair an almost
broken diamond pickaxe
2012-12-24 13:00:50 +01:00
TfT_02
bb1dbab984 Iron golem and Snowman pumpkin drop rates are now 3% for the sake of consistency 2012-12-23 22:05:10 +01:00
TfT_02
8a97718dd4 Don't use MaterialData when its not needed. 2012-12-23 18:44:39 +01:00
TfT_02
01142b67c6 Changed skull drop rates to 3% 2012-12-23 00:00:29 +01:00
TfT_02
e0bba80f55 Made skulls drops more rare. 2012-12-22 11:17:48 +01:00
TfT_02
34276539fa Got rid of reflection code, now uses Bukkit method to check if witherskeleton 2012-12-22 10:11:18 +01:00
TfT_02
4511dd79fa Now uses proper gamemode check and uses Misc.dropItem 2012-12-22 10:10:54 +01:00
nossr50
7500685115 Merge pull request #334 from Glitchfinder/fixes
More fixes.
2012-12-10 05:36:59 -08:00
Glitchfinder
658e7d64c2 Fixing dependency issues resulting from a recent change to the Spout API. 2012-12-06 11:22:22 -08:00
Glitchfinder
569079fed0 Fixing build issues caused by recent changes to CraftBukkit. 2012-12-06 11:11:12 -08:00
Glitchfinder
b042d78186 Fixing an error introduced by @TfT-02 that prevented the project from compiling. 2012-12-03 21:40:38 -08:00
Grant
abd051d07b Merge pull request #332 from TfT-02/master
Fixed and patches
2012-12-03 21:08:58 -08:00
Grant
8c5b22a8fb Merge pull request #327 from Glitchfinder/fixes
Additional fixes and patches.
2012-12-03 21:08:40 -08:00
TfT_02
de93b11c25 Fixed an error where Greater Impact was confused with Armor Impact 2012-12-02 22:54:03 +01:00
TfT_02
7f16339bd9 Fixed a small bug where players could salvage items in creative mode 2012-12-02 22:44:26 +01:00
U-YUE\Sean
42dc6e7c4f Fixing the broken repair config. 2012-11-29 12:24:56 -08:00
U-YUE\Sean
3153973c2b Fiuxing merge issue. 2012-11-29 12:18:35 -08:00
Glitchfinder
cc044fe41b Dealing with more minor typecasting issues. 2012-11-26 12:20:44 -08:00
Grant
fd5de7b218 Merge pull request #326 from Glitchfinder/fixes
More fixes and patches.
2012-11-26 11:11:51 -08:00
Glitchfinder
0037524cfd Fixing more errors with typecasting. 2012-11-25 16:40:42 -08:00
Glitchfinder
082fa2ca0d Dealing with type conversion issues in the skill commands. 2012-11-25 16:18:30 -08:00
Glitchfinder
b1cf9d139a Fixing some issues with Arcane Forging. 2012-11-24 15:47:28 -08:00
Grant
9854360ab7 Merge pull request #324 from Glitchfinder/fixes
Further fixes and refinements.
2012-11-22 20:54:14 -08:00
Glitchfinder
b8755b808e Fixing perks spam on login. 2012-11-22 13:40:55 -08:00
Glitchfinder
139812b3bc Trying to fix a new duping bug. 2012-11-22 13:15:01 -08:00
Grant
6adbe9a29b Merge pull request #322 from Glitchfinder/fixes
Resolving merge conflict with Advanced Config
2012-11-21 13:56:02 -08:00
Glitchfinder
52f7120392 Resolving merge conflict. 2012-11-21 13:47:17 -08:00
TfT_02
0d2abb95b5 Adding AdvancedConfig 2012-11-21 21:49:54 +01:00
Grant
6b2adc9359 Merge pull request #318 from mastershake71/master
Fixes Nuker Dupe
2012-11-21 12:37:51 -08:00
Grant
325f89a80d Merge pull request #311 from Glitchfinder/fixes
Additional fixes and patches.
2012-11-21 12:37:15 -08:00
mastershake71
e8152a3475 Solves nuker dupe glitch. Not all anti-cheat block damage, so check
and make sure both are allowed not just one.
2012-11-18 23:31:19 -05:00
Glitchfinder
6d42d14575 Fixed a bug where Herablism magically converted potatoes to carrots. 2012-11-15 16:34:57 -08:00
U-YUE\Sean
2b269ebf54 Adding missing permissions. 2012-11-15 12:40:20 -08:00
Glitchfinder
d2493e89ca A few more minor things. 2012-11-13 14:31:02 -08:00
Glitchfinder
a61423aa99 Dealing with a few minor issues. 2012-11-13 14:27:58 -08:00
Glitchfinder
506efec858 Merge pull request #3 from TfT-02/master
Salvage ability for Repair
2012-11-13 13:37:04 -08:00
TfT_02
8e3320ad72 Hehe, you were soo right. This is MUCH cleaner to look at. :) 2012-11-13 22:28:56 +01:00
TfT_02
ff279bf633 Moved Salvage check to ItemChecks 2012-11-13 22:17:34 +01:00
TfT_02
a582b07549 Small error fix - As mentioned by Glitchfinder 2012-11-13 22:14:26 +01:00
TfT_02
1e7fef4557 Revert "/fishing command will now also display the bonus gained from lucky perk"
This reverts commit 1bf0cd1d15.
2012-11-13 16:55:06 +01:00
TfT_02
f8b44cd8ce New Salvage ability for Repair!
Added a fully working ability to Repair. With this ability you can
salvage items and get bars in return.

- Added new permission node for Salvage ability
- Added new config options for Salvage
- Added new locale strings for Salvage
- Added a check to make sure that Repair Anvil != Salvage Anvil
2012-11-13 16:50:00 +01:00
TfT_02
b0681c10b9 About time that this got changed to 1.3.12 2012-11-13 16:47:59 +01:00
TfT_02
1bf0cd1d15 /fishing command will now also display the bonus gained from lucky perk 2012-11-13 10:08:05 +01:00
Glitchfinder
01f38537de Fixing cooldown timers so that they display the proper cooldown for players with perks. 2012-11-12 21:57:57 -08:00
Glitchfinder
adbb20d7c9 Displaying all perks upon login, and adding them to the locale files. 2012-11-12 21:43:43 -08:00
Glitchfinder
c3c7fe08b6 Fixing a bug where an entity dealing 0 damage still earned experience. 2012-11-12 19:53:55 -08:00
Glitchfinder
4a52135a0b Nerfing overpowered Herbalism double drops for melons and netherwart. 2012-11-12 19:10:14 -08:00
Glitchfinder
a56f805787 Modified drop rates for Fishing's Shake ability. Also reverted spacing to match the rest of the project. 2012-11-12 16:33:37 -08:00
Glitchfinder
3a467b3da4 Adding Fishermans Diet ability to fishing. 2012-11-12 16:18:27 -08:00
Glitchfinder
4500c4d407 Attempting to fix dupe bug with certain plugins and Super Breaker. 2012-11-12 14:58:32 -08:00
Glitchfinder
eebda74bb7 Merge branch 'master' of https://github.com/mcMMO-Dev/mcMMO into fixes 2012-11-12 13:48:31 -08:00
Glitchfinder
e6e8c12735 Merge branch 'master' into fixes 2012-11-12 13:47:31 -08:00
Grant
212b42c8b9 Merge pull request #305 from TfT-02/master
Changed the fishing skill shake + small fix for lucky perk in fishing
2012-11-11 11:45:55 -08:00
Grant
9c4ff30ce7 Merge pull request #304 from Glitchfinder/master
Attempting a minor reduction in lag for larger servers.
2012-11-11 11:45:11 -08:00
Grant
d7510b83c8 Merge pull request #307 from Glitchfinder/fixes
Additional fixes and patches.
2012-11-11 11:44:54 -08:00
Glitchfinder
9a9e0cc7de Modifying the amount of experience earned when using Tree Feller on jungle trees. It was nerfed a bit too much. 2012-11-10 12:45:54 -08:00
Glitchfinder
a8a90ee815 Fixing excessive null chunk before earning Woodcutting experience. 2012-11-10 12:43:08 -08:00
Glitchfinder
7859660ece Adding herbalism green thumb ability to carrots, potatoes, and netherwart. 2012-11-09 16:37:12 -08:00
Glitchfinder
b93dafee63 Applying a temporary patch to stop the wrong sand and gravel from being flagged as touched by players. 2012-11-09 09:45:50 -08:00
TfT_02
a1a61e9d4a Added new method for calculating the ShakeChance 2012-11-08 20:15:40 +01:00
TfT_02
464d6bdd35 Added the shake percentage
There are associated stats now.

Also added a '%' to Arcane chances in locale file
2012-11-08 20:15:02 +01:00
Glitchfinder
2c613d5b99 Fixing a null pointer error related to skill cooldowns. 2012-11-07 19:04:17 -08:00
Glitchfinder
d1f683b8a5 Adding the option to negate experience earned for Acrobatics or Herbalism while in a minecart to prevent afk leveling. 2012-11-07 18:41:18 -08:00
TfT_02
f4bb8ccb7d Add Shake chances in the default config.yml 2012-11-07 14:14:49 +01:00
TfT_02
00364afd8f Made the shake rank chance configurable 2012-11-07 14:02:30 +01:00
TfT_02
f5f07f7016 This wasn't right. 2012-11-07 13:32:30 +01:00
TfT_02
2bdeeb2d6e Changed shake drops from guaranteed to based upon fishing level and perks. 2012-11-07 13:30:20 +01:00
Glitchfinder
f023529d37 Reducing filesystem usage. Should help reduce lag on larger servers. THIS IS NOT A PERMANENT SOLUTION. 2012-11-06 23:15:15 -08:00
NuclearW
b8d37cb223 Merge pull request #299 from Glitchfinder/master
Fixing index error.

Better not do this all night, I'm not sticking around for that much :I
2012-11-05 20:18:26 -08:00
Glitchfinder
88ed14fe5c Fixing index error. 2012-11-05 20:14:23 -08:00
NuclearW
cd30771775 Merge pull request #298 from Glitchfinder/master
Fixing conversion lag.
2012-11-05 19:50:29 -08:00
Glitchfinder
00a5bc5cf3 Fixing lag caused by conversion. 2012-11-05 19:48:41 -08:00
Glitchfinder
a17d58fe32 Fixing previous commit. 2012-11-05 19:42:18 -08:00
Glitchfinder
c21286dbc3 Offloading chunk conversion. SHould alleviate lag. 2012-11-05 19:28:00 -08:00
Glitchfinder
7fc99630e0 Resolving a few issues with playability. Should be a bit better. 2012-11-05 18:02:53 -08:00
NuclearW
69a5cd1017 Merge pull request #295 from Glitchfinder/master
Updating block storage to a region-style format.
2012-11-05 17:37:49 -08:00
Glitchfinder
3129acfc19 General cleanup for pull request. 2012-11-05 16:03:44 -08:00
Glitchfinder
c3dd777e44 Merge remote-tracking branch 'mcmmo/master' 2012-11-05 14:02:07 -08:00
Grant
c5120b9c72 Merge pull request #293 from Glitchfinder/fixes
Additional fixes and patches.
2012-11-05 07:53:50 -08:00
Glitchfinder
91a18fe7a2 Fixing herbalism to look for cobble walls when trying to convert cobble walls. 2012-11-04 21:47:15 -08:00
Glitchfinder
62f5185a1b Attempting to fix index error. 2012-11-04 20:36:47 -08:00
Glitchfinder
f4cb83319e Fixes an NPE involving certain explosions. 2012-11-04 16:39:06 -08:00
Glitchfinder
c7b3b7a826 Green thumb now converts cobble walls to mossy cobble walls. 2012-11-04 16:06:33 -08:00
Glitchfinder
01fb245da3 Fixing double drops for herbalism so that carrots and potatoes drop items instead of blocks. 2012-11-04 15:54:22 -08:00
Glitchfinder
83e072dad1 Fixing a potential error with legacy chunklet types. 2012-11-04 13:43:14 -08:00
Glitchfinder
eb5ac80714 Updating modified block storage to a region-style format. 2012-11-04 13:36:57 -08:00
Grant
b57cc7bd59 Merge pull request #284 from Glitchfinder/master
Attempting to resolve various issues in the issue tracker.
2012-11-04 11:24:32 -08:00
Glitchfinder
d532164cd6 Incorporating #287 due to incompatible edits. 2012-11-02 08:45:50 -07:00
Glitchfinder
61ae4826d1 Addresses issue #286. 2012-11-01 16:43:59 -07:00
Glitchfinder
be4e62fe9d Hopefully addresses part of the empty enchant issue. 2012-10-31 22:47:04 -07:00
Glitchfinder
d9346ab260 Fixing default experience for the newer herbalism materials. 2012-10-31 15:44:45 -07:00
Glitchfinder
87c4f318a4 Fixing fishing a bit. 2012-10-31 12:39:04 -07:00
Glitchfinder
30b87e8035 Resolving potential conflict with #285. (Missed the newline) 2012-10-30 20:12:43 -07:00
Glitchfinder
26a85846fc Resolving potential conflict with #285. 2012-10-30 20:11:24 -07:00
Glitchfinder
cd40507609 Resolving issue #211. 2012-10-30 20:05:37 -07:00
Glitchfinder
a9ea2e0137 Resolving issue #258. 2012-10-30 19:24:20 -07:00
Glitchfinder
6964f7adfc Resolving issue #238. 2012-10-30 18:12:50 -07:00
Glitchfinder
70231b6ae0 Resolving issues #243, #241, and #234. 2012-10-30 17:59:58 -07:00
U-YUE\Sean
9354831729 Finished fixing issues #272, #266, #261, and #255. 2012-10-30 13:14:22 -07:00
U-YUE\Sean
ab7a83b37e Attempting to fix issues #272 , #266 , #261 , and #255 . 2012-10-30 11:46:52 -07:00
U-YUE\Sean
8dfa8c20f3 Resolving first half of issue #283 . Recommend closing issue and reopening with a new ticket number for the issue regarding stats. Stat bug probably involves commit @42aa42699129448ef7fa0e4e5de96840004c13ee 2012-10-30 10:26:46 -07:00
Grant
67499eeff7 Merge pull request #281 from Glitchfinder/master
Fixed checked data values for carrots and potatoes.
2012-10-30 07:01:35 -07:00
Grant
d43ff6263f Merge pull request #282 from Glitchfinder/master
Adds support for newer mobs to the fishing shake ability.
2012-10-30 07:01:25 -07:00
Glitchfinder
058dc8c611 Added support for newer mobs to fishing's shake ability. 2012-10-29 14:27:22 -07:00
Glitchfinder
8871964be0 Fixing checked data values for carrots and potatoes. 2012-10-29 12:33:13 -07:00
Grant
42aa426991 Merge pull request #271 from mcunha/better-db-handling
Better db handling
2012-10-29 10:25:49 -07:00
Grant
7cee94e0b8 Merge pull request #274 from zippy120/master
Added checks in the events to prevent errors when Citizens NPCs perform tasks.
2012-10-29 10:25:39 -07:00
Grant
fa96a6beec Merge pull request #278 from Glitchfinder/master
Basic update for 1.4.2
2012-10-29 10:25:29 -07:00
Grant
efc0edf3ef Merge pull request #279 from mcunha/fix-mossied-cobblestone
Don't award double drops to mossified cobblestone
2012-10-29 10:25:07 -07:00
Marco Cunha
f1d785777c Don't award double drops to mossified cobblestone 2012-10-29 17:17:52 +01:00
Glitchfinder
db0168205d Added herbalism food bonuses. 2012-10-28 22:47:26 -07:00
Glitchfinder
2a20ed95fa Added missed checks for potatoes and carrots. 2012-10-28 20:56:33 -07:00
Glitchfinder
11f1889f1f Added support for carrots and potatoes. Also updated to ignore beacon blocks and anvil blocks. 2012-10-28 20:53:03 -07:00
zippy120
703b5b2f3f Added checks in the events to prevent errors when Citizens NPCs perform tasks. 2012-10-28 09:26:46 -06:00
Marco Cunha
58a15e61dd Fix refactoring typos 2012-10-22 19:05:13 +02:00
Marco Cunha
896f57f0b4 Force proper disposal of resultsets and statements 2012-10-22 15:03:31 +02:00
Marco Cunha
34ae64706e Improved DB connection handling
Support for aggressive connection timeouts, with exponential backoff
for multiple failures.
2012-10-22 14:45:16 +02:00
Grant
43fe92fe3f Merge pull request #269 from Glitchfinder/master
Finished adding skill checks for Emerald Ore and Cocoa.
2012-10-18 08:34:47 -07:00
Glitchfinder
31513d52d7 Fixing spacing issues and making herbalism drop cocoa beans instead of a cocoa block. 2012-10-17 21:26:16 -07:00
Glitchfinder
70a16fe344 Finished adding skill checks for Emerald Ore and Cocoa. 2012-10-17 13:41:19 -07:00
nossr50
4570ffb8f5 Merge pull request #263 from h31ix/enderchest2
Don't activate abilities by opening an Ender Chest
2012-09-30 18:38:34 -07:00
h31ix
22f6ed324d Added ender chest to list of blocks that should not cause ability activation 2012-09-30 12:48:20 -04:00
nossr50
e29484e14b Merge pull request #252 from mcunha/master
Fix ore dupe bug with ore blocks on pistons
2012-09-09 16:50:17 -07:00
Marco Cunha
7e21fdd862 Fix ore dupe bug with ore blocks on pistons 2012-09-10 01:53:16 +03:00
nossr50
01e69cdf5e Fixing some mistakes. 2012-09-07 14:49:00 -07:00
nossr50
9ad7840236 Merge pull request #246 from matix931/patch-4
Update src/main/java/com/gmail/nossr50/config/Config.java
2012-09-05 21:11:15 -07:00
nossr50
e97ec36094 Merge pull request #247 from matix931/patch-5
Update src/main/resources/config.yml
2012-09-05 21:11:07 -07:00
nossr50
ef318eeaec Merge pull request #248 from matix931/patch-7
Update src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java
2012-09-05 21:10:58 -07:00
nossr50
3314b18318 Merge pull request #249 from matix931/patch-6
Update src/main/java/com/gmail/nossr50/skills/gathering/Mining.java
2012-09-05 21:10:44 -07:00
matix931
5f04ecfdd4 Update src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java 2012-09-05 11:45:43 +03:00
matix931
91d294acff Update src/main/java/com/gmail/nossr50/skills/gathering/Mining.java
Another change against 1.3.2
2012-09-05 11:19:34 +03:00
matix931
283cdeed6c Update src/main/resources/config.yml 2012-09-05 11:10:50 +03:00
matix931
a283fce4ec Update src/main/java/com/gmail/nossr50/config/Config.java
Doing something against 1.3.2
2012-09-05 11:09:14 +03:00
nossr50
f8d525d797 Merge branch 'master' of https://github.com/mcMMO-Dev/mcMMO 2012-09-03 13:27:11 -07:00
nossr50
80dabad10e Nerfs to axes 2012-09-03 13:26:48 -07:00
nossr50
8181989e98 Merge pull request #240 from matix931/patch-3
Update src/main/java/com/gmail/nossr50/skills/repair/Repair.java
2012-09-02 08:04:26 -07:00
matix931
0f7bf13834 Update src/main/java/com/gmail/nossr50/skills/repair/Repair.java
When DowngradeChance is 0 random can be the same (0 to 99) so can't be <= becouse downgrade will continue
2012-08-31 18:03:54 +03:00
nossr50
c1d6e79a41 Vampirism fix 2012-08-30 09:16:08 -07:00
nossr50
6f073250f4 Merge pull request #233 from t00thpick1/master
Added missing null check
2012-08-18 06:19:00 -07:00
t00thpick1
c084ccde40 Added missing null check 2012-08-17 18:45:08 -03:00
nossr50
b73a06b9ab Merge pull request #232 from t00thpick1/master
Actually fixed dupes
2012-08-16 22:23:27 -07:00
t00thpick1
740c1131ea Made superbreaker not dupe if event is cancelled 2012-08-17 01:28:28 -03:00
t00thpick1
0a798aec30 Made gigadrill not dupe if event is cancelled 2012-08-17 01:27:41 -03:00
nossr50
9089e70155 Dupes are bad mmkay 2012-08-14 14:24:54 -07:00
nossr50
f532630d1b Another fix to make us more compatible with other plugins 2012-08-14 14:21:07 -07:00
nossr50
7b47d32a96 Citizens compatibility. Bug fix for Woodcutting/custom trees. 2012-08-14 14:09:49 -07:00
nossr50
3934392219 Did somebody say HOTFIX? 2012-08-14 13:52:31 -07:00
nossr50
ed6f48b5fe Merge pull request #215 from btarb24/master
Player command to reset a skill level (for when cap is enabled)
2012-08-09 13:10:44 -07:00
nossr50
729e4a6eac Fixed some deprecated things, removed some unneeded imports. 2012-08-07 17:41:13 -07:00
nossr50
9a39dead4f Forgot an import. 2012-08-07 17:38:28 -07:00
nossr50
cb1eabc3fa 1.3.10 release soon, added 1.3.1 compatibility 2012-08-07 16:49:25 -07:00
nossr50
b30002948c Fix for COTW and a fix for stat wipes w/ offline mode off for FlatFile 2012-08-04 15:21:34 -07:00
Bill Tarbell
d528f11082 Allow global multiplier to be a double 2012-08-01 19:32:25 -04:00
GJ
42a1fdf2df Removed deprecated function in 1.2.5-R5 2012-07-31 09:06:23 -04:00
Bill Tarbell
394ddd4e51 copy paste error. 2012-07-30 00:02:41 -04:00
Bill Tarbell
8c7d95f9ea Add player command to reset skill levels 2012-07-29 23:49:42 -04:00
Bill Tarbell
422550abfd Display power level cap on mcstats command 2012-07-29 20:05:05 -04:00
GJ
ca9ce1ba1b Fixed possible ClassCastException from catching something other than a
mob when using the Shake Mob skill
2012-07-21 09:37:17 -04:00
nossr50
ac1c420cb5 Ryokai! 2012-07-13 10:01:51 -07:00
GJ
05a9e85529 No reason to pull the ArrayLists every time. 2012-07-10 14:52:43 -04:00
GJ
ca6ed76e8f Log when someone's missing from a table. 2012-07-10 14:43:48 -04:00
GJ
3d04da39e3 Null check our DB tables. 2012-07-10 14:38:51 -04:00
GJ
127908f104 Save the tablePrefix as a String. 2012-07-10 14:32:56 -04:00
GJ
686bcd5308 Null check ALL the profiles.
We should probably find a more elegant way to do this, though.
2012-07-10 14:02:48 -04:00
GJ
07c66378c0 Some optimizations to how we handle our SQL connections and queries. 2012-07-10 12:04:18 -04:00
GJ
4e7107c8a8 Remove unused variable 2012-07-09 11:12:58 -04:00
GJ
3c2d658b37 Protect our database. 2012-07-09 11:12:46 -04:00
GJ
f0b2cc1bab Protect our file paths. 2012-07-09 10:55:33 -04:00
GJ
d038cbf357 Bad variables names are bad. 2012-07-09 10:47:33 -04:00
GJ
c3ea632cb9 This should be private. 2012-07-09 10:46:55 -04:00
GJ
a31d50924d Only create objects where we need them. 2012-07-09 10:43:16 -04:00
GJ
c567e2714a Fixed custom woodcutting blocks throwing errors. 2012-07-09 09:26:22 -04:00
bm01
a2e342b4fc Oops 2012-07-08 00:17:33 +02:00
bm01
4469637f27 NPE prevention for Users.getProfile() 2012-07-08 00:02:40 +02:00
bm01
f4ecbe7f65 Removed unused import 2012-07-07 23:48:36 +02:00
bm01
dbaab4efe1 Don't call SpoutStuff if Spout isn't enabled 2012-07-07 23:48:22 +02:00
bm01
8c178869b7 Fixed /mcremove 2012-07-07 23:38:05 +02:00
NuclearW
3c7bcb990e NPE Prevention 2012-07-07 17:02:33 -04:00
NuclearW
f7a5678814 Change ChunkletManager to a notify/demand system
Allowing NullChunkletManager to bypass the ChunkletUnloader as it is not needed.
2012-07-07 14:43:14 -04:00
NuclearW
646bb32965 Let the Unit testing begin
Could use some more test cases on the make test, though
2012-07-07 14:43:14 -04:00
NuclearW
dce7d8fdd3 Format this before GJ finds out 2012-07-07 14:43:14 -04:00
NuclearW
6dd17312f4 Change this back to private 2012-07-07 14:43:14 -04:00
NuclearW
9c64f40ea1 Changelog 2012-07-07 14:43:13 -04:00
NuclearW
da6b461408 Move our Externalizeable to PrimitveExChunkletStore
This will let us deserialize Primitive normally.

In addition, we now enforce all chunklets being of type PrimitiveEx, as any non-Ex are repalced with a new Ex on load.
2012-07-07 14:43:13 -04:00
NuclearW
77dce75108 Formatting a single line 2012-07-07 14:43:13 -04:00
NuclearW
37308917d1 Parenthesis for clarity 2012-07-07 14:43:13 -04:00
NuclearW
21d2229572 Column comment 2012-07-07 14:43:13 -04:00
NuclearW
7d372af51e Some address byte comments 2012-07-07 14:43:12 -04:00
NuclearW
a3e0753076 We must be sure to flush 2012-07-07 14:43:12 -04:00
NuclearW
a728d1f9c8 These must be called in the reverse order we open them 2012-07-07 14:43:12 -04:00
NuclearW
b893e86f3c A bit more clear
But no functional change
2012-07-07 14:43:12 -04:00
NuclearW
63cf6e9b3a Do not increment i in this location 2012-07-07 14:43:12 -04:00
NuclearW
67738d811e Move things around to fit together better 2012-07-07 14:43:12 -04:00
bm01
4d77f6d04d Introducing external chunklets 2012-07-07 14:43:11 -04:00
bm01
3702495038 Don't need to .save() for online players 2012-07-07 20:02:54 +02:00
bm01
ede08ce5ac Moved hudType back to PlayerProfile
Removed some convenient methods from PlayerProfile to avoid NPE because of
spoutHud
2012-07-07 19:59:10 +02:00
bm01
5571e0bc0c Arranged InspectCommand 2012-07-07 19:39:22 +02:00
bm01
73bb73c8ca Fixed /mmoedit 2012-07-07 19:35:32 +02:00
bm01
54011fdeb7 Removed unused OfflinePlayer from PlayerProfile 2012-07-07 19:27:47 +02:00
GJ
5b8811bd09 More work on McMMOPlayer 2012-07-06 11:57:17 -04:00
GJ
c460eec0ab Oops. 2012-07-06 09:30:30 -04:00
GJ
bc6233541a Start changing PlayerProfile to use an OfflinePlayer 2012-07-06 09:14:25 -04:00
bm01
18aef9d526 Typo 2012-07-06 07:13:52 +02:00
bm01
ccc6fd30f8 Fixed /inspect not working on offline player 2012-07-06 07:07:29 +02:00
GJ
1ba498c443 Because "final static" is just backwards. 2012-07-06 00:12:17 -04:00
GJ
64f31f2b5a Fixed issue with JSON API plugin & player chat events 2012-07-05 11:25:36 -04:00
GJ
b94085c5f4 Make 'em final 2012-07-05 09:33:57 -04:00
GJ
62b90ad552 Using .equals() is better 2012-07-05 09:25:48 -04:00
GJ
d6d1e0ffed More efficient handling of Party/Admin chat messages 2012-07-05 09:21:07 -04:00
GJ
ccd103cd88 More efficient iteration. 2012-07-05 09:11:40 -04:00
GJ
0606f16a11 pm is lazy too. 2012-07-04 15:38:26 -04:00
GJ
c9e3ea005b Because loc is lazy. 2012-07-04 15:38:25 -04:00
bm01
f009f5803f Changelog update 2012-07-04 20:24:34 +02:00
GJ
3f8268d848 Fixed custom blocks dropping the wrong thing with Super Breaker & Silk
Touch
2012-07-04 10:33:20 -04:00
GJ
cefec723d0 Javadoc typo 2012-07-04 10:12:10 -04:00
GJ
124aa72fd9 Better file handling 2012-07-04 10:00:11 -04:00
GJ
dbc7277ba9 FileWriter is pointless here. 2012-07-04 09:45:47 -04:00
GJ
24d8769b5b Remove useless FileWriter 2012-07-03 21:23:32 -04:00
GJ
4aecb9756e Improve file handling. 2012-07-03 21:21:32 -04:00
bm01
51ca29ab9f Forgot to loadKeys() 2012-07-03 23:29:26 +02:00
bm01
c6e5264b7b Print the stack trace for easier debugging 2012-07-03 23:28:58 +02:00
bm01
73203ce869 Removed unneeded method call 2012-07-03 22:05:47 +02:00
bm01
b80a29ca04 Configs rework, fixed mod config files not loading, fixed comment blocks not being copied 2012-07-03 21:57:46 +02:00
GJ
5ee440d9a5 Ensure that our stuff gets closed when working with Chunklets. 2012-07-03 15:10:35 -04:00
GJ
cda3675dc5 More bad variable names. 2012-07-03 10:14:01 -04:00
GJ
caf9c07ba3 Because PP is an awful variable name. 2012-07-03 10:04:04 -04:00
GJ
96e70aa4d2 Fixed "lower tool" messages still being displayed even when ability
messages are disabled.
2012-07-03 08:40:56 -04:00
GJ
9f1b77a007 Refactoring 2012-07-03 08:36:21 -04:00
GJ
946b5bb006 Added null checks to BlockBreak & BlockDamage events to help with mod
compatibility.
2012-07-03 07:59:36 -04:00
bm01
bebcc40987 Added missing annotations 2012-07-03 03:55:19 +02:00
bm01
d6d7f5099f Removed unused import 2012-07-03 03:54:20 +02:00
bm01
bdcc2f644b Removed unneeded instanceof 2012-07-03 03:53:51 +02:00
bm01
c3ba54a0ce Removed unneeded cast 2012-07-03 03:53:11 +02:00
bm01
1443e2f6b8 Removed unneeded null check, according to eclipse :3 2012-07-03 03:52:12 +02:00
bm01
7799acec05 Oops 2012-07-03 03:40:12 +02:00
bm01
1bbc1f28aa TrackedEntity.java cleanup 2012-07-03 03:37:11 +02:00
GJ
8257fd8e7c Tweaked a few switch statements. 2012-07-02 21:05:55 -04:00
GJ
bc58aff362 Fixed resource leak from never closing the JarFile. 2012-07-02 20:44:54 -04:00
GJ
1073954550 Lucky perk is actually a 33.3% boost. 2012-07-02 20:17:48 -04:00
GJ
c3d7a4e3de Fixed "lucky" perk making downgrades from repair more likely. 2012-07-02 19:56:48 -04:00
GJ
92ae92c116 Fixed children nodes of "lucky" perk not being set to true. 2012-07-02 19:46:47 -04:00
GJ
3c10be6d1a Added some missing defaults to switch cases. 2012-07-02 19:27:07 -04:00
bm01
f18a9bdcc7 Fixed duplication bug with sticky pistons 2012-07-02 23:54:05 +02:00
bm01
87f59cd3eb Fixed the possibility to use some abilities without the proper tool 2012-07-02 21:30:19 +02:00
GJ
819b6fcacb Added "lucky" donor perk - abilities have 25% better chance to activate 2012-07-02 11:09:55 -04:00
bm01
246961887e Build test 2012-07-01 13:09:34 +02:00
bm01
54e21333a3 Reworked some Spout stuff
among other things
2012-07-01 12:54:11 +02:00
bm01
c45beec59d Fixed repair enchant downgrade 2012-07-01 00:04:53 +02:00
bm01
c88ada489a Chunklets optimization 2012-06-30 02:38:22 +02:00
GJ
189f23f407 Fixed custom tools not handling the Ability_Enabled flag properly. 2012-06-28 11:20:53 -04:00
GJ
9789143c6d Check if player is online for EntityDamage events too. 2012-06-28 10:22:00 -04:00
GJ
f4dd7ff483 Fixed ClassDef error that prevented the server from loading unless
Spout was installed.
2012-06-28 10:03:22 -04:00
GJ
50e05c6320 Minor refactoring 2012-06-28 09:01:02 -04:00
GJ
9ba5360bfc Cleaned up inSameParty method 2012-06-28 08:14:49 -04:00
GJ
565ef693ce Fix issue with EntityDamageByEntityEvents & Offline Players 2012-06-28 08:14:49 -04:00
bm01
0c1a8eff85 Fixed NPE caused by Spout players after a /reload 2012-06-28 06:51:13 +02:00
GJ
32e9de6e9a Fix for NPE on party checks due to CombatTag plugin. 2012-06-27 23:51:18 -04:00
bm01
533955a9c7 Removed redundant calls 2012-06-28 05:35:56 +02:00
bm01
2faa0356a5 It's better that way 2012-06-27 20:46:45 +02:00
GJ
ee2a5c199a Added functionality to specify custom blocks that should not trigger
abilities.
2012-06-27 14:46:44 -04:00
bm01
bdcc522897 Fixed ConcurrentModificationException on world unload 2012-06-27 20:39:54 +02:00
GJ
71b20bdeaa Fixed ArrayIndexOutOfBounds error 2012-06-27 11:18:04 -04:00
GJ
0e85b4776a Add more XP boost permissions nodes. 2012-06-27 08:31:10 -04:00
GJ
24d2c1bc7a Fix for UTFDataFormatException 2012-06-26 14:58:51 -04:00
GJ
1610e932c6 Removed some debug code that got left in... 2012-06-26 13:23:56 -04:00
GJ
31d7bb2332 Javadoc fix 2012-06-26 08:03:19 -04:00
GJ
3d9c03c0c8 Added a few requested functions to the ExperienceAPI 2012-06-26 08:02:49 -04:00
bm01
dd94343d92 One more fix to admin chat 2012-06-25 21:35:38 +02:00
GJ
4b93dede33 Add ability to check if any ability is enabled. 2012-06-25 10:35:47 -04:00
GJ
61205989cc Cleanup cooldown monitoring a bit. 2012-06-25 10:29:29 -04:00
GJ
2559ea61d8 Added Ability API 2012-06-25 10:05:47 -04:00
GJ
eae665c1c5 Added ability for custom blocks to drop a range of items. MOD BLOCK
FILES WILL NEED TO BE REDONE.
2012-06-25 09:47:22 -04:00
bm01
d73521e0a0 Fixed admin chat being seen by everyone 2012-06-25 15:05:20 +02:00
GJ
e8deb0384a Fix Iron Grip calculations using incorrect values. 2012-06-25 08:54:05 -04:00
GJ
881f2c023e Added permission node for Iron Grip 2012-06-25 08:54:05 -04:00
bm01
5057a8a7a3 Fixed memory leak in ProfileSaveTask 2012-06-25 14:38:07 +02:00
bm01
b8e9269488 Made things cleaner 2012-06-25 14:37:18 +02:00
GJ
76afd5a7ca Back to new development. 2012-06-25 08:29:58 -04:00
bm01
dc48d467f5 Return to HashMap! 2012-06-24 22:46:45 +02:00
nossr50
0b0390620e Whoops :D 2012-06-24 13:26:49 -07:00
nossr50
24eb34c182 Back to the old way of doing things 2012-06-24 13:26:21 -07:00
nossr50
1a5bd1b6a2 Getting ready for release 2012-06-24 12:59:54 -07:00
nossr50
ab7b6ce460 Fixed bug that caused NPE when trying to compare null parties 2012-06-24 12:48:03 -07:00
GJ
c4cd677021 Added new methods to replace deprecation in latest Bukkit. Commented out
until RB.
2012-06-23 12:13:51 -04:00
bm01
6b84d39dda Fixed AE abilities not being applied correctly 2012-06-22 23:10:17 +02:00
bm01
e61342177d Simplified combat ability checks 2012-06-22 20:20:28 +02:00
bm01
d51fa92b46 Made 'shooterless' arrows dodgeable 2012-06-22 19:39:14 +02:00
bm01
3e20dc7de6 combatChecks optimization 2012-06-22 18:54:49 +02:00
GJ
dce1d7ba39 Fixed calculations on Reduced Cooldown perk 2012-06-22 10:57:51 -04:00
GJ
adffea1d52 Increased the seconds for activation time perk. 2012-06-22 10:13:37 -04:00
GJ
20b73dcc84 Fixed not checking if an Entity was a LivingEntity before applying the
Counter-Attack ability.
2012-06-22 09:47:18 -04:00
GJ
b331fa353b Added increased activate time donor perks 2012-06-21 23:01:02 -04:00
GJ
9fe14609af Locale update. 2012-06-21 22:26:29 -04:00
GJ
f6973b8907 Changelog update. 2012-06-21 21:51:43 -04:00
GJ
8738036f6f Added Reduced Cooldown perk for donors. 2012-06-21 21:50:48 -04:00
GJ
fce02dc0e5 Fixed possible NPE with Acrobatics fall checks. 2012-06-21 21:04:19 -04:00
GJ
2bef0e833f Rework of Swords handling 2012-06-21 09:04:45 -04:00
GJ
9040a2a2e3 Optimizations to Combat.java 2012-06-18 08:50:14 -04:00
NuclearW
4407ed0a6f Fixed bug with Chunklets not being reloaded on /reload 2012-06-16 21:43:04 -04:00
GJ
09721518b0 Fixed Unarmed using Taming levels.
My copy-paste skills are failing.
2012-06-15 11:11:57 -04:00
GJ
8ad6337dde Avoid calling the same thing 3 times. 2012-06-15 10:58:38 -04:00
bm01
271740d2ac Re-added mcMMO.getPlayerProfile(Player) 2012-06-15 10:03:00 +02:00
GJ
48dd537257 More reworking of Unarmed, renamed ArcheryBonusDamageEventHandler for
clarity's sake.
2012-06-14 23:59:36 -04:00
GJ
77b4aaa50d Updating Unarmed (WIP) 2012-06-14 23:59:35 -04:00
bm01
1014316581 Whoops D: 2012-06-15 03:32:46 +02:00
bm01
739cd83155 Forgot to cancel the task 2012-06-15 03:30:36 +02:00
bm01
df08bc4da0 Changelog update 2012-06-15 02:56:36 +02:00
bm01
55e832d4f6 Do not track arrow if the bow has Infinity 2012-06-15 02:53:11 +02:00
bm01
032472dcb3 Avoid unnecessary iteration 2012-06-15 02:46:41 +02:00
bm01
68bf93d1ac Remove inactive entities from the arrow tracker 2012-06-15 02:43:13 +02:00
bm01
ba133f94fc Extra equals 2012-06-15 02:34:24 +02:00
bm01
064c16f4d7 Reverted last commit 2012-06-15 02:14:53 +02:00
bm01
5a394ee744 Fixed killed entities not being removed from arrowTracker 2012-06-15 02:08:15 +02:00
bm01
3bc2f5dc55 Fixed Archery using Taming skill level 2012-06-15 02:06:06 +02:00
GJ
6f63818e5f Check for the block before throwing the fake break event. 2012-06-14 10:24:58 -04:00
GJ
a5d7bee939 Spacing 2012-06-14 00:01:31 -04:00
bm01
9d396162f1 Hardcore.java cleanup 2012-06-14 01:22:35 +02:00
bm01
4a0d9a96ab Fixed minor bug with Vampirism notification 2012-06-14 00:48:40 +02:00
GJ
9f65e5a9ab PermissionsHandler was a stupid idea. 2012-06-13 12:31:20 -04:00
GJ
c71f4e438b Organize imports. 2012-06-13 08:54:02 -04:00
GJ
14d13eb4c7 Archery rework. 2012-06-13 08:53:18 -04:00
GJ
29c629eb22 WIP on Archery rework. 2012-06-12 21:36:17 -04:00
bm01
050b794b42 Fixed NPE with /mmoedit 2012-06-12 23:31:32 +02:00
NuclearW
89b5f8c275 Changelog 2012-06-12 17:01:18 -04:00
NuclearW
f589197321 Load the lowest chunklets right now.
Thanks for @Glitchfinder for finding this glitch.

Closes #205
2012-06-12 17:00:05 -04:00
NuclearW
09575a68f0 Handle corrupt chunklets by making a new one and not throw stacktrace 2012-06-12 16:45:28 -04:00
NuclearW
c1b838e356 Typo fix 2012-06-12 16:45:00 -04:00
GJ
8ed2696315 Fix issue with trying to remove all of the item in hand. 2012-06-12 15:11:13 -04:00
GJ
ab138bdba2 Javadocs, added Lighting to the damage types affected by Shock Proof 2012-06-12 14:48:28 -04:00
GJ
5ba9fb78fd More tweaks to Taming. 2012-06-12 14:42:38 -04:00
GJ
2d47447375 Begin rework of Taming skill 2012-06-12 11:07:51 -04:00
GJ
d9eaede4c2 Spacing 2012-06-12 11:07:27 -04:00
GJ
c6db11a10b Use EntityDamage event instead of EntityDamageByEnitity 2012-06-12 10:23:34 -04:00
GJ
2225e542ad Spacing issues. 2012-06-12 09:20:39 -04:00
GJ
975e13d45f Tweaked how we check XP gain permissions. 2012-06-12 08:10:18 -04:00
bm01
534a165c45 Tweaked a few things 2012-06-12 06:18:00 +02:00
bm01
5cff6ed67b Removed xpGainATS, it actually never worked 2012-06-12 05:59:26 +02:00
bm01
3448733834 Removed unused variable 2012-06-12 05:40:07 +02:00
bm01
c382c95d24 Re-added respawnATS 2012-06-12 05:38:32 +02:00
GJ
0034226fa7 Reorder constructors to avoid errors 2012-06-11 21:03:49 -04:00
GJ
5f067a6bb5 More tweaks to Acrobatics. 2012-06-11 20:37:09 -04:00
GJ
6ab1996440 Reworking of Acrobatics, plus an Acrobatics bugfix. 2012-06-11 16:11:23 -04:00
bm01
5bff6d63f2 Removed unneeded reference 2012-06-11 08:26:48 +02:00
bm01
5fe227b874 Forgot to change getParties 2012-06-11 08:26:22 +02:00
bm01
cbaf2f8370 More work on parties 2012-06-11 07:50:10 +02:00
bm01
393ac886e2 Removed unneeded method 2012-06-10 06:57:55 +02:00
bm01
c9082083d1 Merged ProfileSaveTask and RemoveProfileFromMemory 2012-06-10 06:56:39 +02:00
bm01
5d0d89e74d Changed party name restriction 2012-06-09 22:24:04 +02:00
bm01
e9c3583fd8 Added few forgotten things 2012-06-09 20:11:11 +02:00
bm01
81eadc1418 No longer use/save party name in database and users flat file 2012-06-09 19:48:18 +02:00
bm01
dfff0efc0b Cleanup 2012-06-09 19:29:44 +02:00
bm01
3732db2226 Reworked Party 2012-06-09 03:08:36 +02:00
bm01
e9ccdcfbbe Missing space! 2012-06-08 20:04:45 +02:00
bm01
01345a5dc4 Fixed /mcremove on existing PlayerProfile 2012-06-08 20:03:02 +02:00
bm01
90c8e57ed7 Reworked a little Users.java 2012-06-08 20:00:02 +02:00
GJ
d644b4c331 Fixed NPE with repairing items that rely on metadata. 2012-06-06 18:27:52 -04:00
GJ
2f15c71412 Because making it upper case broke all the things. 2012-06-06 18:02:22 -04:00
GJ
0a44a74f59 Cleanup (Yes, I'm that picky). 2012-06-06 16:49:42 -04:00
bm01
f876fe8d25 Made API classes 'statics' 2012-06-06 22:04:21 +02:00
GJ
290032646f Protect our hashmaps from bad people. 2012-06-06 15:38:44 -04:00
GJ
e5d2ed4bb2 Because lowercase class names are evil. 2012-06-06 14:49:07 -04:00
GJ
e9ea0e0389 Created a variable for player name. 2012-06-06 09:32:01 -04:00
bm01
35565bb021 Removed PlayerProfile save on User.removeUser, it's already done in RemoveProfileFromMemoryTask 2012-06-06 02:20:33 +02:00
bm01
56aff1d191 Replaced playerName fields in PlayerProfile and Users by the Player object 2012-06-06 02:03:27 +02:00
GJ
b8be1d1866 Fix the Javadocs 2012-06-05 11:05:51 -04:00
GJ
1d7d2cd52e Make it static. 2012-06-05 11:05:44 -04:00
GJ
71446a12af Static ALL the things! 2012-06-05 10:42:56 -04:00
GJ
ca6cafaebd Cleanup 2012-06-05 10:42:56 -04:00
GJ
c97be335ee Avoid using mcMMO.p when we can 2012-06-05 10:42:56 -04:00
GJ
fd1227b87e No need for public constructor 2012-06-05 10:42:56 -04:00
bm01
7ef72c501e Cleanup 2012-06-05 16:32:26 +02:00
GJ
f7ee96aa99 Fixed bug where admin chat was displayed to the whole server. 2012-06-05 10:19:23 -04:00
GJ
b84478898d Cleanup. 2012-06-05 10:18:05 -04:00
GJ
6afe0e8a34 Organize imports. 2012-06-05 10:13:10 -04:00
GJ
6e4f4b5c8d More cleanup. 2012-06-05 10:07:45 -04:00
bm01
f86fe4a138 Changelog update 2012-06-05 16:03:08 +02:00
bm01
63c663b8c1 Fixed Archery PVP/PVE enablement not being used properly 2012-06-05 16:00:32 +02:00
bm01
a1296596fa Fixed possible NPE when a projectile doesn't have a shooter 2012-06-05 16:00:27 +02:00
GJ
1cca4de9e5 Cleanup! 2012-06-05 09:57:10 -04:00
GJ
7ada587df3 More Spout tool stuff. 2012-06-04 10:36:24 -04:00
GJ
1e58c32a5f Change XP processing to use a single function. 2012-06-04 09:30:51 -04:00
GJ
2a27048174 Functions that start with capital letters are bad. 2012-06-04 09:08:41 -04:00
GJ
2b291954cf Javadocs. 2012-06-04 09:03:25 -04:00
GJ
8f8bfc62ca Cleanup. 2012-06-04 08:51:10 -04:00
GJ
38d4d448a9 Remove unused imports. 2012-06-04 08:46:12 -04:00
nossr50
d5d11ca4bd Whoops 2012-06-03 15:39:13 -07:00
nossr50
e3e400f376 This should make us AntiCheat friendly. 2012-06-03 14:38:33 -07:00
GJ
6637758ad0 Fixed Spout item checks. 2012-06-01 15:29:16 -04:00
GJ
41e9bd3cb5 WIP - Spout custom tool support 2012-05-31 16:02:11 -04:00
GJ
c2d1909379 Changelog update. 2012-05-31 16:00:20 -04:00
GJ
77688f297f Fixed a few permissions errors. 2012-05-31 15:23:38 -04:00
GJ
714f665cc7 Woodcutting to SkillCommand 2012-05-31 15:15:00 -04:00
GJ
ec138d5741 Unarmed to SkillCommand 2012-05-31 15:14:59 -04:00
GJ
560e5aa19a Taming to SkillCommand 2012-05-31 15:14:59 -04:00
GJ
ad162f3366 Swords to SkillCommand 2012-05-31 15:14:59 -04:00
GJ
5d07830339 Repair to SkillCommand 2012-05-31 15:14:59 -04:00
GJ
b310d25ee3 Cleanup. 2012-05-31 15:14:59 -04:00
GJ
443ccbd807 Mining to SkillCommand 2012-05-31 15:14:59 -04:00
GJ
8cdecf80c7 Herbalism to SkillCommand 2012-05-31 15:14:59 -04:00
GJ
a16d5435de Removed unneeded function call. 2012-05-31 15:14:59 -04:00
GJ
ec02422226 Fishing to SkillCommand 2012-05-31 15:14:58 -04:00
GJ
cc5d438550 Excavation to SkillCommand 2012-05-31 15:14:58 -04:00
GJ
806d116501 Axes to SkillCommand 2012-05-31 15:14:58 -04:00
GJ
066c9d9fec Archery to SkillCommand 2012-05-31 15:14:58 -04:00
GJ
5b3b9fbc30 Tweak the way SkillCommands are constructed. 2012-05-31 15:14:58 -04:00
GJ
d15e189b7c Acrobatics to SkillCommand 2012-05-31 15:14:58 -04:00
GJ
1bd9974f89 Abstract Skill Commands 2012-05-31 15:14:58 -04:00
NuclearW
90296d87df Similarly return admin chat to ye olden method 2012-05-30 11:18:47 -04:00
NuclearW
75b287771a Return party chat to ye olden method 2012-05-30 11:18:46 -04:00
GJ
5765504796 Locale updates. 2012-05-30 11:11:07 -04:00
GJ
dda8c0c9e0 Fixed bug with Tree Feller changing durability too soon. 2012-05-30 10:48:25 -04:00
GJ
ce9d668602 Fixed bug with locale strings and party teleport. 2012-05-30 10:41:22 -04:00
NuclearW
39c2c5f25f Handle EOFException in Chunklets by returning a new empty ChunkletStore and printing an error. 2012-05-29 21:02:36 -04:00
nossr50
12a7d794b4 Always forget the changelog 2012-05-28 17:02:02 -04:00
nossr50
ff8b0300ae Make the MOTD prettier about the perks 2012-05-28 16:49:21 -04:00
NuclearW
f882df4cb7 Fix this yaml error 2012-05-28 16:43:06 -04:00
nossr50
e1300005cb Notify users of their perks on login (if MOTD enabled) 2012-05-28 13:14:10 -07:00
nossr50
e599ab9214 Added permissions that will grant users 4x 3x or 2x XP 2012-05-28 13:07:52 -07:00
GJ
92acf62884 More mod fixes for Woodcutting. 2012-05-27 14:40:35 -04:00
GJ
c2fb57fce9 Fix Tree Feller not working with custom axes 2012-05-27 14:31:37 -04:00
GJ
3699d26e5d Only try to back up the mod files if they exist... 2012-05-27 10:23:13 -04:00
GJ
6eb0159ea1 More tracking of falling sand/gravel. (WIP) 2012-05-27 10:21:00 -04:00
GJ
433913c77a Another fix for falling sand/gravel tracking issues. 2012-05-27 09:42:38 -04:00
bm01
d955feef61 Fixed piston tracking 2012-05-27 10:34:04 +02:00
GJ
5377b9b618 Remove debug messages. 2012-05-26 21:11:50 -04:00
GJ
5c9371c575 Fixed falling sand/gravel stuff not being tracked 2012-05-26 19:52:24 -04:00
GJ
23d916f191 Fixed dupe exploit with pistons (again). 2012-05-26 10:50:12 -04:00
GJ
35d4914518 This has to be Arrow to keep Potions from giving XP. 2012-05-24 15:26:01 -04:00
GJ
eb2ec71d2b More priority tweaks. 2012-05-24 14:17:51 -04:00
GJ
dc50758dc9 Minor priority tweaks to the Spout XP bar. 2012-05-24 14:02:23 -04:00
GJ
9775d71c28 Cleanup. 2012-05-24 10:35:46 -04:00
GJ
c40e4ee9ee Cleanup. 2012-05-24 10:30:07 -04:00
GJ
2b469c385c Changelog update 2012-05-24 08:39:13 -04:00
GJ
a104fe45aa Fix for NoCheatPlus fight.noswing checks 2012-05-24 08:38:44 -04:00
bm01
257df25a67 Fixed NPE, Config.defaulthud was used instead of SpoutConfig.defaulthud 2012-05-24 06:58:11 +02:00
bm01
2a977557c2 Made sure that SpoutConfig.load is called when the instance is created, for safety 2012-05-24 06:18:43 +02:00
bm01
d0e9f03311 Reverted last commit from NuclearW 2012-05-24 05:29:05 +02:00
bm01
97ca699170 Removed unneeded method override 2012-05-24 05:27:29 +02:00
NuclearW
702537e8fd We don't need this 2012-05-23 15:33:08 -04:00
NuclearW
83a3488d0d Because loading a config we hadn't made yet makes sense 2012-05-23 15:32:58 -04:00
GJ
450e938092 Change Spout Config file to only load if Spout is enabled.
Removed unused imports.
2012-05-23 14:31:03 -04:00
GJ
b88e076f27 Updates to config loading. 2012-05-23 13:52:33 -04:00
GJ
0fe90df01e Cleanup. 2012-05-23 11:16:23 -04:00
GJ
66ad909908 Cleanup. 2012-05-23 11:08:56 -04:00
GJ
77d74717d2 Moved all Spout checks into one listener. 2012-05-23 11:06:02 -04:00
GJ
63f683982f Moved Spout stuff to its own config file. 2012-05-23 10:50:47 -04:00
GJ
9525ce8299 Cleanup. 2012-05-23 09:35:16 -04:00
GJ
d7b8ec1274 Cleanup. 2012-05-23 07:33:19 -04:00
GJ
96cd16faf7 Cleanup 2012-05-23 07:32:03 -04:00
NuclearW
9ddc7501fe Derp 2012-05-22 09:16:40 -04:00
NuclearW
301c496fb2 Onward to 1.3.09 2012-05-22 08:45:21 -04:00
NuclearW
3eb265c5f7 1.3.08
Minor addition to changelog
2012-05-22 08:42:06 -04:00
GJ
049338e83b Remove unused variables & methods from old repair system 2012-05-22 08:37:32 -04:00
GJ
a336e9f460 Removed unused imports. 2012-05-22 08:31:32 -04:00
GJ
0294cf8c4a Implement new repairable stuff for custom tools/armor. 2012-05-22 08:21:05 -04:00
NuclearW
c5183309ae New line on the factory floor
For RepairableFactory
2012-05-22 08:10:22 -04:00
NuclearW
0a15cb1e13 Modify custom items loading to permit registering of repairables from these configs.
Move loading of the main repairables to below the custom items so that repair.*.yml will over-write any custom items when the list is processed and repairables registered.
2012-05-22 07:57:09 -04:00
nossr50
9546cc42b2 Redundant 2012-05-22 02:57:54 -07:00
NuclearW
ac01262655 Fix error in config 2012-05-22 05:46:40 -04:00
nossr50
6ea962c1fa Changing the MOTD again, modified a few messages. Now hardcore mode only
tells you about itself when motd is enabled.
2012-05-22 02:45:42 -07:00
nossr50
9e35283273 Changelog updates 2012-05-22 02:41:19 -07:00
NuclearW
9c8e1d9c9f Some changelog for @nossr50 2012-05-22 05:34:23 -04:00
NuclearW
7d324b3fd4 Changelog
and supercomment to default repair.vanilla.yml
2012-05-22 05:33:05 -04:00
NuclearW
badc5738ff Fix up repair command as best as possible given what it is... 2012-05-22 05:33:05 -04:00
NuclearW
8feaf4410f getRepairable by id 2012-05-22 05:33:04 -04:00
NuclearW
4e224d761e Cleanup Repair.java 2012-05-22 05:33:04 -04:00
NuclearW
e775abdc5a Remove all the old stuff from the config 2012-05-22 05:33:04 -04:00
NuclearW
60754c9380 Implement xp 2012-05-22 05:33:04 -04:00
NuclearW
c890ff5605 Use new system! 2012-05-22 05:33:04 -04:00
NuclearW
9f9c0059a5 Change xpHandler for new system usage
This commit marks the first breaking change for this new system
2012-05-22 05:33:03 -04:00
NuclearW
4eabd417b9 Level check 2012-05-22 05:33:03 -04:00
NuclearW
c218de9567 Change to new line in locale 2012-05-22 05:33:03 -04:00
NuclearW
4b5ca5ecf4 Logic fix 2012-05-22 05:33:02 -04:00
NuclearW
edbf46a751 Unused import 2012-05-22 05:33:02 -04:00
NuclearW
c9c90bb86a New line in locale 2012-05-22 05:33:02 -04:00
NuclearW
437a608d2b Return on this error 2012-05-22 05:33:01 -04:00
nossr50
b638eef1c6 Players are now informed about Hardcore mode when logging in 2012-05-22 02:31:01 -07:00
NuclearW
b7cec8a0c4 Most of handleRepair() done, level checking still needed
- Move Repair
- Change visibility of a few methods for repurposing Repair soon
2012-05-22 04:22:29 -04:00
NuclearW
28578bd6b0 Convenience method for RepairManager 2012-05-22 02:59:10 -04:00
nossr50
160004fa7e Hardcore mode now has some exploit prevention and much more information 2012-05-21 23:56:08 -07:00
nossr50
f4332761f9 Many changes to Hardcore / Vampirism 2012-05-21 23:30:16 -07:00
NuclearW
a4d1a18850 Example repair config for chainmail 2012-05-22 01:11:56 -04:00
NuclearW
c3e1e55e9c Fix for minimumQuantity default 2012-05-22 01:08:29 -04:00
NuclearW
e20bcd19b9 Make our RepairManager, load configs, and register them all 2012-05-22 00:57:24 -04:00
NuclearW
1fbf213ada Load message 2012-05-22 00:56:57 -04:00
NuclearW
c2d2359a8c RepairConfig loader
and small fix for RepairConfigManager
2012-05-22 00:56:14 -04:00
NuclearW
586a2a065e Shears 2012-05-22 00:00:02 -04:00
NuclearW
adf43b7e35 String 2012-05-22 00:00:02 -04:00
NuclearW
45a4cddeef Leather 2012-05-22 00:00:02 -04:00
NuclearW
69f62551c7 Your repair is now diamonds 2012-05-22 00:00:02 -04:00
NuclearW
f1bdf502be Gold
and fix for minQuantity on iron armor
2012-05-22 00:00:02 -04:00
NuclearW
e89b3795f8 Save vanilla from jar 2012-05-22 00:00:02 -04:00
NuclearW
20b169e8eb Typo 2012-05-22 00:00:01 -04:00
NuclearW
1480ee2779 Changelog 2012-05-22 00:00:01 -04:00
GJ
41c9741b72 Fixed exploit where you could gain tons of Acrobatics XP from spamming
Ender Pearls
2012-05-21 23:41:11 -04:00
GJ
f9e5096ceb Cleanup 2012-05-21 10:31:24 -04:00
NuclearW
a9b2a4940e Max_Ticks to Max_Seconds 2012-05-21 10:04:07 -04:00
GJ
f66c6ab8fc Cleanup 2012-05-21 09:33:21 -04:00
GJ
73902d5f92 Minor cleanup / refactoring 2012-05-21 09:21:26 -04:00
NuclearW
0bb5f9f297 Max ticks for abilities 2012-05-21 09:17:16 -04:00
GJ
16ad8502d2 Cleanup, changed order of some logic checks. 2012-05-21 09:04:51 -04:00
GJ
ad68e6057e More cleanup. 2012-05-21 08:45:33 -04:00
GJ
54b4faeeff Minor cleanup. 2012-05-21 08:39:27 -04:00
NuclearW
a7f69545f2 Emulate unbreaking properly 2012-05-21 08:31:29 -04:00
NuclearW
93ea558ec3 Cleanup 2012-05-21 08:27:26 -04:00
GJ
d0cdc208e3 Avoid a duplicate config call. 2012-05-21 07:53:52 -04:00
NuclearW
0d7c483bd5 Tameable not a part of combat checks at the moment, only wolves 2012-05-21 07:25:20 -04:00
NuclearW
3f211c6277 Generalize Wolf to Tameable
Also generalize Arrow to Projectile
For MCCORE-263
2012-05-21 04:44:48 -04:00
NuclearW
79e93edfef Switch order of sticky check and placeStore check.
sticky check is much less expensive than placeStore, so it's better to ensure that the piston is sticky before doing a placeStore check
2012-05-21 02:19:45 -04:00
Travis Ralston
44e8efda36 Check for sticky pistons 2012-05-19 08:00:34 -06:00
NuclearW
9726ac6f12 Send metrics information on if this server uses timings 2012-05-19 00:42:50 -04:00
NuclearW
898d8c6449 Changelog 2012-05-18 22:09:28 -04:00
NuclearW
01006ed76d Hidden config and use of NullChunkletManager
ChunkletManagerFactory now produces NullChunkletManagers if Chunklets are disabeld in the hidden.yml
2012-05-18 22:01:15 -04:00
NuclearW
2936823d03 NullChunkletManager 2012-05-18 21:44:25 -04:00
GJ
7d05d53f9e Whoops. Can't initialize something that doesn't exist. 2012-05-18 14:40:48 -04:00
GJ
f3074461ed More cleanup. 2012-05-18 14:29:53 -04:00
GJ
146f832919 Minor refactoring & cleanup. 2012-05-18 13:40:21 -04:00
GJ
a622707608 Cleanup & Silk Touch changes. 2012-05-18 11:15:30 -04:00
NuclearW
6da43b15c8 Move to a more ideal location.
Not as efficient as I would like, but certainly better than it was before
2012-05-18 03:14:19 -04:00
NuclearW
d0bb7b075e This was a bad idea 2012-05-18 03:12:40 -04:00
NuclearW
c1ecd74644 Actually remove from map on unload 2012-05-18 03:12:16 -04:00
NuclearW
a1aada0777 Iron armor 2012-05-17 23:53:25 -04:00
NuclearW
c55a8eeccd Iron tools 2012-05-17 23:40:34 -04:00
NuclearW
73cc8adcab Beginnings of repair.vanilla.yml 2012-05-17 23:16:59 -04:00
NuclearW
7bb05f7f26 Update version for development
towards a stronger nation defense system
2012-05-17 22:41:40 -04:00
NuclearW
7f0803c3f6 Add in xpMultiplier 2012-05-17 22:40:46 -04:00
NuclearW
1185ea4f96 Beginnings of RepairConfig 2012-05-17 22:40:46 -04:00
NuclearW
43db51a664 RepairConfigManager 2012-05-17 22:40:46 -04:00
250 changed files with 22164 additions and 10657 deletions

4
.gitignore vendored
View File

@@ -24,7 +24,7 @@
/world
# Mac filesystem dust
/.DS_Store
*.DS_Store
# intellij
*.iml
@@ -39,4 +39,4 @@
*.jar
# Atlassian Stuff
/atlassian-ide-plugin.xml
/atlassian-ide-plugin.xml

View File

@@ -7,6 +7,199 @@ Key:
! Change
- Removal
Version 1.3.13-dev
! Indexed most used mySQL columns for faster queries
+ Added task & command to prune old and powerless users from the SQL database.
+ Added Craftbukkit 1.4.6 / 1.4.7 compatibility
+ Added new /mcrank command for showing a players leader board ranking for all skills in one place
+ Added a configurable durability cap for ArmorImpact to advanced.yml
+ Added the version number to /mcmmo
+ Added bats, giants, witches, withers, and wither skeletons to the mcMMO combat experience list, and makes their experience drops configurable
+ Added the ability to track mobs spawned by mob spawners or the Taming ability when the chunks they are in unload and reload
+ Added wooden button to the list of items that shouldn't trigger abilities
+ Added a new feature to fishing. Players will have +10% chance of finding enchanted items when fishing while it's raining
+ Added displaying bonus perks on skill commands
+ Added config option to disable gaining Acrobatics XP from dodging lightning
+ Added missing skill guides. They're finally here!
+ Added more localization
+ Added a very secret easter egg
= Fix issue with Sand/Gravel tracking
= Fix possible NPE when using the PartyAPI to add a player to a party that doesn't exist.
= Fix mcremove command for mySQL
= Fix a java.io.FileNotFoundException when using SQL
= Impact now works with mobs wearing armor
= Fixed issue with Tree Feller dropping player-placed blocks
= Fixed issue with missing default cases from several switch/case statements
= Fixed issue with Mining using actual skill level rather than max skill level
= Fixed some issues with static access
= Fixed ItemStack deprecation issues
= Fixed Async deprecation issues
= Fixed a bug with MySQL databases (non-alphanumeric characters preventing MySQL access)
= Fixed a bug where the /skillreset command was broken
= Fixed a bug where skill commands displaying .x% instead of 0.x%
= Fixed a bug Unbreaking enchantments being ignored when using Treefelling and when hit by Armor Impact
= Fixed a bug where only 1 diamond was needed to fully repair a broken item: Repaired the Repair skill!
= Fixed a bug where a infinite loop of errors caused by mySQL database could cause the server to crash
= Fixed a bug where PartyChangeEvent was fired even when a player isn't able to change parties
= Fixed a bug which caused advanced.yml not to work for Swords
= Fixed a bug which caused advanced.yml not to respect every MaxChance node
= Fixed a bug where GreenThumb_StageChange wasn't read from advanced.yml
= Fixed a bug where Repair would remove enchantments but the glow effect remained
= Fixed a bug where dropped items did not retain custom NBT data
= Fixed a bug which caused a potentially infinite recursion in a btree structure
= Fixed a NPE with custom blocks
= Fixed a bug with Blast Mining never dropping debris blocks
= Fixed a bug with Blast Mining incorrectly handling reduced TNT damage
= Fixed a bug with conflicting fishing enchantments
= Fixed a bug where triple drops wouldn't happen
= Fixed a bug which caused fishing to ignore max/min levels in treasures.yml
= Fixed a bug where treefeller affected player-placed blocks
= Fixed bug where Skull Splitter would be applied twice.
! GJ stopped being a lazy slacker and got stuff done
! Nossr50 actually committed something
! Changed code that uses SpoutPlugin to make it compatible with the latest version
! Reimplemented skill level and power level caps.
! Moved Arcane Forging and Fishing setting from config.yml to advanced.yml
! Overall SQL query improvements
! Reduced number of SQL queries for mcTop command from 11 to 1, speeding it up immensely
! Changed FFS Leaderboards to hold information in memory rather than doing IO work (optimizations)
! Improved chunk conversion (less errors)
! Changed Fishing Treasure Hunter, chance has increased and now actually is level dependent
- Removed dead code relating to null profiles
- Removed unused imports
- Removed ChunkletUnloader and dependents, since they are no longer necessary.
Version 1.3.12
+ Added Craftbukkit 1.4.5 compatibility
+ Added the new 1.3.2 items, xp and double drops for Cocoa beans & Emeralds, EnderChest to the list of blocks that shouldn't trigger abilities
+ Added new items from Minecraft 1.4 to Herbalism (potatoes & carrots)
+ Added new configuration file for advanced users.
+ Added new permission nodes to greenthumb for the 1.4 items
+ Added new mobs from Minecraft 1.4 checks for every ability
+ Added new active ability for Repair: Salvage
+ Added options to 'config.yml' configure shake chance
+ Added the option to negate experience earned for Herbalism while in a minecart to prevent afk leveling
+ Added Green thumb now converts cobble walls to mossy cobble walls
+ Added beacons and anvils to list of blocks that don't trigger abilities
+ Added a configuration option to disable experience gains when in a minecraft for Acrobatics and Herbalism, to prevent AFK leveling
+ Added a new passive ability for Fishing, Fishermans diet. Increases hunger restored from fish
+ Added a feature to display all active perks on login
! Changed Fishing, Shake drops changed from guaranteed to based upon fishing level and perks
! Changed Woodcutting, the amount of experience earned when using Tree Feller on jungle trees has increased
! Changed Herbalism double drop rates for melons and netherwart
! Changed filesystem usage, it's reduced a lot. Should help reduce lag on larger servers
! Changed database connection handling. Support for aggressive connection timeouts, with exponential backoff for multiple failures
! Changed Cobblestone walls are now mossy-able with Greenthumb
! Changed the skull drop rates of the shake ability to 3%
= Fixed a NPE when Citizens perform certain tasks
= Fixed a NPE with Woodcutting, excessive null chunk before earning Woodcutting experience
= Fixed a NPE related to skill cooldowns
= Fixed a NPE when a players profile was null
= Fixed a NPE involving certain explosions
= Fixed a dupe bug when for players who were using a 'nuker' client
= Fixed a dupe bug where pistons were used to dupe ores
= Fixed a dupe bug with Salvage when players were in Creative mode
= Fixed a bug where the player was displayed an incorrect cooldown time
= Fixed a bug where players could earn experience when they were dealing 0 damage
= Fixed a bug where players could get double drops from mossified Cobblestone
= Fixed a bug where Herablism magically converted potatoes to carrots
= Fixed a bug where you couldn't modify the stats of offline players
= Fixed a bug where treefeller didn't work properly on tree's with side-way logs
= Fixed a bug where the Arcane forging downgrade chance should've been 0, but actually wasn't
= Fixed a bug where Fishing would sometimes give items with empty enchantments
= Fixed a bug where the lucky perk for Fishing was actually an unlucky perk
- Removed nothing
Version 1.3.11
! Changed axes to start with 1 durability damage instead of 5, gain 1 durability damage every 50 levels instead of 30, and only have a 25% chance on hit to damage armor (per armor piece)
+ Added compatibility with bow-wielding NPCs from Citizens/NPC mods
+ Added compatibility for pvp-prevention plugins for Serrated Strikes
= Fixed bug where mcMMO could throw NPE errors if trees cut down were from a custom mod and had an id of 17
= Fixed dupe bug where mcMMO would ignore other block-protection plugins for various abilities
= Fixed NPE with hardcore mode's vampirism
Version 1.3.10
+ Added 1.3.1 compatibility
+ Added permission node for Iron Grip ability (mcmmo.ability.unarmed.irongrip)
+ Added ability for custom blocks to drop a range of items.
+ Added Ability API functions
+ Added 50% & 150% XP boost perks
+ Added "lucky" perk for donors
= Fixed /inspect not working on offline players
= Fixed custom blocks, tools and armors not loading properly
= Fixed duplication bug with sticky pistons
= Fixed "GenericLabel belonging to mcMMO..." message
= Fixed menu exit button not working
= Fixed Repair enchant downgrade not working
= Fixed NPE caused by Spout players after a /reload
= Fixed ConcurrentModificationException on world unload
= Fixed players never being removed from memory (memory leak)
= Fixed admin chat being seen by everyone
= Fixed issue with UTFDataFormatException occurring on occasion when trying to load Chunklets
= Fixed ArrayIndexOutOfBounds error caused when trying to use /xplock after logging in but before gaining XP
= Fixed custom tools not properly respecting the Ability_Enabled flag.
= Fixed "lower tool" messages still being displayed even when ability messages are disabled.
= Fixed custom blocks not dropping the proper item with Super Breaker when Silk Touch is used
= Fixed custom woodcutting blocks throwing errors.
= Fixed possible ClassCastException from catching something other than a mob when using the Shake Mob skill
! Changed the format by which Chunklets are stored to be much smaller, and much faster to load
! Optimized how player placed blocks are tracked
Version 1.3.09
+ Added compatibility with AntiCheat (Which I highly recommend to prevent cheating)
+ Added several permission nodes to give individual users special perks (Double/Triple/Quadruple XP)
+ Added reduced cooldown permission nodes as special perks (1/4, 1/3, 1/2 cooldown)
+ Added increased activation time permissions nodes as special perks (+4, +8, and +12 seconds)
+ Added API for plugins to add custom tools directly via Spout - repair / abilities do not work ATM
+ Added offline party members to the list displayed by /party
+ Added possibility to kick offline members from parties
= Fixed bug that would cause a NPE for players that had no parties
= Fixed Vampirism not notifying the correct amount of stolen levels
= Fixed bug with Acrobatics not saving you from deadly falls
= Fixed /mcremove being applied only after a reload
= Fixed Archery PVE disablement not working properly
= Fixed possible NPE when a projectile is shot by a dispenser or doesn't have any shooter
= Fixed issue with NoCheatPlus and Serrated Strikes / Skull Splitter (fight.noswing)
= Fixed tiny memory leak concerning Archery
= Fixed bug where you could receive Archery XP from Potions
= Fixed bug where Chunklets for the < 64 y coordinates would not be properly loaded
= Fixed exploit with block duplication via piston pushing
= Fixed bug with falling sand/gravel not being tracked
= Fixed bug with Tree Feller not working with custom axes
= Fixed bug with locale strings when trying to teleport to a non-existent player
= Fixed bug with Tree Feller changing durability before checking for axe splintering
= Fixed bug with Repair Mastery permission due to typo
= Fixed bug with repairing items that use metadata
= Fixed bug with Chunklets not being reloaded on /reload
= Fixed possible NPE when falling with no item in hand
! API methods can now only be used in a static way
! Arrows shot from a bow having the Infinity enchantment can no longer be retrieved
! Arrows that aren't shot by an entity are now able to be dodged (currently only from dispensers)
! Changed Spout settings to be in their own config file (spout.yml)
! Changed file format for parties (parties.yml), previous files are no longer used
! Changed mcMMO to inform on corrupt Chunklets and make new ones
Version 1.3.08
+ Added more notifications about Vampirism and Hardcore mode on player death
+ Added information about Hardcore mode when joining a server running Hardcore mode
+ Added new hidden.yml inside the jar for very sensitive config options for advanced users
+ Added option to disable Chunklets for servers which do not have doubledrops and do not care about xp farming
+ Added new "Max_Seconds" setting in config.yml to limit the max time of abilities
+ Added new repair configs to allow customization of the repair skill
+ Added message to inform users about hardcore mode on login
= Fixed exploit where you could gain tons of Acrobatics XP from spamming Ender Pearls
= Fixed normal pistons marking a block as user-placed on retract if it wasn't a sticky piston (thanks turt2live!)
= Fixed handling of the Unbreaking enchantment so that tools are actually damaged as they should now
= Fixed hurting pet cats with serrated strikes
! Changed Hardcore Vampirism to require the victim to have at least half the skill level of the killer in order for vampirism to proc (this is to avoid exploitation)
! Changed Hardcore Vampirism to steal a minimum of 1 skill level from a player no matter the percentage
! Changed Hardcore & Vampirism to not be executed if percentages were set to zero or below
! Changed Vampirism to actually remove stats from the victim
! Changed Vampirism to inform the victim of their stat loss
! Changed Mining to allow Silk Touch to work again since the dupe exploit has been fixed.
! Changed Metrics to also report if the server uses plugin profiling
- Removed level and item settings from Repair skill in config.yml
Version 1.3.07
+ Added ability to gain XP from custom blocks. Enable custom blocks in the config file, then enter the data in the blocks.yml file.
+ Added ability to gain XP with custom tools. Enable custom tools in the config file, then enter the data in the tools.yml file.
@@ -66,7 +259,7 @@ Version 1.3.06
= Fixed NPE error with Metrics on startup
= Fixed bug where Herbalism required double drops permission to give XP
= Fixed bug where {0} would be displayed in front of your power level in mcstats
= Fixed mmoupdate not being useable from console
= Fixed mmoupdate not being useable from console
= Fixed bug with repairing wooden tools
= Fixed bug with Nether Wart not awarding XP
= Fixed bug with fishing treasures when treasures list is empty
@@ -79,19 +272,19 @@ Version 1.3.06
! Changed how we handled the config file to prevent any bugs when returning values
! Changed locale files to use a new naming scheme. This breaks ALL old locale files. If you want to assist with re-translating anything, go to getlocalization.com/mcMMO
! Changed /mcremove to check for users in the MySQL DB before sending queries to remove them
! Changed how the tree feller threshold worked for the better
! Changed how the tree feller threshold worked for the better
! Changed /mcremove to no longer kick players when they are removed from database
! Changed /mcremove to work on offline users for FlatFile
! Changed /mcremove to work on offline users for FlatFile
! Changed PlayerProfile constructor to always take a boolean
! Changed getPlayerProfile function to work for online & offline users
! Changed Archery's Daze to deal 4 DMG on proc (2 Hearts)
! Changed /addlevel command to work for offline users
! Changed party & admin chat handling to be nicer to developers
! Changed party & admin chat handling to be nicer to developers
! Changed /mcrefresh to work from console
! Changed /mcrefresh to work for offline players
! Changed /mcrefresh to work for offline players
! Changed UpdateXPBar function to hopefully avoid errors
! Changed /party to show offline party members
! Changed Blast Mining requirements, now asks for the player to be crouching
! Changed Blast Mining requirements, now asks for the player to be crouching
Version 1.3.05
+ Added Skill Shot to Archery which increases damage dealt by 10% every 50 skill levels (caps at 200%)
@@ -140,7 +333,7 @@ Version 1.3.03
+ Added console functionality to mctop
= Fixed Green Terra not awarding Triple Drops
= Fixed ClassCastException from Taming preventDamage checks
= Fixed issue with Blast Mining not seeing TNT for detonation due to snow
= Fixed issue with Blast Mining not seeing TNT for detonation due to snow
= Fixed issue with block interaction returning NPEs
= Fixed issue where every block broken had a mining check applied
= Fixed issue where every block broken had a herbalism check applied
@@ -156,7 +349,7 @@ Version 1.3.03
! Changed mcMMO to be better about saving player information on server shutdown
! Changed PTP to prevent teleporting if you've been hurt in the last 30 seconds (configurable)
! Changed Chimera Wing failure check to use the maxWorldHeight.
! Changed inspect failed message to say inspect rather than whois
! Changed inspect failed message to say inspect rather than whois
! Changed Call of the Wild to activate on left-click rather than right-click
! Changed Blast Mining to track based on Entity ID vs. Location
! Changed mmoedit to save a profile when used (this will make mctop update)

View File

@@ -1,8 +1,8 @@
== mcMMO
**The RPG lovers mod**
=== Forums
http://forums.mcmmo.info Talk with developers and the community about mcMMO here
=== Dev builds
http://nuclearw.com:8080/job/mcMMO/ Download the latest dev build of mcMMO here.
=== Brief Description
mcMMO takes core Minecraft game mechanics and expands them to add an extensive RPG experience, the goal of the project has always been a quality RPG experience. Everything in mcMMO is carefully thought out and is constantly improving. mcMMO adds eleven skills to train in and level in, while also offering a high level of customization for server admins. There are countless features, including custom sounds, graphical elements, and more added when running mcMMO in conjunction with Spout. I carefully read feedback and evaluate the mechanics of mcMMO in every update to provide an ever-evolving experience.
@@ -20,6 +20,7 @@ Hearing that people enjoy mcMMO and seeing the daily youtube videos about my mod
Required Libraries:
* Spout API
* JUnit
Required to Run:
* Bukkit

73
extras/repair.chain.yml Normal file
View File

@@ -0,0 +1,73 @@
#
# Any file named repair.*.yml in the mcmmmo folder will be loaded as a repair config
# All repair configs have a main section titled "Repairables"
# Afterwards, all sub-items are considered a Repairable to be loaded
# The bare minimum of a Repairable is that it have an ItemId, a RepairMaterialId, and a MaximumDurability
#
# ItemId: This is the id of the item to be repairable.
## This is required to be set.
#
# ItemType: This is the type of item to be repaired, this is only important to permissions.
## Valid values are ARMOR, TOOL, and OTHER.
## This defaults to OTHER.
#
# MaterialType: This is the type of the material of the item to be repaired, this is only important for permissions.
## Valid values are STRING, LEATHER, WOOD, STONE, IRON, GOLD, DIAMOND, and OTHER
## This defaults to OTHER.
#
# RepairMaterialId: This is the id of the item used to repair this repairable.
## This is required to be set.
#
# RepairMaterialMetadata: This is the metadata of the item used to repair this repairable.
## A value of -1 means to ignore all metadata when repairing.
## This defaults to -1
#
# MaximumDurability: This is the maximum durability of the item.
## This is required to be set.
#
# MinimumLevel: This is the minimum repair level needed to repair this item.
## Valid values are > 0
## This defaults to 0
#
# MinimumQuantity: This is the minimum number of items needed to repair this item ignoring all other repair bonuses.
## This is typically the number of the repair material needed to create a new item, for example for a sword it is 2, for an axe it is 3
## This defaults to 2
#
# XpMultiplier: This is the amount to multiply the xp bonus by.
## This defaults to 1
#
#
# The following is an example of a repair.*.yml config which adds the ability to repair Chainmail armor using fire.
#
#
###
Repairables:
ChainHelmet:
ItemId: 302
ItemType: ARMOR
RepairMaterialId: 51
MaximumDurability: 165
MinimumQuantity: 5
XpMultiplier: 2
ChainChest:
ItemId: 303
ItemType: ARMOR
RepairMaterialId: 51
MaximumDurability: 240
MinimumQuantity: 8
XpMultiplier: 2
ChainLegs:
ItemId: 304
ItemType: ARMOR
RepairMaterialId: 51
MaximumDurability: 225
MinimumQuantity: 7
XpMultiplier: 2
ChainBoots:
ItemId: 305
ItemType: ARMOR
RepairMaterialId: 51
RepairMaterialMetadata: -1
MaximumDurability: 195
MinimumQuantity: 4
XpMultiplier: 2

29
pom.xml Normal file → Executable file
View File

@@ -2,12 +2,12 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>1.3.07</version>
<version>1.3.13</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<issueManagement>
<url>http://issues.mcmmo.org</url>
<system>JIRA</system>
<url>https://github.com/mcMMO-Dev/mcMMO/issues</url>
<system>GitHub</system>
</issueManagement>
<build>
<finalName>mcMMO</finalName>
@@ -92,6 +92,13 @@
</executions>
</plugin>
</plugins>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-file</artifactId>
<version>2.2</version>
</extension>
</extensions>
</build>
<repositories>
<repository>
@@ -123,12 +130,24 @@
</dependency>
<dependency>
<groupId>org.getspout</groupId>
<artifactId>spoutpluginapi</artifactId>
<version>dev-SNAPSHOT</version>
<artifactId>spoutplugin</artifactId>
<version>LATEST</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>mcmmo-repo</id>
<url>file:///var/lib/jenkins/repo</url>
</repository>
</distributionManagement>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

View File

@@ -0,0 +1,47 @@
package com.gmail.nossr50.api;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.util.Users;
public class AbilityAPI {
public static boolean berserkEnabled(Player player) {
return Users.getProfile(player).getAbilityMode(AbilityType.BERSERK);
}
public static boolean gigaDrillBreakerEnabled(Player player) {
return Users.getProfile(player).getAbilityMode(AbilityType.GIGA_DRILL_BREAKER);
}
public static boolean greenTerraEnabled(Player player) {
return Users.getProfile(player).getAbilityMode(AbilityType.GREEN_TERRA);
}
public static boolean serratedStrikesEnabled(Player player) {
return Users.getProfile(player).getAbilityMode(AbilityType.SERRATED_STRIKES);
}
public static boolean skullSplitterEnabled(Player player) {
return Users.getProfile(player).getAbilityMode(AbilityType.SKULL_SPLIITER);
}
public static boolean superBreakerEnabled(Player player) {
return Users.getProfile(player).getAbilityMode(AbilityType.SUPER_BREAKER);
}
public static boolean treeFellerEnabled(Player player) {
return Users.getProfile(player).getAbilityMode(AbilityType.TREE_FELLER);
}
public static boolean isAnyAbilityEnabled(Player player) {
for (AbilityType ability : AbilityType.values()) {
if (Users.getProfile(player).getAbilityMode(ability)) {
return true;
}
}
return false;
}
}

View File

@@ -1,15 +1,18 @@
package com.gmail.nossr50.api;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class ChatAPI {
public final class ChatAPI {
private ChatAPI() {}
/**
* Send a message to all members of a party
* </br>
@@ -19,7 +22,7 @@ public class ChatAPI {
* @param party The name of the party to send to
* @param message The message to send
*/
public void sendPartyChat(String sender, String party, String message) {
public static void sendPartyChat(String sender, String party, String message) {
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(sender, party, message);
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
@@ -27,14 +30,12 @@ public class ChatAPI {
return;
}
String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE + chatEvent.getSender() + ChatColor.GREEN + ") ";
mcMMO.p.getLogger().info("[P](" + chatEvent.getParty() + ")" + "<" + chatEvent.getSender() + "> " + chatEvent.getMessage());
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
if (Users.getProfile(player).inParty()) {
if (Users.getProfile(player).getParty().equalsIgnoreCase(chatEvent.getParty())) {
player.sendMessage(pPrefix + chatEvent.getMessage());
if (Users.getProfile(player).getParty().getName().equalsIgnoreCase(chatEvent.getParty())) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Prefix", new Object[] {chatEvent.getSender()} ) + chatEvent.getMessage());
}
}
}
@@ -48,7 +49,7 @@ public class ChatAPI {
* @param sender The name of the sender to display in the chat
* @param message The message to send
*/
public void sendAdminChat(String sender, String message) {
public static void sendAdminChat(String sender, String message) {
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(sender, message);
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
@@ -56,13 +57,11 @@ public class ChatAPI {
return;
}
String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + chatEvent.getSender() + ChatColor.AQUA + "} ";
mcMMO.p.getLogger().info("[A]<" + chatEvent.getSender() + "> " + chatEvent.getMessage());
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
if (Permissions.getInstance().adminChat(player) || player.isOp())
player.sendMessage(aPrefix + chatEvent.getMessage());
if (Permissions.adminChat(player) || player.isOp())
player.sendMessage(LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {chatEvent.getSender()} ) + chatEvent.getMessage());
}
}
}

View File

@@ -6,7 +6,9 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
public class ExperienceAPI {
public final class ExperienceAPI {
private ExperienceAPI() {}
/**
* Check the XP of a player. This should be called after giving XP to process level-ups.
@@ -14,12 +16,12 @@ public class ExperienceAPI {
* @param player The player to check
* @param skillType The skill to check
*/
private void checkXP(Player player, SkillType skillType) {
private static void checkXP(Player player, SkillType skillType) {
if (skillType.equals(SkillType.ALL)) {
Skills.XpCheckAll(player);
Skills.xpCheckAll(player, Users.getProfile(player));
}
else {
Skills.XpCheckSkill(skillType, player);
Skills.xpCheckSkill(skillType, player, Users.getProfile(player));
}
}
@@ -32,8 +34,8 @@ public class ExperienceAPI {
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
*/
public void addRawXP(Player player, SkillType skillType, int XP) {
Users.getProfile(player).addXPOverride(skillType, XP);
public static void addRawXP(Player player, SkillType skillType, int XP) {
Users.getPlayer(player).addXPOverride(skillType, XP);
checkXP(player, skillType);
}
@@ -46,8 +48,8 @@ public class ExperienceAPI {
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
*/
public void addMultipliedXP(Player player, SkillType skillType, int XP) {
Users.getProfile(player).addXPOverrideBonus(skillType, XP);
public static void addMultipliedXP(Player player, SkillType skillType, int XP) {
Users.getPlayer(player).addXPOverrideBonus(skillType, XP);
checkXP(player, skillType);
}
@@ -60,8 +62,8 @@ public class ExperienceAPI {
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
*/
public void addXP(Player player, SkillType skillType, int XP) {
Users.getProfile(player).addXP(player, skillType, XP);
public static void addXP(Player player, SkillType skillType, int XP) {
Users.getPlayer(player).addXP(skillType, XP);
checkXP(player, skillType);
}
@@ -74,7 +76,7 @@ public class ExperienceAPI {
* @param skillType The skill to get XP for
* @return the amount of XP in a given skill
*/
public int getXP(Player player, SkillType skillType) {
public static int getXP(Player player, SkillType skillType) {
return Users.getProfile(player).getSkillXpLevel(skillType);
}
@@ -87,7 +89,7 @@ public class ExperienceAPI {
* @param skillType The skill to get the XP amount for
* @return the amount of XP left before leveling up a specifc skill
*/
public int getXPToNextLevel(Player player, SkillType skillType) {
public static int getXPToNextLevel(Player player, SkillType skillType) {
return Users.getProfile(player).getXpToLevel(skillType);
}
@@ -101,7 +103,7 @@ public class ExperienceAPI {
* @param levels Number of levels to add
* @param notify True if this should fire a level up notification, false otherwise.
*/
public void addLevel(Player player, SkillType skillType, int levels, boolean notify) {
public static void addLevel(Player player, SkillType skillType, int levels, boolean notify) {
Users.getProfile(player).addLevels(skillType, levels);
if (notify) {
@@ -118,7 +120,7 @@ public class ExperienceAPI {
* @param skillType The skill to get the level for
* @return the level of a given skill
*/
public int getLevel(Player player, SkillType skillType) {
public static int getLevel(Player player, SkillType skillType) {
return Users.getProfile(player).getSkillLevel(skillType);
}
@@ -130,7 +132,46 @@ public class ExperienceAPI {
* @param player The player to get the power level for
* @return the power level of the player
*/
public int getPowerLevel(Player player) {
return Users.getProfile(player).getPowerLevel();
public static int getPowerLevel(Player player) {
return Users.getPlayer(player).getPowerLevel();
}
/**
* Sets the level of a player in a specific skill type.
* </br>
* This function is designed for API usage.
*
* @param player The player to set the level of
* @param skillType The skill to set the level for
* @param skillLevel The value to set the level to
*/
public static void setLevel(Player player, SkillType skillType, int skillLevel) {
Users.getProfile(player).modifySkill(skillType, skillLevel);
}
/**
* Sets the XP of a player in a specific skill type.
* </br>
* This function is designed for API usage.
*
* @param player The player to set the XP of
* @param skillType The skill to set the XP for
* @param newValue The value to set the XP to
*/
public static void setXP(Player player, SkillType skillType, int newValue) {
Users.getProfile(player).setSkillXPLevel(skillType, newValue);
}
/**
* Removes XP from a player in a specific skill type.
* </br>
* This function is designed for API usage.
*
* @param player The player to change the XP of
* @param skillType The skill to change the XP for
* @param xp The amount of XP to remove
*/
public static void removeXP(Player player, SkillType skillType, int xp) {
Users.getProfile(player).removeXP(skillType, xp);
}
}

View File

@@ -1,13 +1,16 @@
package com.gmail.nossr50.api;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Users;
public class PartyAPI {
public final class PartyAPI {
private PartyAPI() {}
/**
* Get the name of the party a player is in.
@@ -17,8 +20,8 @@ public class PartyAPI {
* @param player The player to check the party name of
* @return the name of the player's party
*/
public String getPartyName(Player player) {
return Users.getProfile(player).getParty();
public static String getPartyName(Player player) {
return Users.getProfile(player).getParty().getName();
}
/**
@@ -29,7 +32,7 @@ public class PartyAPI {
* @param player The player to check
* @return true if the player is in a party, false otherwise
*/
public boolean inParty(Player player) {
public static boolean inParty(Player player) {
return Users.getProfile(player).inParty();
}
@@ -42,19 +45,19 @@ public class PartyAPI {
* @param playerb The second player to check
* @return true if the two players are in the same party, false otherwise
*/
public boolean inSameParty(Player playera, Player playerb) {
return Party.getInstance().inSameParty(playera, playerb);
public static boolean inSameParty(Player playera, Player playerb) {
return PartyManager.getInstance().inSameParty(playera, playerb);
}
/**
* Get a list of all current party names.
* Get a list of all current parties.
* </br>
* This function is designed for API usage.
*
* @return the list of parties.
*/
public ArrayList<String> getParties() {
return Party.getInstance().getParties();
public static List<Party> getParties() {
return PartyManager.getInstance().getParties();
}
/**
@@ -65,8 +68,17 @@ public class PartyAPI {
* @param player The player to add to the party
* @param partyName The party to add the player to
*/
public void addToParty(Player player, String partyName) {
Party.getInstance().addToParty(player, Users.getProfile(player), partyName, false, null);
public static void addToParty(Player player, String partyName) {
Party party = PartyManager.getInstance().getParty(partyName);
String playerName = player.getName();
if (party == null) {
party = new Party();
party.setName(partyName);
party.setLeader(playerName);
}
PartyManager.getInstance().addToParty(playerName, Users.getProfile(player), party);
}
/**
@@ -76,8 +88,8 @@ public class PartyAPI {
*
* @param player The player to remove
*/
public void removeFromParty(Player player) {
Party.getInstance().removeFromParty(player, Users.getProfile(player));
public static void removeFromParty(Player player) {
PartyManager.getInstance().removeFromParty(player.getName(), Users.getProfile(player).getParty());
}
/**
@@ -88,8 +100,8 @@ public class PartyAPI {
* @param partyName The party name
* @return the leader of the party
*/
public Player getPartyLeader(String partyName) {
return Party.getInstance().getPartyLeader(partyName);
public static String getPartyLeader(String partyName) {
return PartyManager.getInstance().getPartyLeader(partyName);
}
/**
@@ -100,8 +112,8 @@ public class PartyAPI {
* @param partyName The name of the party to set the leader of
* @param player The player to set as leader
*/
public void setPartyLeader(String partyName, String player) {
Party.getInstance().setPartyLeader(partyName, player);
public static void setPartyLeader(String partyName, String player) {
PartyManager.getInstance().setPartyLeader(player, PartyManager.getInstance().getParty(partyName));
}
/**
@@ -112,8 +124,8 @@ public class PartyAPI {
* @param player The player to check
* @return all the players in the player's party
*/
public ArrayList<Player> getAllMembers(Player player) {
return Party.getInstance().getAllMembers(player);
public static List<String> getAllMembers(Player player) {
return PartyManager.getInstance().getAllMembers(player);
}
/**
@@ -124,8 +136,8 @@ public class PartyAPI {
* @param partyName The party to check
* @return all online players in this party
*/
public ArrayList<Player> getOnlineMembers(String partyName) {
return Party.getInstance().getOnlineMembers(partyName);
public static List<Player> getOnlineMembers(String partyName) {
return PartyManager.getInstance().getOnlineMembers(partyName);
}
/**
@@ -136,7 +148,7 @@ public class PartyAPI {
* @param player The player to check
* @return all online players in the player's party
*/
public ArrayList<Player> getOnlineMembers(Player player) {
return Party.getInstance().getOnlineMembers(player);
public static List<Player> getOnlineMembers(Player player) {
return PartyManager.getInstance().getOnlineMembers(player);
}
}

View File

@@ -0,0 +1,54 @@
package com.gmail.nossr50.api;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.ToolType;
public final class SpoutToolsAPI {
private SpoutToolsAPI() {}
public static final List<ItemStack> spoutSwords = new ArrayList<ItemStack>();
public static final List<ItemStack> spoutAxes = new ArrayList<ItemStack>();
public static final List<ItemStack> spoutPickaxes = new ArrayList<ItemStack>();
public static final List<ItemStack> spoutHoes = new ArrayList<ItemStack>();
public static final List<ItemStack> spoutShovels = new ArrayList<ItemStack>();
/**
* Add a custom Spout tool to mcMMO for XP gain & ability use.
* </br>
* This function is designed for API usage.
*
* @param spoutTool The tool to add
* @param type The type of tool to add
*/
public static void addCustomTool(ItemStack spoutTool, ToolType type) {
switch (type) {
case AXE:
spoutAxes.add(spoutTool);
break;
case HOE:
spoutHoes.add(spoutTool);
break;
case PICKAXE:
spoutPickaxes.add(spoutTool);
break;
case SHOVEL:
spoutShovels.add(spoutTool);
break;
case SWORD:
spoutSwords.add(spoutTool);
break;
default:
break;
}
}
}

View File

@@ -23,7 +23,7 @@ public class CommandHelper {
if (sender instanceof Player) {
Player player = (Player) sender;
if (player != null && !Permissions.getInstance().permission(player, permission)) {
if (!Permissions.hasPermission(player, permission)) {
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
return true;
}
@@ -49,28 +49,33 @@ public class CommandHelper {
*/
public static void printGatheringSkills(Player inspect, CommandSender display) {
if (Skills.hasGatheringSkills(inspect)) {
PlayerProfile PP = Users.getProfile(inspect);
PlayerProfile profile = Users.getProfile(inspect);
if (profile == null) {
display.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return;
}
display.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
if (Permissions.getInstance().excavation(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Excavation.Listener"), PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) }));
if (Permissions.excavation(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION) }));
}
if (Permissions.getInstance().fishing(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Fishing.Listener"), PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) }));
if (Permissions.fishing(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING) }));
}
if (Permissions.getInstance().herbalism(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Herbalism.Listener"), PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) }));
if (Permissions.herbalism(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM) }));
}
if (Permissions.getInstance().mining(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Mining.Listener"), PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING) }));
if (Permissions.mining(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING) }));
}
if (Permissions.getInstance().woodcutting(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Woodcutting.Listener"), PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) }));
if (Permissions.woodcutting(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Woodcutting.Listener"), profile.getSkillLevel(SkillType.WOODCUTTING), profile.getSkillXpLevel(SkillType.WOODCUTTING), profile.getXpToLevel(SkillType.WOODCUTTING) }));
}
}
}
@@ -87,28 +92,33 @@ public class CommandHelper {
*/
public static void printCombatSkills(Player inspect, CommandSender display) {
if (Skills.hasCombatSkills(inspect)) {
PlayerProfile PP = Users.getProfile(inspect);
PlayerProfile profile = Users.getProfile(inspect);
if (profile == null) {
display.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return;
}
display.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
if (Permissions.getInstance().axes(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Axes.Listener"), PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES) }));
if (Permissions.axes(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES) }));
}
if (Permissions.getInstance().archery(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Archery.Listener"), PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) }));
if (Permissions.archery(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY) }));
}
if (Permissions.getInstance().swords(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Swords.Listener"), PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS) }));
if (Permissions.swords(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS) }));
}
if (Permissions.getInstance().taming(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Taming.Listener"), PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) }));
if (Permissions.taming(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING) }));
}
if (Permissions.getInstance().unarmed(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Unarmed.Listener"), PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) }));
if (Permissions.unarmed(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Unarmed.Listener"), profile.getSkillLevel(SkillType.UNARMED), profile.getSkillXpLevel(SkillType.UNARMED), profile.getXpToLevel(SkillType.UNARMED) }));
}
}
}
@@ -125,15 +135,21 @@ public class CommandHelper {
*/
public static void printMiscSkills(Player inspect, CommandSender display) {
if (Skills.hasMiscSkills(inspect)) {
PlayerProfile PP = Users.getProfile(inspect);
display.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
PlayerProfile profile = Users.getProfile(inspect);
if (Permissions.getInstance().acrobatics(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Acrobatics.Listener"), PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) }));
if (profile == null) {
display.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return;
}
if (Permissions.getInstance().repair(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Repair.Listener"), PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) }));
display.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
if (Permissions.acrobatics(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS) }));
}
if (Permissions.repair(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR) }));
}
}
}

View File

@@ -0,0 +1,88 @@
package com.gmail.nossr50.commands;
import java.text.DecimalFormat;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Users;
public abstract class SkillCommand implements CommandExecutor {
private SkillType skill;
private String skillString;
private String permission;
protected Player player;
protected PlayerProfile profile;
protected float skillValue;
protected DecimalFormat percent = new DecimalFormat("##0.00%");
public SkillCommand(SkillType skill) {
this.skill = skill;
this.skillString = Misc.getCapitalized(skill.toString());
this.permission = "mcmmo.skills." + skillString.toLowerCase();
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
if (CommandHelper.noCommandPermissions(sender, permission)) {
return true;
}
player = (Player) sender;
profile = Users.getProfile(player);
if (profile == null) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
skillValue = profile.getSkillLevel(skill);
dataCalculations();
permissionsCheck();
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString(skillString + ".SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain." + skillString) }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill) }));
if (effectsHeaderPermissions()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
}
effectsDisplay();
if (statsHeaderPermissions()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
}
statsDisplay();
Page.grabGuidePageForSkill(skill, player, args);
return true;
}
protected abstract void dataCalculations();
protected abstract void permissionsCheck();
protected abstract boolean effectsHeaderPermissions();
protected abstract void effectsDisplay();
protected abstract boolean statsHeaderPermissions();
protected abstract void statsDisplay();
}

View File

@@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.general;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -26,11 +25,10 @@ public class AddlevelsCommand implements CommandExecutor{
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
OfflinePlayer modifiedPlayer;
PlayerProfile PP;
PlayerProfile profile;
int levels;
SkillType skill;
String skillName;
String usage = ChatColor.RED + "Proper usage is /addlevels [player] <skill> <level>"; //TODO: Needs more locale.
String usage = LocaleLoader.getString("Commands.Usage.3", new Object[] {"addlevels", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">" });
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
return true;
@@ -48,17 +46,16 @@ public class AddlevelsCommand implements CommandExecutor{
modifiedPlayer = (Player) sender;
levels = Integer.valueOf(args[1]);
skill = Skills.getSkillType(args[0]);
PP = Users.getProfile(modifiedPlayer);
profile = Users.getProfile(modifiedPlayer);
if (skill.equals(SkillType.ALL)) {
skillName = "all skills";
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", new Object[] {levels}));
}
else {
skillName = Misc.getCapitalized(skill.toString());
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", new Object[] {levels, Misc.getCapitalized(skill.toString())}));
}
PP.addLevels(skill, levels);
sender.sendMessage(ChatColor.GREEN + "You were awarded " + levels + " levels in " + skillName + "!"); //TODO: Needs more locale.
profile.addLevels(skill, levels);
}
}
else {
@@ -70,9 +67,14 @@ public class AddlevelsCommand implements CommandExecutor{
case 3:
modifiedPlayer = plugin.getServer().getOfflinePlayer(args[0]);
String playerName = modifiedPlayer.getName();
PP = Users.getProfile(modifiedPlayer);
profile = Users.getProfile(modifiedPlayer);
if (!PP.isLoaded()) {
if (profile == null) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
if (!profile.isLoaded()) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
@@ -85,23 +87,23 @@ public class AddlevelsCommand implements CommandExecutor{
if (Misc.isInt(args[2])) {
levels = Integer.valueOf(args[2]);
skill = Skills.getSkillType(args[1]);
String message;
Users.getProfile(modifiedPlayer).addLevels(skill, levels);
if (skill.equals(SkillType.ALL)) {
skillName = "all skills";
message = ChatColor.RED + "All skills have been modified for " + playerName + "."; //TODO: Use locale
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", new Object[] {playerName}));
}
else {
skillName = Misc.getCapitalized(skill.toString());
message = ChatColor.RED + skillName + " has been modified for " + playerName + "."; //TODO: Use locale
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", new Object[] {Misc.getCapitalized(skill.toString()), playerName}));
}
sender.sendMessage(message);
if (modifiedPlayer.isOnline()) {
((Player) modifiedPlayer).sendMessage(ChatColor.GREEN + "You were awarded " + levels + " levels in " + skillName + "!"); //TODO: Needs more locale.
if (skill.equals(SkillType.ALL)) {
((Player) modifiedPlayer).sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", new Object[] {levels}));
}
else {
((Player) modifiedPlayer).sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", new Object[] {levels, Misc.getCapitalized(skill.toString())}));
}
}
}
else {

View File

@@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.general;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -8,6 +7,8 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
@@ -27,8 +28,7 @@ public class AddxpCommand implements CommandExecutor {
Player modifiedPlayer;
int xp;
SkillType skill;
String skillName;
String usage = ChatColor.RED + "Proper usage is /addxp [playername] <skill> <xp>"; //TODO: Needs more locale.
String usage = LocaleLoader.getString("Commands.Usage.3", new Object[] {"addxp", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.XP") + ">" });
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
return true;
@@ -47,22 +47,22 @@ public class AddxpCommand implements CommandExecutor {
xp = Integer.valueOf(args[1]);
skill = Skills.getSkillType(args[0]);
Users.getProfile(modifiedPlayer).addXPOverride(skill, xp);
PlayerProfile profile = Users.getProfile(modifiedPlayer);
McMMOPlayer mcMMOPlayer = Users.getPlayer(modifiedPlayer);
mcMMOPlayer.addXPOverride(skill, xp);
if (skill.equals(SkillType.ALL)) {
skillName = "all skills";
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", new Object[] {xp}));
}
else {
skillName = Misc.getCapitalized(skill.toString());
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", new Object[] {xp, Misc.getCapitalized(skill.toString())}));
}
modifiedPlayer.sendMessage(ChatColor.GREEN + "You were awarded " + xp + " experience in " + skillName + "!"); //TODO: Needs more locale.
if (skill.equals(SkillType.ALL)) {
Skills.XpCheckAll(modifiedPlayer);
Skills.xpCheckAll(modifiedPlayer, profile);
}
else {
Skills.XpCheckSkill(skill, modifiedPlayer);
Skills.xpCheckSkill(skill, modifiedPlayer, profile);
}
}
else {
@@ -78,8 +78,15 @@ public class AddxpCommand implements CommandExecutor {
case 3:
modifiedPlayer = plugin.getServer().getPlayer(args[0]);
String playerName = modifiedPlayer.getName();
McMMOPlayer mcMMOPlayer = Users.getPlayer(modifiedPlayer);
PlayerProfile profile = Users.getProfile(modifiedPlayer);
if (!Users.getProfile(modifiedPlayer).isLoaded()) {
if (profile == null) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
if (!profile.isLoaded()) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
@@ -92,27 +99,23 @@ public class AddxpCommand implements CommandExecutor {
if (Misc.isInt(args[2])) {
xp = Integer.valueOf(args[2]);
skill = Skills.getSkillType(args[1]);
String message;
Users.getProfile(modifiedPlayer).addXPOverride(skill, xp);
mcMMOPlayer.addXPOverride(skill, xp);
if (skill.equals(SkillType.ALL)) {
skillName = "all skills";
message = ChatColor.RED + "All skills have been modified for " + playerName + "."; //TODO: Use locale
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", new Object[] {playerName}));
}
else {
skillName = Misc.getCapitalized(skill.toString());
message = ChatColor.RED + skillName + " has been modified for " + playerName + "."; //TODO: Use locale
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", new Object[] {Misc.getCapitalized(skill.toString()), playerName}));
}
sender.sendMessage(message);
modifiedPlayer.sendMessage(ChatColor.GREEN + "You were awarded " + xp + " experience in " + skillName + "!"); //TODO: Needs more locale.
if (skill.equals(SkillType.ALL)) {
Skills.XpCheckAll(modifiedPlayer);
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", new Object[] {xp}));
Skills.xpCheckAll(modifiedPlayer, profile);
}
else {
Skills.XpCheckSkill(skill, modifiedPlayer);
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", new Object[] {xp, Misc.getCapitalized(skill.toString())}));
Skills.xpCheckSkill(skill, modifiedPlayer, profile);
}
}
else {

View File

@@ -1,13 +1,12 @@
package com.gmail.nossr50.commands.general;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
@@ -16,17 +15,9 @@ import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class InspectCommand implements CommandExecutor {
private final mcMMO plugin;
public InspectCommand (mcMMO plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
OfflinePlayer target;
PlayerProfile PP;
String usage = "Proper usage is /inspect <player>"; //TODO: Needs more locale.
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"inspect", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"});
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.inspect")) {
return true;
@@ -34,59 +25,59 @@ public class InspectCommand implements CommandExecutor {
switch (args.length) {
case 1:
target = plugin.getServer().getOfflinePlayer(args[0]);
PP = Users.getProfile(target);
McMMOPlayer mcmmoPlayer = Users.getPlayer(args[0]);
if (target.isOnline()) {
Player player = (Player) target;
if (mcmmoPlayer != null) {
Player target = mcmmoPlayer.getPlayer();
if (sender instanceof Player && !sender.isOp() && !Misc.isNear(((Player) sender).getLocation(), player.getLocation(), 5.0) && !Permissions.getInstance().inspectDistanceBypass((Player) sender)) {
if (sender instanceof Player && !sender.isOp() && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !Permissions.inspectDistanceBypass((Player) sender)) {
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
return true;
}
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", new Object[] { target.getName() }));
CommandHelper.printGatheringSkills(player, sender);
CommandHelper.printCombatSkills(player, sender);
CommandHelper.printMiscSkills(player, sender);
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { PP.getPowerLevel() }));
CommandHelper.printGatheringSkills(target, sender);
CommandHelper.printCombatSkills(target, sender);
CommandHelper.printMiscSkills(target, sender);
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { mcmmoPlayer.getPowerLevel() }));
return true;
}
else {
if (sender instanceof Player && !sender.isOp() && !Permissions.getInstance().inspectOfflineBypass((Player) sender)) {
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
return true;
}
if (!PP.isLoaded()) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", new Object[] { args[0] }));
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Excavation.Listener"), PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Fishing.Listener"), PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Herbalism.Listener"), PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Mining.Listener"), PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Woodcutting.Listener"), PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) }));
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Axes.Listener"), PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Archery.Listener"), PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Swords.Listener"), PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Taming.Listener"), PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Unarmed.Listener"), PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) }));
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Acrobatics.Listener"), PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Repair.Listener"), PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) }));
if (sender instanceof Player && !sender.isOp() && !Permissions.inspectOfflineBypass((Player) sender)) {
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
return true;
}
PlayerProfile profile = new PlayerProfile(args[0], false); //Temporary Profile
if (!profile.isLoaded()) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", new Object[] { args[0] }));
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Woodcutting.Listener"), profile.getSkillLevel(SkillType.WOODCUTTING), profile.getSkillXpLevel(SkillType.WOODCUTTING), profile.getXpToLevel(SkillType.WOODCUTTING) }));
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Unarmed.Listener"), profile.getSkillLevel(SkillType.UNARMED), profile.getSkillXpLevel(SkillType.UNARMED), profile.getXpToLevel(SkillType.UNARMED) }));
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR) }));
return true;
default:
sender.sendMessage(usage);
return true;

View File

@@ -6,7 +6,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Users;
@@ -19,7 +19,6 @@ public class McstatsCommand implements CommandExecutor {
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
@@ -27,8 +26,13 @@ public class McstatsCommand implements CommandExecutor {
CommandHelper.printGatheringSkills(player);
CommandHelper.printCombatSkills(player);
CommandHelper.printMiscSkills(player);
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { String.valueOf(PP.getPowerLevel()) }));
int powerLevelCap = Config.getInstance().getPowerLevelCap();
if (powerLevelCap > 0)
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", new Object[] { String.valueOf(Users.getPlayer(player).getPowerLevel()), String.valueOf(powerLevelCap) }));
else
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { String.valueOf(Users.getPlayer(player).getPowerLevel()) }));
return true;
}

View File

@@ -1,14 +1,12 @@
package com.gmail.nossr50.commands.general;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
@@ -17,20 +15,13 @@ import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
public class MmoeditCommand implements CommandExecutor {
private final mcMMO plugin;
public MmoeditCommand (mcMMO plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
OfflinePlayer modifiedPlayer;
PlayerProfile PP;
PlayerProfile profile;
int newValue;
SkillType skill;
String skillName;
String usage = ChatColor.RED + "Proper usage is /mmoedit [player] <skill> <level>"; //TODO: Needs more locale.
String usage = LocaleLoader.getString("Commands.Usage.3", new Object[] {"mmoedit", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">" });
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
return true;
@@ -45,10 +36,10 @@ public class MmoeditCommand implements CommandExecutor {
}
if (Misc.isInt(args[1])) {
modifiedPlayer = (Player) sender;
Player player = (Player) sender;
newValue = Integer.valueOf(args[1]);
skill = Skills.getSkillType(args[0]);
PP = Users.getProfile(modifiedPlayer);
profile = Users.getProfile(player);
if (skill.equals(SkillType.ALL)) {
skillName = "all skills";
@@ -57,8 +48,8 @@ public class MmoeditCommand implements CommandExecutor {
skillName = Misc.getCapitalized(skill.toString());
}
PP.modifySkill(skill, newValue);
sender.sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
profile.modifySkill(skill, newValue);
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", new Object[] {skillName, newValue}));
}
else {
sender.sendMessage(usage);
@@ -71,46 +62,51 @@ public class MmoeditCommand implements CommandExecutor {
return true;
case 3:
modifiedPlayer = plugin.getServer().getOfflinePlayer(args[0]);
String playerName = modifiedPlayer.getName();
PP = Users.getProfile(modifiedPlayer);
if (!PP.isLoaded()) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
if (!Misc.isInt(args[2])) {
sender.sendMessage(usage);
return true;
}
if (!Skills.isSkill(args[1])) {
skill = Skills.getSkillType(args[1]);
if (skill == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
if (Misc.isInt(args[2])) {
newValue = Integer.valueOf(args[2]);
skill = Skills.getSkillType(args[1]);
String message;
Users.getProfile(modifiedPlayer).modifySkill(skill, newValue);
if (skill.equals(SkillType.ALL)) {
skillName = "all skills";
message = ChatColor.RED + "All skills have been modified for " + playerName + "."; //TODO: Use locale
}
else {
skillName = Misc.getCapitalized(skill.toString());
message = ChatColor.RED + skillName + " has been modified for " + playerName + "."; //TODO: Use locale
}
sender.sendMessage(message);
if (modifiedPlayer.isOnline()) {
((Player) modifiedPlayer).sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
}
if (skill.equals(SkillType.ALL)) {
skillName = "all skills";
}
else {
sender.sendMessage(usage);
skillName = Misc.getCapitalized(skill.toString());
}
newValue = Integer.valueOf(args[2]);
McMMOPlayer mcmmoPlayer = Users.getPlayer(args[0]);
if (mcmmoPlayer != null) {
profile = mcmmoPlayer.getProfile();
if (profile == null) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
profile.modifySkill(skill, newValue);
mcmmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", new Object[] {skillName, newValue}));
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", new Object[] {skillName, args[0]}));
}
else {
profile = new PlayerProfile(args[0], false); //Temporary Profile
if (!profile.isLoaded()) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
profile.modifySkill(skill, newValue);
profile.save();
}
return true;
default:

View File

@@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.general;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -9,6 +8,7 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.SQLConversionTask;
import com.gmail.nossr50.util.Users;
@@ -25,15 +25,15 @@ public class MmoupdateCommand implements CommandExecutor {
return true;
}
sender.sendMessage(ChatColor.GRAY + "Starting conversion..."); //TODO: Needs more locale.
Users.clearUsers();
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Start"));
Users.clearAll();
convertToMySQL();
for (Player x : plugin.getServer().getOnlinePlayers()) {
Users.addUser(x);
}
sender.sendMessage(ChatColor.GREEN + "Conversion finished!"); //TODO: Needs more locale.
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Finish"));
return true;
}
@@ -46,6 +46,6 @@ public class MmoupdateCommand implements CommandExecutor {
return;
}
plugin.getServer().getScheduler().scheduleAsyncDelayedTask(plugin, new SQLConversionTask(plugin), 1);
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new SQLConversionTask(plugin), 1);
}
}

View File

@@ -0,0 +1,65 @@
package com.gmail.nossr50.commands.general;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Users;
public class SkillResetCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
//ensure they have the skillreset perm
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skillreset")) {
return true;
}
SkillType skillType = null; //simple initialization
//make sure there's only one argument. output at least some kind of error if not
if (args.length == 0 || (args.length != 1 && args[0] != null)) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
//parse the skilltype that they sent
try
{
skillType = SkillType.valueOf(args[0].toUpperCase().trim()); //ucase needed to match enum since it's case sensitive. trim to be nice
}catch(IllegalArgumentException ex)
{
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
//reset the values in the hash table and persist them
PlayerProfile profile = Users.getProfile((Player)sender);
if (profile == null) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
profile.resetSkill(skillType);
profile.save();
//display a success message to the user
if (skillType == SkillType.ALL)
sender.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
else
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", new Object[] { args[0] }));
return true;
}
}

View File

@@ -13,8 +13,8 @@ import com.gmail.nossr50.util.Misc;
public class XprateCommand implements CommandExecutor {
private final mcMMO plugin;
private static int oldrate = Config.getInstance().xpGainMultiplier;
public static boolean xpevent = false;
private static double oldRate = Config.getInstance().xpGainMultiplier;
private static boolean xpEvent = false;
public XprateCommand (mcMMO plugin) {
this.plugin = plugin;
@@ -33,16 +33,16 @@ public class XprateCommand implements CommandExecutor {
switch (args.length) {
case 1:
if (args[0].equalsIgnoreCase("reset")) {
if (xpevent) {
if (xpEvent) {
for (Player x : plugin.getServer().getOnlinePlayers()) {
x.sendMessage(LocaleLoader.getString("Commands.xprate.over"));
}
xpevent = !xpevent;
Config.getInstance().xpGainMultiplier = oldrate;
xpEvent = !xpEvent;
Config.getInstance().xpGainMultiplier = oldRate;
}
else {
Config.getInstance().xpGainMultiplier = oldrate;
Config.getInstance().xpGainMultiplier = oldRate;
}
}
else if (Misc.isInt(args[0])) {
@@ -56,10 +56,10 @@ public class XprateCommand implements CommandExecutor {
case 2:
if (Misc.isInt(args[0])) {
oldrate = Config.getInstance().xpGainMultiplier;
oldRate = Config.getInstance().xpGainMultiplier;
if (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")) {
xpevent = Boolean.valueOf(args[1]);
xpEvent = Boolean.valueOf(args[1]);
}
else {
sender.sendMessage(usage3);
@@ -67,14 +67,14 @@ public class XprateCommand implements CommandExecutor {
Config.getInstance().xpGainMultiplier = Misc.getInt(args[0]);
if (xpevent) {
if (xpEvent) {
for (Player x : plugin.getServer().getOnlinePlayers()) {
x.sendMessage(LocaleLoader.getString("Commands.xprate.started.0"));
x.sendMessage(LocaleLoader.getString("Commands.xprate.started.1", new Object[] {Config.getInstance().xpGainMultiplier}));
}
}
else {
sender.sendMessage("The XP RATE was modified to " + Config.getInstance().xpGainMultiplier); //TODO: Locale
sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", new Object[] {Config.getInstance().xpGainMultiplier}));
}
}
else {
@@ -90,4 +90,8 @@ public class XprateCommand implements CommandExecutor {
return true;
}
}
public static boolean isXpEventRunning() {
return xpEvent;
}
}

View File

@@ -22,16 +22,21 @@ public class McabilityCommand implements CommandExecutor {
return true;
}
PlayerProfile PP = Users.getProfile((Player) sender);
PlayerProfile profile = Users.getProfile((Player) sender);
if (PP.getAbilityUse()) {
if (profile == null) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
if (profile.getAbilityUse()) {
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
}
PP.toggleAbilityUse();
profile.toggleAbilityUse();
return true;
}

View File

@@ -1,12 +1,12 @@
package com.gmail.nossr50.commands.mc;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
@@ -21,21 +21,21 @@ public class MccCommand implements CommandExecutor {
Player player = (Player) sender;
player.sendMessage(ChatColor.RED + "---[]" + ChatColor.YELLOW + "mcMMO Commands" + ChatColor.RED + "[]---"); //TODO: Needs more locale.
player.sendMessage(LocaleLoader.getString("Commands.mcc.Header"));
if (Permissions.getInstance().party(player)) {
if (Permissions.party(player)) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Commands"));
player.sendMessage("/party " + LocaleLoader.getString("Commands.Party"));
player.sendMessage("/party q " + LocaleLoader.getString("Commands.Party.Quit"));
if (Permissions.getInstance().partyChat(player)) {
if (Permissions.partyChat(player)) {
player.sendMessage("/p " + LocaleLoader.getString("Commands.Party.Toggle"));
}
player.sendMessage("/invite " + LocaleLoader.getString("Commands.Party.Invite"));
player.sendMessage("/accept " + LocaleLoader.getString("Commands.Party.Accept"));
if (Permissions.getInstance().partyTeleport(player)) {
if (Permissions.partyTeleport(player)) {
player.sendMessage("/ptp " + LocaleLoader.getString("Commands.Party.Teleport"));
}
}
@@ -44,23 +44,27 @@ public class MccCommand implements CommandExecutor {
player.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
player.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards"));
if (Permissions.getInstance().mcAbility(player)) {
if (Config.getInstance().getCommandSkillResetEnabled() && Permissions.skillReset(player)) {
player.sendMessage("/skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
}
if (Permissions.mcAbility(player)) {
player.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
}
if (Permissions.getInstance().adminChat(player)) {
if (Permissions.adminChat(player)) {
player.sendMessage("/a " + LocaleLoader.getString("Commands.AdminToggle"));
}
if (Permissions.getInstance().inspect(player)) {
if (Permissions.inspect(player)) {
player.sendMessage("/inspect " + LocaleLoader.getString("Commands.Inspect"));
}
if (Permissions.getInstance().mmoedit(player)) {
if (Permissions.mmoedit(player)) {
player.sendMessage("/mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
}
if (Permissions.getInstance().mcgod(player)) {
if (Permissions.mcgod(player)) {
player.sendMessage("/mcgod " + LocaleLoader.getString("Commands.mcgod"));
}

View File

@@ -22,16 +22,21 @@ public class McgodCommand implements CommandExecutor {
return true;
}
PlayerProfile PP = Users.getProfile((Player) sender);
PlayerProfile profile = Users.getProfile((Player) sender);
if (PP.getGodMode()) {
if (profile == null) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
if (profile.getGodMode()) {
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
}
PP.toggleGodMode();
profile.toggleGodMode();
return true;
}

View File

@@ -7,11 +7,12 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Anniversary;
public class McmmoCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String description = LocaleLoader.getString("mcMMO.Description");
@@ -19,16 +20,19 @@ public class McmmoCommand implements CommandExecutor {
sender.sendMessage(mcSplit);
if (Config.getInstance().getDonateMessageEnabled()) {
if (Config.getInstance().spoutEnabled && sender instanceof SpoutPlayer) {
SpoutPlayer sPlayer = (SpoutPlayer) sender;
if (mcMMO.spoutEnabled && sender instanceof SpoutPlayer) {
SpoutPlayer spoutPlayer = (SpoutPlayer) sender;
sPlayer.sendNotification(ChatColor.YELLOW + "[mcMMO]" + ChatColor.GOLD + " Donate!", ChatColor.GREEN + "mcmmodev@gmail.com", Material.DIAMOND);
spoutPlayer.sendNotification(LocaleLoader.getString("Spout.Donate"), ChatColor.GREEN + "gjmcferrin@gmail.com", Material.DIAMOND);
}
sender.sendMessage(ChatColor.DARK_AQUA + "Donation Info:");
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "mcmmodev@gmail.com" + ChatColor.GOLD + " Paypal");
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
}
sender.sendMessage(LocaleLoader.getString("MOTD.Version", new Object[] {mcMMO.p.getDescription().getVersion()}));
Anniversary anniversary = new Anniversary();
anniversary.anniversaryCheck(sender);
return true;
}
}

View File

@@ -0,0 +1,36 @@
package com.gmail.nossr50.commands.mc;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Database;
public class McpurgeCommand implements CommandExecutor{
private Database database = mcMMO.getPlayerDatabase();
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcremove")) {
return true;
}
if (Config.getInstance().getUseMySQL()) {
database.purgePowerlessSQL();
if (Config.getInstance().getOldUsersCutoff() != -1) {
database.purgeOldSQL();
}
}
else {
//TODO: Make this work for Flatfile data.
}
sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success"));
return true;
}
}

View File

@@ -0,0 +1,88 @@
package com.gmail.nossr50.commands.mc;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.McRankAsync;
import com.gmail.nossr50.util.Leaderboard;
import com.gmail.nossr50.util.Skills;
public class McrankCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
//TODO: Better input handling, add usage string
if (!Config.getInstance().getUseMySQL()) {
Leaderboard.updateLeaderboards(); //Make sure the information is up to date
}
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
Player player = (Player) sender;
String playerName;
switch (args.length) {
case 0:
playerName = player.getName();
break;
case 1:
playerName = args[0];
break;
default:
return false;
}
if (Config.getInstance().getUseMySQL()) {
sqlDisplay(sender, playerName);
}
else {
flatfileDisplay(sender, playerName);
}
return true;
}
public void flatfileDisplay(CommandSender sender, String playerName) {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", new Object[] {playerName}));
for (SkillType skillType : SkillType.values()) {
int[] rankInts = Leaderboard.getPlayerRank(playerName, skillType);
if (skillType.equals(SkillType.ALL)) {
continue; // We want the overall ranking to be at the bottom
}
if (rankInts[1] == 0) {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {Skills.localizeSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked")} )); //Don't bother showing ranking for players without skills
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {Skills.localizeSkillName(skillType), String.valueOf(rankInts[0])} ));
}
}
//Show the powerlevel ranking
int[] rankInts = Leaderboard.getPlayerRank(playerName, SkillType.ALL);
if (rankInts[1] == 0) {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overalll", new Object[] {LocaleLoader.getString("Commands.mcrank.Unranked")} )); //Don't bother showing ranking for players without skills
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", new Object[] {String.valueOf(rankInts[0])} ));
}
}
private void sqlDisplay(CommandSender sender, String playerName) {
Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getPluginManager().getPlugin("mcMMO"), new McRankAsync(playerName, sender));
}
}

View File

@@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.mc;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -23,8 +22,8 @@ public class McrefreshCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
OfflinePlayer player;
PlayerProfile PP;
String usage = ChatColor.RED + "Proper usage is /mcrefresh [player]"; //TODO: Needs more locale
PlayerProfile profile;
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"mcrefresh", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"});
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcrefresh")) {
return true;
@@ -34,7 +33,7 @@ public class McrefreshCommand implements CommandExecutor {
case 0:
if (sender instanceof Player) {
player = (Player) sender;
PP = Users.getProfile(player);
profile = Users.getProfile(player);
}
else {
sender.sendMessage(usage);
@@ -44,15 +43,20 @@ public class McrefreshCommand implements CommandExecutor {
case 1:
player = plugin.getServer().getOfflinePlayer(args[0]);
PP = Users.getProfile(player);
profile = Users.getProfile(player);
String playerName = player.getName();
if (!PP.isLoaded()) {
if (profile == null) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
sender.sendMessage("You have refreshed " + playerName + "'s cooldowns!"); //TODO: Use locale
if (!profile.isLoaded()) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", new Object[] {playerName}));
break;
@@ -61,10 +65,10 @@ public class McrefreshCommand implements CommandExecutor {
return true;
}
PP.setRecentlyHurt((long) 0);
PP.resetCooldowns();
PP.resetToolPrepMode();
PP.resetAbilityMode();
profile.setRecentlyHurt(0);
profile.resetCooldowns();
profile.resetToolPrepMode();
profile.resetAbilityMode();
if (player.isOnline()) {
((Player) player).sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));

View File

@@ -3,18 +3,17 @@ package com.gmail.nossr50.commands.mc;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.util.Database;
public class McremoveCommand implements CommandExecutor {
private final String location;
@@ -22,15 +21,15 @@ public class McremoveCommand implements CommandExecutor {
public McremoveCommand (mcMMO plugin) {
this.plugin = plugin;
this.location = plugin.usersFile;
this.location = mcMMO.getUsersFile();
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String playerName;
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
String databaseName = Config.getInstance().getMySQLDatabaseName();
String usage = ChatColor.RED + "Proper usage is /mcremove <player>"; //TODO: Needs more locale.
//String databaseName = Config.getInstance().getMySQLDatabaseName();
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"mcremove", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"});
String success;
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcremove")) {
@@ -40,7 +39,7 @@ public class McremoveCommand implements CommandExecutor {
switch (args.length) {
case 1:
playerName = args[0];
success = ChatColor.GREEN + playerName + "was successfully removed from the database!"; //TODO: Locale
success = LocaleLoader.getString("Commands.mcremove.Success", new Object[] {playerName});
break;
default:
@@ -50,39 +49,13 @@ public class McremoveCommand implements CommandExecutor {
/* MySQL */
if (Config.getInstance().getUseMySQL()) {
int userId = 0;
userId = mcMMO.database.getInt("SELECT id FROM " + tablePrefix + "users WHERE user = '" + playerName + "'");
if (userId > 0) {
mcMMO.database.write("DELETE FROM "
+ databaseName + "."
+ tablePrefix + "users WHERE "
+ tablePrefix + "users.id=" + userId);
mcMMO.database.write("DELETE FROM "
+ databaseName + "."
+ tablePrefix + "cooldowns WHERE "
+ tablePrefix + "cooldowns.user_id=" + userId);
mcMMO.database.write("DELETE FROM "
+ databaseName + "."
+ tablePrefix + "huds WHERE "
+ tablePrefix + "huds.user_id=" + userId);
mcMMO.database.write("DELETE FROM "
+ databaseName + "."
+ tablePrefix + "skills WHERE "
+ tablePrefix + "skills.user_id=" + userId);
mcMMO.database.write("DELETE FROM "
+ databaseName + "."
+ tablePrefix + "experience WHERE "
+ tablePrefix + "experience.user_id=" + userId);
Database database = mcMMO.getPlayerDatabase();
int affected = 0;
affected = database.update("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.user = '" + playerName + "'");
if (affected > 0) {
sender.sendMessage(success);
}
else {
} else {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
}
}
@@ -95,13 +68,7 @@ public class McremoveCommand implements CommandExecutor {
}
}
//Force PlayerProfile stuff to update
Player player = plugin.getServer().getPlayer(playerName);
if (player != null && Users.players.containsKey(playerName.toLowerCase())) {
Users.removeUser(player);
Users.addUser(player);
}
Database.profileCleanup(playerName);
return true;
}
@@ -109,9 +76,12 @@ public class McremoveCommand implements CommandExecutor {
private boolean removeFlatFileUser(String playerName) {
boolean worked = false;
BufferedReader in = null;
FileWriter out = null;
try {
FileReader file = new FileReader(location);
BufferedReader in = new BufferedReader(file);
in = new BufferedReader(file);
StringBuilder writer = new StringBuilder();
String line = "";
@@ -128,16 +98,32 @@ public class McremoveCommand implements CommandExecutor {
}
}
in.close();
FileWriter out = new FileWriter(location); //Write out the new file
out = new FileWriter(location); //Write out the new file
out.write(writer.toString());
out.close();
return worked;
}
catch (Exception e) {
plugin.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
return worked;
}
finally {
if (in != null) {
try {
in.close();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
if (out != null) {
try {
out.close();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
return worked;
}
}

View File

@@ -7,9 +7,12 @@ import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Database;
import com.gmail.nossr50.util.Leaderboard;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Skills;
@@ -18,8 +21,8 @@ public class MctopCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String usage = ChatColor.RED + "Proper usage is /mctop [skill] [page]"; //TODO: Needs more locale.
String usage = LocaleLoader.getString("Commands.Usage.2", new Object[] {"mctop", "[" + LocaleLoader.getString("Commands.Usage.Skill") + "]", "[" + LocaleLoader.getString("Commands.Usage.Page") + "]"});
if (!Config.getInstance().getUseMySQL()) {
switch (args.length) {
@@ -34,6 +37,9 @@ public class MctopCommand implements CommandExecutor {
else if (Skills.isSkill(args[0])) {
flatfileDisplay(1, args[0].toUpperCase(), sender);
}
else if (Skills.isLocalizedSkill(args[0])) {
flatfileDisplay(1, Skills.translateLocalizedSkill(args[0]).toUpperCase(), sender);
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
}
@@ -41,13 +47,16 @@ public class MctopCommand implements CommandExecutor {
return true;
case 2:
if (!Skills.isSkill(args[0])) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
if (Misc.isInt(args[1])) {
flatfileDisplay(Integer.valueOf(args[1]), args[0].toUpperCase(), sender);
if (Skills.isSkill(args[0])) {
flatfileDisplay(Integer.valueOf(args[1]), args[0].toUpperCase(), sender);
}
else if (Skills.isLocalizedSkill(args[0])) {
flatfileDisplay(Integer.valueOf(args[1]), Skills.translateLocalizedSkill(args[0]).toUpperCase(), sender);
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
}
}
else {
sender.sendMessage(usage);
@@ -60,53 +69,60 @@ public class MctopCommand implements CommandExecutor {
return true;
}
}
else {
String powerlevel = "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing";
switch (args.length) {
case 0:
sqlDisplay(1, powerlevel, sender);
return true;
String powerlevel = "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing";
case 1:
if (Misc.isInt(args[0])) {
sqlDisplay(Integer.valueOf(args[0]), powerlevel, sender);
}
else if (Skills.isSkill(args[0])) {
sqlDisplay(1, args[0].toLowerCase(), sender);
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
}
switch (args.length) {
case 0:
sqlDisplay(1, powerlevel, sender);
return true;
return true;
case 1:
if (Misc.isInt(args[0])) {
sqlDisplay(Integer.valueOf(args[0]), powerlevel, sender);
}
else if (Skills.isSkill(args[0])) {
sqlDisplay(1, args[0].toLowerCase(), sender);
}
else if (Skills.isLocalizedSkill(args[0])) {
sqlDisplay(1, Skills.translateLocalizedSkill(args[0]).toLowerCase(), sender);
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
}
case 2:
if (!Skills.isSkill(args[0])) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
return true;
if (Misc.isInt(args[1])) {
case 2:
if (Misc.isInt(args[1])) {
if (Skills.isSkill(args[0])) {
sqlDisplay(Integer.valueOf(args[1]), args[0].toLowerCase(), sender);
}
else {
sender.sendMessage(usage);
else if (Skills.isLocalizedSkill(args[0])) {
sqlDisplay(Integer.valueOf(args[1]), Skills.translateLocalizedSkill(args[0]).toLowerCase(), sender);
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
}
return true;
default:
sender.sendMessage(usage);
return true;
}
else {
sender.sendMessage(usage);
}
return true;
default:
sender.sendMessage(usage);
return true;
}
}
private void flatfileDisplay(int page, String skill, CommandSender sender) {
String[] info = Leaderboard.retrieveInfo(skill, page);
Leaderboard.updateLeaderboards(); //Make sure we have the latest information
SkillType skillType = SkillType.getSkill(skill);
String[] info = Leaderboard.retrieveInfo(skillType, page);
if (skill == "ALL") {
if (skill.equalsIgnoreCase("ALL")) {
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
}
else {
@@ -129,26 +145,31 @@ public class MctopCommand implements CommandExecutor {
n++;
}
}
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
}
private void sqlDisplay(int page, String query, CommandSender sender) {
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.read("SELECT " + query + ", user_id FROM " + tablePrefix + "skills WHERE " + query + " > 0 ORDER BY " + query + " DESC ");
Database database = mcMMO.getPlayerDatabase();
if (query == "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing") {
HashMap<Integer, ArrayList<String>> userslist = database.read("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 ORDER BY " + query + " DESC, user LIMIT "+((page * 10) - 10)+",10");
if (query.equals("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", new Object[] { Misc.getCapitalized(query) }));
}
for (int i = (page * 10) - 9; i <= (page * 10); i++) {
if (i > userslist.size() || mcMMO.database.read("SELECT user FROM " + tablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null) {
int place = (page * 10) - 9;
for (int i = 1; i <= 10; i++) {
if(userslist.get(i) == null) {
break;
}
HashMap<Integer, ArrayList<String>> username = mcMMO.database.read("SELECT user FROM " + tablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'");
sender.sendMessage(String.valueOf(i) + ". " + ChatColor.GREEN + userslist.get(i).get(0) + " - " + ChatColor.WHITE + username.get(1).get(0));
sender.sendMessage(String.valueOf(place) + ". " + ChatColor.GREEN + userslist.get(i).get(1) + " - " + ChatColor.WHITE + userslist.get(i).get(0));
place++;
}
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
}
}

View File

@@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.party;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -23,8 +22,8 @@ public class ACommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
PlayerProfile PP;
String usage = ChatColor.RED + "Proper usage is /a <message>"; //TODO: Needs more locale.
PlayerProfile profile;
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"a", "<" + LocaleLoader.getString("Commands.Usage.Message") + ">"});
if (CommandHelper.noCommandPermissions(sender, "mcmmo.chat.adminchat")) {
return true;
@@ -33,15 +32,15 @@ public class ACommand implements CommandExecutor {
switch (args.length) {
case 0:
if (sender instanceof Player) {
PP = Users.getProfile((Player) sender);
profile = Users.getProfile((Player) sender);
if (PP.getPartyChatMode()) {
PP.togglePartyChat();
if (profile.getPartyChatMode()) {
profile.togglePartyChat();
}
PP.toggleAdminChat();
profile.toggleAdminChat();
if (PP.getAdminChatMode()) {
if (profile.getAdminChatMode()) {
sender.sendMessage(LocaleLoader.getString("Commands.AdminChat.On"));
}
else {
@@ -55,23 +54,35 @@ public class ACommand implements CommandExecutor {
return true;
default:
String message = args[0];
StringBuffer buffer = new StringBuffer();
buffer.append(args[0]);
for (int i = 1; i < args.length; i++) {
message = message + " " + args [i];
buffer.append(" ");
buffer.append(args[i]);
}
String message = buffer.toString();
if (sender instanceof Player) {
Player player = (Player) sender;
PP = Users.getProfile(player);
if (PP.getAdminChatMode()) {
player.chat(message);
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), message);
plugin.getServer().getPluginManager().callEvent(chatEvent);
if (chatEvent.isCancelled()) {
return true;
}
else {
PP.toggleAdminChat();
player.chat(message);
PP.toggleAdminChat();
message = chatEvent.getMessage();
String prefix = LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {player.getName()} );
plugin.getLogger().info("[A]<" + player.getName() + "> " + message);
for (Player otherPlayer : plugin.getServer().getOnlinePlayers()) {
if (Permissions.adminChat(otherPlayer) || otherPlayer.isOp()) {
otherPlayer.sendMessage(prefix + message);
}
}
}
else {
@@ -83,12 +94,12 @@ public class ACommand implements CommandExecutor {
}
message = chatEvent.getMessage();
String prefix = ChatColor.AQUA + "{" + ChatColor.WHITE + "*Console*" + ChatColor.AQUA + "} ";
String prefix = LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {LocaleLoader.getString("Commands.Chat.Console")} );
plugin.getLogger().info("[A]<*Console*> " + message);
for (Player player : plugin.getServer().getOnlinePlayers()) {
if (Permissions.getInstance().adminChat(player) || player.isOp()) {
if (Permissions.adminChat(player) || player.isOp()) {
player.sendMessage(prefix + message);
}
}

View File

@@ -12,6 +12,7 @@ import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Users;
public class AcceptCommand implements CommandExecutor {
@@ -32,32 +33,33 @@ public class AcceptCommand implements CommandExecutor {
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
PlayerProfile playerProfile = Users.getProfile(player);
if (PP.hasPartyInvite()) {
Party partyInstance = Party.getInstance();
if (playerProfile.hasPartyInvite()) {
PartyManager partyManagerInstance = PartyManager.getInstance();
if (playerProfile.inParty()) {
Party party = playerProfile.getParty();
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), playerProfile.getInvite().getName(), EventReason.CHANGED_PARTIES);
if (PP.inParty()) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, PP.getParty(), PP.getInvite(), EventReason.CHANGED_PARTIES);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyInstance.removeFromParty(player, PP);
partyManagerInstance.removeFromParty(player.getName(), party);
}
else {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, PP.getInvite(), EventReason.JOINED_PARTY);
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, playerProfile.getInvite().getName(), EventReason.JOINED_PARTY);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
}
PP.acceptInvite();
partyInstance.addToParty(player, PP, PP.getParty(), true, null);
partyManagerInstance.joinInvitedParty(player, playerProfile);
}
else {
player.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));

View File

@@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.party;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -11,6 +10,7 @@ import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Users;
//TODO: Make this work from console.
@@ -23,7 +23,7 @@ public class InviteCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String usage = ChatColor.RED + "Proper usage is /invite <player>"; //TODO: Needs more locale.
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"});
if (CommandHelper.noConsoleUsage(sender)) {
return true;
@@ -36,11 +36,9 @@ public class InviteCommand implements CommandExecutor {
switch (args.length) {
case 1:
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
PlayerProfile playerProfile = Users.getProfile(player);
Party partyInstance = Party.getInstance();
if (!PP.inParty()) {
if (!playerProfile.inParty()) {
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return true;
}
@@ -48,26 +46,23 @@ public class InviteCommand implements CommandExecutor {
Player target = plugin.getServer().getPlayer(args[0]);
if (target != null) {
if (partyInstance.canInvite(player, PP)) {
PlayerProfile PPt = Users.getProfile(target);
PPt.modifyInvite(PP.getParty());
if (PartyManager.getInstance().canInvite(player, playerProfile)) {
Party party = playerProfile.getParty();
Users.getProfile(target).setInvite(party);
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", new Object[] { PPt.getInvite(), player.getName() }));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", new Object[] {party.getName(), player.getName()}));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
return true;
}
else {
player.sendMessage(LocaleLoader.getString("Party.Locked"));
return true;
}
}
else {
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
player.sendMessage(LocaleLoader.getString("Party.Locked"));
return true;
}
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
return true;
default:
sender.sendMessage(usage);
return true;

View File

@@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.party;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -12,6 +11,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Users;
public class PCommand implements CommandExecutor {
@@ -23,26 +23,25 @@ public class PCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
PlayerProfile PP;
String usage = ChatColor.RED + "Proper usage is /p <party-name> <message>"; //TODO: Needs more locale.
PlayerProfile profile;
String usage = LocaleLoader.getString("Commands.Usage.2", new Object[] {"p", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">", "<" + LocaleLoader.getString("Commands.Usage.Message") + ">"});
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) {
return true;
}
switch (args.length) {
case 0:
if (sender instanceof Player) {
PP = Users.getProfile((Player) sender);
profile = Users.getProfile((Player) sender);
if (PP.getAdminChatMode()) {
PP.toggleAdminChat();
if (profile.getAdminChatMode()) {
profile.toggleAdminChat();
}
PP.togglePartyChat();
profile.togglePartyChat();
if (PP.getPartyChatMode()) {
if (profile.getPartyChatMode()) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.Chat.On"));
}
else {
@@ -58,26 +57,37 @@ public class PCommand implements CommandExecutor {
default:
if (sender instanceof Player) {
Player player = (Player) sender;
PP = Users.getProfile(player);
Party party = Users.getProfile(player).getParty();
if (!PP.inParty()) {
if (party == null) {
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return true;
}
String message = args[0];
StringBuffer buffer = new StringBuffer();
buffer.append(args[0]);
for (int i = 1; i < args.length; i++) {
message = message + " " + args [i];
buffer.append(" ");
buffer.append(args[i]);
}
if (PP.getPartyChatMode()) {
player.chat(message);
String message = buffer.toString();
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), party.getName(), message);
plugin.getServer().getPluginManager().callEvent(chatEvent);
if (chatEvent.isCancelled()) {
return true;
}
else {
PP.togglePartyChat();
player.chat(message);
PP.togglePartyChat();
message = chatEvent.getMessage();
String prefix = LocaleLoader.getString("Commands.Party.Chat.Prefix", new Object[] {player.getName()} );
plugin.getLogger().info("[P](" + party.getName() + ")" + "<" + player.getName() + "> " + message);
for (Player member : party.getOnlineMembers()) {
member.sendMessage(prefix + message);
}
}
else {
@@ -86,17 +96,21 @@ public class PCommand implements CommandExecutor {
return true;
}
if (!Party.getInstance().isParty(args[0])) {
if (!PartyManager.getInstance().isParty(args[0])) {
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
return true;
}
String message = args[1];
StringBuffer buffer = new StringBuffer();
buffer.append(args[1]);
for (int i = 2; i < args.length; i++) {
message = message + " " + args [i];
buffer.append(" ");
buffer.append(args[i]);
}
String message = buffer.toString();
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent("Console", args[0], message);
plugin.getServer().getPluginManager().callEvent(chatEvent);
@@ -105,12 +119,12 @@ public class PCommand implements CommandExecutor {
}
message = chatEvent.getMessage();
String prefix = ChatColor.GREEN + "(" + ChatColor.WHITE + "*Console*" + ChatColor.GREEN + ") ";
String prefix = LocaleLoader.getString("Commands.Party.Chat.Prefix", new Object[] {LocaleLoader.getString("Commands.Chat.Console")} );
plugin.getLogger().info("[P](" + args[0] + ")" + "<*Console*> " + message);
for (Player player : Party.getInstance().getOnlineMembers(args[0])) {
player.sendMessage(prefix + message);
for (Player member : PartyManager.getInstance().getOnlineMembers(args[0])) {
member.sendMessage(prefix + message);
}
}

View File

@@ -1,6 +1,7 @@
package com.gmail.nossr50.commands.party;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -13,6 +14,7 @@ import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Users;
public class PartyCommand implements CommandExecutor {
@@ -34,59 +36,58 @@ public class PartyCommand implements CommandExecutor {
Player player = (Player) sender;
String playerName = player.getName();
PlayerProfile PP = Users.getProfile(player);
PlayerProfile playerProfile = Users.getProfile(player);
Party partyInstance = Party.getInstance();
boolean inParty = PP.inParty();
String partyName = PP.getParty();
boolean isLeader = partyInstance.isPartyLeader(playerName, partyName);
if (PP.inParty() && (!partyInstance.isParty(PP.getParty()) || !partyInstance.isInParty(player, PP))) {
partyInstance.addToParty(player, PP, PP.getParty(), false, null);
}
PartyManager partyManagerInstance = PartyManager.getInstance();
Party party = playerProfile.getParty();
switch (args.length) {
case 0:
if (!inParty) {
if (party == null) {
player.sendMessage(LocaleLoader.getString("Party.Help.0"));
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
player.sendMessage(LocaleLoader.getString("Party.Help.2"));
}
else {
String tempList = "";
Server server = plugin.getServer();
String leader = party.getLeader();
StringBuffer tempList = new StringBuffer();
for (Player p : partyInstance.getAllMembers(player)) {
if (p.equals(partyInstance.getPartyLeader(partyName))) {
tempList += ChatColor.GOLD;
for (String otherPlayerName : party.getMembers()) {
if (leader.equals(otherPlayerName)) {
tempList.append(ChatColor.GOLD);
}
else if (server.getPlayer(otherPlayerName) != null) {
tempList.append(ChatColor.WHITE);
}
else {
tempList += ChatColor.WHITE;
tempList.append(ChatColor.GRAY);
}
tempList += p.getName() + " ";
tempList.append(otherPlayerName + " ");
}
player.sendMessage(LocaleLoader.getString("Commands.Party.InParty", new Object[] { partyName }));
player.sendMessage(LocaleLoader.getString("Commands.Party.Members", new Object[] { tempList }));
player.sendMessage(LocaleLoader.getString("Commands.Party.InParty", new Object[] {party.getName()}));
player.sendMessage(LocaleLoader.getString("Commands.Party.Members", new Object[] {tempList}));
}
return true;
case 1:
if (args[0].equalsIgnoreCase("q")) {
if (inParty) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, null, EventReason.LEFT_PARTY);
if (party != null) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), null, EventReason.LEFT_PARTY);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyInstance.removeFromParty(player, PP);
partyManagerInstance.removeFromParty(playerName, party);
player.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
}
else {
player.sendMessage("Commands.Party.None");
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
}
}
else if (args[0].equals("?")) {
@@ -98,13 +99,13 @@ public class PartyCommand implements CommandExecutor {
player.sendMessage(LocaleLoader.getString("Party.Help.7"));
}
else if (args[0].equalsIgnoreCase("lock")) {
if (inParty) {
if (isLeader) {
if (partyInstance.isPartyLocked(partyName)) {
if (party != null) {
if (party.getLeader().equals(playerName)) {
if (party.isLocked()) {
player.sendMessage(LocaleLoader.getString("Party.IsLocked"));
}
else {
partyInstance.lockParty(partyName);
party.setLocked(true);
player.sendMessage(LocaleLoader.getString("Party.Locked"));
}
}
@@ -117,13 +118,13 @@ public class PartyCommand implements CommandExecutor {
}
}
else if (args[0].equalsIgnoreCase("unlock")) {
if (inParty) {
if (isLeader) {
if (!partyInstance.isPartyLocked(partyName)) {
if (party != null) {
if (party.getLeader().equals(playerName)) {
if (!party.isLocked()) {
player.sendMessage(LocaleLoader.getString("Party.IsntLocked"));
}
else {
partyInstance.unlockParty(partyName);
party.setLocked(false);
player.sendMessage(LocaleLoader.getString("Party.Unlocked"));
}
}
@@ -136,15 +137,22 @@ public class PartyCommand implements CommandExecutor {
}
}
else {
if (inParty) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, args[0], EventReason.CHANGED_PARTIES);
Party newParty = partyManagerInstance.getParty(args[0]);
// Check to see if the party exists, and if it does, can the player join it?
if (newParty != null && !partyManagerInstance.checkJoinability(player, newParty, null)) {
return true; // End before any event is fired.
}
if (party != null) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), args[0], EventReason.CHANGED_PARTIES);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyInstance.removeFromParty(player, PP);
partyManagerInstance.removeFromParty(playerName, party);
}
else {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY);
@@ -155,96 +163,82 @@ public class PartyCommand implements CommandExecutor {
}
}
partyInstance.addToParty(player, PP, args[0], false, null);
partyManagerInstance.joinParty(player, playerProfile, args[0], null);
}
return true;
case 2:
if (PP.inParty()) {
if (playerProfile.inParty()) {
if (args[0].equalsIgnoreCase("password")) {
if (isLeader) {
if (!partyInstance.isPartyLocked(partyName)) {
partyInstance.lockParty(partyName);
}
partyInstance.setPartyPassword(partyName, args[1]);
player.sendMessage(LocaleLoader.getString("Party.PasswordSet", new Object[] { args[1] }));
if (party.getLeader().equals(playerName)) {
party.setLocked(true);
party.setPassword(args[1]);
player.sendMessage(LocaleLoader.getString("Party.PasswordSet", new Object[] {args[1]}));
}
else {
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
}
}
else if (args[0].equalsIgnoreCase("kick")) {
if (isLeader) {
Player target = plugin.getServer().getPlayer(args[1]);
if (target == null) {
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
if (party.getLeader().equals(playerName)) {
if (!party.getMembers().contains(args[1])) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]}));
return true;
}
PlayerProfile PPt = Users.getProfile(target);
String targetName = target.getName();
String partyName = party.getName();
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, null, EventReason.KICKED_FROM_PARTY);
if (!partyInstance.inSameParty(player, (Player) target)) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { targetName }));
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
else {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, null, EventReason.KICKED_FROM_PARTY);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyInstance.removeFromParty(target, PPt);
target.sendMessage(LocaleLoader.getString("Commands.Party.Kick", new Object[] { partyName }));
}
partyManagerInstance.removeFromParty(args[1], party);
}
else {
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
}
}
else if (args[0].equalsIgnoreCase("owner")) {
if (isLeader) {
Player target = plugin.getServer().getPlayer(args[1]);
if (target == null) {
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
if (party.getLeader().equals(playerName)) {
if (!party.getMembers().contains(args[1])) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]}));
return true;
}
String targetName = target.getName();
if (!partyInstance.inSameParty(player, (Player) target)) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { targetName }));
return true;
}
else {
partyInstance.setPartyLeader(partyName, targetName);
}
}
else {
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
partyManagerInstance.setPartyLeader(args[1], party);
}
}
else {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, args[0], EventReason.CHANGED_PARTIES);
Party newParty = partyManagerInstance.getParty(args[0]);
// Check to see if the party exists, and if it does, can the player join it?
if (newParty != null && !partyManagerInstance.checkJoinability(player, newParty, args[1])) {
return true; // End before any event is fired.
}
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), args[0], EventReason.CHANGED_PARTIES);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyInstance.removeFromParty(player, PP);
partyInstance.addToParty(player, PP, args[0], false, args[1]);
partyManagerInstance.removeFromParty(playerName, party);
partyManagerInstance.joinParty(player, playerProfile, args[0], args[1]);
}
}
else {
Party newParty = partyManagerInstance.getParty(args[0]);
// Check to see if the party exists, and if it does, can the player join it?
if (newParty != null && !partyManagerInstance.checkJoinability(player, newParty, args[1])) {
return true; // End before any event is fired.
}
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY);
plugin.getServer().getPluginManager().callEvent(event);
@@ -252,7 +246,7 @@ public class PartyCommand implements CommandExecutor {
return true;
}
partyInstance.addToParty(player, PP, args[0], false, args[1]);
partyManagerInstance.joinParty(player, playerProfile, args[0], args[1]);
}
return true;

View File

@@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.party;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -12,7 +11,8 @@ import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Users;
public class PtpCommand implements CommandExecutor {
@@ -24,7 +24,7 @@ public class PtpCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String usage = ChatColor.RED + "Proper usage is /ptp <player>"; //TODO: Needs more locale.
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"ptp", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"});
if (CommandHelper.noConsoleUsage(sender)) {
return true;
@@ -37,14 +37,9 @@ public class PtpCommand implements CommandExecutor {
switch (args.length) {
case 1:
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
PlayerProfile profile = Users.getProfile(player);
if (!Party.getInstance().isInParty(player, PP)) {
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return true;
}
if (PP.getRecentlyHurt() + (Config.getInstance().getPTPCommandCooldown() * 1000) > System.currentTimeMillis()) {
if (profile.getRecentlyHurt() + (Config.getInstance().getPTPCommandCooldown() * Misc.TIME_CONVERSION_FACTOR) > System.currentTimeMillis()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", new Object[] { Config.getInstance().getPTPCommandCooldown() }));
return true;
}
@@ -52,12 +47,12 @@ public class PtpCommand implements CommandExecutor {
Player target = plugin.getServer().getPlayer(args[0]);
if (player.equals(target)) {
player.sendMessage("You can't teleport to yourself!"); //TODO: Use locale
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
return true;
}
if (target == null) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Invalid"));
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
return true;
}
@@ -66,8 +61,8 @@ public class PtpCommand implements CommandExecutor {
return true;
}
if (Party.getInstance().inSameParty(player, target)) {
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, PP.getParty());
if (PartyManager.getInstance().inSameParty(player, target)) {
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, profile.getParty().getName());
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
@@ -77,6 +72,7 @@ public class PtpCommand implements CommandExecutor {
player.teleport(target);
player.sendMessage(LocaleLoader.getString("Party.Teleport.Player", new Object[] { target.getName() }));
target.sendMessage(LocaleLoader.getString("Party.Teleport.Target", new Object[] { player.getName() }));
profile.setRecentlyHurt(System.currentTimeMillis());
}
else {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { target.getName() }));
@@ -89,5 +85,5 @@ public class PtpCommand implements CommandExecutor {
sender.sendMessage(usage);
return true;
}
}
}
}

View File

@@ -1,53 +1,75 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.skills.acrobatics.Acrobatics;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.util.Skills;
public class AcrobaticsCommand implements CommandExecutor {
private float skillValue;
public class AcrobaticsCommand extends SkillCommand {
private String dodgeChance;
private String dodgeChanceLucky;
private String rollChance;
private String rollChanceLucky;
private String gracefulRollChance;
private String gracefulRollChanceLucky;
private boolean canDodge;
private boolean canRoll;
private boolean canGracefulRoll;
private boolean lucky;
public AcrobaticsCommand() {
super(SkillType.ACROBATICS);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
protected void dataCalculations() {
float dodgeChanceF;
float rollChanceF;
float gracefulRollChanceF;
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.acrobatics")) {
return true;
}
// DODGE
if (skillValue >= Acrobatics.dodgeMaxBonusLevel) dodgeChanceF = (float) Acrobatics.dodgeMaxChance;
else dodgeChanceF = (float) ((Acrobatics.dodgeMaxChance / Acrobatics.dodgeMaxBonusLevel) * skillValue);
dodgeChance = percent.format(dodgeChanceF / 100D);
if (dodgeChanceF * 1.3333D >= 100D) dodgeChanceLucky = percent.format(1D);
else dodgeChanceLucky = percent.format(dodgeChanceF * 1.3333D / 100D);
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
// ROLL
if (skillValue >= Acrobatics.rollMaxBonusLevel) rollChanceF = (float) Acrobatics.rollMaxChance;
else rollChanceF = (float) ((Acrobatics.rollMaxChance / Acrobatics.rollMaxBonusLevel) * skillValue);
rollChance = percent.format(rollChanceF / 100D);
if (rollChanceF * 1.3333D >= 100D) rollChanceLucky = percent.format(1D);
else rollChanceLucky = percent.format(rollChanceF * 1.3333D / 100D);
skillValue = (float) PP.getSkillLevel(SkillType.ACROBATICS);
dataCalculations(skillValue);
permissionsCheck(player);
// GRACEFULROLL
if (skillValue >= Acrobatics.gracefulRollMaxBonusLevel) gracefulRollChanceF = (float) Acrobatics.gracefulRollMaxChance;
else gracefulRollChanceF = (float) ((Acrobatics.gracefulRollMaxChance / Acrobatics.gracefulRollMaxBonusLevel) * skillValue);
gracefulRollChance = percent.format(gracefulRollChanceF / 100D);
if (gracefulRollChanceF * 1.3333D >= 100D) gracefulRollChanceLucky = percent.format(1D);
else gracefulRollChanceLucky = percent.format(gracefulRollChanceF * 1.3333D / 100D);
}
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Acrobatics.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Acrobatics") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) }));
@Override
protected void permissionsCheck() {
canDodge = Permissions.dodge(player);
canRoll = Permissions.roll(player);
canGracefulRoll = Permissions.gracefulRoll(player);
lucky = Permissions.luckyAcrobatics(player);
}
if (canDodge || canGracefulRoll || canRoll) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
@Override
protected boolean effectsHeaderPermissions() {
return canDodge || canGracefulRoll || canRoll;
}
@Override
protected void effectsDisplay() {
if (lucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.ACROBATICS) }) }));
}
if (canRoll) {
@@ -61,58 +83,34 @@ public class AcrobaticsCommand implements CommandExecutor {
if (canDodge) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.4"), LocaleLoader.getString("Acrobatics.Effect.5") }));
}
}
if (canDodge || canGracefulRoll || canRoll) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
}
@Override
protected boolean statsHeaderPermissions() {
return canDodge || canGracefulRoll || canRoll;
}
@Override
protected void statsDisplay() {
if (canRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", new Object[] { rollChance }));
if (lucky)
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", new Object[] { rollChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { rollChanceLucky }));
else
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", new Object[] { rollChance }));
}
if (canGracefulRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance }));
if (lucky)
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { gracefulRollChanceLucky }));
else
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance }));
}
if (canDodge) {
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance }));
if (lucky)
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { dodgeChanceLucky }));
else
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance }));
}
Page.grabGuidePageForSkill(SkillType.ACROBATICS, player, args);
return true;
}
private void dataCalculations(float skillValue) {
DecimalFormat percent = new DecimalFormat("##0.00%");
if (skillValue >= 1000) {
dodgeChance = "20.00%";
rollChance = "100.00%";
gracefulRollChance = "100.00%";
}
else if (skillValue >= 800) {
dodgeChance = "20.00%";
rollChance = percent.format(skillValue / 1000);
gracefulRollChance = "100.00%";
}
else if (skillValue >= 500) {
dodgeChance = percent.format(skillValue / 4000);
rollChance = percent.format(skillValue / 1000);
gracefulRollChance = "100.00%";
}
else {
dodgeChance = percent.format(skillValue / 4000);
rollChance = percent.format(skillValue / 1000);
gracefulRollChance = percent.format(skillValue / 500);
}
}
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
canDodge = permInstance.dodge(player);
canRoll = permInstance.roll(player);
canGracefulRoll = permInstance.gracefulRoll(player);
}
}

View File

@@ -1,53 +1,71 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.skills.archery.Archery;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.util.Skills;
public class ArcheryCommand implements CommandExecutor {
private float skillValue;
public class ArcheryCommand extends SkillCommand {
private String skillShotBonus;
private String dazeChance;
private String dazeChanceLucky;
private String retrieveChance;
private String retrieveChanceLucky;
private boolean canSkillShot;
private boolean canDaze;
private boolean canRetrieve;
private boolean lucky;
public ArcheryCommand() {
super(SkillType.ARCHERY);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
protected void dataCalculations() {
float dazeChanceF;
float retrieveChanceF;
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.archery")) {
return true;
}
// SkillShot
double bonus = (int)((double) skillValue / (double) Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage;
if (bonus > Archery.skillShotMaxBonusPercentage) skillShotBonus = percent.format(Archery.skillShotMaxBonusPercentage);
else skillShotBonus = percent.format(bonus);
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
// Daze
if (skillValue >= Archery.dazeMaxBonusLevel) dazeChanceF = (float) Archery.dazeMaxBonus;
else dazeChanceF = (float) (( Archery.dazeMaxBonus / Archery.dazeMaxBonusLevel) * skillValue);
dazeChance = percent.format(dazeChanceF / 100D);
if (dazeChanceF * 1.3333D >= 100D) dazeChanceLucky = percent.format(1D);
else dazeChanceLucky = percent.format(dazeChanceF * 1.3333D / 100D);
skillValue = (float) PP.getSkillLevel(SkillType.ARCHERY);
dataCalculations(skillValue);
permissionsCheck(player);
// Retrieve
if (skillValue >= Archery.retrieveMaxBonusLevel) retrieveChanceF = (float) Archery.retrieveMaxChance;
else retrieveChanceF = (float) ((Archery.retrieveMaxChance / Archery.retrieveMaxBonusLevel) * skillValue);
retrieveChance = percent.format(retrieveChanceF / 100D);
if (retrieveChanceF * 1.3333D >= 100D) retrieveChanceLucky = percent.format(1D);
else retrieveChanceLucky = percent.format(retrieveChanceF * 1.3333D / 100D);
}
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Archery.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Archery") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) }));
@Override
protected void permissionsCheck() {
canSkillShot = Permissions.archeryBonus(player);
canDaze = Permissions.daze(player);
canRetrieve = Permissions.trackArrows(player);
lucky = Permissions.luckyArchery(player);
}
if (canSkillShot || canDaze || canRetrieve) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
@Override
protected boolean effectsHeaderPermissions() {
return canSkillShot || canDaze || canRetrieve;
}
@Override
protected void effectsDisplay() {
if (lucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.ARCHERY) }) }));
}
if (canSkillShot) {
@@ -61,48 +79,31 @@ public class ArcheryCommand implements CommandExecutor {
if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5") }));
}
}
if (canSkillShot || canDaze || canRetrieve) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
}
@Override
protected boolean statsHeaderPermissions() {
return canSkillShot || canDaze || canRetrieve;
}
@Override
protected void statsDisplay() {
if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", new Object[] { skillShotBonus }));
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", new Object[] { skillShotBonus }));
}
if (canDaze) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", new Object[] { dazeChance }));
if (lucky)
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", new Object[] { dazeChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { dazeChanceLucky }));
else
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", new Object[] { dazeChance }));
}
if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance }));
if (lucky)
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { retrieveChanceLucky }));
else
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance }));
}
Page.grabGuidePageForSkill(SkillType.ARCHERY, player, args);
return true;
}
private void dataCalculations(float skillValue) {
DecimalFormat percent = new DecimalFormat("##0.00%");
if (skillValue >= 1000) {
skillShotBonus = "200.00%";
dazeChance = "50.00%";
retrieveChance = "100.00%";
}
else {
skillShotBonus = percent.format(((int) skillValue / 50) * 0.1D); //TODO: Not sure if this is the best way to calculate this or not...
dazeChance = percent.format(skillValue / 2000);
retrieveChance = percent.format(skillValue / 1000);
}
}
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
canSkillShot = permInstance.archeryBonus(player);
canDaze = permInstance.daze(player);
canRetrieve = permInstance.trackArrows(player);
}
}

View File

@@ -1,56 +1,94 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.axes.Axes;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.util.Skills;
public class AxesCommand implements CommandExecutor {
private float skillValue;
public class AxesCommand extends SkillCommand {
private String critChance;
private String critChanceLucky;
private String bonusDamage;
private String impactDamage;
private String greaterImpactDamage;
private String skullSplitterLength;
private String skullSplitterLengthEndurance;
private boolean canSkullSplitter;
private boolean canCritical;
private boolean canBonusDamage;
private boolean canImpact;
private boolean canGreaterImpact;
private boolean lucky;
private boolean endurance;
public AxesCommand() {
super(SkillType.AXES);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
protected void dataCalculations() {
float critChanceF;
int skillCheck = Misc.skillCheck((int) skillValue, Axes.criticalHitMaxBonusLevel);
//Armor Impact
impactDamage = String.valueOf(1 + ((double) skillValue / (double) Axes.impactIncreaseLevel));
//Skull Splitter
int length = 2 + (int) ((double) skillValue / (double) Misc.abilityLengthIncreaseLevel);
skullSplitterLength = String.valueOf(length);
if (Permissions.activationTwelve(player)) {
length = length + 12;
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.axes")) {
return true;
else if (Permissions.activationEight(player)) {
length = length + 8;
}
else if (Permissions.activationFour(player)) {
length = length + 4;
}
int maxLength = SkillType.AXES.getAbility().getMaxTicks();
if (maxLength != 0 && length > maxLength) {
length = maxLength;
}
skullSplitterLengthEndurance = String.valueOf(length);
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
//Greater Impact
greaterImpactDamage = String.valueOf(Axes.greaterImpactBonusDamage);
//Critical Strikes
if (skillValue >= Axes.criticalHitMaxBonusLevel) critChanceF = (float) Axes.criticalHitMaxChance;
else critChanceF = (float) ((Axes.criticalHitMaxChance / Axes.criticalHitMaxBonusLevel) * skillCheck);
critChance = percent.format(critChanceF / 100D);
if (critChanceF * 1.3333D >= 100D) critChanceLucky = percent.format(1D);
else critChanceLucky = percent.format(critChanceF * 1.3333D / 100D);
//Axe Mastery
if (skillValue >= Axes.bonusDamageMaxBonusLevel) bonusDamage = String.valueOf(Axes.bonusDamageMaxBonus);
else bonusDamage = String.valueOf(skillValue / ((double) Axes.bonusDamageMaxBonusLevel / (double) Axes.bonusDamageMaxBonus));
}
skillValue = (float) PP.getSkillLevel(SkillType.AXES);
dataCalculations(skillValue);
permissionsCheck(player);
@Override
protected void permissionsCheck() {
canSkullSplitter = Permissions.skullSplitter(player);
canCritical = Permissions.criticalHit(player);
canBonusDamage = Permissions.axeBonus(player);
canImpact = Permissions.impact(player);
canGreaterImpact = Permissions.greaterImpact(player);
lucky = Permissions.luckyAxes(player);
endurance = Permissions.activationTwelve(player) || Permissions.activationEight(player) || Permissions.activationFour(player);
}
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Axes.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Axes") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES) }));
@Override
protected boolean effectsHeaderPermissions() {
return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact;
}
if (canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
@Override
protected void effectsDisplay() {
if (lucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.AXES) }) }));
}
if (canSkullSplitter) {
@@ -72,11 +110,15 @@ public class AxesCommand implements CommandExecutor {
if (canGreaterImpact) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.8"), LocaleLoader.getString("Axes.Effect.9") }));
}
}
if (canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
}
@Override
protected boolean statsHeaderPermissions() {
return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact;
}
@Override
protected void statsDisplay() {
if (canBonusDamage) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", new Object[] {bonusDamage}) }));
}
@@ -90,44 +132,17 @@ public class AxesCommand implements CommandExecutor {
}
if (canCritical) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", new Object[] { critChance }));
if (lucky)
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", new Object[] { critChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { critChanceLucky }));
else
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", new Object[] { critChance }));
}
if (canSkullSplitter) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", new Object[] { skullSplitterLength }));
if (endurance)
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", new Object[] { skullSplitterLength }) + LocaleLoader.getString("Perks.activationtime.bonus", new Object[] { skullSplitterLengthEndurance }));
else
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", new Object[] { skullSplitterLength }));
}
return true;
}
private void dataCalculations(float skillValue) {
DecimalFormat percent = new DecimalFormat("##0.00%");
impactDamage = String.valueOf(5 + ((int) skillValue / 30));
skullSplitterLength = String.valueOf(2 + ((int) skillValue / 50));
greaterImpactDamage = "2";
if (skillValue >= 750) {
critChance = "37.50";
bonusDamage = "4";
}
else if (skillValue >= 200) {
critChance = percent.format(skillValue / 2000);
bonusDamage = "4";
}
else {
critChance = percent.format(skillValue / 2000);
bonusDamage = String.valueOf((int) skillValue / 50);
}
}
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
canSkullSplitter = permInstance.skullSplitter(player);
canCritical = permInstance.criticalHit(player);
canBonusDamage = permInstance.axeBonus(player);
canImpact = permInstance.impact(player);
canGreaterImpact = permInstance.greaterImpact(player);
}
}

View File

@@ -1,48 +1,67 @@
package com.gmail.nossr50.commands.skills;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.util.Skills;
public class ExcavationCommand implements CommandExecutor {
private float skillValue;
public class ExcavationCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private String gigaDrillBreakerLength;
private String gigaDrillBreakerLengthEndurance;
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
private boolean canGigaDrill;
private boolean canTreasureHunt;
private boolean lucky;
private boolean endurance;
public ExcavationCommand() {
super(SkillType.EXCAVATION);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
protected void dataCalculations() {
int length = 2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel);
gigaDrillBreakerLength = String.valueOf(length);
if (Permissions.activationTwelve(player)) {
length = length + 12;
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.excavation")) {
return true;
else if (Permissions.activationEight(player)) {
length = length + 8;
}
else if (Permissions.activationFour(player)) {
length = length + 4;
}
int maxLength = SkillType.EXCAVATION.getAbility().getMaxTicks();
if (maxLength != 0 && length > maxLength) {
length = maxLength;
}
gigaDrillBreakerLengthEndurance = String.valueOf(length);
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
@Override
protected void permissionsCheck() {
canGigaDrill = Permissions.gigaDrillBreaker(player);
canTreasureHunt = Permissions.excavationTreasures(player);
lucky = Permissions.luckyExcavation(player);
endurance = Permissions.activationTwelve(player) || Permissions.activationEight(player) || Permissions.activationFour(player);
}
skillValue = (float) PP.getSkillLevel(SkillType.EXCAVATION);
dataCalculations(skillValue);
permissionsCheck(player);
@Override
protected boolean effectsHeaderPermissions() {
return canGigaDrill || canTreasureHunt;
}
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Excavation.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Excavation") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) }));
if (canGigaDrill || canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
@Override
protected void effectsDisplay() {
if (lucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.EXCAVATION) }) }));
}
if (canGigaDrill) {
@@ -52,25 +71,20 @@ public class ExcavationCommand implements CommandExecutor {
if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canGigaDrill;
}
@Override
protected void statsDisplay() {
if (canGigaDrill) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", new Object[] { gigaDrillBreakerLength }));
if (endurance)
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", new Object[] { gigaDrillBreakerLength }) + LocaleLoader.getString("Perks.activationtime.bonus", new Object[] { gigaDrillBreakerLengthEndurance }));
else
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", new Object[] { gigaDrillBreakerLength }));
}
Page.grabGuidePageForSkill(SkillType.EXCAVATION, player, args);
return true;
}
private void dataCalculations(float skillValue) {
gigaDrillBreakerLength = String.valueOf(2 + ((int) skillValue / 50));
}
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
canGigaDrill = permInstance.gigaDrillBreaker(player);
canTreasureHunt = permInstance.excavationTreasures(player);
}
}

View File

@@ -1,52 +1,87 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.gathering.Fishing;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.util.Skills;
public class FishingCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
public class FishingCommand implements CommandExecutor {
private int lootTier;
private String magicChance;
private String magicChanceLucky;
private String chanceRaining;
private int shakeUnlockLevel;
private String shakeChance;
private String shakeChanceLucky;
private String fishermansDietRank;
private int magicHunterMultiplier = advancedConfig.getFishingMagicMultiplier();
private int fishermansDietRankChange = advancedConfig.getFarmerDietRankChange();
private int fishermansDietRankMaxLevel = fishermansDietRankChange * 5;
private boolean canTreasureHunt;
private boolean canMagicHunt;
private boolean canShake;
private boolean canFishermansDiet;
private boolean lucky;
private boolean raining;
public FishingCommand() {
super(SkillType.FISHING);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
protected void dataCalculations() {
raining = player.getWorld().hasStorm();
chanceRaining = "";
//Treasure Hunter
lootTier = Fishing.getFishingLootTier(profile);
double magicChanceD = lootTier * magicHunterMultiplier;
if (raining) {
chanceRaining = LocaleLoader.getString("Fishing.Chance.Raining");
magicChanceD = magicChanceD * 1.1D;
}
magicChance = percent.format(magicChanceD / 100D);
if (magicChanceD * 1.3333D >= 100D) magicChanceLucky = percent.format(1D);
else magicChanceLucky = percent.format(magicChanceD * 1.3333D / 100D);
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.fishing")) {
return true;
}
//Shake
int dropChance = Fishing.getShakeChance(lootTier);
shakeChance = percent.format(dropChance / 100D);
if (dropChance * 1.3333D >= 100D) shakeChanceLucky = percent.format(1D);
else shakeChanceLucky = percent.format(dropChance * 1.3333D / 100D);
shakeUnlockLevel = advancedConfig.getShakeUnlockLevel();
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
//Fishermans Diet
if (skillValue >= fishermansDietRankMaxLevel) fishermansDietRank = "5";
else fishermansDietRank = String.valueOf((int) ((double) skillValue / (double) fishermansDietRankChange));
}
lootTier = Fishing.getFishingLootTier(PP);
dataCalculations(lootTier);
permissionsCheck(player);
@Override
protected void permissionsCheck() {
canTreasureHunt = Permissions.fishingTreasures(player);
canMagicHunt = Permissions.fishingMagic(player);
canShake = Permissions.shakeMob(player);
canFishermansDiet = Permissions.fishermansDiet(player);
lucky = Permissions.luckyFishing(player);
}
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Fishing.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Fishing") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) }));
@Override
protected boolean effectsHeaderPermissions() {
return canTreasureHunt || canMagicHunt || canShake;
}
if (canTreasureHunt || canMagicHunt || canShake) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
@Override
protected void effectsDisplay() {
if (lucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.FISHING) }) }));
}
if (canTreasureHunt) {
@@ -61,44 +96,43 @@ public class FishingCommand implements CommandExecutor {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5") }));
}
if (canTreasureHunt || canMagicHunt || canShake) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
if (canFishermansDiet) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canTreasureHunt || canMagicHunt || canShake;
}
@Override
protected void statsDisplay() {
if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", new Object[] { lootTier }));
}
if (canMagicHunt) {
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", new Object[] { magicChance }));
if (lucky)
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", new Object[] { magicChance}) + chanceRaining + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { magicChanceLucky }));
else
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", new Object[] { magicChance}) + chanceRaining);
}
if (canShake) {
//TODO: Do we really need to display this twice? Not like there are any associated stats.
if (PP.getSkillLevel(SkillType.FISHING) < 150) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Fishing.Ability.Locked.0") }));
if (skillValue < advancedConfig.getShakeUnlockLevel()) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Fishing.Ability.Locked.0", new Object[] { shakeUnlockLevel }) }));
}
else {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake"));
if (lucky)
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", new Object[] { shakeChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { shakeChanceLucky }));
else
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", new Object[] { shakeChance }));
}
}
Page.grabGuidePageForSkill(SkillType.FISHING, player, args);
return true;
}
private void dataCalculations(int lootTier) {
DecimalFormat percent = new DecimalFormat("##0.00%");
magicChance = percent.format((float) lootTier / 15);
}
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
canTreasureHunt = permInstance.fishingTreasures(player);
canMagicHunt = permInstance.fishingMagic(player);
canShake = permInstance.shakeMob(player);
if (canFishermansDiet) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", new Object[] { fishermansDietRank }));
}
}
}

View File

@@ -1,28 +1,34 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.util.Skills;
public class HerbalismCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
public class HerbalismCommand implements CommandExecutor {
private float skillValue;
private String greenTerraLength;
private String greenTerraLengthEndurance;
private String greenThumbChance;
private String greenThumbChanceLucky;
private String greenThumbStage;
private String farmersDietRank;
private String doubleDropChance;
private String doubleDropChanceLucky;
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
private int farmersDietRankChange = advancedConfig.getFarmerDietRankChange();
private int farmersDietMaxLevel = farmersDietRankChange * 5;
private int greenThumbStageChange = advancedConfig.getGreenThumbStageChange();
private int greenThumbStageMaxLevel = greenThumbStageChange * 4;
private double greenThumbMaxBonus = advancedConfig.getGreenThumbChanceMax();
private int greenThumbMaxLevel = advancedConfig.getGreenThumbMaxLevel();
private double doubleDropsMaxBonus = advancedConfig.getHerbalismDoubleDropsChanceMax();
private int doubleDropsMaxLevel = advancedConfig.getHerbalismDoubleDropsMaxLevel();
private boolean canGreenTerra;
private boolean canGreenThumbWheat;
@@ -30,30 +36,79 @@ public class HerbalismCommand implements CommandExecutor {
private boolean canFarmersDiet;
private boolean canDoubleDrop;
private boolean doubleDropsDisabled;
private boolean lucky;
private boolean endurance;
public HerbalismCommand() {
super(SkillType.HERBALISM);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
protected void dataCalculations() {
float greenThumbChanceF;
float doubleDropChanceF;
int length = 2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel);
greenTerraLength = String.valueOf(length);
if (Permissions.activationTwelve(player)) {
length = length + 12;
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.herbalism")) {
return true;
else if (Permissions.activationEight(player)) {
length = length + 8;
}
else if (Permissions.activationFour(player)) {
length = length + 4;
}
int maxLength = SkillType.HERBALISM.getAbility().getMaxTicks();
if (maxLength != 0 && length > maxLength) {
length = maxLength;
}
greenTerraLengthEndurance = String.valueOf(length);
//FARMERS DIET
if (skillValue >= farmersDietMaxLevel) farmersDietRank = "5";
else farmersDietRank = String.valueOf((int) ((double) skillValue / (double) farmersDietRankChange));
//GREEN THUMB
if (skillValue >= greenThumbStageMaxLevel) greenThumbStage = "4";
else greenThumbStage = String.valueOf((int) ((double) skillValue / (double) greenThumbStageChange));
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
if (skillValue >= greenThumbMaxLevel) greenThumbChanceF = (float) (greenThumbMaxBonus);
else greenThumbChanceF = (float) ((greenThumbMaxBonus / greenThumbMaxLevel) * skillValue);
greenThumbChance = percent.format(greenThumbChanceF / 100D);
if (greenThumbChanceF * 1.3333D >= 100D) greenThumbChanceLucky = percent.format(1D);
else greenThumbChanceLucky = percent.format(greenThumbChanceF * 1.3333D / 100D);
//DOUBLE DROPS
if (skillValue >= doubleDropsMaxLevel) doubleDropChanceF = (float) (doubleDropsMaxBonus);
else doubleDropChanceF = (float) ((doubleDropsMaxBonus / doubleDropsMaxLevel) * skillValue);
doubleDropChance = percent.format(doubleDropChanceF / 100D);
if (doubleDropChanceF * 1.3333D >= 100D) doubleDropChanceLucky = percent.format(1D);
else doubleDropChanceLucky = percent.format(doubleDropChanceF * 1.3333D / 100D);
}
skillValue = (float) PP.getSkillLevel(SkillType.HERBALISM);
dataCalculations(skillValue);
permissionsCheck(player);
@Override
protected void permissionsCheck() {
Config configInstance = Config.getInstance();
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Herbalism.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Herbalism") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) }));
canGreenTerra = Permissions.greenTerra(player);
canGreenThumbWheat = Permissions.greenThumbWheat(player);
canGreenThumbBlocks = Permissions.greenThumbBlocks(player);
canFarmersDiet = Permissions.farmersDiet(player);
canDoubleDrop = Permissions.herbalismDoubleDrops(player);
doubleDropsDisabled = configInstance.herbalismDoubleDropsDisabled();
lucky = Permissions.luckyHerbalism(player);
endurance = Permissions.activationTwelve(player) || Permissions.activationEight(player) || Permissions.activationFour(player);
}
if (canGreenTerra || (canDoubleDrop && !doubleDropsDisabled )|| canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
@Override
protected boolean effectsHeaderPermissions() {
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat;
}
@Override
protected void effectsDisplay() {
if (lucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.HERBALISM) }) }));
}
if (canGreenTerra) {
@@ -75,17 +130,27 @@ public class HerbalismCommand implements CommandExecutor {
if (canDoubleDrop && !doubleDropsDisabled) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9") }));
}
}
if (canGreenTerra || (canDoubleDrop && !doubleDropsDisabled ) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
}
@Override
protected boolean statsHeaderPermissions() {
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat;
}
@Override
protected void statsDisplay() {
if (canGreenTerra) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", new Object[] { greenTerraLength }));
if (endurance)
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", new Object[] { greenTerraLength }) + LocaleLoader.getString("Perks.activationtime.bonus", new Object[] { greenTerraLengthEndurance }));
else
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", new Object[] { greenTerraLength }));
}
if (canGreenThumbBlocks || canGreenThumbWheat) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", new Object[] { greenThumbChance }));
if (lucky)
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", new Object[] { greenThumbChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { greenThumbChanceLucky }));
else
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", new Object[] { greenThumbChance }));
}
if (canGreenThumbWheat) {
@@ -97,72 +162,10 @@ public class HerbalismCommand implements CommandExecutor {
}
if (canDoubleDrop && !doubleDropsDisabled) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", new Object[] { doubleDropChance }));
if (lucky)
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", new Object[] { doubleDropChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { doubleDropChanceLucky }));
else
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", new Object[] { doubleDropChance }));
}
Page.grabGuidePageForSkill(SkillType.HERBALISM, player, args);
return true;
}
private void dataCalculations(float skillValue) {
DecimalFormat percent = new DecimalFormat("##0.00%");
greenTerraLength = String.valueOf(2 + ((int) skillValue / 50));
if (skillValue >= 1500) {
greenThumbChance = "100.00%";
greenThumbStage = "4";
farmersDietRank = "5";
doubleDropChance = "100.00%";
}
else if (skillValue >= 1000) {
greenThumbChance = percent.format(skillValue / 1500);
greenThumbStage = "4";
farmersDietRank = "5";
doubleDropChance = "100.00%";
}
else if (skillValue >= 800) {
greenThumbChance = percent.format(skillValue / 1500);
greenThumbStage = "4";
farmersDietRank = "4";
doubleDropChance = percent.format(skillValue / 1000);
}
else if (skillValue >= 600) {
greenThumbChance = percent.format(skillValue / 1500);
greenThumbStage = "4";
farmersDietRank = "3";
doubleDropChance = percent.format(skillValue / 1000);
}
else if (skillValue >= 400) {
greenThumbChance = percent.format(skillValue / 1500);
greenThumbStage = "3";
farmersDietRank = "2";
doubleDropChance = percent.format(skillValue / 1000);
}
else if (skillValue >= 200) {
greenThumbChance = percent.format(skillValue / 1500);
greenThumbStage = "2";
farmersDietRank = "1";
doubleDropChance = percent.format(skillValue / 1000);
}
else {
greenThumbChance = percent.format(skillValue / 1500);
greenThumbStage = "1";
farmersDietRank = "1";
doubleDropChance = percent.format(skillValue / 1000);
}
}
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
Config configInstance = Config.getInstance();
canGreenTerra = permInstance.greenTerra(player);
canGreenThumbWheat = permInstance.greenThumbWheat(player);
canGreenThumbBlocks = permInstance.greenThumbBlocks(player);
canFarmersDiet = permInstance.farmersDiet(player);
canDoubleDrop = permInstance.herbalismDoubleDrops(player);
doubleDropsDisabled = configInstance.herbalismDoubleDropsDisabled();
}
}

View File

@@ -1,60 +1,150 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.util.Skills;
public class MiningCommand implements CommandExecutor {
private float skillValue;
public class MiningCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private String doubleDropChance;
private String doubleDropChanceLucky;
private String superBreakerLength;
private String superBreakerLengthEndurance;
private String blastMiningRank;
private String blastRadiusIncrease;
private String blastDamageDecrease;
private int blastMiningRank1 = advancedConfig.getBlastMiningRank1();
private int blastMiningRank2 = advancedConfig.getBlastMiningRank2();
private int blastMiningRank3 = advancedConfig.getBlastMiningRank3();
private int blastMiningRank4 = advancedConfig.getBlastMiningRank4();
private int blastMiningRank5 = advancedConfig.getBlastMiningRank5();
private int blastMiningRank6 = advancedConfig.getBlastMiningRank6();
private int blastMiningRank7 = advancedConfig.getBlastMiningRank7();
private int blastMiningRank8 = advancedConfig.getBlastMiningRank8();
private double doubleDropsMaxBonus = advancedConfig.getMiningDoubleDropChance();
private int doubleDropsMaxLevel = advancedConfig.getMiningDoubleDropMaxLevel();
public int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
private boolean canSuperBreaker;
private boolean canDoubleDrop;
private boolean canBlast;
private boolean canBiggerBombs;
private boolean canDemoExpert;
private boolean doubleDropsDisabled;
private boolean lucky;
private boolean endurance;
public MiningCommand() {
super(SkillType.MINING);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
protected void dataCalculations() {
float doubleDropChanceF;
//Super Breaker
int length = 2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel);
superBreakerLength = String.valueOf(length);
if (Permissions.activationTwelve(player)) {
length = length + 12;
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.mining")) {
return true;
else if (Permissions.activationEight(player)) {
length = length + 8;
}
else if (Permissions.activationFour(player)) {
length = length + 4;
}
int maxLength = SkillType.MINING.getAbility().getMaxTicks();
if (maxLength != 0 && length > maxLength) {
length = maxLength;
}
superBreakerLengthEndurance = String.valueOf(length);
//Double Drops
if (skillValue >= doubleDropsMaxLevel) doubleDropChanceF = (float) (doubleDropsMaxBonus);
else doubleDropChanceF = (float) ((doubleDropsMaxBonus / doubleDropsMaxLevel) * skillValue);
doubleDropChance = percent.format(doubleDropChanceF / 100D);
if (doubleDropChanceF * 1.3333D >= 100D) doubleDropChanceLucky = percent.format(1D);
else doubleDropChanceLucky = percent.format(doubleDropChanceF * 1.3333D / 100D);
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
//Blast Mining
if (skillValue >= blastMiningRank8) {
blastMiningRank = "8";
blastDamageDecrease = "100.00%";
blastRadiusIncrease = "4";
}
else if (skillValue >= blastMiningRank7) {
blastMiningRank = "7";
blastDamageDecrease = "50.00%";
blastRadiusIncrease = "3";
}
else if (skillValue >= blastMiningRank6) {
blastMiningRank = "6";
blastDamageDecrease = "50.00%";
blastRadiusIncrease = "3";
}
else if (skillValue >= blastMiningRank5) {
blastMiningRank = "5";
blastDamageDecrease = "25.00%";
blastRadiusIncrease = "2";
}
else if (skillValue >= blastMiningRank4) {
blastMiningRank = "4";
blastDamageDecrease = "25.00%";
blastRadiusIncrease = "2";
}
else if (skillValue >= blastMiningRank3) {
blastMiningRank = "3";
blastDamageDecrease = "0.00%";
blastRadiusIncrease = "1";
}
else if (skillValue >= blastMiningRank2) {
blastMiningRank = "2";
blastDamageDecrease = "0.00%";
blastRadiusIncrease = "1";
}
else if (skillValue >= blastMiningRank1) {
blastMiningRank = "1";
blastDamageDecrease = "0.00%";
blastRadiusIncrease = "0";
}
else {
blastMiningRank = "0";
blastDamageDecrease = "0.00%";
blastRadiusIncrease = "0";
}
}
skillValue = (float) PP.getSkillLevel(SkillType.MINING);
dataCalculations(skillValue);
permissionsCheck(player);
@Override
protected void permissionsCheck() {
Config configInstance = Config.getInstance();
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Mining.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Mining") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING) }));
canBiggerBombs = Permissions.biggerBombs(player);
canBlast = Permissions.blastMining(player);
canDemoExpert = Permissions.demolitionsExpertise(player);
canDoubleDrop = Permissions.miningDoubleDrops(player);
canSuperBreaker = Permissions.superBreaker(player);
doubleDropsDisabled = configInstance.miningDoubleDropsDisabled();
lucky = Permissions.luckyMining(player);
endurance = Permissions.activationTwelve(player) || Permissions.activationEight(player) || Permissions.activationFour(player);
}
if (canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled ) || canSuperBreaker) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
@Override
protected boolean effectsHeaderPermissions() {
return canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled) || canSuperBreaker;
}
@Override
protected void effectsDisplay() {
if (lucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.MINING) }) }));
}
if (canSuperBreaker) {
@@ -76,22 +166,32 @@ public class MiningCommand implements CommandExecutor {
if (canDemoExpert) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.8"), LocaleLoader.getString("Mining.Effect.9") }));
}
}
if (canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled ) || canSuperBreaker) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
}
@Override
protected boolean statsHeaderPermissions() {
return canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled) || canSuperBreaker;
}
@Override
protected void statsDisplay() {
if (canDoubleDrop && !doubleDropsDisabled) {
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", new Object[] { doubleDropChance }));
if (lucky)
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", new Object[] { doubleDropChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { doubleDropChanceLucky }));
else
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", new Object[] { doubleDropChance }));
}
if (canSuperBreaker) {
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", new Object[] { superBreakerLength }));
if (endurance)
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", new Object[] { superBreakerLength }) + LocaleLoader.getString("Perks.activationtime.bonus", new Object[] { superBreakerLengthEndurance }));
else
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", new Object[] { superBreakerLength }));
}
if (canBlast) {
if (PP.getSkillLevel(SkillType.MINING) < 125) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.0") }));
if (skillValue < blastMiningRank1) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.0", new Object[] { blastMiningRank1 }) }));
}
else {
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", new Object[] { blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect." + (Misc.getInt(blastMiningRank) - 1)) }));
@@ -99,8 +199,8 @@ public class MiningCommand implements CommandExecutor {
}
if (canBiggerBombs) {
if (PP.getSkillLevel(SkillType.MINING) < 250) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.1") }));
if (skillValue < blastMiningRank2) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.1", new Object[] { blastMiningRank2 }) }));
}
else {
player.sendMessage(LocaleLoader.getString("Mining.Blast.Radius.Increase", new Object[] { blastRadiusIncrease }));
@@ -108,89 +208,12 @@ public class MiningCommand implements CommandExecutor {
}
if (canDemoExpert) {
if (PP.getSkillLevel(SkillType.MINING) < 500) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.2") }));
if (skillValue < blastMiningRank4) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.2", new Object[] { blastMiningRank4 }) }));
}
else {
player.sendMessage(LocaleLoader.getString("Mining.Effect.Decrease", new Object[] { blastDamageDecrease }));
}
}
Page.grabGuidePageForSkill(SkillType.MINING, player, args);
return true;
}
private void dataCalculations(float skillValue) {
DecimalFormat percent = new DecimalFormat("##0.00%");
superBreakerLength = String.valueOf(2 + ((int) skillValue / 50));
if (skillValue >= 1000) {
blastMiningRank = "8";
blastDamageDecrease = "100.00%";
blastRadiusIncrease = "4";
doubleDropChance = "100.00%";
}
else if (skillValue >= 875) {
blastMiningRank = "7";
blastDamageDecrease = "50.00%";
blastRadiusIncrease = "3";
doubleDropChance = percent.format(skillValue / 1000);
}
else if (skillValue >= 750) {
blastMiningRank = "6";
blastDamageDecrease = "50.00%";
blastRadiusIncrease = "3";
doubleDropChance = percent.format(skillValue / 1000);
}
else if (skillValue >= 625) {
blastMiningRank = "5";
blastDamageDecrease = "25.00%";
blastRadiusIncrease = "2";
doubleDropChance = percent.format(skillValue / 1000);
}
else if (skillValue >= 500) {
blastMiningRank = "4";
blastDamageDecrease = "25.00%";
blastRadiusIncrease = "2";
doubleDropChance = percent.format(skillValue / 1000);
}
else if (skillValue >= 375) {
blastMiningRank = "3";
blastDamageDecrease = "0.00%";
blastRadiusIncrease = "1";
doubleDropChance = percent.format(skillValue / 1000);
}
else if (skillValue >= 250) {
blastMiningRank = "2";
blastDamageDecrease = "0.00%";
blastRadiusIncrease = "1";
doubleDropChance = percent.format(skillValue / 1000);
}
else if (skillValue >= 125) {
blastMiningRank = "1";
blastDamageDecrease = "0.00%";
blastRadiusIncrease = "0";
doubleDropChance = percent.format(skillValue / 1000);
}
else {
blastMiningRank = "0";
blastDamageDecrease = "0.00%";
blastRadiusIncrease = "0";
doubleDropChance = percent.format(skillValue / 1000);
}
}
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
Config configInstance = Config.getInstance();
canBiggerBombs = permInstance.biggerBombs(player);
canBlast = permInstance.blastMining(player);
canDemoExpert = permInstance.demolitionsExpertise(player);
canDoubleDrop = permInstance.miningDoubleDrops(player);
canSuperBreaker = permInstance.superBreaker(player);
doubleDropsDisabled = configInstance.miningDoubleDropsDisabled();
}
}

View File

@@ -1,30 +1,32 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.misc.Repair;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.Repairable;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.util.Skills;
public class RepairCommand implements CommandExecutor {
private float skillValue;
public class RepairCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private int arcaneForgingRank;
private String repairMasteryBonus;
private String superRepairChance;
private String superRepairChanceLucky;
private float repairMasteryMaxBonus = advancedConfig.getRepairMasteryMaxBonus();
private float repairMasteryMaxBonusLevel = advancedConfig.getRepairMasteryMaxLevel();
private float superRepairChanceMax = advancedConfig.getSuperRepairChanceMax();
private float superRepairMaxBonusLevel = advancedConfig.getSuperRepairMaxLevel();
private boolean canSuperRepair;
private boolean canMasterRepair;
private boolean canArcaneForge;
private boolean canSalvage;
private boolean canRepairStone;
private boolean canRepairIron;
private boolean canRepairGold;
@@ -32,37 +34,74 @@ public class RepairCommand implements CommandExecutor {
private boolean canRepairString;
private boolean canRepairLeather;
private boolean canRepairWood;
private boolean arcaneBypass;
private boolean lucky;
private int salvageLevel;
private int diamondLevel;
private int goldLevel;
private int ironLevel;
private int stoneLevel;
public RepairCommand() {
super(SkillType.REPAIR);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
protected void dataCalculations() {
float superRepairChanceF;
// We're using pickaxes here, not the best but it works
Repairable diamondRepairable = mcMMO.repairManager.getRepairable(278);
Repairable goldRepairable = mcMMO.repairManager.getRepairable(285);
Repairable ironRepairable = mcMMO.repairManager.getRepairable(257);
Repairable stoneRepairable = mcMMO.repairManager.getRepairable(274);
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.repair")) {
return true;
}
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
goldLevel = (goldRepairable == null) ? 0 : goldRepairable.getMinimumLevel();
ironLevel = (ironRepairable == null) ? 0 : ironRepairable.getMinimumLevel();
stoneLevel = (stoneRepairable == null) ? 0 : stoneRepairable.getMinimumLevel();
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
salvageLevel = Config.getInstance().getSalvageUnlockLevel();
skillValue = (float) PP.getSkillLevel(SkillType.REPAIR);
dataCalculations(skillValue);
permissionsCheck(player);
if (skillValue >= repairMasteryMaxBonusLevel) repairMasteryBonus = percent.format(repairMasteryMaxBonus / 100D);
else repairMasteryBonus = percent.format((((double) repairMasteryMaxBonus / (double) repairMasteryMaxBonusLevel) * skillValue) / 100D);
int arcaneForgingRank = Repair.getArcaneForgingRank(PP);
if (skillValue >= superRepairMaxBonusLevel) superRepairChanceF = superRepairChanceMax;
else superRepairChanceF = (float) (((double) superRepairChanceMax / (double) superRepairMaxBonusLevel) * skillValue);
superRepairChance = percent.format(superRepairChanceF / 100D);
if (superRepairChanceF * 1.3333D >= 100D) superRepairChanceLucky = percent.format(1D);
else superRepairChanceLucky = percent.format((superRepairChanceF * 1.3333D) / 100D);
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Repair.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Repair") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) }));
arcaneForgingRank = Repair.getArcaneForgingRank(profile);
}
if (canArcaneForge || canRepairDiamond || canRepairGold || canRepairIron || canMasterRepair || canRepairStone || canSuperRepair || canRepairString || canRepairWood || canRepairLeather) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
@Override
protected void permissionsCheck() {
canSuperRepair = Permissions.repairBonus(player);
canMasterRepair = Permissions.repairMastery(player);
canArcaneForge = Permissions.arcaneForging(player);
canSalvage = Permissions.salvage(player);
canRepairDiamond = Permissions.diamondRepair(player);
canRepairGold = Permissions.goldRepair(player);
canRepairIron = Permissions.ironRepair(player);
canRepairStone = Permissions.stoneRepair(player);
canRepairString = Permissions.stringRepair(player);
canRepairLeather = Permissions.leatherRepair(player);
canRepairWood = Permissions.woodRepair(player);
arcaneBypass = Permissions.arcaneBypass(player);
lucky = Permissions.luckyRepair(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canArcaneForge || canSalvage || canRepairDiamond || canRepairGold || canRepairIron || canMasterRepair || canRepairStone || canSuperRepair || canRepairString || canRepairWood || canRepairLeather;
}
@Override
protected void effectsDisplay() {
if (lucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.REPAIR) }) }));
}
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1") }));
@@ -93,70 +132,43 @@ public class RepairCommand implements CommandExecutor {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.6", new Object[] { diamondLevel }), LocaleLoader.getString("Repair.Effect.7") }));
}
if (canSalvage && salvageLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.16", new Object[] { salvageLevel }), LocaleLoader.getString("Repair.Effect.17") }));
}
if (canArcaneForge) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9") }));
}
}
if (canArcaneForge || canMasterRepair || canSuperRepair) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
}
@Override
protected boolean statsHeaderPermissions() {
return canArcaneForge || canMasterRepair || canSuperRepair;
}
if (canMasterRepair) {
@Override
protected void statsDisplay() {
if (canMasterRepair) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", new Object[] { repairMasteryBonus }));
}
if (canSuperRepair) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", new Object[] { superRepairChance }));
if (lucky)
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", new Object[] { superRepairChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { superRepairChanceLucky }));
else
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", new Object[] { superRepairChance }));
}
if (canArcaneForge) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", new Object[] { arcaneForgingRank }));
if (Config.getInstance().getArcaneForgingEnchantLossEnabled()) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", new Object[] { Repair.getEnchantChance(arcaneForgingRank) }));
if (advancedConfig.getArcaneForgingEnchantLossEnabled()) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", new Object[] { (arcaneBypass ? 100 : Repair.getEnchantChance(arcaneForgingRank)) }));
}
if (Config.getInstance().getArcaneForgingDowngradeEnabled()) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", new Object[] { Repair.getDowngradeChance(arcaneForgingRank) }));
if (advancedConfig.getArcaneForgingDowngradeEnabled()) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", new Object[] { (arcaneBypass ? 0 : Repair.getDowngradeChance(arcaneForgingRank)) }));
}
}
Page.grabGuidePageForSkill(SkillType.REPAIR, player, args);
return true;
}
private void dataCalculations(float skillValue) {
DecimalFormat percent = new DecimalFormat("##0.00%");
Config configInstance = Config.getInstance();
diamondLevel = configInstance.getRepairDiamondLevelRequirement();
goldLevel = configInstance.getRepairGoldLevelRequirement();
ironLevel = configInstance.getRepairIronLevelRequirement();
stoneLevel = configInstance.getRepairStoneLevelRequirement();
repairMasteryBonus = percent.format(skillValue / 500);
if (skillValue >= 1000) {
superRepairChance = "100.00%";
}
else {
superRepairChance = percent.format(skillValue / 1000);
}
}
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
canSuperRepair = permInstance.repairBonus(player);
canMasterRepair = permInstance.repairMastery(player);
canArcaneForge = permInstance.arcaneForging(player);
canRepairDiamond = permInstance.diamondRepair(player);
canRepairGold = permInstance.goldRepair(player);
canRepairIron = permInstance.ironRepair(player);
canRepairStone = permInstance.stoneRepair(player);
canRepairString = permInstance.stringRepair(player);
canRepairLeather = permInstance.leatherRepair(player);
canRepairWood = permInstance.woodRepair(player);
}
}

View File

@@ -1,54 +1,101 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.util.Skills;
public class SwordsCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
public class SwordsCommand implements CommandExecutor {
private float skillValue;
private String counterAttackChance;
private String counterAttackChanceLucky;
private String bleedLength;
private String bleedChance;
private String bleedChanceLucky;
private String serratedStrikesLength;
private String serratedStrikesLengthEndurance;
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
private float bleedChanceMax = advancedConfig.getBleedChanceMax();
private float bleedMaxLevel = advancedConfig.getBleedMaxBonusLevel();
private int bleedMaxTicks = advancedConfig.getBleedMaxTicks();
private int bleedBaseTicks = advancedConfig.getBleedBaseTicks();
private float counterChanceMax = advancedConfig.getCounterChanceMax();
private float counterMaxLevel = advancedConfig.getCounterMaxBonusLevel();
private boolean canCounter;
private boolean canSerratedStrike;
private boolean canBleed;
private boolean lucky;
private boolean endurance;
public SwordsCommand() {
super(SkillType.SWORDS);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
protected void dataCalculations() {
float bleedChanceF;
float counterAttackChanceF;
//Serrated Strikes
int length = 2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel);
serratedStrikesLength = String.valueOf(length);
if (Permissions.activationTwelve(player)) {
length = length + 12;
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.swords")) {
return true;
else if (Permissions.activationEight(player)) {
length = length + 8;
}
else if (Permissions.activationFour(player)) {
length = length + 4;
}
int maxLength = SkillType.SWORDS.getAbility().getMaxTicks();
if (maxLength != 0 && length > maxLength) {
length = maxLength;
}
serratedStrikesLengthEndurance = String.valueOf(length);
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
//Bleed
if (skillValue >= bleedMaxLevel) bleedLength = String.valueOf(bleedMaxTicks);
else bleedLength = String.valueOf(bleedBaseTicks);
skillValue = (float) PP.getSkillLevel(SkillType.SWORDS);
dataCalculations(skillValue);
permissionsCheck(player);
if (skillValue >= bleedMaxLevel) bleedChanceF = bleedChanceMax;
else bleedChanceF = (float) (((double) bleedChanceMax / (double) bleedMaxLevel) * skillValue);
bleedChance = percent.format(bleedChanceF / 100D);
if (bleedChanceF * 1.3333D >= 100D) bleedChanceLucky = percent.format(1D);
else bleedChanceLucky = percent.format(bleedChanceF * 1.3333D / 100D);
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Swords.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Swords") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS) }));
//Counter Attack
if (skillValue >= counterMaxLevel) counterAttackChanceF = counterChanceMax;
else counterAttackChanceF = (float) (((double) counterChanceMax / (double) counterMaxLevel) * skillValue);
counterAttackChance = percent.format(counterAttackChanceF / 100D);
if (counterAttackChanceF * 1.3333D >= 100D) counterAttackChanceLucky = percent.format(1D);
else counterAttackChanceLucky = percent.format(counterAttackChanceF * 1.3333D / 100D);
}
if (canBleed || canCounter || canSerratedStrike) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
@Override
protected void permissionsCheck() {
canBleed = Permissions.swordsBleed(player);
canCounter = Permissions.counterAttack(player);
canSerratedStrike = Permissions.serratedStrikes(player);
lucky = Permissions.luckySwords(player);
endurance = Permissions.activationTwelve(player) || Permissions.activationEight(player) || Permissions.activationFour(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canBleed || canCounter || canSerratedStrike;
}
@Override
protected void effectsDisplay() {
if (lucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.SWORDS) }) }));
}
if (canCounter) {
@@ -63,57 +110,36 @@ public class SwordsCommand implements CommandExecutor {
if (canBleed) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.6"), LocaleLoader.getString("Swords.Effect.7") }));
}
}
if (canBleed || canCounter || canSerratedStrike) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
}
@Override
protected boolean statsHeaderPermissions() {
return canBleed || canCounter || canSerratedStrike;
}
@Override
protected void statsDisplay() {
if (canCounter) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", new Object[] { counterAttackChance }));
if (lucky)
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", new Object[] { counterAttackChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { counterAttackChanceLucky }));
else
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", new Object[] { counterAttackChance }));
}
if (canBleed) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", new Object[] { bleedLength }));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", new Object[] { bleedChance }));
if (lucky)
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", new Object[] { bleedChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { bleedChanceLucky }));
else
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", new Object[] { bleedChance }));
}
if (canSerratedStrike) {
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", new Object[] { serratedStrikesLength }));
if (endurance)
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", new Object[] { serratedStrikesLength }) + LocaleLoader.getString("Perks.activationtime.bonus", new Object[] { serratedStrikesLengthEndurance }));
else
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", new Object[] { serratedStrikesLength }));
}
Page.grabGuidePageForSkill(SkillType.SWORDS, player, args);
return true;
}
private void dataCalculations(float skillValue) {
DecimalFormat percent = new DecimalFormat("##0.00%");
serratedStrikesLength = String.valueOf(2 + ((int) skillValue / 50));
if (skillValue >= 750) {
bleedLength = "3";
bleedChance = "75.00%";
counterAttackChance = "30.00%";
}
else if (skillValue >= 600) {
bleedLength = "2";
bleedChance = percent.format(skillValue / 1000);
counterAttackChance = "30.00%";
}
else {
bleedLength = "2";
bleedChance = percent.format(skillValue / 1000);
counterAttackChance = percent.format(skillValue / 2000);
}
}
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
canBleed = permInstance.swordsBleed(player);
canCounter = permInstance.counterAttack(player);
canSerratedStrike = permInstance.serratedStrikes(player);
}
}

View File

@@ -1,24 +1,26 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.util.Skills;
public class TamingCommand implements CommandExecutor {
private float skillValue;
public class TamingCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private String goreChance;
private String goreChanceLucky;
private float goreChanceMax = advancedConfig.getGoreChanceMax();
private float goreMaxLevel = advancedConfig.getGoreMaxBonusLevel();
private int fastFoodUnlock = advancedConfig.getFastFoodUnlock();
private float fastFoodChance = advancedConfig.getFastFoodChance();
private int enviromentallyAwareUnlock = advancedConfig.getEnviromentallyAwareUnlock();
private int thickFurUnlock = advancedConfig.getThickFurUnlock();
private int shockProofUnlock = advancedConfig.getShockProofUnlock();
private int sharpenedClawUnlock = advancedConfig.getSharpenedClawsUnlock();
private boolean canBeastLore;
private boolean canGore;
@@ -28,31 +30,48 @@ public class TamingCommand implements CommandExecutor {
private boolean canShockProof;
private boolean canCallWild;
private boolean canFastFood;
private boolean lucky;
public TamingCommand() {
super(SkillType.TAMING);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
protected void dataCalculations() {
float goreChanceF;
if (skillValue >= goreMaxLevel) goreChanceF = (goreChanceMax);
else goreChanceF = (float) (((double) goreChanceMax / (double) goreMaxLevel) * skillValue);
goreChance = percent.format(goreChanceF / 100D);
if (goreChanceF * 1.3333D >= 100D) goreChanceLucky = percent.format(1D);
else goreChanceLucky = percent.format(goreChanceF * 1.3333D / 100D);
}
@Override
protected void permissionsCheck() {
canBeastLore = Permissions.beastLore(player);
canCallWild = Permissions.callOfTheWild(player);
canEnvironmentallyAware = Permissions.environmentallyAware(player);
canFastFood = Permissions.fastFoodService(player);
canGore = Permissions.gore(player);
canSharpenedClaws = Permissions.sharpenedClaws(player);
canShockProof = Permissions.shockProof(player);
canThickFur = Permissions.thickFur(player);
lucky = Permissions.luckyTaming(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canBeastLore || canCallWild || canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur;
}
@Override
protected void effectsDisplay() {
if (lucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.TAMING) }) }));
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.taming")) {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
skillValue = (float) PP.getSkillLevel(SkillType.TAMING);
dataCalculations(skillValue);
permissionsCheck(player);
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Taming.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Taming") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) }));
if (canBeastLore || canCallWild || canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
}
Config configInstance = Config.getInstance();
if (canBeastLore) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1") }));
@@ -84,26 +103,30 @@ public class TamingCommand implements CommandExecutor {
if (canCallWild) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13") }));
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", new Object[] { Config.getInstance().getTamingCOTWOcelotCost() }));
player.sendMessage(LocaleLoader.getString("Taming.Effect.15", new Object[] { Config.getInstance().getTamingCOTWWolfCost() }));
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", new Object[] { configInstance.getTamingCOTWOcelotCost() }));
player.sendMessage(LocaleLoader.getString("Taming.Effect.15", new Object[] { configInstance.getTamingCOTWWolfCost() }));
}
}
if (canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
}
@Override
protected boolean statsHeaderPermissions() {
return canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur;
}
@Override
protected void statsDisplay() {
if (canFastFood) {
if (PP.getSkillLevel(SkillType.TAMING) < 50) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.4") }));
if (skillValue < fastFoodUnlock) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.4", new Object[] { fastFoodUnlock } ) }));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9") }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9", new Object[] { fastFoodChance } ) }));
}
}
if (canEnvironmentallyAware) {
if (PP.getSkillLevel(SkillType.TAMING) < 100) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.0") }));
if (skillValue < enviromentallyAwareUnlock) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.0", new Object[] { enviromentallyAwareUnlock } ) }));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1") }));
@@ -111,8 +134,8 @@ public class TamingCommand implements CommandExecutor {
}
if (canThickFur) {
if (PP.getSkillLevel(SkillType.TAMING) < 250) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.1") }));
if (skillValue < thickFurUnlock) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.1", new Object[] { thickFurUnlock } ) }));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3") }));
@@ -120,8 +143,8 @@ public class TamingCommand implements CommandExecutor {
}
if (canShockProof) {
if (PP.getSkillLevel(SkillType.TAMING) < 500) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.2") }));
if (skillValue < shockProofUnlock) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.2", new Object[] { shockProofUnlock } ) }));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5") }));
@@ -129,8 +152,8 @@ public class TamingCommand implements CommandExecutor {
}
if (canSharpenedClaws) {
if (PP.getSkillLevel(SkillType.TAMING) < 750) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.3") }));
if (skillValue < sharpenedClawUnlock) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.3", new Object[] { sharpenedClawUnlock } ) }));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7") }));
@@ -138,35 +161,10 @@ public class TamingCommand implements CommandExecutor {
}
if (canGore) {
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", new Object[] { goreChance }));
if (lucky)
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", new Object[] { goreChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { goreChanceLucky }));
else
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", new Object[] { goreChance }));
}
Page.grabGuidePageForSkill(SkillType.TAMING, player, args);
return true;
}
private void dataCalculations(float skillValue) {
DecimalFormat percent = new DecimalFormat("##0.00%");
if (skillValue >= 1000) {
goreChance = "100.00%";
}
else {
goreChance = percent.format(skillValue / 1000);
}
}
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
canBeastLore = permInstance.beastLore(player);
canCallWild = permInstance.callOfTheWild(player);
canEnvironmentallyAware = permInstance.environmentallyAware(player);
canFastFood = permInstance.fastFoodService(player);
canGore = permInstance.gore(player);
canSharpenedClaws = permInstance.sharpenedClaws(player);
canShockProof = permInstance.shockProof(player);
canThickFur = permInstance.thickFur(player);
}
}

View File

@@ -1,55 +1,103 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.util.Skills;
public class UnarmedCommand implements CommandExecutor {
private float skillValue;
public class UnarmedCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private String berserkLength;
private String berserkLengthEndurance;
private String deflectChance;
private String deflectChanceLucky;
private String disarmChance;
private String disarmChanceLucky;
private String ironArmBonus;
private float disarmChanceMax = advancedConfig.getDisarmChanceMax();
private float disarmMaxLevel = advancedConfig.getDisarmMaxBonusLevel();
private float deflectChanceMax = advancedConfig.getDeflectChanceMax();
private float deflectMaxLevel = advancedConfig.getDeflectMaxBonusLevel();
private float ironArmMaxBonus = advancedConfig.getIronArmBonus();
private int ironArmIncreaseLevel = advancedConfig.getIronArmIncreaseLevel();
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
private boolean canBerserk;
private boolean canDisarm;
private boolean canBonusDamage;
private boolean canDeflect;
private boolean lucky;
private boolean endurance;
public UnarmedCommand() {
super(SkillType.UNARMED);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
protected void dataCalculations() {
float disarmChanceF;
float deflectChanceF;
//Berserk
int length = 2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel);
berserkLength = String.valueOf(length);
if (Permissions.activationTwelve(player)) {
length = length + 12;
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.unarmed")) {
return true;
else if (Permissions.activationEight(player)) {
length = length + 8;
}
else if (Permissions.activationFour(player)) {
length = length + 4;
}
int maxLength = SkillType.UNARMED.getAbility().getMaxTicks();
if (maxLength != 0 && length > maxLength) {
length = maxLength;
}
berserkLengthEndurance = String.valueOf(length);
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
//Disarm
if (skillValue >= disarmMaxLevel) disarmChanceF = disarmChanceMax;
else disarmChanceF = (float) (((double) disarmChanceMax / (double) disarmMaxLevel) * skillValue);
disarmChance = percent.format(disarmChanceF / 100D);
if (disarmChanceF * 1.3333D >= 100D) disarmChanceLucky = percent.format(1D);
else disarmChanceLucky = percent.format(disarmChanceF * 1.3333D / 100D);
skillValue = (float) PP.getSkillLevel(SkillType.UNARMED);
dataCalculations(skillValue);
permissionsCheck(player);
//Deflect
if (skillValue >= deflectMaxLevel) deflectChanceF = deflectChanceMax;
else deflectChanceF = (float) (((double) deflectChanceMax / (double) deflectMaxLevel) * skillValue);
deflectChance = percent.format(deflectChanceF / 100D);
if (deflectChanceF * 1.3333D >= 100D) deflectChanceLucky = percent.format(1D);
else deflectChanceLucky = percent.format(deflectChanceF * 1.3333D / 100D);
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Unarmed.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Unarmed") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) }));
//Iron Arm
if (skillValue >= 250) ironArmBonus = String.valueOf(ironArmMaxBonus);
else ironArmBonus = String.valueOf(3 + ((double) skillValue / (double) ironArmIncreaseLevel));
}
if (canBerserk || canBonusDamage || canDeflect || canDisarm) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
@Override
protected void permissionsCheck() {
canBerserk = Permissions.berserk(player);
canBonusDamage = Permissions.unarmedBonus(player);
canDeflect = Permissions.deflect(player);
canDisarm = Permissions.disarm(player);
lucky = Permissions.luckyUnarmed(player);
endurance = Permissions.activationTwelve(player) || Permissions.activationEight(player) || Permissions.activationFour(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canBerserk || canBonusDamage || canDeflect || canDisarm;
}
@Override
protected void effectsDisplay() {
if (lucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.UNARMED) }) }));
}
if (canBerserk) {
@@ -67,60 +115,38 @@ public class UnarmedCommand implements CommandExecutor {
if (canDeflect) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7") }));
}
}
if (canBerserk || canBonusDamage || canDeflect || canDisarm) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
}
@Override
protected boolean statsHeaderPermissions() {
return canBerserk || canBonusDamage || canDeflect || canDisarm;
}
@Override
protected void statsDisplay() {
if (canBonusDamage) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", new Object[] {ironArmBonus}) }));
}
if (canDeflect) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", new Object[] { deflectChance }));
if (lucky)
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", new Object[] { deflectChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { deflectChanceLucky }));
else
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", new Object[] { deflectChance }));
}
if (canDisarm) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", new Object[] { disarmChance }));
if (lucky)
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", new Object[] { disarmChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { disarmChanceLucky }));
else
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", new Object[] { disarmChance }));
}
if (canBerserk) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", new Object[] { berserkLength }));
if (endurance)
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", new Object[] { berserkLength }) + LocaleLoader.getString("Perks.activationtime.bonus", new Object[] { berserkLengthEndurance }));
else
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", new Object[] { berserkLength }));
}
Page.grabGuidePageForSkill(SkillType.UNARMED, player, args);
return true;
}
private void dataCalculations(float skillValue) {
DecimalFormat percent = new DecimalFormat("##0.00%");
berserkLength = String.valueOf(2 + ((int) skillValue / 50));
if (skillValue >= 1000) {
disarmChance = "33.33%";
deflectChance = "50.00%";
ironArmBonus = "8";
}
else if (skillValue >= 250) {
disarmChance = percent.format(skillValue / 3000);
deflectChance = percent.format(skillValue / 2000);
ironArmBonus = "8";
}
else {
disarmChance = percent.format(skillValue / 3000);
deflectChance = percent.format(skillValue / 2000);
ironArmBonus = String.valueOf(3 + ((int) skillValue / 50));
}
}
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
canBerserk = permInstance.berserk(player);
canBonusDamage = permInstance.unarmedBonus(player);
canDeflect = permInstance.deflect(player);
canDisarm = permInstance.disarm(player);
}
}

View File

@@ -1,54 +1,89 @@
package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.util.Skills;
public class WoodcuttingCommand implements CommandExecutor {
private float skillValue;
public class WoodcuttingCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private String treeFellerLength;
private String treeFellerLengthEndurance;
private String doubleDropChance;
private String doubleDropChanceLucky;
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
private double doubleDropsMaxBonus = advancedConfig.getWoodcuttingDoubleDropChance();
private int doubleDropsMaxLevel = advancedConfig.getWoodcuttingDoubleDropMaxLevel();
private int leafBlowUnlock = advancedConfig.getLeafBlowUnlockLevel();
private boolean canTreeFell;
private boolean canLeafBlow;
private boolean canDoubleDrop;
private boolean doubleDropsDisabled;
private boolean lucky;
private boolean endurance;
public WoodcuttingCommand() {
super(SkillType.WOODCUTTING);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
protected void dataCalculations() {
float doubleDropChanceF;
//Tree Feller
int length = 2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel);
treeFellerLength = String.valueOf(length);
if (Permissions.activationTwelve(player)) {
length = length + 12;
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.woodcutting")) {
return true;
else if (Permissions.activationEight(player)) {
length = length + 8;
}
else if (Permissions.activationFour(player)) {
length = length + 4;
}
int maxLength = SkillType.WOODCUTTING.getAbility().getMaxTicks();
if (maxLength != 0 && length > maxLength) {
length = maxLength;
}
treeFellerLengthEndurance = String.valueOf(length);
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
//Double Drops
if (skillValue >= doubleDropsMaxLevel) doubleDropChanceF = (float) (doubleDropsMaxBonus);
else doubleDropChanceF = (float) ((doubleDropsMaxBonus / doubleDropsMaxLevel) * skillValue);
doubleDropChance = percent.format(doubleDropChanceF / 100D);
if (doubleDropChanceF * 1.3333D >= 100D) doubleDropChanceLucky = percent.format(1D);
else doubleDropChanceLucky = percent.format(doubleDropChanceF * 1.3333D / 100D);
}
skillValue = (float) PP.getSkillLevel(SkillType.UNARMED);
dataCalculations(skillValue);
permissionsCheck(player);
@Override
protected void permissionsCheck() {
Config configInstance = Config.getInstance();
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Woodcutting.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.WoodCutting") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) }));
canTreeFell = Permissions.treeFeller(player);
canDoubleDrop = Permissions.woodcuttingDoubleDrops(player);
canLeafBlow = Permissions.leafBlower(player);
doubleDropsDisabled = configInstance.woodcuttingDoubleDropsDisabled();
lucky = Permissions.luckyWoodcutting(player);
endurance = Permissions.activationTwelve(player) || Permissions.activationEight(player) || Permissions.activationFour(player);
}
if ((canDoubleDrop && !doubleDropsDisabled ) || canLeafBlow || canTreeFell) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
@Override
protected boolean effectsHeaderPermissions() {
return (canDoubleDrop && !doubleDropsDisabled) || canLeafBlow || canTreeFell;
}
@Override
protected void effectsDisplay() {
if (lucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.WOODCUTTING) }) }));
}
if (canTreeFell) {
@@ -62,15 +97,19 @@ public class WoodcuttingCommand implements CommandExecutor {
if (canDoubleDrop && !doubleDropsDisabled) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5") }));
}
}
if ((canDoubleDrop && !doubleDropsDisabled ) || canLeafBlow || canTreeFell) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
}
@Override
protected boolean statsHeaderPermissions() {
return (canDoubleDrop && !doubleDropsDisabled) || canLeafBlow || canTreeFell;
}
@Override
protected void statsDisplay() {
//TODO: Remove? Basically duplicates the above.
if (canLeafBlow) {
if (PP.getSkillLevel(SkillType.WOODCUTTING) < 100) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Woodcutting.Ability.Locked.0") }));
if (skillValue < leafBlowUnlock) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Woodcutting.Ability.Locked.0", new Object[] { leafBlowUnlock }) }));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1") }));
@@ -78,38 +117,17 @@ public class WoodcuttingCommand implements CommandExecutor {
}
if (canDoubleDrop && !doubleDropsDisabled) {
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }));
if (lucky)
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { doubleDropChanceLucky }));
else
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }));
}
if (canTreeFell) {
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }));
if (endurance)
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }) + LocaleLoader.getString("Perks.activationtime.bonus", new Object[] { treeFellerLengthEndurance }));
else
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }));
}
Page.grabGuidePageForSkill(SkillType.WOODCUTTING, player, args);
return true;
}
private void dataCalculations(float skillValue) {
DecimalFormat percent = new DecimalFormat("##0.00%");
treeFellerLength = String.valueOf(2 + ((int) skillValue / 50));
if (skillValue >= 1000) {
doubleDropChance = "100.00%";
}
else {
doubleDropChance = percent.format(skillValue / 1000);
}
}
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
Config configInstance = Config.getInstance();
canTreeFell = permInstance.treeFeller(player);
canDoubleDrop = permInstance.woodcuttingDoubleDrops(player);
canLeafBlow = permInstance.leafBlower(player);
doubleDropsDisabled = configInstance.woodcuttingDoubleDropsDisabled();
}
}

View File

@@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.spout;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -8,69 +7,54 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.HUDType;
import com.gmail.nossr50.datatypes.HUDmmo;
import com.gmail.nossr50.config.SpoutConfig;
import com.gmail.nossr50.datatypes.HudType;
import com.gmail.nossr50.datatypes.SpoutHud;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.Users;
public class MchudCommand implements CommandExecutor {
private final mcMMO plugin;
public MchudCommand (mcMMO plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String usage = ChatColor.RED + "Proper usage is /mchud <hud-type>"; //TODO: Locale
String invalid = ChatColor.RED + "That is not a valid HUD type."; //TODO: Locale
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"mchud", "<DISABLED | STANDARD | SMALL | RETRO>"});
String invalid = LocaleLoader.getString("Commands.mchud.Invalid");
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
if (!Config.getInstance().spoutEnabled || !Config.getInstance().getSpoutXPBarEnabled()) {
if (!mcMMO.spoutEnabled || !SpoutConfig.getInstance().getXPBarEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
return true;
}
Player player = (Player) sender;
PlayerProfile playerProfile = Users.getProfile(player);
SpoutHud spoutHud = playerProfile.getSpoutHud();
if (spoutHud == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
return true;
}
switch (args.length) {
case 1:
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
HUDType hud;
for (HudType hudType : HudType.values()) {
if (hudType.toString().equalsIgnoreCase(args[0])) {
playerProfile.setHudType(hudType);
spoutHud.initializeXpBar();
spoutHud.updateXpBar();
if (args[0].equalsIgnoreCase("disabled")) {
hud = HUDType.DISABLED;
}
else if (args[0].equalsIgnoreCase("standard")) {
hud = HUDType.STANDARD;
}
else if (args[0].equalsIgnoreCase("small")) {
hud = HUDType.SMALL;
}
else if (args[0].equalsIgnoreCase("retro")) {
hud = HUDType.RETRO;
}
else {
player.sendMessage(invalid);
return true;
}
if (SpoutStuff.playerHUDs.containsKey(player)) {
SpoutStuff.playerHUDs.get(player).resetHUD();
SpoutStuff.playerHUDs.remove(player);
PP.setHUDType(hud);
SpoutStuff.playerHUDs.put(player, new HUDmmo(player, plugin));
return true;
}
}
player.sendMessage(invalid);
return true;
default:
sender.sendMessage(usage);
player.sendMessage(usage);
return true;
}
}

View File

@@ -1,17 +1,18 @@
package com.gmail.nossr50.commands.spout;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.SpoutConfig;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.SpoutHud;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Skills;
@@ -20,57 +21,66 @@ import com.gmail.nossr50.util.Users;
public class XplockCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String usage = ChatColor.RED + "Proper usage is /xplock [skill]";
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"xplock", "[skill]"});
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
if (!Config.getInstance().spoutEnabled || !Config.getInstance().getSpoutXPBarEnabled() || !Config.getInstance().getCommandXPLockEnabled()) {
if (!mcMMO.spoutEnabled || !SpoutConfig.getInstance().getXPBarEnabled() || !Config.getInstance().getCommandXPLockEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
PlayerProfile playerProfile = Users.getProfile(player);
SpoutHud spoutHud = playerProfile.getSpoutHud();
if (spoutHud == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
return true;
}
switch (args.length) {
case 0:
if (PP.getXpBarLocked()) {
PP.toggleXpBarLocked();
if (spoutHud.getXpBarLocked()) {
spoutHud.toggleXpBarLocked();
player.sendMessage(LocaleLoader.getString("Commands.xplock.unlocked"));
return true;
}
SkillType lastGained = PP.getLastGained();
SkillType lastGained = spoutHud.getLastGained();
if (lastGained != null) {
PP.toggleXpBarLocked();
PP.setSkillLock(lastGained);
spoutHud.toggleXpBarLocked();
spoutHud.setSkillLock(lastGained);
player.sendMessage(LocaleLoader.getString("Commands.xplock.locked", new Object[] { Misc.getCapitalized(lastGained.toString()) }));
return true;
}
else {
player.sendMessage(usage);
}
return true;
case 1:
if (Skills.isSkill(args[0])) {
if (Permissions.getInstance().permission(player, "mcmmo.skills." + args[0].toLowerCase())) {
PP.setXpBarLocked(true);
PP.setSkillLock(Skills.getSkillType(args[0]));
SpoutStuff.updateXpBar(player);
if (Permissions.hasPermission(player, "mcmmo.skills." + args[0].toLowerCase())) {
spoutHud.setXpBarLocked(true);
spoutHud.setSkillLock(Skills.getSkillType(args[0]));
spoutHud.updateXpBar();
player.sendMessage(LocaleLoader.getString("Commands.xplock.locked", new Object[] { Misc.getCapitalized(args[0]) }));
return true;
}
else {
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
return true;
}
}
else {
player.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
return true;
default:
player.sendMessage(usage);
return true;

View File

@@ -0,0 +1,186 @@
package com.gmail.nossr50.config;
public class AdvancedConfig extends ConfigLoader {
private static AdvancedConfig instance;
private AdvancedConfig() {
super("advanced.yml");
loadKeys();
}
public static AdvancedConfig getInstance() {
if (instance == null) {
instance = new AdvancedConfig();
}
return instance;
}
@Override
protected void loadKeys() {
// TODO Do we need to use this?
}
/* GENERAL */
public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); }
/* ACROBATICS */
public double getDodgeChanceMax() { return config.getDouble("Skills.Acrobatics.Dodge_ChanceMax", 20.0D); }
public int getDodgeMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Dodge_MaxBonusLevel", 800); }
public double getRollChanceMax() { return config.getDouble("Skills.Acrobatics.Roll_ChanceMax", 100.0D); }
public int getRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Roll_MaxBonusLevel", 1000); }
public double getGracefulRollChanceMax() { return config.getDouble("Skills.Acrobatics.GracefulRoll_ChanceMax", 100.0D); }
public int getGracefulRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.GracefulRoll_MaxBonusLevel", 500); }
public int getDodgeXPModifier() { return config.getInt("Skills.Acrobatics.Dodge_XP_Modifier", 120); }
public int getRollXPModifier() { return config.getInt("Skills.Acrobatics.Roll_XP_Modifier", 80); }
public int getFallXPModifier() { return config.getInt("Skills.Acrobatics.Fall_XP_Modifier", 120); }
/* ARCHERY */
public int getSkillShotIncreaseLevel() { return config.getInt("Skills.Archery.SkillShot_IncreaseLevel", 50); }
public double getSkillShotIncreasePercentage() { return config.getDouble("Skills.Archery.SkillShot_IncreasePercentage", 0.1D); }
public double getSkillShotBonusMax() { return config.getDouble("Skills.Archery.SkillShot_MaxBonus", 2.0D); }
public double getDazeBonusMax() { return config.getDouble("Skills.Archery.Daze_MaxChance", 50.0D); }
public int getDazeMaxBonusLevel() { return config.getInt("Skills.Archery.Daze_MaxBonusLevel", 1000); }
public int getDazeModifier() { return config.getInt("Skills.Archery.Daze_BonusDamage", 4); }
public double getRetrieveChanceMax() { return config.getDouble("Skills.Archery.Retrieve_MaxBonus", 100.0D); }
public int getRetrieveMaxBonusLevel() { return config.getInt("Skills.Archery.Retrieve_MaxBonusLevel", 1000); }
/* AXES */
public int getBonusDamageAxesBonusMax() { return config.getInt("Skills.Axes.DamageIncrease_MaxBonus", 4); }
public int getBonusDamageAxesMaxBonusLevel() { return config.getInt("Skills.Axes.DamageIncrease_MaxBonusLevel", 200); }
public double getAxesCriticalChance() { return config.getDouble("Skills.Axes.AxesCritical_MaxChance", 37.50D); }
public int getAxesCriticalMaxBonusLevel() { return config.getInt("Skills.Axes.AxesCritical_MaxBonusLevel", 750); }
public double getAxesCriticalPVPModifier() { return config.getDouble("Skills.Axes.AxesCritical_PVP_Modifier", 1.5D); }
public double getAxesCriticalPVEModifier() { return config.getDouble("Skills.Axes.AxesCritical_PVE_Modifier", 2.0D); }
public double getGreaterImpactChance() { return config.getDouble("Skills.Axes.GreaterImpact_Chance", 25.0D); }
public double getGreaterImpactModifier() { return config.getDouble("Skills.Axes.GreaterImpact_KnockbackModifier", 1.5); }
public int getGreaterImpactBonusDamage() { return config.getInt("Skills.Axes.GreaterImpact_BonusDamage", 2); }
public int getArmorImpactIncreaseLevel() { return config.getInt("Skills.Axes.ArmorImpact_IncreaseLevel", 50); }
public double getArmorImpactMaxDurabilityDamage() { return config.getDouble("Skills.Axes.ArmorImpact_MaxPercentageDurabilityDamage", 20.0D); }
public int getSkullSplitterModifier() { return config.getInt("Skills.Axes.SkullSplitter_DamagerModifier", 2); }
/* EXCAVATION */
//Nothing to configure, everything is already configurable in config.yml
/* FISHING */
public int getFishingTierLevelsTier1() { return config.getInt("Skills.Fishing.Tier_Levels.Tier1", 0); }
public int getFishingTierLevelsTier2() { return config.getInt("Skills.Fishing.Tier_Levels.Tier2", 200); }
public int getFishingTierLevelsTier3() { return config.getInt("Skills.Fishing.Tier_Levels.Tier3", 400); }
public int getFishingTierLevelsTier4() { return config.getInt("Skills.Fishing.Tier_Levels.Tier4", 600); }
public int getFishingTierLevelsTier5() { return config.getInt("Skills.Fishing.Tier_Levels.Tier5", 800); }
public int getFishingMagicMultiplier() { return config.getInt("Skills.Fishing.MagicHunter_Multiplier", 5); }
/* 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); }
/* HERBALISM */
public int getFarmerDietRankChange() { return config.getInt("Skills.Herbalism.Food_RankChange", 200); }
public int getGreenThumbStageChange() { return config.getInt("Skills.Herbalism.GreenThumb_StageChange", 200); }
public int getGreenThumbChanceMax() { return config.getInt("Skills.Herbalism.GreenThumb_ChanceMax", 100); }
public int getGreenThumbMaxLevel() { return config.getInt("Skills.Herbalism.GreenThumb_MaxBonusLevel", 1500); }
public int getHerbalismDoubleDropsChanceMax() { return config.getInt("Skills.Herbalism.DoubleDrops_ChanceMax", 100); }
public int getHerbalismDoubleDropsMaxLevel() { return config.getInt("Skills.Herbalism.DoubleDrops_MaxBonusLevel", 1000); }
/* MINING */
public int getMiningDoubleDropChance() { return config.getInt("Skills.Mining.DoubleDrops_ChanceMax", 100); }
public int getMiningDoubleDropMaxLevel() { return config.getInt("Skills.Mining.DoubleDrops_MaxBonusLevel", 1000); }
public int getBlastMiningRank1() { return config.getInt("Skills.Mining.BlastMining_Rank1", 125); }
public int getBlastMiningRank2() { return config.getInt("Skills.Mining.BlastMining_Rank2", 250); }
public int getBlastMiningRank3() { return config.getInt("Skills.Mining.BlastMining_Rank3", 375); }
public int getBlastMiningRank4() { return config.getInt("Skills.Mining.BlastMining_Rank4", 500); }
public int getBlastMiningRank5() { return config.getInt("Skills.Mining.BlastMining_Rank5", 625); }
public int getBlastMiningRank6() { return config.getInt("Skills.Mining.BlastMining_Rank6", 750); }
public int getBlastMiningRank7() { return config.getInt("Skills.Mining.BlastMining_Rank7", 875); }
public int getBlastMiningRank8() { return config.getInt("Skills.Mining.BlastMining_Rank8", 1000); }
/* REPAIR */
public int getRepairMasteryMaxBonus() { return config.getInt("Skills.Repair.RepairMastery_MaxBonusPercentage", 200); }
public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery_MaxBonusLevel", 1000); }
public int getSuperRepairChanceMax() { return config.getInt("Skills.Repair.SuperRepair_ChanceMax", 100); }
public int getSuperRepairMaxLevel() { return config.getInt("Skills.Repair.SuperRepair_MaxBonusLevel", 1000); }
/* Arcane Forging */
public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Skills.Repair.Arcane_Forging.Downgrades.Enabled", true); }
public int getArcaneForgingDowngradeChanceRank1() { return config.getInt("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_1", 75); }
public int getArcaneForgingDowngradeChanceRank2() { return config.getInt("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_2", 50); }
public int getArcaneForgingDowngradeChanceRank3() { return config.getInt("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_3", 25); }
public int getArcaneForgingDowngradeChanceRank4() { return config.getInt("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_4", 15); }
public boolean getArcaneForgingEnchantLossEnabled() { return config.getBoolean("Skills.Repair.Arcane_Forging.May_Lose_Enchants", true); }
public int getArcaneForgingKeepEnchantsChanceRank1() { return config.getInt("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_1", 10); }
public int getArcaneForgingKeepEnchantsChanceRank2() { return config.getInt("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_2", 20); }
public int getArcaneForgingKeepEnchantsChanceRank3() { return config.getInt("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_3", 30); }
public int getArcaneForgingKeepEnchantsChanceRank4() { return config.getInt("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_4", 40); }
public int getArcaneForgingRankLevels1() { return config.getInt("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_1", 100); }
public int getArcaneForgingRankLevels2() { return config.getInt("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_2", 250); }
public int getArcaneForgingRankLevels3() { return config.getInt("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_3", 500); }
public int getArcaneForgingRankLevels4() { return config.getInt("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_4", 750); }
/* SWORDS */
public int getBleedChanceMax() { return config.getInt("Skills.Swords.Bleed_ChanceMax", 75); }
public int getBleedMaxBonusLevel() { return config.getInt("Skills.Swords.Bleed_MaxBonusLevel", 750); }
public int getBleedMaxTicks() { return config.getInt("Skills.Swords.Bleed_MaxTicks", 3); }
public int getBleedBaseTicks() { return config.getInt("Skills.Swords.Bleed_BaseTicks", 2); }
public int getCounterChanceMax() { return config.getInt("Skills.Swords.Counter_ChanceMax", 30); }
public int getCounterMaxBonusLevel() { return config.getInt("Skills.Swords.Counter_MaxBonusLevel", 600); }
public int getCounterModifier() { return config.getInt("Skills.Swords.Counter_DamageModifier", 2); }
public int getSerratedStrikesModifier() { return config.getInt("Skills.Swords.SerratedStrikes_DamageModifier", 4); }
public int getSerratedStrikesTicks() { return config.getInt("Skills.Swords.SerratedStrikes_BleedTicks", 5); }
/* TAMING */
public int getGoreChanceMax() { return config.getInt("Skills.Taming.Gore_ChanceMax", 100); }
public int getGoreMaxBonusLevel() { return config.getInt("Skills.Taming.Gore_MaxBonusLevel", 1000); }
public int getGoreBleedTicks() { return config.getInt("Skills.Taming.Gore_BleedTicks", 2); }
public int getGoreModifier() { return config.getInt("Skills.Taming.Gore_Modifier", 2); }
public int getFastFoodUnlock() { return config.getInt("Skills.Taming.FastFood_UnlockLevel", 50); }
public int getFastFoodChance() { return config.getInt("Skills.Taming.FastFood_Chance", 50); }
public int getEnviromentallyAwareUnlock() { return config.getInt("Skills.Taming.EnvironmentallyAware_UnlockLevel", 100); }
public int getThickFurUnlock() { return config.getInt("Skills.Taming.ThickFur_UnlockLevel", 250); }
public int getThickFurModifier() { return config.getInt("Skills.Taming.ThickFur_Modifier", 2); }
public int getShockProofUnlock() { return config.getInt("Skills.Taming.ShockProof_UnlockLevel", 500); }
public int getShockProofModifier() { return config.getInt("Skills.Taming.ShockProof_Modifier", 6); }
public int getSharpenedClawsUnlock() { return config.getInt("Skills.Taming.SharpenedClaws_UnlockLevel", 750); }
public int getSharpenedClawsBonus() { return config.getInt("Skills.Taming.SharpenedClaws_Bonus", 2); }
/* UNARMED */
public int getDisarmChanceMax() { return config.getInt("Skills.Unarmed.Disarm_ChanceMax", 33); }
public int getDisarmMaxBonusLevel() { return config.getInt("Skills.Unarmed.Disarm_MaxBonusLevel", 1000); }
public int getDeflectChanceMax() { return config.getInt("Skills.Unarmed.Deflect_ChanceMax", 50); }
public int getDeflectMaxBonusLevel() { return config.getInt("Skills.Unarmed.Deflect_MaxBonusLevel", 1000); }
public int getIronGripChanceMax() { return config.getInt("Skills.Unarmed.IronGrip_ChanceMax", 100); }
public int getIronGripMaxBonusLevel() { return config.getInt("Skills.Unarmed.IronGrip_MaxBonusLevel", 1000); }
public int getIronArmBonus() { return config.getInt("Skills.Unarmed.IronArm_BonusMax", 8); }
public int getIronArmIncreaseLevel() { return config.getInt("Skills.Unarmed.IronArm_IncreaseLevel", 50); }
/* WOODCUTTING */
public int getLeafBlowUnlockLevel() { return config.getInt("Skills.Woodcutting.LeafBlower_UnlockLevel", 100); }
public int getWoodcuttingDoubleDropChance() { return config.getInt("Skills.Woodcutting.DoubleDrops_ChanceMax", 100); }
public 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); }
}

View File

@@ -1,26 +1,30 @@
package com.gmail.nossr50.config;
import java.util.Iterator;
import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.HUDType;
public class Config extends ConfigLoader {
public int xpGainMultiplier = 1;
private static Config instance;
public double xpGainMultiplier = 1;
private Config() {
super("config.yml");
xpGainMultiplier = getExperienceGainsGlobalMultiplier();
loadKeys();
}
public static Config getInstance() {
if (instance == null) {
instance = new Config(mcMMO.p);
instance.load();
instance = new Config();
}
return instance;
}
@Override
protected void loadKeys() {}
/*
* GENERAL SETTINGS
*/
@@ -32,23 +36,35 @@ public class Config extends ConfigLoader {
public boolean getStatsTrackingEnabled() { return config.getBoolean("General.Stats_Tracking", true); }
public boolean getEventCallbackEnabled() { return config.getBoolean("General.Event_Callback", true); }
/* Database Purging */
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
public int getOldUsersCutoff() { return config.getInt("Database_Purging.Old_User_Cutoff", 6); }
/* mySQL */
public boolean getUseMySQL() { return config.getBoolean("MySQL.Enabled", false); }
public String getMySQLTablePrefix() { return config.getString("MySQL.Database.TablePrefix", "mcmmo_"); }
public String getMySQLDatabaseName() { return config.getString("MySQL.Database.Name", "DatabaseName"); }
public String getMySQLUserName() { return config.getString("MySQL.Database.User_Name", "UserName"); } //Really should be labeled under MySQL.User_Name instead...
public String getMySQLDatabaseName() { return getStringIncludingInts(config, "MySQL.Database.Name"); }
public String getMySQLUserName() { return getStringIncludingInts(config, "MySQL.Database.User_Name"); }
public int getMySQLServerPort() { return config.getInt("MySQL.Server.Port", 3306); }
public String getMySQLServerName() { return config.getString("MySQL.Server.Address", "localhost"); }
public String getMySQLUserPassword() {
if (config.getString("MySQL.Database.User_Password", null) != null) {
return config.getString("MySQL.Database.User_Password", null);
}
else {
return "";
if (getStringIncludingInts(config, "MySQL.Database.User_Password") != null) {
return getStringIncludingInts(config, "MySQL.Database.User_Password");
}
return "";
}
private static String getStringIncludingInts(ConfigurationSection cfg, String key) {
String str = cfg.getString(key);
if (str == null)
str = String.valueOf(cfg.getInt(key));
if (str == null)
str = "No value set for '" + key + "'";
return str;
}
/* Hardcore Mode */
public boolean getHardcoreEnabled() { return config.getBoolean("Hardcore.Enabled", false); }
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss_Penalty_Percentage", 75); }
@@ -64,6 +80,7 @@ public class Config extends ConfigLoader {
public boolean getCommandXPLockEnabled() { return config.getBoolean("Commands.xplock.Enabled", true); }
public boolean getCommandXPRateEnabled() { return config.getBoolean("Commands.xprate.Enabled", true); }
public boolean getCommandMCTopEnabled() { return config.getBoolean("Commands.mctop.Enabled", true); }
public boolean getCommandMCRankEnabled() { return config.getBoolean("Commands.mcrank.Enabled", true); }
public boolean getCommandAddXPEnabled() { return config.getBoolean("Commands.addxp.Enabled", true); }
public boolean getCommandAddLevelsEnabled() { return config.getBoolean("Commands.addlevels.Enabled", true); }
public boolean getCommandMCAbilityEnabled() { return config.getBoolean("Commands.mcability.Enabled", true); }
@@ -72,8 +89,10 @@ public class Config extends ConfigLoader {
public boolean getCommandMCCEnabled() { return config.getBoolean("Commands.mcc.Enabled", true); }
public boolean getCommandMCGodEnabled() { return config.getBoolean("Commands.mcgod.Enabled", true); }
public boolean getCommandMCStatsEnabled() { return config.getBoolean("Commands.mcstats.Enabled", true); }
public boolean getCommandSkillResetEnabled() { return config.getBoolean("Commands.skillreset.Enabled", true); }
public boolean getCommandMmoeditEnabled() { return config.getBoolean("Commands.mmoedit.Enabled", true); }
public boolean getCommandMCRemoveEnabled() { return config.getBoolean("Commands.mcremove.Enable", true); }
public boolean getCommandMCPurgeEnabled() { return config.getBoolean("Commands.mcpurge.Enable", true); }
public boolean getCommandPTPEnabled() { return config.getBoolean("Commands.ptp.Enabled", true); }
public boolean getCommandPartyEnabled() { return config.getBoolean("Commands.party.Enabled", true); }
public boolean getCommandInspectEnabled() { return config.getBoolean("Commands.inspect.Enabled", true); }
@@ -113,6 +132,16 @@ public class Config extends ConfigLoader {
public int getAbilityCooldownSkullSplitter() { return config.getInt("Abilities.Cooldowns.Skull_Splitter", 240); }
public int getAbilityCooldownBlastMining() { return config.getInt("Abilities.Cooldowns.Blast_Mining", 60); }
/* Max ticks */
public int getAbilityMaxTicksGreenTerra() { return config.getInt("Abilities.Max_Seconds.Green_Terra", 0); }
public int getAbilityMaxTicksSuperBreaker() { return config.getInt("Abilities.Max_Seconds.Super_Breaker", 0); }
public int getAbilityMaxTicksGigaDrillBreaker() { return config.getInt("Abilities.Max_Seconds.Giga_Drill_Breaker", 0); }
public int getAbilityMaxTicksTreeFeller() { return config.getInt("Abilities.Max_Seconds.Tree_Feller", 0); }
public int getAbilityMaxTicksBerserk() { return config.getInt("Abilities.Max_Seconds.Berserk", 0); }
public int getAbilityMaxTicksSerratedStrikes() { return config.getInt("Abilities.Max_Seconds.Serrated_Strikes", 0); }
public int getAbilityMaxTicksSkullSplitter() { return config.getInt("Abilities.Max_Seconds.Skull_Splitter", 0); }
public int getAbilityMaxTicksBlastMining() { return config.getInt("Abilities.Max_Seconds.Blast_Mining", 0); }
/* Thresholds */
public int getTreeFellerThreshold() { return config.getInt("Abilities.Limits.Tree_Feller_Threshold", 500); }
@@ -130,12 +159,7 @@ public class Config extends ConfigLoader {
/* Fishing */
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
public boolean getFishingDropsEnabled() { return config.getBoolean("Fishing.Drops_Enabled", true); }
public int getFishingTierLevelsTier1() { return config.getInt("Fishing.Tier_Levels.Tier1", 0); }
public int getFishingTierLevelsTier2() { return config.getInt("Fishing.Tier_Levels.Tier2", 200); }
public int getFishingTierLevelsTier3() { return config.getInt("Fishing.Tier_Levels.Tier3", 400); }
public int getFishingTierLevelsTier4() { return config.getInt("Fishing.Tier_Levels.Tier4", 600); }
public int getFishingTierLevelsTier5() { return config.getInt("Fishing.Tier_Levels.Tier5", 800); }
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
/* Herbalism */
public int getHerbalismXPSugarCane() { return config.getInt("Experience.Herbalism.Sugar_Cane", 30); }
@@ -148,8 +172,12 @@ public class Config extends ConfigLoader {
public int getHerbalismXPNetherWart() { return config.getInt("Experience.Herbalism.Nether_Wart", 50); }
public int getHerbalismXPLilyPads() { return config.getInt("Experience.Herbalism.Lily_Pads", 100); }
public int getHerbalismXPVines() { return config.getInt("Experience.Herbalism.Vines", 10); }
public int getHerbalismXPCocoa() { return config.getInt("Experience.Herbalism.Cocoa", 30); }
public int getHerbalismXPCarrot() { return config.getInt("Experience.Herbalism.Carrot", 50); }
public int getHerbalismXPPotato() { return config.getInt("Experience.Herbalism.Potato", 50); }
public boolean getHerbalismGreenThumbCobbleToMossy() { return config.getBoolean("Skills.Herbalism.Green_Thumb.Cobble_To_Mossy", true); }
public boolean getHerbalismGreenThumbCobbleWallToMossyWall() { return config.getBoolean("Skills.Herbalism.Green_Thumb.CobbleWall_To_MossyWall", true); }
public boolean getHerbalismGreenThumbSmoothbrickToMossy() { return config.getBoolean("Skills.Herbalism.Green_Thumb.SmoothBrick_To_MossyBrick", true); }
public boolean getHerbalismGreenThumbDirtToGrass() { return config.getBoolean("Skills.Herbalism.Green_Thumb.Dirt_To_Grass", true); }
@@ -165,28 +193,16 @@ public class Config extends ConfigLoader {
public boolean getVinesDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Vines", true); }
public boolean getWaterLiliesDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Water_Lilies", true); }
public boolean getYellowFlowersDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Yellow_Flowers", true); }
public boolean getCocoaDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Cocoa", true); }
public boolean getCarrotDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Carrot", true); }
public boolean getPotatoDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Potato", true); }
public boolean herbalismDoubleDropsDisabled() {
ConfigurationSection section = config.getConfigurationSection("Double_Drops.Herbalism");
Set<String> keys = section.getKeys(false);
Iterator<String> iterator = keys.iterator();
boolean disabled = true;
while (iterator.hasNext()) {
String key = iterator.next();
if (config.getBoolean("Double_Drops.Herbalism." + key)) {
disabled = false;
break;
}
}
return disabled;
return doubleDropsDisabled("Herbalism");
}
/* Mining */
public int getMiningXPGoldOre() { return config.getInt("Experience.Mining.Gold", 250); }
public int getMiningXPGoldOre() { return config.getInt("Experience.Mining.Gold", 250); }
public int getMiningXPDiamondOre() { return config.getInt("Experience.Mining.Diamond", 750); }
public int getMiningXPIronOre() { return config.getInt("Experience.Mining.Iron", 250); }
public int getMiningXPRedstoneOre() { return config.getInt("Experience.Mining.Redstone", 150); }
@@ -199,6 +215,7 @@ public class Config extends ConfigLoader {
public int getMiningXPSandstone() { return config.getInt("Experience.Mining.Sandstone", 30); }
public int getMiningXPEndStone() { return config.getInt("Experience.Mining.End_Stone", 150); }
public int getMiningXPMossyStone() { return config.getInt("Experience.Mining.Moss_Stone", 30); }
public int getMiningXPEmeraldOre() { return config.getInt("Experience.Mining.Emerald", 1000); }
public boolean getCoalDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Coal", true); }
public boolean getDiamondDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Diamond", true); }
@@ -213,24 +230,10 @@ public class Config extends ConfigLoader {
public boolean getRedstoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Redstone", true); }
public boolean getSandstoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Sandstone", true); }
public boolean getStoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Stone", true); }
public boolean getEmeraldDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Emerald", true); }
public boolean miningDoubleDropsDisabled() {
ConfigurationSection section = config.getConfigurationSection("Double_Drops.Mining");
Set<String> keys = section.getKeys(false);
Iterator<String> iterator = keys.iterator();
boolean disabled = true;
while (iterator.hasNext()) {
String key = iterator.next();
if (config.getBoolean("Double_Drops.Mining." + key)) {
disabled = false;
break;
}
}
return disabled;
return doubleDropsDisabled("Mining");
}
public int getDetonatorItemID() { return config.getInt("Skills.Mining.Detonator_ID", 259); }
@@ -238,19 +241,11 @@ public class Config extends ConfigLoader {
/* Repair */
public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); }
public int getRepairAnvilId() { return config.getInt("Skills.Repair.Anvil_ID", 42); }
public int getRepairGoldMaterial() { return config.getInt("Skills.Repair.Gold.ID", 266); }
public int getRepairStoneMaterial() { return config.getInt("Skills.Repair.Stone.ID", 4); }
public int getRepairWoodMaterial() { return config.getInt("Skills.Repair.Wood.ID", 5); }
public int getRepairDiamondMaterial() { return config.getInt("Skills.Repair.Diamond.ID", 264); }
public int getRepairIronMaterial() { return config.getInt("Skills.Repair.Iron.ID", 265); }
public int getRepairStringMaterial() { return config.getInt("Skills.Repair.String.ID", 287); }
public int getRepairLeatherMaterial() { return config.getInt("Skills.Repair.Leather.ID", 334); }
public int getRepairDiamondLevelRequirement() { return config.getInt("Skills.Repair.Diamond.Level_Required", 50); }
public int getRepairIronLevelRequirement() { return config.getInt("Skills.Repair.Iron.Level_Required", 0); }
public int getRepairGoldLevelRequirement() { return config.getInt("Skills.Repair.Gold.Level_Required", 0); }
public int getRepairStoneLevelRequirement() { return config.getInt("Skills.Repair.Stone.Level_Required", 0); }
public boolean getSalvageEnabled() { return config.getBoolean("Skills.Repair.Salvage_enabled", true); }
public int getSalvageAnvilId() { return config.getInt("Skills.Repair.Salvage_Anvil_ID", 41); }
public int getSalvageUnlockLevel() { return config.getInt("Skills.Repair.Salvage_UnlockLevel", 600); }
public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); }
/* Taming */
public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); }
@@ -270,54 +265,68 @@ public class Config extends ConfigLoader {
public boolean getJungleDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Jungle", true); }
public boolean woodcuttingDoubleDropsDisabled() {
ConfigurationSection section = config.getConfigurationSection("Double_Drops.Woodcutting");
Set<String> keys = section.getKeys(false);
Iterator<String> iterator = keys.iterator();
boolean disabled = true;
while (iterator.hasNext()) {
String key = iterator.next();
if (config.getBoolean("Double_Drops.Woodcutting." + key)) {
disabled = false;
break;
}
}
return disabled;
return doubleDropsDisabled("Woodcutting");
}
/* Arcane Forging */
public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Arcane_Forging.Downgrades.Enabled", true); }
public int getArcaneForgingDowngradeChanceRank1() { return config.getInt("Arcane_Forging.Downgrades.Chance.Rank_1", 75); }
public int getArcaneForgingDowngradeChanceRank2() { return config.getInt("Arcane_Forging.Downgrades.Chance.Rank_2", 50); }
public int getArcaneForgingDowngradeChanceRank3() { return config.getInt("Arcane_Forging.Downgrades.Chance.Rank_3", 25); }
public int getArcaneForgingDowngradeChanceRank4() { return config.getInt("Arcane_Forging.Downgrades.Chance.Rank_4", 15); }
public boolean getArcaneForgingEnchantLossEnabled() { return config.getBoolean("Arcane_Forging.May_Lose_Enchants", true); }
public int getArcaneForgingKeepEnchantsChanceRank1() { return config.getInt("Arcane_Forging.Keep_Enchants.Chance.Rank_1", 10); }
public int getArcaneForgingKeepEnchantsChanceRank2() { return config.getInt("Arcane_Forging.Keep_Enchants.Chance.Rank_2", 20); }
public int getArcaneForgingKeepEnchantsChanceRank3() { return config.getInt("Arcane_Forging.Keep_Enchants.Chance.Rank_3", 30); }
public int getArcaneForgingKeepEnchantsChanceRank4() { return config.getInt("Arcane_Forging.Keep_Enchants.Chance.Rank_4", 40); }
public int getArcaneForgingRankLevels1() { return config.getInt("Arcane_Forging.Rank_Levels.Rank_1", 100); }
public int getArcaneForgingRankLevels2() { return config.getInt("Arcane_Forging.Rank_Levels.Rank_2", 250); }
public int getArcaneForgingRankLevels3() { return config.getInt("Arcane_Forging.Rank_Levels.Rank_3", 500); }
public int getArcaneForgingRankLevels4() { return config.getInt("Arcane_Forging.Rank_Levels.Rank_4", 750); }
/* AFK Leveling */
public boolean getAcrobaticsAFKDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
public boolean getHerbalismAFKDisabled() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
/* Dogde Lightning */
public boolean getDodgeLightningDisabled() {return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
/* Level Caps */
public int getLevelCapAcrobatics() { return config.getInt("Skills.Acrobatics.Level_Cap", 0); }
public int getLevelCapArchery() { return config.getInt("Skills.Archery.Level_Cap", 0); }
public int getLevelCapAxes() { return config.getInt("Skills.Axes.Level_Cap", 0); }
public int getLevelCapExcavation() { return config.getInt("Skills.Excavation.Level_Cap", 0); }
public int getLevelCapFishing() { return config.getInt("Skills.Fishing.Level_Cap", 0); }
public int getLevelCapHerbalism() { return config.getInt("Skills.Herbalism.Level_Cap", 0); }
public int getLevelCapMining() { return config.getInt("Skills.Mining.Level_Cap", 0); }
public int getLevelCapRepair() { return config.getInt("Skills.Repair.Level_Cap", 0); }
public int getLevelCapSwords() { return config.getInt("Skills.Swords.Level_Cap", 0); }
public int getLevelCapTaming() { return config.getInt("Skills.Taming.Level_Cap", 0); }
public int getLevelCapUnarmed() { return config.getInt("Skills.Unarmed.Level_Cap", 0); }
public int getLevelCapWoodcutting() { return config.getInt("Skills.Woodcutting.Level_Cap", 0); }
public int getPowerLevelCap() { return config.getInt("General.Power_Level_Cap", 0); }
public int getLevelCapAcrobatics() {
return getLevelCap("Skills.Acrobatics.Level_Cap");
}
public int getLevelCapArchery() {
return getLevelCap("Skills.Archery.Level_Cap");
}
public int getLevelCapAxes() {
return getLevelCap("Skills.Axes.Level_Cap");
}
public int getLevelCapExcavation() {
return getLevelCap("Skills.Excavation.Level_Cap");
}
public int getLevelCapFishing() {
return getLevelCap("Skills.Fishing.Level_Cap");
}
public int getLevelCapHerbalism() {
return getLevelCap("Skills.Herbalism.Level_Cap");
}
public int getLevelCapMining() {
return getLevelCap("Skills.Mining.Level_Cap");
}
public int getLevelCapRepair() {
return getLevelCap("Skills.Repair.Level_Cap");
}
public int getLevelCapSwords() {
return getLevelCap("Skills.Swords.Level_Cap");
}
public int getLevelCapTaming() {
return getLevelCap("Skills.Taming.Level_Cap");
}
public int getLevelCapUnarmed() {
return getLevelCap("Skills.Unarmed.Level_Cap");
}
public int getLevelCapWoodcutting() {
return getLevelCap("Skills.Woodcutting.Level_Cap");
}
public int getPowerLevelCap() {
return getLevelCap("General.Power_Level_Cap");
}
/* PVP & PVE Settings */
public boolean getAcrobaticsPVP() { return config.getBoolean("Skills.Acrobatics.Enabled_For_PVP", true); }
@@ -340,11 +349,10 @@ public class Config extends ConfigLoader {
/* General Settings */
public boolean getExperienceGainsMobspawnersEnabled() { return config.getBoolean("Experience.Gains.Mobspawners.Enabled", false); }
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
public int getExperienceGainsGlobalMultiplier() { return config.getInt("Experience.Gains.Multiplier.Global", 1); }
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience.Gains.Multiplier.Global", 1.0); }
/* Combat XP Multipliers */
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience.Gains.Multiplier.PVP", 1.0); }
public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); }
public double getCreeperXP() { return config.getDouble("Experience.Combat.Multiplier.Creeper", 4.0); }
public double getSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Skeleton", 2.0); }
@@ -360,6 +368,10 @@ public class Config extends ConfigLoader {
public double getMagmaCubeXP() { return config.getDouble("Experience.Combat.Multiplier.Magma_Cube", 2.0); }
public double getEnderDragonXP() { return config.getDouble("Experience.Combat.Multiplier.Ender_Dragon", 8.0); }
public double getIronGolemXP() { return config.getDouble("Experience.Combat.Multiplier.Iron_Golem", 2.0); }
public double getGiantXP() { return config.getDouble("Experience.Combat.Multiplier.Giant", 4.0); }
public double getWitherXP() { return config.getDouble("Experience.Combat.Multiplier.Wither", 7.0); }
public double getWitherSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Wither_Skeleton", 4.0); }
public double getWitchXP() { return config.getDouble("Experience.Combat.Multiplier.Witch", 4.0); }
/* XP Formula Multiplier */
public int getFormulaMultiplierCurve() { return config.getInt("Experience.Formula.Curve_Modifier", 20); }
@@ -376,103 +388,24 @@ public class Config extends ConfigLoader {
public double getFormulaMultiplierAcrobatics() { return config.getDouble("Experience.Formula.Multiplier.Acrobatics", 1.0); }
public double getFormulaMultiplierFishing() { return config.getDouble("Experience.Formula.Multiplier.Fishing", 1.0); }
/*
* SPOUT SETTINGS
*/
private boolean doubleDropsDisabled(String skillName) {
ConfigurationSection section = config.getConfigurationSection("Double_Drops." + skillName);
Set<String> keys = section.getKeys(false);
public boolean spoutEnabled;
public boolean getShowPowerLevelForSpout() { return config.getBoolean("Spout.HUD.Show_Power_Level", true); }
boolean disabled = true;
/* Spout XP Bar */
public boolean getSpoutXPBarEnabled() { return config.getBoolean("Spout.XP.Bar.Enabled", true); }
public boolean getSpoutXPBarIconEnabled() { return config.getBoolean("Spout.XP.Icon.Enabled", true); }
public int getSpoutXPBarXPosition() { return config.getInt("Spout.XP.Bar.X_POS", 95); }
public int getSpoutXPBarYPosition() { return config.getInt("Spout.XP.Bar.Y_POS", 6); }
public int getSpoutXPIconXPosition() { return config.getInt("Spout.XP.Icon.X_POS", 78); }
public int getSpoutXPIconYPosition() { return config.getInt("Spout.XP.Icon.Y_POS", 2); }
/* Spout HUD Colors */
public double getSpoutRetroHUDXPBorderRed() { return config.getDouble("Spout.HUD.Retro.Colors.Border.RED", 0.0); }
public double getSpoutRetroHUDXPBorderGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Border.GREEN", 0.0); }
public double getSpoutRetroHUDXPBorderBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Border.BLUE", 0.0); }
public double getSpoutRetroHUDXPBackgroundRed() { return config.getDouble("Spout.HUD.Retro.Colors.Background.RED", 0.75); }
public double getSpoutRetroHUDXPBackgroundGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Background.GREEN", 0.75); }
public double getSpoutRetroHUDXPBackgroundBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Background.BLUE", 0.75); }
public double getSpoutRetroHUDAcrobaticsRed() { return config.getDouble("Spout.HUD.Retro.Colors.Acrobatics.RED", 0.3); }
public double getSpoutRetroHUDAcrobaticsGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Acrobatics.GREEN", 0.3); }
public double getSpoutRetroHUDAcrobaticsBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Acrobatics.BLUE", 0.75); }
public double getSpoutRetroHUDArcheryRed() { return config.getDouble("Spout.HUD.Retro.Colors.Archery.RED", 0.3); }
public double getSpoutRetroHUDArcheryGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Archery.GREEN", 0.3); }
public double getSpoutRetroHUDArcheryBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Archery.BLUE", 0.75); }
public double getSpoutRetroHUDAxesRed() { return config.getDouble("Spout.HUD.Retro.Colors.Axes.RED", 0.3); }
public double getSpoutRetroHUDAxesGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Axes.GREEN", 0.3); }
public double getSpoutRetroHUDAxesBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Axes.BLUE", 0.75); }
public double getSpoutRetroHUDExcavationRed() { return config.getDouble("Spout.HUD.Retro.Colors.Excavation.RED", 0.3); }
public double getSpoutRetroHUDExcavationGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Excavation.GREEN", 0.3); }
public double getSpoutRetroHUDExcavationBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Excavation.BLUE", 0.75); }
public double getSpoutRetroHUDHerbalismRed() { return config.getDouble("Spout.HUD.Retro.Colors.Herbalism.RED", 0.3); }
public double getSpoutRetroHUDHerbalismGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Herbalism.GREEN", 0.3); }
public double getSpoutRetroHUDHerbalismBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Herbalism.BLUE", 0.75); }
public double getSpoutRetroHUDMiningRed() { return config.getDouble("Spout.HUD.Retro.Colors.Mining.RED", 0.3); }
public double getSpoutRetroHUDMiningGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Mining.GREEN", 0.3); }
public double getSpoutRetroHUDMiningBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Mining.BLUE", 0.75); }
public double getSpoutRetroHUDRepairRed() { return config.getDouble("Spout.HUD.Retro.Colors.Repair.RED", 0.3); }
public double getSpoutRetroHUDRepairGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Repair.GREEN", 0.3); }
public double getSpoutRetroHUDRepairBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Repair.BLUE", 0.75); }
public double getSpoutRetroHUDSwordsRed() { return config.getDouble("Spout.HUD.Retro.Colors.Swords.RED", 0.3); }
public double getSpoutRetroHUDSwordsGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Swords.GREEN", 0.3); }
public double getSpoutRetroHUDSwordsBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Swords.BLUE", 0.75); }
public double getSpoutRetroHUDTamingRed() { return config.getDouble("Spout.HUD.Retro.Colors.Taming.RED", 0.3); }
public double getSpoutRetroHUDTamingGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Taming.GREEN", 0.3); }
public double getSpoutRetroHUDTamingBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Taming.BLUE", 0.75); }
public double getSpoutRetroHUDUnarmedRed() { return config.getDouble("Spout.HUD.Retro.Colors.Unarmed.RED", 0.3); }
public double getSpoutRetroHUDUnarmedGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Unarmed.GREEN", 0.3); }
public double getSpoutRetroHUDUnarmedBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Unarmed.BLUE", 0.75); }
public double getSpoutRetroHUDWoodcuttingRed() { return config.getDouble("Spout.HUD.Retro.Colors.Woodcutting.RED", 0.3); }
public double getSpoutRetroHUDWoodcuttingGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Woodcutting.GREEN", 0.3); }
public double getSpoutRetroHUDWoodcuttingBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Woodcutting.BLUE", 0.75); }
public double getSpoutRetroHUDFishingRed() { return config.getDouble("Spout.HUD.Retro.Colors.Fishing.RED", 0.3); }
public double getSpoutRetroHUDFishingGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Fishing.GREEN", 0.3); }
public double getSpoutRetroHUDFishingBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Fishing.BLUE", 0.75); }
/*
* CONFIG LOADING
*/
public HUDType defaulthud;
private Config(mcMMO plugin) {
super(plugin, "config.yml");
config = plugin.getConfig();
xpGainMultiplier = getExperienceGainsGlobalMultiplier();
}
@Override
protected void load() {
if (!configFile.exists()) {
dataFolder.mkdir();
plugin.saveDefaultConfig();
}
addDefaults();
loadKeys();
}
@Override
protected void loadKeys() {
plugin.getLogger().info("Loading mcMMO config.yml File...");
// Setup default HUD
String temp = config.getString("Spout.HUD.Default", "STANDARD");
for (HUDType x : HUDType.values()) {
if (x.toString().toLowerCase().equalsIgnoreCase(temp.toString().toLowerCase())) {
defaulthud = x;
for (String key : keys) {
if (config.getBoolean("Double_Drops." + skillName + "." + key)) {
disabled = false;
break;
}
}
if(defaulthud == null)
defaulthud = HUDType.STANDARD;
return disabled;
}
private int getLevelCap(String configString) {
int cap = config.getInt(configString, 0);
return ((cap <= 0) ? Integer.MAX_VALUE : cap);
}
}

View File

@@ -1,54 +1,79 @@
package com.gmail.nossr50.config;
import java.io.File;
import java.io.IOException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import com.gmail.nossr50.mcMMO;
public abstract class ConfigLoader {
protected static final mcMMO plugin = mcMMO.p;
protected String fileName;
protected File configFile;
protected File dataFolder;
protected final mcMMO plugin;
protected FileConfiguration config;
public ConfigLoader(mcMMO plugin, String fileName){
this.plugin = plugin;
dataFolder = plugin.getDataFolder();
configFile = new File(dataFolder, File.separator + fileName);
public ConfigLoader(String relativePath, String fileName) {
this.fileName = fileName;
configFile = new File(plugin.getDataFolder(), relativePath + File.separator + fileName);
loadFile();
}
/**
* Load this config file.
*/
protected abstract void load();
public ConfigLoader(String fileName) {
this.fileName = fileName;
configFile = new File(plugin.getDataFolder(), fileName);
loadFile();
}
/**
* Save this config file.
*/
private void saveConfig() {
try {
config.save(configFile);
protected void loadFile() {
if (!configFile.exists()) {
plugin.getLogger().info("Creating mcMMO " + fileName + " File...");
createFile();
}
catch (IOException e) {
e.printStackTrace();
else {
plugin.getLogger().info("Loading mcMMO " + fileName + " File...");
}
config = YamlConfiguration.loadConfiguration(configFile);
}
/**
* Add the defaults to this config file.
*/
protected void addDefaults() {
// Load from included config.yml
config.options().copyDefaults(true);
saveConfig();
}
/**
* Load the keys from this config file.
*/
protected abstract void loadKeys();
protected void createFile() {
if (configFile.exists()) {
return;
}
configFile.getParentFile().mkdirs();
InputStream inputStream = plugin.getResource(fileName);
if (inputStream != null) {
try {
copyStreamToFile(inputStream, configFile);
} catch (Exception e) {
e.printStackTrace();
}
}
else {
plugin.getLogger().severe("Missing ressource file: '" + fileName + "' please notify the plugin authors");
}
}
private static void copyStreamToFile(InputStream inputStream, File file) throws Exception {
OutputStream outputStream = new FileOutputStream(file);
int read = 0;
byte[] bytes = new byte[1024];
while ((read = inputStream.read(bytes)) != -1) {
outputStream.write(bytes, 0, read);
}
inputStream.close();
outputStream.close();
}
}

View File

@@ -0,0 +1,42 @@
package com.gmail.nossr50.config;
import org.bukkit.configuration.file.YamlConfiguration;
import com.gmail.nossr50.mcMMO;
public class HiddenConfig {
private static HiddenConfig instance;
private static String fileName;
private static YamlConfiguration config;
private static boolean chunkletsEnabled;
private static int conversionRate;
public HiddenConfig(String fileName) {
HiddenConfig.fileName = fileName;
load();
}
public static HiddenConfig getInstance() {
if (instance == null) {
instance = new HiddenConfig("hidden.yml");
}
return instance;
}
public void load() {
if (mcMMO.p.getResource(fileName) != null) {
config = YamlConfiguration.loadConfiguration(mcMMO.p.getResource(fileName));
chunkletsEnabled = config.getBoolean("Options.Chunklets", true);
conversionRate = config.getInt("Options.ConversionRate", 1);
}
}
public boolean getChunkletsEnabled() {
return chunkletsEnabled;
}
public int getConversionRate() {
return conversionRate;
}
}

View File

@@ -0,0 +1,94 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.datatypes.HudType;
public class SpoutConfig extends ConfigLoader {
private static SpoutConfig instance;
public HudType defaultHudType;
private SpoutConfig() {
super("spout.yml");
loadKeys();
}
public static SpoutConfig getInstance() {
if (instance == null) {
instance = new SpoutConfig();
}
return instance;
}
@Override
protected void loadKeys() {
// Setup default HUD
String temp = config.getString("Spout.HUD.Default", "STANDARD");
for (HudType hudType : HudType.values()) {
if (hudType.toString().equalsIgnoreCase(temp.toString())) {
defaultHudType = hudType;
break;
}
}
if (defaultHudType == null) {
defaultHudType = HudType.STANDARD;
}
}
public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); }
public String getMenuKey() { return config.getString("Menu.Key", "KEY_M"); }
/* XP Bar */
public boolean getXPBarEnabled() { return config.getBoolean("XP.Bar.Enabled", true); }
public boolean getXPBarIconEnabled() { return config.getBoolean("XP.Icon.Enabled", true); }
public int getXPBarXPosition() { return config.getInt("XP.Bar.X_POS", 95); }
public int getXPBarYPosition() { return config.getInt("XP.Bar.Y_POS", 6); }
public int getXPIconXPosition() { return config.getInt("XP.Icon.X_POS", 78); }
public int getXPIconYPosition() { return config.getInt("XP.Icon.Y_POS", 2); }
/* HUD Colors */
public double getRetroHUDXPBorderRed() { return config.getDouble("HUD.Retro.Colors.Border.RED", 0.0); }
public double getRetroHUDXPBorderGreen() { return config.getDouble("HUD.Retro.Colors.Border.GREEN", 0.0); }
public double getRetroHUDXPBorderBlue() { return config.getDouble("HUD.Retro.Colors.Border.BLUE", 0.0); }
public double getRetroHUDXPBackgroundRed() { return config.getDouble("HUD.Retro.Colors.Background.RED", 0.75); }
public double getRetroHUDXPBackgroundGreen() { return config.getDouble("HUD.Retro.Colors.Background.GREEN", 0.75); }
public double getRetroHUDXPBackgroundBlue() { return config.getDouble("HUD.Retro.Colors.Background.BLUE", 0.75); }
public double getRetroHUDAcrobaticsRed() { return config.getDouble("HUD.Retro.Colors.Acrobatics.RED", 0.3); }
public double getRetroHUDAcrobaticsGreen() { return config.getDouble("HUD.Retro.Colors.Acrobatics.GREEN", 0.3); }
public double getRetroHUDAcrobaticsBlue() { return config.getDouble("HUD.Retro.Colors.Acrobatics.BLUE", 0.75); }
public double getRetroHUDArcheryRed() { return config.getDouble("HUD.Retro.Colors.Archery.RED", 0.3); }
public double getRetroHUDArcheryGreen() { return config.getDouble("HUD.Retro.Colors.Archery.GREEN", 0.3); }
public double getRetroHUDArcheryBlue() { return config.getDouble("HUD.Retro.Colors.Archery.BLUE", 0.75); }
public double getRetroHUDAxesRed() { return config.getDouble("HUD.Retro.Colors.Axes.RED", 0.3); }
public double getRetroHUDAxesGreen() { return config.getDouble("HUD.Retro.Colors.Axes.GREEN", 0.3); }
public double getRetroHUDAxesBlue() { return config.getDouble("HUD.Retro.Colors.Axes.BLUE", 0.75); }
public double getRetroHUDExcavationRed() { return config.getDouble("HUD.Retro.Colors.Excavation.RED", 0.3); }
public double getRetroHUDExcavationGreen() { return config.getDouble("HUD.Retro.Colors.Excavation.GREEN", 0.3); }
public double getRetroHUDExcavationBlue() { return config.getDouble("HUD.Retro.Colors.Excavation.BLUE", 0.75); }
public double getRetroHUDHerbalismRed() { return config.getDouble("HUD.Retro.Colors.Herbalism.RED", 0.3); }
public double getRetroHUDHerbalismGreen() { return config.getDouble("HUD.Retro.Colors.Herbalism.GREEN", 0.3); }
public double getRetroHUDHerbalismBlue() { return config.getDouble("HUD.Retro.Colors.Herbalism.BLUE", 0.75); }
public double getRetroHUDMiningRed() { return config.getDouble("HUD.Retro.Colors.Mining.RED", 0.3); }
public double getRetroHUDMiningGreen() { return config.getDouble("HUD.Retro.Colors.Mining.GREEN", 0.3); }
public double getRetroHUDMiningBlue() { return config.getDouble("HUD.Retro.Colors.Mining.BLUE", 0.75); }
public double getRetroHUDRepairRed() { return config.getDouble("HUD.Retro.Colors.Repair.RED", 0.3); }
public double getRetroHUDRepairGreen() { return config.getDouble("HUD.Retro.Colors.Repair.GREEN", 0.3); }
public double getRetroHUDRepairBlue() { return config.getDouble("HUD.Retro.Colors.Repair.BLUE", 0.75); }
public double getRetroHUDSwordsRed() { return config.getDouble("HUD.Retro.Colors.Swords.RED", 0.3); }
public double getRetroHUDSwordsGreen() { return config.getDouble("HUD.Retro.Colors.Swords.GREEN", 0.3); }
public double getRetroHUDSwordsBlue() { return config.getDouble("HUD.Retro.Colors.Swords.BLUE", 0.75); }
public double getRetroHUDTamingRed() { return config.getDouble("HUD.Retro.Colors.Taming.RED", 0.3); }
public double getRetroHUDTamingGreen() { return config.getDouble("HUD.Retro.Colors.Taming.GREEN", 0.3); }
public double getRetroHUDTamingBlue() { return config.getDouble("HUD.Retro.Colors.Taming.BLUE", 0.75); }
public double getRetroHUDUnarmedRed() { return config.getDouble("HUD.Retro.Colors.Unarmed.RED", 0.3); }
public double getRetroHUDUnarmedGreen() { return config.getDouble("HUD.Retro.Colors.Unarmed.GREEN", 0.3); }
public double getRetroHUDUnarmedBlue() { return config.getDouble("HUD.Retro.Colors.Unarmed.BLUE", 0.75); }
public double getRetroHUDWoodcuttingRed() { return config.getDouble("HUD.Retro.Colors.Woodcutting.RED", 0.3); }
public double getRetroHUDWoodcuttingGreen() { return config.getDouble("HUD.Retro.Colors.Woodcutting.GREEN", 0.3); }
public double getRetroHUDWoodcuttingBlue() { return config.getDouble("HUD.Retro.Colors.Woodcutting.BLUE", 0.75); }
public double getRetroHUDFishingRed() { return config.getDouble("HUD.Retro.Colors.Fishing.RED", 0.3); }
public double getRetroHUDFishingGreen() { return config.getDouble("HUD.Retro.Colors.Fishing.GREEN", 0.3); }
public double getRetroHUDFishingBlue() { return config.getDouble("HUD.Retro.Colors.Fishing.BLUE", 0.75); }
}

View File

@@ -2,32 +2,22 @@ package com.gmail.nossr50.config;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
import com.gmail.nossr50.datatypes.treasure.Treasure;
public class TreasuresConfig extends ConfigLoader{
private static TreasuresConfig instance;
public static TreasuresConfig getInstance() {
if (instance == null) {
instance = new TreasuresConfig(mcMMO.p);
instance.load();
}
return instance;
}
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
@@ -35,39 +25,28 @@ public class TreasuresConfig extends ConfigLoader{
public List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
public List<FishingTreasure> fishingRewardsTier1 = new ArrayList<FishingTreasure>();
public List<FishingTreasure> fishingRewardsTier2 = new ArrayList<FishingTreasure>();
public List<FishingTreasure> fishingRewardsTier3 = new ArrayList<FishingTreasure>();
public List<FishingTreasure> fishingRewardsTier4 = new ArrayList<FishingTreasure>();
public List<FishingTreasure> fishingRewardsTier5 = new ArrayList<FishingTreasure>();
public List<FishingTreasure> fishingRewards = new ArrayList<FishingTreasure>();
private TreasuresConfig(mcMMO plugin) {
super(plugin, "treasures.yml");
config = plugin.getTreasuresConfig();
private TreasuresConfig() {
super("treasures.yml");
loadKeys();
}
@Override
protected void load() {
if (!configFile.exists()) {
dataFolder.mkdir();
plugin.saveTreasuresConfig();
public static TreasuresConfig getInstance() {
if (instance == null) {
instance = new TreasuresConfig();
}
addDefaults();
loadKeys();
return instance;
}
@Override
protected void loadKeys() {
plugin.getLogger().info("Loading mcMMO treasures.yml File...");
Map<String, Treasure> treasures = new HashMap<String, Treasure>();
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures");
Set<String> treasureConfigSet = treasureSection.getKeys(false);
Iterator<String> iterator = treasureConfigSet.iterator();
while (iterator.hasNext()) {
String treasureName = iterator.next();
for (String treasureName : treasureConfigSet) {
// Validate all the things!
List<String> reason = new ArrayList<String>();
@@ -140,7 +119,7 @@ public class TreasuresConfig extends ConfigLoader{
* Drops From & Max Level
*/
ItemStack item = new ItemStack(id, amount, (short) 0, (byte) data);
ItemStack item = (new MaterialData(id, (byte) data)).toItemStack(amount);
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) {
@@ -205,41 +184,17 @@ public class TreasuresConfig extends ConfigLoader{
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
List<String> fishingTreasures = config.getStringList("Fishing.Treasure");
Iterator<String> treasureIterator = treasures.keySet().iterator();
while (treasureIterator.hasNext()) {
String treasureKey = treasureIterator.next();
Treasure treasure = treasures.get(treasureKey);
for (Entry<String,Treasure> nextEntry : treasures.entrySet()) {
String treasureKey = nextEntry.getKey();
Treasure treasure = nextEntry.getValue();
if (treasure instanceof FishingTreasure) {
if (!fishingTreasures.contains(treasureKey)) {
continue;
}
FishingTreasure fTreasure = (FishingTreasure) treasure;
int dropLevel = fTreasure.getDropLevel();
int maxLevel = fTreasure.getMaxLevel();
if(dropLevel <= Config.getInstance().getFishingTierLevelsTier1() && maxLevel >= Config.getInstance().getFishingTierLevelsTier1()) {
fishingRewardsTier1.add(fTreasure);
}
if(dropLevel <= Config.getInstance().getFishingTierLevelsTier2() && maxLevel >= Config.getInstance().getFishingTierLevelsTier2()) {
fishingRewardsTier2.add(fTreasure);
}
if (dropLevel <= Config.getInstance().getFishingTierLevelsTier3() && maxLevel >= Config.getInstance().getFishingTierLevelsTier3()) {
fishingRewardsTier3.add(fTreasure);
}
if (dropLevel <= Config.getInstance().getFishingTierLevelsTier4() && maxLevel >= Config.getInstance().getFishingTierLevelsTier4()) {
fishingRewardsTier4.add(fTreasure);
}
if (dropLevel <= Config.getInstance().getFishingTierLevelsTier5() && maxLevel >= Config.getInstance().getFishingTierLevelsTier5()) {
fishingRewardsTier5.add(fTreasure);
}
fishingRewards.add((FishingTreasure) treasure);
}
else if (treasure instanceof ExcavationTreasure) {
if (!excavationTreasures.contains(treasureKey)) {
@@ -283,11 +238,10 @@ public class TreasuresConfig extends ConfigLoader{
if (issues.isEmpty()) {
return true;
}
else {
for (String issue : issues) {
plugin.getLogger().warning(issue);
}
return false;
for (String issue : issues) {
plugin.getLogger().warning(issue);
}
return false;
}
}

View File

@@ -1,54 +1,44 @@
package com.gmail.nossr50.config.mods;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.mods.CustomItem;
import com.gmail.nossr50.skills.repair.Repairable;
import com.gmail.nossr50.skills.repair.RepairableFactory;
public class CustomArmorConfig extends ModConfigLoader{
public class CustomArmorConfig extends ConfigLoader{
private static CustomArmorConfig instance;
private List<Repairable> repairables;
public List<Integer> customBootIDs = new ArrayList<Integer>();
public List<Integer> customChestplateIDs = new ArrayList<Integer>();
public List<Integer> customHelmetIDs = new ArrayList<Integer>();
public List<Integer> customLeggingIDs = new ArrayList<Integer>();
public List<Integer> customIDs = new ArrayList<Integer>();
public List<CustomItem> customArmorList = new ArrayList<CustomItem>();
public HashMap<Integer, CustomItem> customArmor = new HashMap<Integer, CustomItem>();
public CustomArmorConfig() {
super("ModConfigs", "armor.yml");
loadKeys();
}
public static CustomArmorConfig getInstance() {
if (instance == null) {
instance = new CustomArmorConfig(mcMMO.p);
instance = new CustomArmorConfig();
}
return instance;
}
public List<Integer> customBootIDs = new ArrayList<Integer>();
public List<Integer> customChestplateIDs = new ArrayList<Integer>();
public List<Integer> customHelmetIDs = new ArrayList<Integer>();
public List<Integer> customLeggingIDs = new ArrayList<Integer>();
public List<Integer> customIDs = new ArrayList<Integer>();
public List<CustomItem> customItems = new ArrayList<CustomItem>();
public CustomArmorConfig(mcMMO plugin) {
super(plugin, "armor.yml");
config = plugin.getArmorConfig();
}
@Override
public void load() {
if (!configFile.exists()) {
dataFolder.mkdir();
plugin.saveArmorConfig();
}
addDefaults();
loadKeys();
}
@Override
protected void loadKeys() {
plugin.getLogger().info("Loading mcMMO armor.yml File...");
repairables = new ArrayList<Repairable>();
loadArmor("Boots", customBootIDs);
loadArmor("Chestplates", customChestplateIDs);
@@ -58,12 +48,13 @@ public class CustomArmorConfig extends ModConfigLoader{
private void loadArmor(String armorType, List<Integer> idList) {
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
if (armorSection == null)
return;
Set<String> armorConfigSet = armorSection.getKeys(false);
Iterator<String> iterator = armorConfigSet.iterator();
while (iterator.hasNext()) {
String armorName = iterator.next();
for (String armorName : armorConfigSet) {
int id = config.getInt(armorType + "." + armorName + ".ID", 0);
boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable");
int repairID = config.getInt(armorType + "." + armorName + ".Repair_Material_ID", 0);
@@ -84,16 +75,20 @@ public class CustomArmorConfig extends ModConfigLoader{
CustomItem armor;
if (repairable) {
ItemStack repairMaterial = new ItemStack(repairID, 1, (short) 0, repairData);
armor = new CustomItem(durability, repairMaterial, repairQuantity, repairable, id);
}
else {
armor = new CustomItem(durability, null, 0, repairable, id);
repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability));
}
armor = new CustomItem(id, durability);
idList.add(id);
customIDs.add(id);
customItems.add(armor);
customArmorList.add(armor);
customArmor.put(id, armor);
}
}
public List<Repairable> getLoadedRepairables() {
if (repairables == null) return new ArrayList<Repairable>();
return repairables;
}
}

View File

@@ -1,73 +1,60 @@
package com.gmail.nossr50.config.mods;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.mods.CustomBlock;
public class CustomBlocksConfig extends ModConfigLoader{
public class CustomBlocksConfig extends ConfigLoader {
private static CustomBlocksConfig instance;
public List<ItemStack> customExcavationBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customHerbalismBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customMiningBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customWoodcuttingBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customOres = new ArrayList<ItemStack>();
public List<ItemStack> customLogs = new ArrayList<ItemStack>();
public List<ItemStack> customLeaves = new ArrayList<ItemStack>();
public List<ItemStack> customAbilityBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customItems = new ArrayList<ItemStack>();
public List<CustomBlock> customBlocks = new ArrayList<CustomBlock>();
public CustomBlocksConfig() {
super("ModConfigs", "blocks.yml");
loadKeys();
}
public static CustomBlocksConfig getInstance() {
if (instance == null) {
instance = new CustomBlocksConfig(mcMMO.p);
instance = new CustomBlocksConfig();
}
return instance;
}
public List<ItemStack> customExcavationBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customHerbalismBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customMiningBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customWoodcuttingBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customOres = new ArrayList<ItemStack>();
public List<ItemStack> customLogs = new ArrayList<ItemStack>();
public List<ItemStack> customLeaves = new ArrayList<ItemStack>();
public List<ItemStack> customItems = new ArrayList<ItemStack>();
public List<CustomBlock> customBlocks = new ArrayList<CustomBlock>();
public CustomBlocksConfig(mcMMO plugin) {
super(plugin, "blocks.yml");
config = plugin.getBlocksConfig();
}
@Override
public void load() {
if (!configFile.exists()) {
dataFolder.mkdir();
plugin.saveBlocksConfig();
}
addDefaults();
loadKeys();
}
@Override
protected void loadKeys() {
plugin.getLogger().info("Loading mcMMO blocks.yml File...");
loadBlocks("Excavation", customExcavationBlocks);
loadBlocks("Herbalism", customHerbalismBlocks);
loadBlocks("Mining", customMiningBlocks);
loadBlocks("Woodcutting", customWoodcuttingBlocks);
loadBlocks("Ability_Blocks", customAbilityBlocks);
}
private void loadBlocks(String skillType, List<ItemStack> blockList) {
ConfigurationSection skillSection = config.getConfigurationSection(skillType);
if (skillSection == null)
return;
Set<String> skillConfigSet = skillSection.getKeys(false);
Iterator<String> iterator = skillConfigSet.iterator();
while (iterator.hasNext()) {
String blockName = iterator.next();
for (String blockName : skillConfigSet) {
int id = config.getInt(skillType + "." + blockName + ".ID", 0);
byte data = (byte) config.getInt(skillType + "." + blockName + ".Data_Value", 0);
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain", 0);
@@ -75,31 +62,39 @@ public class CustomBlocksConfig extends ModConfigLoader{
boolean dropItem = config.getBoolean(skillType + "." + blockName + ".Drop_Item", false);
int dropID = config.getInt(skillType + "." + blockName + ".Drop_Item_ID", 0);
byte dropData = (byte) config.getInt(skillType + "." + blockName + ".Drop_Item_Data_Value", 0);
int dropAmount = config.getInt(skillType + "." + blockName + ".Drop_Item_Amount", 1);
int minimumDropAmount = config.getInt(skillType + "." + blockName + ".Min_Drop_Item_Amount", 1);
int maxiumDropAmount = config.getInt(skillType + "." + blockName + ".Max_Drop_Item_Amount", 1);
CustomBlock block;
ItemStack itemDrop;
ItemStack blockItem;
if (id == 0) {
plugin.getLogger().warning("Missing ID. This block will be skipped.");
continue;
}
if (skillType.equals("Ability_Blocks")) {
blockItem = (new MaterialData(id, data)).toItemStack(1);
blockList.add(blockItem);
continue;
}
if (dropItem && dropID == 0) {
plugin.getLogger().warning("Incomplete item drop information. This block will drop itself.");
dropItem = false;
}
CustomBlock block;
ItemStack itemDrop;
ItemStack blockItem;
if (dropItem) {
itemDrop = new ItemStack(dropID, dropAmount, (short) 0, dropData);
itemDrop = (new MaterialData(dropID, dropData)).toItemStack(1);
}
else {
itemDrop = new ItemStack(id, dropAmount, (short) 0, data);
itemDrop = (new MaterialData(id, data)).toItemStack(1);
}
block = new CustomBlock(itemDrop, tier, xp, data, id);
blockItem = new ItemStack(id, 1, (short) 0, data);
block = new CustomBlock(minimumDropAmount, maxiumDropAmount, itemDrop, tier, xp, data, id);
blockItem = (new MaterialData(id, data)).toItemStack(1);
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
customOres.add(blockItem);

View File

@@ -1,57 +1,46 @@
package com.gmail.nossr50.config.mods;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.mods.CustomItem;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.mods.CustomTool;
import com.gmail.nossr50.skills.repair.Repairable;
import com.gmail.nossr50.skills.repair.RepairableFactory;
public class CustomToolsConfig extends ModConfigLoader {
public class CustomToolsConfig extends ConfigLoader {
private static CustomToolsConfig instance;
public static CustomToolsConfig getInstance() {
if (instance == null) {
instance = new CustomToolsConfig(mcMMO.p);
}
return instance;
}
private List<Repairable> repairables;
public List<Integer> customAxeIDs = new ArrayList<Integer>();
public List<Integer> customBowIDs = new ArrayList<Integer>();
public List<Integer> customHoeIDs = new ArrayList<Integer>();
public List<Integer> customPickaxeIDs = new ArrayList<Integer>();
public List<Integer> customShovelIDs = new ArrayList<Integer>();
public List<Integer> customSwordIDs = new ArrayList<Integer>();
public List<Integer> customIDs = new ArrayList<Integer>();
public List<CustomItem> customItems = new ArrayList<CustomItem>();
public List<CustomTool> customToolList = new ArrayList<CustomTool>();
public HashMap<Integer, CustomTool> customTools = new HashMap<Integer, CustomTool>();
private CustomToolsConfig(mcMMO plugin) {
super(plugin, "tools.yml");
config = plugin.getToolsConfig();
private CustomToolsConfig() {
super("ModConfigs", "tools.yml");
loadKeys();
}
@Override
public void load() {
if (!configFile.exists()) {
dataFolder.mkdir();
plugin.saveToolsConfig();
public static CustomToolsConfig getInstance() {
if (instance == null) {
instance = new CustomToolsConfig();
}
addDefaults();
loadKeys();
return instance;
}
@Override
protected void loadKeys() {
plugin.getLogger().info("Loading mcMMO tools.yml File...");
repairables = new ArrayList<Repairable>();
loadTool("Axes", customAxeIDs);
loadTool("Bows", customBowIDs);
@@ -63,12 +52,13 @@ public class CustomToolsConfig extends ModConfigLoader {
private void loadTool(String toolType, List<Integer> idList) {
ConfigurationSection toolSection = config.getConfigurationSection(toolType);
if (toolSection == null)
return;
Set<String> toolConfigSet = toolSection.getKeys(false);
Iterator<String> iterator = toolConfigSet.iterator();
while (iterator.hasNext()) {
String toolName = iterator.next();
for (String toolName : toolConfigSet) {
int id = config.getInt(toolType + "." + toolName + ".ID", 0);
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);
boolean abilityEnabled = config.getBoolean(toolType + "." + toolName + ".Ability_Enabled", true);
@@ -92,16 +82,20 @@ public class CustomToolsConfig extends ModConfigLoader {
CustomTool tool;
if (repairable) {
ItemStack repairMaterial = new ItemStack(repairID, 1, (short) 0, repairData);
tool = new CustomTool(durability, repairMaterial, repairQuantity, repairable, tier, abilityEnabled, multiplier, id);
}
else {
tool = new CustomTool(durability, null, 0, repairable, tier, abilityEnabled, multiplier, id);
repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability));
}
tool = new CustomTool(tier, abilityEnabled, multiplier, durability, id);
idList.add(id);
customIDs.add(id);
customItems.add(tool);
customToolList.add(tool);
customTools.put(id, tool);
}
}
public List<Repairable> getLoadedRepairables() {
if (repairables == null) return new ArrayList<Repairable>();
return repairables;
}
}

View File

@@ -1,13 +0,0 @@
package com.gmail.nossr50.config.mods;
import java.io.File;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.ConfigLoader;
public abstract class ModConfigLoader extends ConfigLoader{
public ModConfigLoader(mcMMO plugin, String fileName) {
super(plugin, "ModConfigs" + File.separator + fileName);
}
}

View File

@@ -0,0 +1,108 @@
package com.gmail.nossr50.config.repair;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.skills.repair.RepairItemType;
import com.gmail.nossr50.skills.repair.RepairMaterialType;
import com.gmail.nossr50.skills.repair.Repairable;
import com.gmail.nossr50.skills.repair.RepairableFactory;
public class RepairConfig extends ConfigLoader {
private List<Repairable> repairables;
public RepairConfig(String fileName) {
super(fileName);
loadKeys();
}
@Override
protected void loadKeys() {
repairables = new ArrayList<Repairable>();
ConfigurationSection section = config.getConfigurationSection("Repairables");
Set<String> keys = section.getKeys(false);
for (String key : keys) {
// Validate all the things!
List<String> reason = new ArrayList<String>();
if (!config.contains("Repairables." + key + ".ItemId")) {
reason.add(key + " is missing ItemId");
}
if (!config.contains("Repairables." + key + ".RepairMaterialId")) {
reason.add(key + " is missing RepairMaterialId");
}
if (!config.contains("Repairables." + key + ".MaximumDurability")) {
reason.add(key + " is missing MaximumDurability");
}
int itemId = config.getInt("Repairables." + key + ".ItemId", 0);
int repairMaterialId = config.getInt("Repairables." + key + ".RepairMaterialId", 0);
int maximumDurability = config.getInt("Repairables." + key + ".MaximumDurability", 0);
int repairMetadata = config.getInt("Repairables." + key + ".RepairMaterialMetadata", -1);
int minimumLevel = config.getInt("Repairables." + key + ".MinimumLevel", 0);
int minimumQuantity = config.getInt("Repairables." + key + ".MinimumQuantity", 2);
double xpMultiplier = config.getDouble("Repairables." + key + ".XpMultiplier", 1);
RepairItemType repairItemType = RepairItemType.OTHER;
RepairMaterialType repairMaterialType = RepairMaterialType.OTHER;
String repairItemTypeString = config.getString("Repairables." + key + ".ItemType", "OTHER");
String repairMaterialTypeString = config.getString("Repairables." + key + ".MaterialType", "OTHER");
if (minimumLevel < 0) {
reason.add(key + " has an invalid MinimumLevel of " + minimumLevel);
}
if (minimumQuantity < 0) {
reason.add(key + " has an invalid MinimumQuantity of " + minimumQuantity);
}
try {
repairItemType = RepairItemType.valueOf(repairItemTypeString);
}
catch (IllegalArgumentException ex) {
reason.add(key + " has an invalid ItemType of " + repairItemTypeString);
}
try {
repairMaterialType = RepairMaterialType.valueOf(repairMaterialTypeString);
}
catch (IllegalArgumentException ex) {
reason.add(key + " has an invalid MaterialType of " + repairMaterialTypeString);
}
if (noErrorsInRepairable(reason)) {
Repairable repairable = RepairableFactory.getRepairable(itemId, repairMaterialId, (byte) repairMetadata, minimumLevel, minimumQuantity, (short) maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
repairables.add(repairable);
}
}
}
protected List<Repairable> getLoadedRepairables() {
if (repairables == null) {
return new ArrayList<Repairable>();
}
return repairables;
}
private boolean noErrorsInRepairable(List<String> issues) {
if (issues.isEmpty()) {
return true;
}
for (String issue : issues) {
plugin.getLogger().warning(issue);
}
return false;
}
}

View File

@@ -0,0 +1,52 @@
package com.gmail.nossr50.config.repair;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.repair.Repairable;
public class RepairConfigManager {
private List<Repairable> repairables;
public RepairConfigManager(mcMMO plugin) {
repairables = new ArrayList<Repairable>();
Pattern pattern = Pattern.compile("repair\\.(?:.+)\\.yml");
File dataFolder = plugin.getDataFolder();
File vanilla = new File(dataFolder, "repair.vanilla.yml");
if (!vanilla.exists()) {
plugin.saveResource("repair.vanilla.yml", false);
}
for (String fileName : dataFolder.list()) {
if (!pattern.matcher(fileName).matches()) {
continue;
}
File file = new File(dataFolder, fileName);
if (file.isDirectory()) {
continue;
}
RepairConfig rConfig = new RepairConfig(fileName);
List<Repairable> rConfigRepairables = rConfig.getLoadedRepairables();
if (rConfigRepairables != null) {
repairables.addAll(rConfigRepairables);
}
}
}
public List<Repairable> getLoadedRepairables() {
if (repairables == null) {
return new ArrayList<Repairable>();
}
return repairables;
}
}

View File

@@ -12,6 +12,7 @@ import com.gmail.nossr50.util.Permissions;
public enum AbilityType {
BERSERK(
Config.getInstance().getAbilityCooldownBerserk(),
Config.getInstance().getAbilityMaxTicksBerserk(),
"Unarmed.Skills.Berserk.On",
"Unarmed.Skills.Berserk.Off",
"Unarmed.Skills.Berserk.Other.On",
@@ -20,6 +21,7 @@ public enum AbilityType {
SUPER_BREAKER(
Config.getInstance().getAbilityCooldownSuperBreaker(),
Config.getInstance().getAbilityMaxTicksSuperBreaker(),
"Mining.Skills.SuperBreaker.On",
"Mining.Skills.SuperBreaker.Off",
"Mining.Skills.SuperBreaker.Other.On",
@@ -28,6 +30,7 @@ public enum AbilityType {
GIGA_DRILL_BREAKER(
Config.getInstance().getAbilityCooldownGigaDrillBreaker(),
Config.getInstance().getAbilityMaxTicksGigaDrillBreaker(),
"Excavation.Skills.GigaDrillBreaker.On",
"Excavation.Skills.GigaDrillBreaker.Off",
"Excavation.Skills.GigaDrillBreaker.Other.On",
@@ -36,6 +39,7 @@ public enum AbilityType {
GREEN_TERRA(
Config.getInstance().getAbilityCooldownGreenTerra(),
Config.getInstance().getAbilityMaxTicksGreenTerra(),
"Herbalism.Skills.GTe.On",
"Herbalism.Skills.GTe.Off",
"Herbalism.Skills.GTe.Other.On",
@@ -44,6 +48,7 @@ public enum AbilityType {
SKULL_SPLIITER(
Config.getInstance().getAbilityCooldownSkullSplitter(),
Config.getInstance().getAbilityMaxTicksSkullSplitter(),
"Axes.Skills.SS.On",
"Axes.Skills.SS.Off",
"Axes.Skills.SS.Other.On",
@@ -52,6 +57,7 @@ public enum AbilityType {
TREE_FELLER(
Config.getInstance().getAbilityCooldownTreeFeller(),
Config.getInstance().getAbilityMaxTicksTreeFeller(),
"Woodcutting.Skills.TreeFeller.On",
"Woodcutting.Skills.TreeFeller.Off",
"Woodcutting.Skills.TreeFeller.Other.On",
@@ -60,6 +66,7 @@ public enum AbilityType {
SERRATED_STRIKES(
Config.getInstance().getAbilityCooldownSerratedStrikes(),
Config.getInstance().getAbilityMaxTicksSerratedStrikes(),
"Swords.Skills.SS.On",
"Swords.Skills.SS.Off",
"Swords.Skills.SS.Other.On",
@@ -68,6 +75,7 @@ public enum AbilityType {
BLAST_MINING(
Config.getInstance().getAbilityCooldownBlastMining(),
Config.getInstance().getAbilityMaxTicksBlastMining(),
null,
null,
"Mining.Blast.Other.On",
@@ -75,6 +83,7 @@ public enum AbilityType {
null),
LEAF_BLOWER(
0,
0,
null,
null,
@@ -83,14 +92,16 @@ public enum AbilityType {
null);
private int cooldown;
private int maxTicks;
private String abilityOn;
private String abilityOff;
private String abilityPlayer;
private String abilityRefresh;
private String abilityPlayerOff;
private AbilityType(int cooldown, String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
private AbilityType(int cooldown, int maxTicks, String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
this.cooldown = cooldown;
this.maxTicks = maxTicks;
this.abilityOn = abilityOn;
this.abilityOff = abilityOff;
this.abilityPlayer = abilityPlayer;
@@ -122,6 +133,10 @@ public enum AbilityType {
return LocaleLoader.getString(this.abilityRefresh);
}
public int getMaxTicks() {
return this.maxTicks;
}
/**
* Get the permissions for this ability.
*
@@ -129,35 +144,34 @@ public enum AbilityType {
* @return true if the player has permissions, false otherwise
*/
public boolean getPermissions(Player player) {
Permissions permInstance = Permissions.getInstance();
switch (this) {
case BERSERK:
return permInstance.berserk(player);
return Permissions.berserk(player);
case BLAST_MINING:
return permInstance.blastMining(player);
return Permissions.blastMining(player);
case GIGA_DRILL_BREAKER:
return permInstance.gigaDrillBreaker(player);
return Permissions.gigaDrillBreaker(player);
case GREEN_TERRA:
return permInstance.greenTerra(player);
return Permissions.greenTerra(player);
case LEAF_BLOWER:
return permInstance.leafBlower(player);
return Permissions.leafBlower(player);
case SERRATED_STRIKES:
return permInstance.serratedStrikes(player);
return Permissions.serratedStrikes(player);
case SKULL_SPLIITER:
return permInstance.skullSplitter(player);
return Permissions.skullSplitter(player);
case SUPER_BREAKER:
return permInstance.superBreaker(player);
return Permissions.superBreaker(player);
case TREE_FELLER:
return permInstance.treeFeller(player);
return Permissions.treeFeller(player);
default:
return false;

View File

@@ -2,5 +2,7 @@ package com.gmail.nossr50.datatypes;
public enum DatabaseUpdate {
FISHING,
BLAST_MINING;
BLAST_MINING,
CASCADE_DELETE,
INDEX;
}

View File

@@ -1,8 +0,0 @@
package com.gmail.nossr50.datatypes;
public enum HUDType {
DISABLED,
STANDARD,
SMALL,
RETRO;
}

View File

@@ -1,413 +0,0 @@
package com.gmail.nossr50.datatypes;
import org.bukkit.entity.Player;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.gui.Color;
import org.getspout.spoutapi.gui.GenericGradient;
import org.getspout.spoutapi.gui.GenericTexture;
import org.getspout.spoutapi.gui.RenderPriority;
import org.getspout.spoutapi.gui.Widget;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Users;
public class HUDmmo {
private int center_x = 427 / 2;
private String playerName;
private final mcMMO plugin;
private Widget xpbar = null;
private GenericGradient xpfill = null;
private GenericGradient xpbg = null;
private GenericGradient xpicon_bg = null;
private GenericGradient xpicon_border = null;
private GenericTexture xpicon = null;
public HUDmmo(Player player, mcMMO plugin) {
this.playerName = player.getName();
this.plugin = plugin;
initializeHUD(player);
}
/**
* Initialize the HUD.
*
* @param player Player whose HUD to initialize
*/
public void initializeHUD(Player player) {
HUDType type = Users.getProfile(player).getHUDType();
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
switch (type) {
case RETRO:
initializeXpBarDisplayRetro(sPlayer);
break;
case STANDARD:
initializeXpBarDisplayStandard(sPlayer);
break;
case SMALL:
initializeXpBarDisplaySmall(sPlayer);
break;
case DISABLED:
break;
default:
break;
}
}
/**
* Update the XP bar.
*
* @param type Type of XP bar
* @param player Player whose XP bar to update
*/
public void updateXpBarDisplay(HUDType type, Player player) {
PlayerProfile PP = Users.getProfile(player);
switch (type) {
case RETRO:
updateXpBarRetro(player, PP);
break;
case STANDARD:
updateXpBarStandard(player, PP);
break;
case SMALL:
updateXpBarStandard(player, PP);
break;
case DISABLED:
break;
default:
break;
}
}
/**
* Reset a player's HUD.
*/
public void resetHUD() {
SpoutPlayer sPlayer = SpoutStuff.getSpoutPlayer(playerName);
if (sPlayer != null) {
sPlayer.getMainScreen().removeWidgets(plugin);
//Reset the objects
xpbar = null;
xpfill = null;
xpbg = null;
xpicon = null;
sPlayer.getMainScreen().setDirty(true);
}
}
/**
* Initialize Retro XP bar.
*
* @param sPlayer Player to initialize XP bar for
*/
private void initializeXpBarDisplayRetro(SpoutPlayer sPlayer) {
Color border = new Color((float) Config.getInstance().getSpoutRetroHUDXPBorderRed(), (float) Config.getInstance().getSpoutRetroHUDXPBorderGreen(), (float) Config.getInstance().getSpoutRetroHUDXPBorderBlue(), 1f);
Color green = new Color(0f, 1f, 0f, 1f);
Color background = new Color((float) Config.getInstance().getSpoutRetroHUDXPBackgroundRed(), (float) Config.getInstance().getSpoutRetroHUDXPBackgroundGreen(), (float) Config.getInstance().getSpoutRetroHUDXPBackgroundBlue(), 1f);
Color darkbg = new Color(0.2f, 0.2f, 0.2f, 1f);
xpicon = new GenericTexture();
xpbar = new GenericGradient();
xpfill = new GenericGradient();
xpbg = new GenericGradient();
xpicon_bg = new GenericGradient();
xpicon_border = new GenericGradient();
xpicon_bg.setBottomColor(darkbg);
xpicon_bg.setTopColor(darkbg);
xpicon_bg.setWidth(4);
xpicon_bg.setHeight(4);
xpicon_bg.setPriority(RenderPriority.High);
xpicon_bg.setX(142);
xpicon_bg.setY(10);
xpicon_bg.setDirty(true);
xpicon_border.setBottomColor(border);
xpicon_border.setTopColor(border);
xpicon_border.setWidth(6);
xpicon_border.setHeight(6);
xpicon_border.setPriority(RenderPriority.Highest);
xpicon_border.setX(141);
xpicon_border.setY(9);
xpicon_border.setDirty(true);
xpicon.setWidth(6);
xpicon.setHeight(6);
xpicon.setX(141);
xpicon.setY(9);
xpicon.setPriority(RenderPriority.Normal);
xpicon.setDirty(true);
xpicon.setUrl("Icon_r.png");
xpbar.setWidth(128);
xpbar.setHeight(4);
xpbar.setX(149);
xpbar.setY(10);
((GenericGradient) xpbar).setBottomColor(border);
((GenericGradient) xpbar).setTopColor(border);
xpbar.setPriority(RenderPriority.Highest);
xpbar.setDirty(true);
xpfill.setWidth(0);
xpfill.setHeight(2);
xpfill.setX(150);
xpfill.setY(11);
xpfill.setBottomColor(green);
xpfill.setTopColor(green);
xpfill.setPriority(RenderPriority.Lowest);
xpfill.setDirty(true);
xpbg.setWidth(126);
xpbg.setHeight(2);
xpbg.setX(150);
xpbg.setY(11);
xpbg.setBottomColor(background);
xpbg.setTopColor(background);
xpbg.setPriority(RenderPriority.Low);
xpbg.setDirty(true);
if (Config.getInstance().getSpoutXPBarEnabled()) {
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
sPlayer.getMainScreen().attachWidget(plugin, xpfill);
sPlayer.getMainScreen().attachWidget(plugin, xpbg);
if (Config.getInstance().getSpoutXPBarIconEnabled()) {
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
sPlayer.getMainScreen().attachWidget(plugin, xpicon_bg);
sPlayer.getMainScreen().attachWidget(plugin, xpicon_border);
}
}
sPlayer.getMainScreen().setDirty(true);
}
/**
* Initialize Standard XP bar.
*
* @param sPlayer Player to initialize XP bar for
*/
public void initializeXpBarDisplayStandard(SpoutPlayer sPlayer) {
if (Config.getInstance().getSpoutXPBarEnabled()) {
xpbar = new GenericTexture();
((GenericTexture) xpbar).setUrl("xpbar_inc000.png");
xpbar.setX(Config.getInstance().getSpoutXPBarXPosition());
xpbar.setY(Config.getInstance().getSpoutXPBarYPosition());
xpbar.setHeight(8);
xpbar.setWidth(256);
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
if (Config.getInstance().getSpoutXPBarIconEnabled()) {
xpicon = new GenericTexture();
xpicon.setUrl("Icon.png");
xpicon.setHeight(16);
xpicon.setWidth(32);
xpicon.setX(Config.getInstance().getSpoutXPIconXPosition());
xpicon.setY(Config.getInstance().getSpoutXPIconYPosition());
xpicon.setDirty(true);
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
}
}
sPlayer.getMainScreen().setDirty(true);
}
/**
* Initialize Small XP bar.
*
* @param sPlayer Player to initialize XP bar for
*/
private void initializeXpBarDisplaySmall(SpoutPlayer sPlayer) {
if (Config.getInstance().getSpoutXPBarEnabled()) {
xpbar = new GenericTexture();
((GenericTexture)xpbar).setUrl("xpbar_inc000.png");
xpbar.setX(center_x - 64);
xpbar.setY(Config.getInstance().getSpoutXPBarYPosition());
xpbar.setHeight(4);
xpbar.setWidth(128);
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
if (Config.getInstance().getSpoutXPBarIconEnabled()) {
xpicon = new GenericTexture();
xpicon.setUrl("Icon.png");
xpicon.setHeight(8);
xpicon.setWidth(16);
xpicon.setX(center_x - (8 + 64));
xpicon.setY(Config.getInstance().getSpoutXPIconYPosition() + 2);
xpicon.setDirty(true);
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
}
}
sPlayer.getMainScreen().setDirty(true);
}
/**
* Update XP bar for Standard & Small styles.
*
* @param player Player whose XP bar to update
* @param PP Profile of the given player
*/
private void updateXpBarStandard(Player player, PlayerProfile PP) {
if (!Config.getInstance().getSpoutXPBarEnabled()) {
return;
}
SkillType theType = getType(PP);
if (theType == null) { //Can this ever actually BE null? (Yes, it's null when the player has just logged in. It's not null when they gain XP in anything)
return;
}
((GenericTexture) xpicon).setUrl(Misc.getCapitalized(theType.toString()) + ".png");
xpicon.setDirty(true);
((GenericTexture) xpbar).setUrl(getUrlBar(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.STANDARD)));
xpbar.setDirty(true);
SpoutManager.getPlayer(player).getMainScreen().setDirty(true);
}
/**
* Update XP bar for Retro styles.
*
* @param player Player whose XP bar to update
* @param PP Profile of the given player
*/
private void updateXpBarRetro(Player player, PlayerProfile PP) {
if (!Config.getInstance().getSpoutXPBarEnabled()) {
return;
}
SkillType theType = getType(PP);
if (theType == null) { //Can this ever actually BE null? (Yes, it's null when the player has just logged in. It's not null when they gain XP in anything)
return;
}
Color color = getRetroColor(theType);
xpicon.setUrl(Misc.getCapitalized(theType.toString()) + "_r.png");
xpfill.setBottomColor(color);
xpfill.setTopColor(color);
xpfill.setWidth(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.RETRO));
xpfill.setDirty(true);
SpoutManager.getPlayer(player).getMainScreen().setDirty(true);
}
private static Color getRetroColor(SkillType type) {
switch (type) {
case ACROBATICS:
return new Color((float) Config.getInstance().getSpoutRetroHUDAcrobaticsRed(), (float) Config.getInstance().getSpoutRetroHUDAcrobaticsGreen(), (float) Config.getInstance().getSpoutRetroHUDAcrobaticsBlue(), 1f);
case ARCHERY:
return new Color((float) Config.getInstance().getSpoutRetroHUDArcheryRed(), (float) Config.getInstance().getSpoutRetroHUDArcheryGreen(), (float) Config.getInstance().getSpoutRetroHUDArcheryBlue(), 1f);
case AXES:
return new Color((float) Config.getInstance().getSpoutRetroHUDAxesRed(), (float) Config.getInstance().getSpoutRetroHUDAxesGreen(), (float) Config.getInstance().getSpoutRetroHUDAxesBlue(), 1f);
case EXCAVATION:
return new Color((float) Config.getInstance().getSpoutRetroHUDExcavationRed(), (float) Config.getInstance().getSpoutRetroHUDExcavationGreen(), (float) Config.getInstance().getSpoutRetroHUDExcavationBlue(), 1f);
case HERBALISM:
return new Color((float) Config.getInstance().getSpoutRetroHUDHerbalismRed(), (float) Config.getInstance().getSpoutRetroHUDHerbalismGreen(), (float) Config.getInstance().getSpoutRetroHUDHerbalismBlue(), 1f);
case MINING:
return new Color((float) Config.getInstance().getSpoutRetroHUDMiningRed(), (float) Config.getInstance().getSpoutRetroHUDMiningGreen(), (float) Config.getInstance().getSpoutRetroHUDMiningBlue(), 1f);
case REPAIR:
return new Color((float) Config.getInstance().getSpoutRetroHUDRepairRed(), (float) Config.getInstance().getSpoutRetroHUDRepairGreen(), (float) Config.getInstance().getSpoutRetroHUDRepairBlue(), 1f);
case SWORDS:
return new Color((float) Config.getInstance().getSpoutRetroHUDSwordsRed(), (float) Config.getInstance().getSpoutRetroHUDSwordsGreen(), (float) Config.getInstance().getSpoutRetroHUDSwordsBlue(), 1f);
case TAMING:
return new Color((float) Config.getInstance().getSpoutRetroHUDTamingRed(), (float) Config.getInstance().getSpoutRetroHUDTamingGreen(), (float) Config.getInstance().getSpoutRetroHUDTamingBlue(), 1f);
case UNARMED:
return new Color((float) Config.getInstance().getSpoutRetroHUDUnarmedRed(), (float) Config.getInstance().getSpoutRetroHUDUnarmedGreen(), (float) Config.getInstance().getSpoutRetroHUDUnarmedBlue(), 1f);
case WOODCUTTING:
return new Color((float) Config.getInstance().getSpoutRetroHUDWoodcuttingRed(), (float) Config.getInstance().getSpoutRetroHUDWoodcuttingGreen(), (float) Config.getInstance().getSpoutRetroHUDWoodcuttingBlue(), 1f);
case FISHING:
return new Color((float) Config.getInstance().getSpoutRetroHUDFishingRed(), (float) Config.getInstance().getSpoutRetroHUDFishingGreen(), (float) Config.getInstance().getSpoutRetroHUDFishingBlue(), 1f);
default:
return new Color(0.3f, 0.3f, 0.75f, 1f);
}
}
private static String getUrlBar(Integer number) {
char[] num = number.toString().toCharArray();
switch (num.length) {
case 1:
return "xpbar_inc00" + number + ".png";
case 2:
return "xpbar_inc0" + number + ".png";
default:
return "xpbar_inc" + number + ".png";
}
}
private static Integer getXpInc(int skillxp, int xptolevel, HUDType hud) {
double percentage = (double) skillxp / xptolevel;
double inc;
switch (hud) {
case RETRO:
inc = 0.0079365079365079;
break;
case STANDARD:
inc = 0.0039370078740157;
break;
default:
return 1;
}
return (int) (percentage / inc);
}
private static SkillType getType(PlayerProfile PP) {
if (PP.getXpBarLocked()) {
return PP.getSkillLock();
}
else {
return PP.getLastGained();
}
}
}

View File

@@ -0,0 +1,12 @@
package com.gmail.nossr50.datatypes;
public enum HudType {
DISABLED,
STANDARD,
SMALL,
RETRO;
public HudType getNext() {
return values()[(ordinal() + 1) % values().length];
}
}

View File

@@ -0,0 +1,239 @@
package com.gmail.nossr50.datatypes;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.mods.CustomTool;
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ModChecks;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class McMMOPlayer {
private Player player;
private PlayerProfile profile;
private Party party;
private Party invite;
public McMMOPlayer (Player player) {
String playerName = player.getName();
this.player = player;
this.profile = new PlayerProfile(playerName, true);
this.party = PartyManager.getInstance().getPlayerParty(playerName);
}
/**
* Gets the power level of this player.
*
* @return the power level of the player
*/
public int getPowerLevel() {
int powerLevel = 0;
for (SkillType type : SkillType.values()) {
if (type.getPermissions(player)) {
powerLevel += profile.getSkillLevel(type);
}
}
return powerLevel;
}
/**
* Calculate the party XP modifier.
*
* @param skillType Type of skill to check
* @return the party bonus multiplier
*/
private double calculatePartyXPModifier(SkillType skillType) {
double bonusModifier = 0.0;
for (Player member : party.getOnlineMembers()) {
if (party.getLeader().equals(member.getName())) {
if (Misc.isNear(player.getLocation(), member.getLocation(), 25.0)) {
PlayerProfile partyLeader = Users.getProfile(member);
int leaderSkill = partyLeader.getSkillLevel(skillType);
int playerSkill = profile.getSkillLevel(skillType);
if (leaderSkill >= playerSkill) {
int difference = leaderSkill - playerSkill;
bonusModifier = (difference * 0.75) / 100.0;
}
}
}
}
return bonusModifier;
}
/**
* Adds XP to the player, doesn't calculate for XP Rate
*
* @param skillType The skill to add XP to
* @param newValue The amount of XP to add
*/
public void addXPOverride(SkillType skillType, int xp) {
if (skillType.equals(SkillType.ALL)) {
for (SkillType type : SkillType.values()) {
if (type.equals(SkillType.ALL)) {
continue;
}
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, type, xp));
profile.setSkillXPLevel(type, profile.getSkillXpLevel(type) + xp);
}
}
else {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
profile.setSkillXPLevel(skillType, profile.getSkillXpLevel(skillType) + xp);
SpoutHud spoutHud = profile.getSpoutHud();
if (spoutHud != null) {
spoutHud.setLastGained(skillType);
}
}
}
/**
* Adds XP to the player, this ignores skill modifiers.
*
* @param skillType The skill to add XP to
* @param newValue The amount of XP to add
*/
public void addXPOverrideBonus(SkillType skillType, int xp) {
int modifiedXp = (int)Math.floor(xp * Config.getInstance().xpGainMultiplier);
addXPOverride(skillType, modifiedXp);
}
/**
* Adds XP to the player, this is affected by skill modifiers and XP Rate and Permissions
*
* @param skillType The skill to add XP to
* @param newvalue The amount of XP to add
*/
public void addXP(SkillType skillType, int newValue) {
if (player == null)
return;
else if (player.getGameMode() == null)
return;
if (player.getGameMode().equals(GameMode.CREATIVE)) {
return;
}
double bonusModifier = 0;
if (inParty()) {
bonusModifier = calculatePartyXPModifier(skillType);
}
int xp = (int)Math.floor((newValue / skillType.getXpModifier()) * Config.getInstance().xpGainMultiplier);
if (bonusModifier > 0) {
if (bonusModifier >= 2) {
bonusModifier = 2;
}
double trueBonus = bonusModifier * xp;
xp += trueBonus;
}
if (Config.getInstance().getToolModsEnabled()) {
ItemStack item = player.getItemInHand();
CustomTool tool = ModChecks.getToolFromItemStack(item);
if (tool != null) {
xp = (int) (xp * tool.getXpMultiplier());
}
}
if (Permissions.xpQuadruple(player)) {
xp = xp * 4;
}
else if (Permissions.xpTriple(player)) {
xp = xp * 3;
}
else if (Permissions.xpDoubleAndOneHalf(player)) {
xp = (int) (xp * 2.5);
}
else if (Permissions.xpDouble(player)) {
xp = xp * 2;
}
else if (Permissions.xpOneAndOneHalf(player)) {
xp = (int) (xp * 1.5);
}
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
profile.setSkillXPLevel(skillType, profile.getSkillXpLevel(skillType) + xp);
SpoutHud spoutHud = profile.getSpoutHud();
if (spoutHud != null) {
spoutHud.setLastGained(skillType);
}
}
// Players & Profiles
public Player getPlayer() {
return player;
}
public void setPlayer(Player player) {
this.player = player;
}
public PlayerProfile getProfile() {
return profile;
}
// Party Stuff
public void setInvite(Party invite) {
this.invite = invite;
}
public Party getInvite() {
return invite;
}
public boolean hasPartyInvite() {
if (invite != null) {
return true;
}
return false;
}
public void setParty(Party party) {
this.party = party;
}
public Party getParty() {
return party;
}
public boolean inParty() {
if (party != null) {
return true;
}
return false;
}
public void removeParty() {
party = null;
}
public void removeInvite() {
invite = null;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -3,4 +3,11 @@ package com.gmail.nossr50.datatypes;
public class PlayerStat {
public String name;
public int statVal = 0;
public PlayerStat() {};
public PlayerStat(String name, int value) {
this.name = name;
this.statVal = value;
}
}

View File

@@ -57,9 +57,8 @@ public enum SkillType {
if (maxLevel > 0) {
return maxLevel;
}
else {
return Integer.MAX_VALUE;
}
return Integer.MAX_VALUE;
}
public ToolType getTool() {
@@ -75,40 +74,40 @@ public enum SkillType {
public boolean getPermissions(Player player) {
switch (this) {
case ACROBATICS:
return Permissions.getInstance().acrobatics(player);
return Permissions.acrobatics(player);
case ARCHERY:
return Permissions.getInstance().archery(player);
return Permissions.archery(player);
case AXES:
return Permissions.getInstance().axes(player);
return Permissions.axes(player);
case EXCAVATION:
return Permissions.getInstance().excavation(player);
return Permissions.excavation(player);
case FISHING:
return Permissions.getInstance().fishing(player);
return Permissions.fishing(player);
case HERBALISM:
return Permissions.getInstance().herbalism(player);
return Permissions.herbalism(player);
case MINING:
return Permissions.getInstance().mining(player);
return Permissions.mining(player);
case REPAIR:
return Permissions.getInstance().repair(player);
return Permissions.repair(player);
case SWORDS:
return Permissions.getInstance().swords(player);
return Permissions.swords(player);
case TAMING:
return Permissions.getInstance().taming(player);
return Permissions.taming(player);
case UNARMED:
return Permissions.getInstance().unarmed(player);
return Permissions.unarmed(player);
case WOODCUTTING:
return Permissions.getInstance().woodcutting(player);
return Permissions.woodcutting(player);
default:
return false;
@@ -118,6 +117,19 @@ public enum SkillType {
public double getXpModifier() {
return xpModifier;
}
public static SkillType getSkill(String skillName) {
if(skillName.equalsIgnoreCase("powerlevel") || skillName.equalsIgnoreCase("all")) {
return SkillType.ALL;
} else {
for(SkillType st : SkillType.values()) {
if(st.name().equalsIgnoreCase(skillName))
return st;
}
System.out.println("[DEBUG] Invalid mcMMO skill ("+skillName+")");
return null;
}
}
/**
* Get the skill level for this skill.

View File

@@ -0,0 +1,102 @@
package com.gmail.nossr50.datatypes;
import org.bukkit.entity.Player;
import org.getspout.spoutapi.SpoutManager;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.SpoutConfig;
import com.gmail.nossr50.datatypes.popups.Menu;
import com.gmail.nossr50.datatypes.popups.XpBar;
public class SpoutHud {
private Player player;
private PlayerProfile profile;
private SkillType lastGained;
private SkillType skillLock;
private boolean xpBarLocked;
private Menu menu;
private XpBar xpBar;
public SpoutHud(McMMOPlayer mcMMOPlayer) {
this.player = mcMMOPlayer.getPlayer();
this.profile = mcMMOPlayer.getProfile();
initializeXpBar();
}
/**
* Initialize the HUD.
*/
public void initializeXpBar() {
if (SpoutConfig.getInstance().getXPBarEnabled()) {
if (xpBar != null) {
xpBar.removeWidgets();
}
xpBar = new XpBar(SpoutManager.getPlayer(player), profile.getHudType());
}
}
/**
* Update the XP bar.
*/
public void updateXpBar() {
SkillType skillType = xpBarLocked ? skillLock : lastGained;
if (skillType == null) {
return;
}
xpBar.update(skillType, profile);
}
public boolean isMenuOpened() {
return (menu != null) ? true : false;
}
public void openMenu() {
menu = new Menu(SpoutManager.getPlayer(player), profile);
}
public void onMenuClose() {
menu = null;
}
public void removeWidgets() {
if (menu != null) {
menu.close();
}
SpoutManager.getPlayer(player).getMainScreen().removeWidgets(mcMMO.p);
}
public SkillType getLastGained() {
return lastGained;
}
public void setLastGained(SkillType type) {
this.lastGained = type;
}
public boolean getXpBarLocked() {
return xpBarLocked;
}
public void setXpBarLocked(boolean locked) {
this.xpBarLocked = locked;
}
public void toggleXpBarLocked() {
xpBarLocked = !xpBarLocked;
}
public SkillType getSkillLock() {
return skillLock;
}
public void setSkillLock(SkillType type) {
this.skillLock = type;
}
}

View File

@@ -1,52 +0,0 @@
package com.gmail.nossr50.datatypes;
import java.util.ArrayList;
import com.gmail.nossr50.datatypes.PlayerStat;
public class Tree {
private TreeNode root = null;
/**
* Add a node to this tree.
*
* @param p Player name
* @param in Stat value
*/
public void add(String p, int in) {
if (root == null) {
root = new TreeNode(p, in);
}
else {
root.add(p, in);
}
}
/**
* Retrieve an array of PlayerStats from the Tree.
*
* @return the player stats of this tree, in order
*/
public PlayerStat[] inOrder() {
if (root != null) {
ArrayList<PlayerStat> order = root.inOrder(new ArrayList<PlayerStat>());
return order.toArray(new PlayerStat[order.size()]);
}
else {
/*
* Throw some dummy info in case the users file is empty.
* It's not a good fix but its better than rewriting the whole system.
*/
ArrayList<PlayerStat> x = new ArrayList<PlayerStat>();
PlayerStat y = new PlayerStat();
y.name = "$mcMMO_DummyInfo";
y.statVal = 0;
x.add(y);
return x.toArray(new PlayerStat[x.size()]);
}
}
}

View File

@@ -1,52 +0,0 @@
package com.gmail.nossr50.datatypes;
import java.util.ArrayList;
import com.gmail.nossr50.datatypes.PlayerStat;
public class TreeNode {
TreeNode left = null;
TreeNode right = null;
PlayerStat ps = new PlayerStat();
public TreeNode(String p, int in) {
ps.statVal = in;
ps.name = p;
}
public void add (String p, int in) {
if (in >= ps.statVal) {
if (left == null) {
left = new TreeNode(p, in);
}
else {
left.add(p, in);
}
}
else if(in < ps.statVal) {
if (right == null) {
right = new TreeNode(p, in);
}
else {
right.add(p, in);
}
}
}
public ArrayList<PlayerStat> inOrder(ArrayList<PlayerStat> a) {
//if left node is not null than assign arrayList(a) to left.inOrder()
//GOES THROUGH THE ENTIRE LEFT BRANCH AND GRABS THE GREATEST NUMBER
if (left != null) {
a = left.inOrder(a);
}
a.add(ps);
if (right != null) {
a = right.inOrder(a);
}
return a;
}
}

View File

@@ -1,13 +0,0 @@
package com.gmail.nossr50.datatypes.buttons;
import org.getspout.spoutapi.gui.GenericButton;
public class ButtonEscape extends GenericButton {
public ButtonEscape() {
this.setText("EXIT");
this.setWidth(60);
this.setHeight(20);
this.setDirty(true);
}
}

View File

@@ -1,14 +0,0 @@
package com.gmail.nossr50.datatypes.buttons;
import com.gmail.nossr50.datatypes.PlayerProfile;
public class ButtonHUDStyle extends ButtonToggle {
public ButtonHUDStyle(PlayerProfile PP) {
super("HUD Type: ", PP.getHUDType().toString(), "Change your HUD style!"); //TODO: Needs more locale
}
public void updateText(PlayerProfile PP) {
super.updateText("HUD Type: ", PP.getHUDType().toString()); //TODO: Needs more locale
}
}

View File

@@ -1,14 +0,0 @@
package com.gmail.nossr50.datatypes.buttons;
import com.gmail.nossr50.datatypes.PlayerProfile;
public class ButtonPartyToggle extends ButtonToggle {
public ButtonPartyToggle(PlayerProfile PP) {
super("Party HUD: ", ((Boolean) PP.getPartyHUD()).toString(), "Toggle the Party HUD!"); //TODO: Needs more locale
}
public void updateText(PlayerProfile PP) {
super.updateText("Party HUD: ", ((Boolean) PP.getPartyHUD()).toString()); //TODO: Needs more locale
}
}

View File

@@ -1,19 +0,0 @@
package com.gmail.nossr50.datatypes.buttons;
import org.getspout.spoutapi.gui.GenericButton;
public class ButtonToggle extends GenericButton{
public ButtonToggle(String text1, String text2, String tooltip) {
this.setText(text1 + text2);
this.setTooltip(tooltip);
this.setWidth(120);
this.setHeight(20);
this.setDirty(true);
}
public void updateText(String text1, String text2) {
this.setText(text1 + text2);
this.setDirty(true);
}
}

View File

@@ -0,0 +1,24 @@
package com.gmail.nossr50.datatypes.buttons;
import org.getspout.spoutapi.gui.GenericButton;
public class McmmoButton extends GenericButton {
private Slot slot;
public McmmoButton(String text, String toolTip) {
this.setText(text);
this.setTooltip(toolTip);
}
public void connect(Slot slot) {
this.slot = slot;
}
public void activate() {
slot.activate();
}
public interface Slot {
public void activate();
}
}

View File

@@ -8,13 +8,17 @@ public class CustomBlock {
private int xpGain;
private int tier;
private ItemStack itemDrop;
private int minimumDropAmount;
private int maximumDropAmount;
public CustomBlock(ItemStack itemDrop, int tier, int xpGain, byte dataValue, int itemID) {
public CustomBlock(int minimumDropAmount, int maximumDropAmount, ItemStack itemDrop, int tier, int xpGain, byte dataValue, int itemID) {
this.itemID = itemID;
this.dataValue = dataValue;
this.xpGain = xpGain;
this.tier = tier;
this.itemDrop = itemDrop;
this.minimumDropAmount = minimumDropAmount;
this.maximumDropAmount = maximumDropAmount;
}
public int getItemID() {
@@ -56,4 +60,20 @@ public class CustomBlock {
public void setItemDrop(ItemStack itemDrop) {
this.itemDrop = itemDrop;
}
public int getMinimumDropAmount() {
return minimumDropAmount;
}
public void setMinimumDropAmount(int minimumDropAmount) {
this.minimumDropAmount = minimumDropAmount;
}
public int getMaximumDropAmount() {
return maximumDropAmount;
}
public void setMaximumDropAmount(int maximumDropAmount) {
this.maximumDropAmount = maximumDropAmount;
}
}

View File

@@ -1,19 +1,11 @@
package com.gmail.nossr50.datatypes.mods;
import org.bukkit.inventory.ItemStack;
public class CustomItem {
protected int itemID;
protected boolean repairable;
protected ItemStack repairMaterial;
protected int repairQuantity;
protected short durability;
public CustomItem(short durability, ItemStack repairMaterial, int repairQuantity, boolean repairable, int itemID) {
public CustomItem(int itemID, short durability) {
this.itemID = itemID;
this.repairable = repairable;
this.repairMaterial = repairMaterial;
this.repairQuantity = repairQuantity;
this.durability = durability;
}
@@ -25,31 +17,6 @@ public class CustomItem {
this.itemID = itemID;
}
public boolean isRepairable() {
return repairable;
}
public void setRepairable(boolean repairable) {
this.repairable = repairable;
}
public ItemStack getRepairMaterial() {
return repairMaterial;
}
public void setRepairMaterial(ItemStack repairMaterial) {
this.repairMaterial = repairMaterial;
}
public int getRepairQuantity() {
return repairQuantity;
}
public void setRepairQuantity(int repairQuantity) {
this.repairQuantity = repairQuantity;
}
public short getDurability() {
return durability;
}

View File

@@ -1,14 +1,12 @@
package com.gmail.nossr50.datatypes.mods;
import org.bukkit.inventory.ItemStack;
public class CustomTool extends CustomItem {
private double xpMultiplier;
private boolean abilityEnabled;
private int tier;
public CustomTool(short durability, ItemStack repairMaterial, int repairQuantity, boolean repairable, int tier, boolean abilityEnabled, double xpMultiplier, int itemID) {
super(durability, repairMaterial, repairQuantity, repairable, itemID);
public CustomTool(int tier, boolean abilityEnabled, double xpMultiplier, short durability, int itemID) {
super(itemID, durability);
this.xpMultiplier = xpMultiplier;
this.abilityEnabled = abilityEnabled;
this.tier = tier;

View File

@@ -0,0 +1,79 @@
package com.gmail.nossr50.datatypes.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.HudType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SpoutHud;
import com.gmail.nossr50.datatypes.buttons.McmmoButton;
import com.gmail.nossr50.datatypes.buttons.McmmoButton.Slot;
import com.gmail.nossr50.locale.LocaleLoader;
public class Menu extends GenericPopup {
private McmmoButton hudButton;
private McmmoButton escapeButton;
private GenericLabel titleLabel = new GenericLabel();
private GenericLabel escapeLabel = new GenericLabel();
private static int centerX = 427 / 2;
private static int centerY = 240 / 2;
public Menu(final SpoutPlayer spoutPlayer, final PlayerProfile playerProfile) {
//240, 427 are the bottom right
titleLabel.setText(LocaleLoader.getString("Spout.Menu.Title"));
titleLabel.setWidth(100);
titleLabel.setHeight(100);
titleLabel.setX(centerX - 35);
titleLabel.setY((centerY / 2) - 20);
escapeLabel.setText(LocaleLoader.getString("Spout.Menu.Exit"));
escapeLabel.setWidth(100);
escapeLabel.setHeight(100);
escapeLabel.setX(titleLabel.getX() - 15);
escapeLabel.setY(titleLabel.getY() + 10);
hudButton = new McmmoButton(LocaleLoader.getString("Spout.Menu.HudButton.1", new Object[] {playerProfile.getHudType().toString()}), LocaleLoader.getString("Spout.Menu.HudButton.2"));
hudButton.setWidth(120);
hudButton.setHeight(20);
hudButton.setX(centerX - (hudButton.getWidth() / 2));
hudButton.setY(centerY / 2);
hudButton.connect(new Slot() {
@Override
public void activate() {
HudType nextHudType = playerProfile.getHudType().getNext();
SpoutHud spoutHud = playerProfile.getSpoutHud();
playerProfile.setHudType(nextHudType);
spoutHud.initializeXpBar();
spoutHud.updateXpBar();
hudButton.setText("HUD Type: " + nextHudType.toString());
hudButton.setDirty(true);
}
});
escapeButton = new McmmoButton(LocaleLoader.getString("Spout.Menu.ExitButton"), null);
escapeButton.setWidth(60);
escapeButton.setHeight(20);
escapeButton.setX(centerX - (escapeButton.getWidth() / 2));
escapeButton.setY((centerY / 2) + (escapeButton.getHeight() * 2) + 5);
escapeButton.connect(new Slot() {
@Override
public void activate() {
spoutPlayer.getMainScreen().closePopup();
}
});
attachWidget(mcMMO.p, hudButton);
attachWidget(mcMMO.p, titleLabel);
attachWidget(mcMMO.p, escapeLabel);
attachWidget(mcMMO.p, escapeButton);
InGameHUD inGameHud = spoutPlayer.getMainScreen();
inGameHud.attachPopupScreen(this);
inGameHud.setDirty(true);
}
}

View File

@@ -1,57 +0,0 @@
package com.gmail.nossr50.datatypes.popups;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.getspout.spoutapi.gui.GenericLabel;
import org.getspout.spoutapi.gui.GenericPopup;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.buttons.ButtonEscape;
import com.gmail.nossr50.datatypes.buttons.ButtonHUDStyle;
public class PopupMMO extends GenericPopup {
private ButtonHUDStyle HUDButton = null;
private ButtonEscape EscapeButton = null;
private GenericLabel mcMMO_label = new GenericLabel();
private GenericLabel tip_escape = new GenericLabel();
private int center_x = 427 / 2;
private int center_y = 240 / 2;
public PopupMMO(Player player, PlayerProfile PP, mcMMO plugin) {
//240, 427 are the bottom right
mcMMO_label.setText(ChatColor.GOLD + "~mcMMO Menu~"); //TODO: Needs more locale
mcMMO_label.setX(center_x - 35);
mcMMO_label.setY((center_y / 2) - 20);
mcMMO_label.setDirty(true);
tip_escape.setText(ChatColor.GRAY + "Press ESCAPE to exit!"); //TODO: Needs more locale
tip_escape.setX(mcMMO_label.getX() - 15);
tip_escape.setY(mcMMO_label.getY() + 10);
tip_escape.setDirty(true);
HUDButton = new ButtonHUDStyle(PP);
HUDButton.setX(center_x - (HUDButton.getWidth() / 2));
HUDButton.setY(center_y / 2);
HUDButton.setDirty(true);
EscapeButton = new ButtonEscape();
EscapeButton.setX(center_x - (EscapeButton.getWidth() / 2));
EscapeButton.setY((center_y / 2) + (HUDButton.getHeight() * 2) + 5);
EscapeButton.setDirty(true);
this.attachWidget(plugin, HUDButton);
this.attachWidget(plugin, mcMMO_label);
this.attachWidget(plugin, tip_escape);
this.attachWidget(plugin, EscapeButton);
this.setDirty(true);
}
public void updateButtons(PlayerProfile PP) {
HUDButton.updateText(PP);
//PartyButton.updateText(PP);
this.setDirty(true);
}
}

View File

@@ -0,0 +1,320 @@
package com.gmail.nossr50.datatypes.popups;
import org.getspout.spoutapi.gui.Color;
import org.getspout.spoutapi.gui.GenericGradient;
import org.getspout.spoutapi.gui.GenericTexture;
import org.getspout.spoutapi.gui.InGameHUD;
import org.getspout.spoutapi.gui.RenderPriority;
import org.getspout.spoutapi.gui.Widget;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.SpoutConfig;
import com.gmail.nossr50.datatypes.HudType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.util.Misc;
public class XpBar {
private SpoutPlayer spoutPlayer;
private Widget xpBar;
private GenericGradient xpFill;
private GenericGradient xpBackground;
private GenericGradient xpIconBackground;
private GenericGradient xpIconBorder;
private GenericTexture xpIcon;
public XpBar(SpoutPlayer spoutPlayer, HudType hudType) {
this.spoutPlayer = spoutPlayer;
switch (hudType) {
case RETRO:
initializeXpBarRetro();
break;
case STANDARD:
initializeXpBarStandard();
break;
case SMALL:
initializeXpBarSmall();
break;
case DISABLED:
break;
}
spoutPlayer.getMainScreen().setDirty(true);
}
/**
* Initialize Retro XP bar.
*/
private void initializeXpBarRetro() {
Color border = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBorderRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderBlue(), 1f);
Color green = new Color(0f, 1f, 0f, 1f);
Color background = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBackgroundRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundBlue(), 1f);
xpBar = new GenericGradient();
xpFill = new GenericGradient();
xpBackground = new GenericGradient();
xpBar.setWidth(128);
xpBar.setHeight(4);
xpBar.setX(149);
xpBar.setY(10);
((GenericGradient) xpBar).setBottomColor(border);
((GenericGradient) xpBar).setTopColor(border);
xpBar.setPriority(RenderPriority.Highest);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBar);
xpFill.setWidth(0);
xpFill.setHeight(2);
xpFill.setX(150);
xpFill.setY(11);
xpFill.setBottomColor(green);
xpFill.setTopColor(green);
xpFill.setPriority(RenderPriority.Lowest);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpFill);
xpBackground.setWidth(126);
xpBackground.setHeight(2);
xpBackground.setX(150);
xpBackground.setY(11);
xpBackground.setBottomColor(background);
xpBackground.setTopColor(background);
xpBackground.setPriority(RenderPriority.Low);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBackground);
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
Color darkbg = new Color(0.2f, 0.2f, 0.2f, 1f);
xpIconBackground = new GenericGradient();
xpIconBorder = new GenericGradient();
xpIcon = new GenericTexture();
xpIconBackground.setBottomColor(darkbg);
xpIconBackground.setTopColor(darkbg);
xpIconBackground.setWidth(4);
xpIconBackground.setHeight(4);
xpIconBackground.setPriority(RenderPriority.High);
xpIconBackground.setX(142);
xpIconBackground.setY(10);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIconBackground);
xpIconBorder.setBottomColor(border);
xpIconBorder.setTopColor(border);
xpIconBorder.setWidth(6);
xpIconBorder.setHeight(6);
xpIconBorder.setPriority(RenderPriority.Highest);
xpIconBorder.setX(141);
xpIconBorder.setY(9);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIconBorder);
xpIcon.setWidth(6);
xpIcon.setHeight(6);
xpIcon.setX(141);
xpIcon.setY(9);
xpIcon.setPriority(RenderPriority.Normal);
xpIcon.setUrl("Icon_r.png");
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIcon);
}
}
/**
* Initialize Standard XP bar.
*/
private void initializeXpBarStandard() {
xpBar = new GenericTexture();
((GenericTexture) xpBar).setUrl("xpbar_inc000.png");
xpBar.setX(SpoutConfig.getInstance().getXPBarXPosition());
xpBar.setY(SpoutConfig.getInstance().getXPBarYPosition());
xpBar.setHeight(8);
xpBar.setWidth(256);
xpBar.setPriority(RenderPriority.Lowest);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBar);
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
xpIcon = new GenericTexture();
xpIcon.setUrl("Icon.png");
xpIcon.setHeight(16);
xpIcon.setWidth(32);
xpIcon.setX(SpoutConfig.getInstance().getXPIconXPosition());
xpIcon.setY(SpoutConfig.getInstance().getXPIconYPosition());
xpIcon.setPriority(RenderPriority.High);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIcon);
}
}
/**
* Initialize Small XP bar.
*/
private void initializeXpBarSmall() {
xpBar = new GenericTexture();
((GenericTexture)xpBar).setUrl("xpbar_inc000.png");
xpBar.setX(427 / 2 - 64);
xpBar.setY(SpoutConfig.getInstance().getXPBarYPosition());
xpBar.setHeight(4);
xpBar.setWidth(128);
xpBar.setPriority(RenderPriority.Lowest);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBar);
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
xpIcon = new GenericTexture();
xpIcon.setUrl("Icon.png");
xpIcon.setHeight(8);
xpIcon.setWidth(16);
xpIcon.setX(427 / 2 - (8 + 64));
xpIcon.setY(SpoutConfig.getInstance().getXPIconYPosition() + 2);
xpIcon.setPriority(RenderPriority.High);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIcon);
}
}
/**
* Update the XP bar.
*
* @param skillType
* @param playerProfile
*/
public void update(SkillType skillType, PlayerProfile playerProfile) {
switch (playerProfile.getHudType()) {
case RETRO:
updateXpBarRetro(skillType, playerProfile);
break;
case STANDARD:
case SMALL:
updateXpBarStandard(skillType, playerProfile);
break;
case DISABLED:
break;
}
}
/**
* Update XP bar for Standard & Small styles.
*
* @param skillType
* @param playerProfile
*/
private void updateXpBarStandard(SkillType skillType, PlayerProfile playerProfile) {
xpIcon.setUrl(Misc.getCapitalized(skillType.toString()) + ".png");
((GenericTexture) xpBar).setUrl(getUrlBar(getXpInc(playerProfile.getSkillXpLevel(skillType), playerProfile.getXpToLevel(skillType), HudType.STANDARD)));
spoutPlayer.getMainScreen().setDirty(true);
}
/**
* Update XP bar for Retro styles.
*
* @param skillType
*/
private void updateXpBarRetro(SkillType skillType, PlayerProfile playerProfile) {
Color color = getRetroColor(skillType);
xpIcon.setUrl(Misc.getCapitalized(skillType.toString()) + "_r.png");
xpFill.setBottomColor(color);
xpFill.setTopColor(color);
xpFill.setWidth(getXpInc(playerProfile.getSkillXpLevel(skillType), playerProfile.getXpToLevel(skillType), HudType.RETRO));
spoutPlayer.getMainScreen().setDirty(true);
}
private static Color getRetroColor(SkillType type) {
switch (type) {
case ACROBATICS:
return new Color((float) SpoutConfig.getInstance().getRetroHUDAcrobaticsRed(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsGreen(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsBlue(), 1f);
case ARCHERY:
return new Color((float) SpoutConfig.getInstance().getRetroHUDArcheryRed(), (float) SpoutConfig.getInstance().getRetroHUDArcheryGreen(), (float) SpoutConfig.getInstance().getRetroHUDArcheryBlue(), 1f);
case AXES:
return new Color((float) SpoutConfig.getInstance().getRetroHUDAxesRed(), (float) SpoutConfig.getInstance().getRetroHUDAxesGreen(), (float) SpoutConfig.getInstance().getRetroHUDAxesBlue(), 1f);
case EXCAVATION:
return new Color((float) SpoutConfig.getInstance().getRetroHUDExcavationRed(), (float) SpoutConfig.getInstance().getRetroHUDExcavationGreen(), (float) SpoutConfig.getInstance().getRetroHUDExcavationBlue(), 1f);
case HERBALISM:
return new Color((float) SpoutConfig.getInstance().getRetroHUDHerbalismRed(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismGreen(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismBlue(), 1f);
case MINING:
return new Color((float) SpoutConfig.getInstance().getRetroHUDMiningRed(), (float) SpoutConfig.getInstance().getRetroHUDMiningGreen(), (float) SpoutConfig.getInstance().getRetroHUDMiningBlue(), 1f);
case REPAIR:
return new Color((float) SpoutConfig.getInstance().getRetroHUDRepairRed(), (float) SpoutConfig.getInstance().getRetroHUDRepairGreen(), (float) SpoutConfig.getInstance().getRetroHUDRepairBlue(), 1f);
case SWORDS:
return new Color((float) SpoutConfig.getInstance().getRetroHUDSwordsRed(), (float) SpoutConfig.getInstance().getRetroHUDSwordsGreen(), (float) SpoutConfig.getInstance().getRetroHUDSwordsBlue(), 1f);
case TAMING:
return new Color((float) SpoutConfig.getInstance().getRetroHUDTamingRed(), (float) SpoutConfig.getInstance().getRetroHUDTamingGreen(), (float) SpoutConfig.getInstance().getRetroHUDTamingBlue(), 1f);
case UNARMED:
return new Color((float) SpoutConfig.getInstance().getRetroHUDUnarmedRed(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedGreen(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedBlue(), 1f);
case WOODCUTTING:
return new Color((float) SpoutConfig.getInstance().getRetroHUDWoodcuttingRed(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingGreen(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingBlue(), 1f);
case FISHING:
return new Color((float) SpoutConfig.getInstance().getRetroHUDFishingRed(), (float) SpoutConfig.getInstance().getRetroHUDFishingGreen(), (float) SpoutConfig.getInstance().getRetroHUDFishingBlue(), 1f);
default:
return new Color(0.3f, 0.3f, 0.75f, 1f);
}
}
private static String getUrlBar(Integer number) {
char[] num = number.toString().toCharArray();
switch (num.length) {
case 1:
return "xpbar_inc00" + number + ".png";
case 2:
return "xpbar_inc0" + number + ".png";
default:
return "xpbar_inc" + number + ".png";
}
}
private static Integer getXpInc(int skillXp, int xpToLevel, HudType hudType) {
double percentage = (double) skillXp / xpToLevel;
double inc;
switch (hudType) {
case RETRO:
inc = 0.0079365079365079;
break;
case STANDARD:
inc = 0.0039370078740157;
break;
default:
return 1;
}
return (int) (percentage / inc);
}
public void removeWidgets() {
InGameHUD inGameHud = spoutPlayer.getMainScreen();
if (xpBar != null) inGameHud.removeWidget(xpBar);
if (xpFill != null) inGameHud.removeWidget(xpFill);
if (xpBackground != null) inGameHud.removeWidget(xpBackground);
if (xpIconBackground != null) inGameHud.removeWidget(xpIconBackground);
if (xpIconBorder != null) inGameHud.removeWidget(xpIconBorder);
if (xpIcon != null) inGameHud.removeWidget(xpIcon);
}
}

View File

@@ -12,4 +12,4 @@ public class FakeBlockBreakEvent extends BlockBreakEvent {
public FakeBlockBreakEvent(Block theBlock, Player player) {
super(theBlock, player);
}
}
}

View File

@@ -0,0 +1,16 @@
package com.gmail.nossr50.events.fake;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.inventory.ItemStack;
/**
* Called when mcMMO damages a block due to a special ability.
*/
public class FakeBlockDamageEvent extends BlockDamageEvent {
public FakeBlockDamageEvent(Player player, Block block, ItemStack itemInHand, boolean instaBreak) {
super(player, block, itemInHand, instaBreak);
}
}

View File

@@ -58,10 +58,11 @@ public class McMMOItemSpawnEvent extends Event implements Cancellable {
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}

View File

@@ -2,32 +2,9 @@ package com.gmail.nossr50.listeners;
import java.util.List;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.ToolType;
import com.gmail.nossr50.skills.gathering.Excavation;
import com.gmail.nossr50.skills.gathering.Herbalism;
import com.gmail.nossr50.skills.gathering.Mining;
import com.gmail.nossr50.skills.gathering.WoodCutting;
import com.gmail.nossr50.skills.misc.Repair;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.ModChecks;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import org.bukkit.CropState;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -38,9 +15,33 @@ import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.getspout.spoutapi.sound.SoundEffect;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.ToolType;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.runnables.StickyPistonTracker;
import com.gmail.nossr50.skills.gathering.Excavation;
import com.gmail.nossr50.skills.gathering.Herbalism;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.gathering.WoodCutting;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.Salvage;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.ModChecks;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
public class BlockListener implements Listener {
private final mcMMO plugin;
@@ -57,18 +58,22 @@ public class BlockListener implements Listener {
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
List<Block> blocks = event.getBlocks();
BlockFace direction = event.getDirection();
// Block that would be air after piston is finished
Block futureEmptyBlock = event.getBlock().getRelative(direction);
for (Block b : blocks) {
if (mcMMO.placeStore.isTrue(b)) {
mcMMO.placeStore.setTrue(b.getRelative(direction));
mcMMO.placeStore.setFalse(b);
b.getRelative(direction).setMetadata("pistonTrack", new FixedMetadataValue(plugin, true));
if (b.equals(futureEmptyBlock)) {
mcMMO.placeStore.setFalse(b);
}
}
}
for (Block b : blocks) {
if (mcMMO.placeStore.isTrue(b.getRelative(direction))) {
if (b.getRelative(direction).hasMetadata("pistonTrack")) {
mcMMO.placeStore.setTrue(b.getRelative(direction));
mcMMO.placeStore.setFalse(b);
b.getRelative(direction).removeMetadata("pistonTrack", plugin);
}
}
}
@@ -80,11 +85,9 @@ public class BlockListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
Block block = event.getRetractLocation().getBlock();
if (mcMMO.placeStore.isTrue(block)) {
mcMMO.placeStore.setFalse(block);
mcMMO.placeStore.setTrue(event.getBlock().getRelative(event.getDirection()));
if (event.isSticky()) {
//Needed only because under some circumstances Minecraft doesn't move the block
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StickyPistonTracker(event), 0);
}
}
@@ -95,33 +98,25 @@ public class BlockListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
Config configInstance = Config.getInstance();
Block block = event.getBlock();
Player player = event.getPlayer();
int id = block.getTypeId();
Material mat = block.getType();
/* Code to prevent issues with placed falling Sand/Gravel not being tracked */
if (mat.equals(Material.SAND) || mat.equals(Material.GRAVEL)) {
for (int y = -1; y + block.getY() >= 0; y--) {
if (block.getRelative(0, y, 0).getType().equals(Material.AIR)) {
continue;
}
else {
Block newLocation = block.getRelative(0, y + 1, 0);
mcMMO.placeStore.setTrue(newLocation);
break;
}
}
}
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
if (BlockChecks.shouldBeWatched(block)) {
mcMMO.placeStore.setTrue(block);
}
if (id == Config.getInstance().getRepairAnvilId() && Config.getInstance().getRepairAnvilMessagesEnabled()) {
if (id == configInstance.getRepairAnvilId() && configInstance.getRepairAnvilMessagesEnabled()) {
Repair.placedAnvilCheck(player, id);
}
if (id == configInstance.getSalvageAnvilId() && configInstance.getRepairAnvilMessagesEnabled()) {
Salvage.placedAnvilCheck(player, id);
}
}
/**
@@ -131,86 +126,85 @@ public class BlockListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
PlayerProfile PP = Users.getProfile(player);
Block block = event.getBlock();
Material mat = block.getType();
ItemStack inhand = player.getItemInHand();
if (event instanceof FakeBlockBreakEvent) {
return;
}
/*
* HERBALISM
*/
Player player = event.getPlayer();
/* Green Terra */
if (PP.getToolPreparationMode(ToolType.HOE) && Permissions.getInstance().greenTerra(player) && ((mat.equals(Material.CROPS) && block.getData() == CropState.RIPE.getData()) || BlockChecks.canBeGreenTerra(block))) {
Skills.abilityCheck(player, SkillType.HERBALISM);
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
PlayerProfile profile = Users.getProfile(player);
if (profile == null) {
return;
}
/* Triple drops */
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && BlockChecks.canBeGreenTerra(block)) {
Herbalism.herbalismProcCheck(block, player, event, plugin);
}
Block block = event.getBlock();
ItemStack inHand = player.getItemInHand();
if (Permissions.getInstance().herbalism(player) && BlockChecks.canBeGreenTerra(block)) {
Herbalism.herbalismProcCheck(block, player, event, plugin);
}
Config configInstance = Config.getInstance();
/*
* MINING
*/
if (Permissions.getInstance().mining(player) && BlockChecks.canBeSuperBroken(block)) {
if (Config.getInstance().getMiningRequiresTool() && ItemChecks.isPickaxe(inhand)) {
Mining.miningBlockCheck(player, block);
/* HERBALISM */
if (BlockChecks.canBeGreenTerra(block)) {
/* Green Terra */
if (profile.getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(player)) {
Skills.abilityCheck(player, SkillType.HERBALISM);
}
else if (!Config.getInstance().getMiningRequiresTool()) {
Mining.miningBlockCheck(player, block);
/* Triple drops */
if (profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
Herbalism.herbalismProcCheck(block, player, event, plugin);
}
if (Permissions.herbalism(player)) {
Herbalism.herbalismProcCheck(block, player, event, plugin);
}
}
/*
* WOOD CUTTING
*/
if (Permissions.getInstance().woodcutting(player) && mat.equals(Material.LOG)) {
if (Config.getInstance().getWoodcuttingRequiresTool() && ItemChecks.isAxe(inhand)) {
WoodCutting.woodcuttingBlockCheck(player, block);
}
else if (!Config.getInstance().getWoodcuttingRequiresTool()) {
WoodCutting.woodcuttingBlockCheck(player, block);
}
}
if (PP.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.getInstance().treeFeller(player) && ItemChecks.isAxe(inhand)) {
if (Config.getInstance().getToolModsEnabled()) {
if ((ItemChecks.isCustomTool(inhand) && ModChecks.getToolFromItemStack(inhand).isAbilityEnabled()) || !ItemChecks.isCustomTool(inhand)) {
WoodCutting.treeFeller(event);
/* MINING */
else if (BlockChecks.canBeSuperBroken(block) && Permissions.mining(player)) {
MiningManager miningManager = new MiningManager(player);
if (configInstance.getMiningRequiresTool()) {
if (ItemChecks.isPickaxe(inHand)) {
miningManager.miningBlockCheck(block);
}
}
else {
miningManager.miningBlockCheck(block);
}
}
/* WOOD CUTTING */
else if (BlockChecks.isLog(block) && Permissions.woodcutting(player)) {
if (configInstance.getWoodcuttingRequiresTool()) {
if (ItemChecks.isAxe(inHand)) {
WoodCutting.woodcuttingBlockCheck(player, block);
}
}
else {
WoodCutting.woodcuttingBlockCheck(player, block);
}
if (profile.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.treeFeller(player) && ItemChecks.isAxe(inHand)) {
WoodCutting.treeFeller(event);
}
}
/*
* EXCAVATION
*/
if (BlockChecks.canBeGigaDrillBroken(block) && Permissions.getInstance().excavation(player) && !mcMMO.placeStore.isTrue(block)) {
if (Config.getInstance().getExcavationRequiresTool() && ItemChecks.isShovel(inhand)) {
Excavation.excavationProcCheck(block, player);
/* EXCAVATION */
else if (BlockChecks.canBeGigaDrillBroken(block) && Permissions.excavation(player) && !mcMMO.placeStore.isTrue(block)) {
if (configInstance.getExcavationRequiresTool()) {
if (ItemChecks.isShovel(inHand)) {
Excavation.excavationProcCheck(block, player);
}
}
else if (!Config.getInstance().getExcavationRequiresTool()) {
else {
Excavation.excavationProcCheck(block, player);
}
}
//Remove metadata when broken
if (mcMMO.placeStore.isTrue(block) && BlockChecks.shouldBeWatched(block)) {
if (BlockChecks.shouldBeWatched(block)) {
mcMMO.placeStore.setFalse(block);
}
}
@@ -222,112 +216,108 @@ public class BlockListener implements Listener {
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockDamage(BlockDamageEvent event) {
if (event instanceof FakeBlockDamageEvent) {
return;
}
final int LEAF_BLOWER_LEVEL = 100;
Player player = event.getPlayer();
PlayerProfile PP = Users.getProfile(player);
ItemStack inhand = player.getItemInHand();
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
PlayerProfile profile = Users.getProfile(player);
if (profile == null) {
return;
}
ItemStack inHand = player.getItemInHand();
Block block = event.getBlock();
Material mat = block.getType();
Material material = block.getType();
Config configInstance = Config.getInstance();
/*
* ABILITY PREPARATION CHECKS
*/
if (BlockChecks.abilityBlockCheck(block)) {
if (PP.getToolPreparationMode(ToolType.HOE) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.makeMossy(block))) {
if (profile.getToolPreparationMode(ToolType.HOE) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.makeMossy(block))) {
Skills.abilityCheck(player, SkillType.HERBALISM);
}
else if (PP.getToolPreparationMode(ToolType.AXE) && mat.equals(Material.LOG) && Permissions.getInstance().treeFeller(player)) { //TODO: Why are we checking the permissions here?
else if (profile.getToolPreparationMode(ToolType.AXE) && BlockChecks.isLog(block) && Permissions.treeFeller(player)) { //TODO: Why are we checking the permissions here?
Skills.abilityCheck(player, SkillType.WOODCUTTING);
}
else if (PP.getToolPreparationMode(ToolType.PICKAXE) && BlockChecks.canBeSuperBroken(block)) {
else if (profile.getToolPreparationMode(ToolType.PICKAXE) && BlockChecks.canBeSuperBroken(block)) {
Skills.abilityCheck(player, SkillType.MINING);
}
else if (PP.getToolPreparationMode(ToolType.SHOVEL) && BlockChecks.canBeGigaDrillBroken(block)) {
else if (profile.getToolPreparationMode(ToolType.SHOVEL) && BlockChecks.canBeGigaDrillBroken(block)) {
Skills.abilityCheck(player, SkillType.EXCAVATION);
}
else if (PP.getToolPreparationMode(ToolType.FISTS) && (BlockChecks.canBeGigaDrillBroken(block) || mat.equals(Material.SNOW))) {
else if (profile.getToolPreparationMode(ToolType.FISTS) && (BlockChecks.canBeGigaDrillBroken(block) || material.equals(Material.SNOW))) {
Skills.abilityCheck(player, SkillType.UNARMED);
}
}
/* TREE FELLER SOUNDS */
if (Config.getInstance().spoutEnabled && mat.equals(Material.LOG) && PP.getAbilityMode(AbilityType.TREE_FELLER)) {
if (mcMMO.spoutEnabled && BlockChecks.isLog(block) && profile.getAbilityMode(AbilityType.TREE_FELLER)) {
SpoutSounds.playSoundForPlayer(SoundEffect.FIZZ, player, block.getLocation());
}
/*
* ABILITY TRIGGER CHECKS
*/
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && Permissions.getInstance().greenTerra(player) && BlockChecks.makeMossy(block)) {
if (Config.getInstance().getToolModsEnabled()) {
if ((ItemChecks.isCustomTool(inhand) && ModChecks.getToolFromItemStack(inhand).isAbilityEnabled()) || !ItemChecks.isCustomTool(inhand)) {
Herbalism.greenTerra(player, block);
}
}
else {
Herbalism.greenTerra(player, block);
}
if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && Permissions.greenTerra(player) && BlockChecks.makeMossy(block)) {
Herbalism.greenTerra(player, block);
}
else if (PP.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
if (Config.getInstance().getExcavationRequiresTool() && ItemChecks.isShovel(inhand)) {
if (Config.getInstance().getToolModsEnabled()) {
if ((ItemChecks.isCustomTool(inhand) && ModChecks.getToolFromItemStack(inhand).isAbilityEnabled()) || !ItemChecks.isCustomTool(inhand)) {
event.setInstaBreak(true);
Excavation.gigaDrillBreaker(player, block);
}
}
else {
else if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
if (configInstance.getExcavationRequiresTool()) {
if (ItemChecks.isShovel(inHand)) {
event.setInstaBreak(true);
Excavation.gigaDrillBreaker(player, block);
}
}
else if (!Config.getInstance().getExcavationRequiresTool()) {
else {
event.setInstaBreak(true);
Excavation.gigaDrillBreaker(player, block);
}
}
else if (PP.getAbilityMode(AbilityType.BERSERK) && Skills.triggerCheck(player, block, AbilityType.BERSERK)) {
if (inhand.getType().equals(Material.AIR)) {
else if (profile.getAbilityMode(AbilityType.BERSERK) && Skills.triggerCheck(player, block, AbilityType.BERSERK)) {
if (inHand.getType().equals(Material.AIR)) {
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
plugin.getServer().getPluginManager().callEvent(armswing);
event.setInstaBreak(true);
}
if (Config.getInstance().spoutEnabled) {
if (mcMMO.spoutEnabled) {
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
}
else if (PP.getAbilityMode(AbilityType.SUPER_BREAKER) && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
if (!player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { //TODO: Why are we checking this?
if (Config.getInstance().getMiningRequiresTool() && ItemChecks.isPickaxe(inhand)) {
if (Config.getInstance().getToolModsEnabled()) {
if ((ItemChecks.isCustomTool(inhand) && ModChecks.getToolFromItemStack(inhand).isAbilityEnabled()) || !ItemChecks.isCustomTool(inhand)) {
event.setInstaBreak(true);
Mining.SuperBreakerBlockCheck(player, block);
}
}
else {
event.setInstaBreak(true);
Mining.SuperBreakerBlockCheck(player, block);
}
}
else if (!Config.getInstance().getMiningRequiresTool()) {
else if (profile.getAbilityMode(AbilityType.SUPER_BREAKER) && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
MiningManager miningManager = new MiningManager(player);
if (configInstance.getMiningRequiresTool()) {
if (ItemChecks.isPickaxe(inHand)) {
event.setInstaBreak(true);
Mining.SuperBreakerBlockCheck(player, block);
miningManager.superBreakerBlockCheck(block);
}
}
else {
event.setInstaBreak(true);
miningManager.superBreakerBlockCheck(block);
}
}
else if (PP.getSkillLevel(SkillType.WOODCUTTING) >= LEAF_BLOWER_LEVEL && (mat.equals(Material.LEAVES) || (Config.getInstance().getBlockModsEnabled() && ModChecks.isCustomLeafBlock(block)))) {
if (Config.getInstance().getWoodcuttingRequiresTool() && ItemChecks.isAxe(inhand)) {
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
event.setInstaBreak(true);
WoodCutting.leafBlower(player, block);
else if (profile.getSkillLevel(SkillType.WOODCUTTING) >= LEAF_BLOWER_LEVEL && (material.equals(Material.LEAVES) || (configInstance.getBlockModsEnabled() && ModChecks.isCustomLeafBlock(block)))) {
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
if (configInstance.getWoodcuttingRequiresTool()) {
if (ItemChecks.isAxe(inHand)) {
event.setInstaBreak(true);
WoodCutting.leafBlower(player, block);
}
}
}
else if (!Config.getInstance().getWoodcuttingRequiresTool() && !inhand.getType().equals(Material.SHEARS)) {
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
else if (!inHand.getType().equals(Material.SHEARS)) {
event.setInstaBreak(true);
WoodCutting.leafBlower(player, block);
}

View File

@@ -1,9 +1,11 @@
package com.gmail.nossr50.listeners;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
@@ -15,6 +17,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
@@ -23,20 +26,20 @@ import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityTameEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.metadata.FixedMetadataValue;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.BleedTimer;
import com.gmail.nossr50.skills.combat.Archery;
import com.gmail.nossr50.skills.combat.Taming;
import com.gmail.nossr50.skills.gathering.BlastMining;
import com.gmail.nossr50.skills.misc.Acrobatics;
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
import com.gmail.nossr50.skills.archery.Archery;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.util.Combat;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
@@ -50,6 +53,24 @@ public class EntityListener implements Listener {
this.plugin = plugin;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityChangeBlockEvent(EntityChangeBlockEvent event) {
Entity entity = event.getEntity();
if (entity instanceof FallingBlock) {
Block block = event.getBlock();
if (mcMMO.placeStore.isTrue(block) && !mcMMO.placeStore.isSpawnedMob(entity)) {
mcMMO.placeStore.setFalse(block);
mcMMO.placeStore.addSpawnedMob(entity);
}
else if (mcMMO.placeStore.isSpawnedMob(entity)) {
mcMMO.placeStore.setTrue(block);
mcMMO.placeStore.removeSpawnedMob(entity);
}
}
}
/**
* Monitor EntityDamageByEntity events.
*
@@ -57,11 +78,16 @@ public class EntityListener implements Listener {
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if (event instanceof FakeEntityDamageByEntityEvent) {
if (event instanceof FakeEntityDamageByEntityEvent)
return;
if (event.getDamage() <= 0)
return;
}
Entity attacker = event.getDamager();
Entity defender = event.getEntity();
if (attacker.hasMetadata("NPC") || defender.hasMetadata("NPC")) return; // Check if either players is are Citizens NPCs
if (attacker instanceof Projectile) {
attacker = ((Projectile) attacker).getShooter();
@@ -69,26 +95,32 @@ public class EntityListener implements Listener {
else if (attacker instanceof Tameable) {
AnimalTamer animalTamer = ((Tameable) attacker).getOwner();
if (animalTamer instanceof Player) {
attacker = (Player) animalTamer;
if (animalTamer instanceof Entity) {
attacker = (Entity) animalTamer;
}
}
Entity defender = event.getEntity();
if (defender instanceof Player) {
Player defendingPlayer = (Player) defender;
if (attacker instanceof Player && defender instanceof Player) {
if (Party.getInstance().inSameParty((Player)defender, (Player)attacker)) {
event.setCancelled(true);
if (!defendingPlayer.isOnline()) {
return;
}
if (attacker instanceof Player) {
if (PartyManager.getInstance().inSameParty(defendingPlayer, (Player) attacker)) {
event.setCancelled(true);
return;
}
}
}
/* Check for invincibility */
if (defender instanceof LivingEntity) {
LivingEntity livingDefender = (LivingEntity)defender;
LivingEntity livingDefender = (LivingEntity) defender;
if (!Misc.isInvincible(livingDefender, event)) {
Combat.combatChecks(event, plugin);
Combat.combatChecks(event);
}
}
}
@@ -105,45 +137,57 @@ public class EntityListener implements Listener {
}
Entity entity = event.getEntity();
EntityType type = entity.getType();
DamageCause cause = event.getCause();
switch(type) {
case PLAYER:
if (entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
if (!(entity instanceof LivingEntity)) {
return;
}
LivingEntity lEntity = (LivingEntity) entity;
if (lEntity instanceof Player) {
/* Check for invincibility */
Player player = (Player) entity;
PlayerProfile PP = Users.getProfile(player);
if (PP.getGodMode()) {
if (!player.isOnline()) {
return;
}
PlayerProfile profile = Users.getProfile(player);
if (profile == null) {
return;
}
if (profile.getGodMode()) {
event.setCancelled(true);
return;
}
if (!Misc.isInvincible(player, event)) {
if (cause == DamageCause.FALL && Permissions.getInstance().acrobatics(player) && !player.isInsideVehicle()) {
Acrobatics.acrobaticsCheck(player, event);
if (cause == DamageCause.FALL && !player.isInsideVehicle() && !(player.getItemInHand().getType() == Material.ENDER_PEARL)) {
AcrobaticsManager acroManager = new AcrobaticsManager(player);
acroManager.rollCheck(event);
}
else if (cause == DamageCause.BLOCK_EXPLOSION && Permissions.getInstance().demolitionsExpertise(player)) {
BlastMining.demolitionsExpertise(player, event);
else if (cause == DamageCause.BLOCK_EXPLOSION && Permissions.demolitionsExpertise(player)) {
MiningManager miningManager = new MiningManager(player);
miningManager.demolitionsExpertise(event);
}
if (event.getDamage() >= 1) {
PP.setRecentlyHurt(System.currentTimeMillis());
profile.actualizeRecentlyHurt();
}
}
break;
} else if (lEntity instanceof Tameable) {
Tameable pet = (Tameable) lEntity;
AnimalTamer owner = pet.getOwner();
case WOLF:
Wolf wolf = (Wolf) entity;
if ((!Misc.isInvincible(wolf, event)) && wolf.isTamed() && (wolf.getOwner() instanceof Player)) {
Taming.preventDamage(event);
if ((!Misc.isInvincible(lEntity, event)) && pet.isTamed() && (owner instanceof Player) && pet instanceof Wolf) {
TamingManager tamingManager = new TamingManager((Player) owner);
tamingManager.preventDamage(event);
}
break;
default:
break;
}
}
@@ -156,9 +200,13 @@ public class EntityListener implements Listener {
public void onEntityDeath(EntityDeathEvent event) {
LivingEntity entity = event.getEntity();
if (entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
entity.setFireTicks(0);
BleedTimer.remove(entity);
Archery.arrowRetrievalCheck(entity);
mcMMO.placeStore.removeSpawnedMob(entity);
mcMMO.placeStore.removeSpawnedPet(entity);
}
/**
@@ -171,7 +219,7 @@ public class EntityListener implements Listener {
SpawnReason reason = event.getSpawnReason();
if ((reason.equals(SpawnReason.SPAWNER) || reason.equals(SpawnReason.SPAWNER_EGG)) && !Config.getInstance().getExperienceGainsMobspawnersEnabled()) {
event.getEntity().setMetadata("mcmmoFromMobSpawner", new FixedMetadataValue(plugin, true));
mcMMO.placeStore.addSpawnedMob(event.getEntity());
}
}
@@ -184,14 +232,17 @@ public class EntityListener implements Listener {
public void onExplosionPrime(ExplosionPrimeEvent event) {
Entity entity = event.getEntity();
if (entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
if (entity instanceof TNTPrimed) {
int id = entity.getEntityId();
if (plugin.tntTracker.containsKey(id)) {
Player player = plugin.tntTracker.get(id);
if (plugin.tntIsTracked(id)) {
Player player = plugin.getTNTPlayer(id);
if (Permissions.getInstance().biggerBombs(player)) {
BlastMining.biggerBombs(player, event);
if (Permissions.biggerBombs(player)) {
MiningManager miningManager = new MiningManager(player);
miningManager.biggerBombs(event);
}
}
}
@@ -206,13 +257,18 @@ public class EntityListener implements Listener {
public void onEnitityExplode(EntityExplodeEvent event) {
Entity entity = event.getEntity();
if (event.getEntity() instanceof TNTPrimed) {
if (entity == null) return;
if (entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
if (entity instanceof TNTPrimed) {
int id = entity.getEntityId();
if (plugin.tntTracker.containsKey(id)) {
Player player = plugin.tntTracker.get(id);
BlastMining.dropProcessing(player, event);
plugin.tntTracker.remove(id);
if (plugin.tntIsTracked(id)) {
Player player = plugin.getTNTPlayer(id);
MiningManager miningManager = new MiningManager(player);
miningManager.blastMiningDropProcessing(event);
plugin.removeFromTNTTracker(id);
}
}
}
@@ -224,16 +280,16 @@ public class EntityListener implements Listener {
*/
@EventHandler (priority = EventPriority.LOW)
public void onFoodLevelChange(FoodLevelChangeEvent event) {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
PlayerProfile PP = Users.getProfile(player);
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
PlayerProfile profile = Users.getProfile(player);
int currentFoodLevel = player.getFoodLevel();
int newFoodLevel = event.getFoodLevel();
if (!Permissions.getInstance().farmersDiet(player)) {
return;
}
/*
* Some foods have 3 ranks
* Some foods have 5 ranks
@@ -243,37 +299,102 @@ public class EntityListener implements Listener {
if (newFoodLevel > currentFoodLevel) {
Material food = player.getItemInHand().getType();
int herbLevel = PP.getSkillLevel(SkillType.HERBALISM);
int herbLevel = profile.getSkillLevel(SkillType.HERBALISM);
int fishLevel = profile.getSkillLevel(SkillType.FISHING);
int foodChange = newFoodLevel - currentFoodLevel;
int rankChange = 0;
boolean fish = false;
boolean herb = false;
int FoodRank1 = advancedConfig.getFarmerDietRankChange();
int FoodRank2 = advancedConfig.getFarmerDietRankChange() * 2;
int FoodRankMax = advancedConfig.getFarmerDietRankChange() * 5;
switch (food) {
case BREAD:
/* BREAD RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
rankChange = 200;
herb = true;
rankChange = FoodRank1;
break;
case COOKIE:
/* COOKIE RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
rankChange = 400;
herb = true;
rankChange = FoodRank2;
break;
case MELON:
/* MELON RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
rankChange = 400;
herb = true;
rankChange = FoodRank2;
break;
case MUSHROOM_SOUP:
/* MUSHROOM SOUP RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
rankChange = 200;
herb = true;
rankChange = FoodRank1;
break;
case CARROT_ITEM:
/* CARROT RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @ 1000 */
herb = true;
rankChange = FoodRank1;
break;
case POTATO_ITEM:
/* POTATO RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
herb = true;
rankChange = FoodRank2;
break;
case BAKED_POTATO:
/* BAKED POTATO RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
herb = true;
rankChange = FoodRank1;
break;
case POISONOUS_POTATO:
/* POISONOUS POTATO RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
herb = true;
rankChange = FoodRank2;
break;
case GOLDEN_CARROT:
/* GOLDEN CARROT RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
herb = true;
rankChange = FoodRank1;
break;
case PUMPKIN_PIE:
/* PUMPKIN PIE RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
herb = true;
rankChange = FoodRank1;
break;
case RAW_FISH:
/* RAW FISH RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
rankChange = FoodRank2;
fish = true;
break;
case COOKED_FISH:
/* COOKED FISH RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
rankChange = FoodRank1;
fish = true;
break;
default:
return;
}
for (int i = 200; i <= 1000; i += rankChange) {
if (herbLevel >= i) {
if (herb && !Permissions.farmersDiet(player)) {
return;
}
else if (fish && !Permissions.fishermansDiet(player)) {
return;
}
for (int i = FoodRank1; i <= FoodRankMax; i += rankChange) {
if ((herb && herbLevel >= i) || (fish && fishLevel >= i)) {
foodChange++;
}
}
@@ -299,8 +420,10 @@ public class EntityListener implements Listener {
public void onEntityTame(EntityTameEvent event) {
Player player = (Player) event.getOwner();
if (Permissions.getInstance().taming(player) && !event.getEntity().hasMetadata("mcmmoSummoned")) {
PlayerProfile PP = Users.getProfile(player);
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
if (Permissions.taming(player) && !mcMMO.placeStore.isSpawnedPet(event.getEntity())) {
PlayerProfile profile = Users.getProfile(player);
EntityType type = event.getEntityType();
int xp = 0;
@@ -317,8 +440,7 @@ public class EntityListener implements Listener {
break;
}
PP.addXP(player, SkillType.TAMING, xp);
Skills.XpCheckSkill(SkillType.TAMING, player);
Skills.xpProcessing(player, profile, SkillType.TAMING, xp);
}
}
}

View File

@@ -2,6 +2,7 @@ package com.gmail.nossr50.listeners;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
@@ -10,18 +11,23 @@ import com.gmail.nossr50.util.Hardcore;
import com.gmail.nossr50.util.Permissions;
public class HardcoreListener implements Listener {
@EventHandler()
public void PlayerDeathEvent(PlayerDeathEvent event) {
/**
* Monitor PlayerDeath events.
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity(); //Note this returns a Player object for this subevent
if(!Permissions.getInstance().hardcoremodeBypass(player)) {
if(player.getKiller() instanceof Player) {
if(Config.getInstance().getHardcoreVampirismEnabled()) {
Hardcore.invokeVampirism(((Player)player.getKiller()), player);
}
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
if (!Permissions.hardcoremodeBypass(player)) {
if (player.getKiller() != null && Config.getInstance().getHardcoreVampirismEnabled()) {
Hardcore.invokeVampirism(player.getKiller(), player);
}
Hardcore.invokeStatPenalty(player);
}
}

View File

@@ -1,19 +1,16 @@
package com.gmail.nossr50.listeners;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.event.player.PlayerFishEvent.State;
@@ -22,14 +19,13 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.general.XprateCommand;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.runnables.BleedTimer;
import com.gmail.nossr50.runnables.RemoveProfileFromMemoryTask;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
@@ -37,20 +33,20 @@ import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.skills.combat.Taming;
import com.gmail.nossr50.skills.gathering.BlastMining;
import com.gmail.nossr50.runnables.BleedTimer;
import com.gmail.nossr50.skills.gathering.Fishing;
import com.gmail.nossr50.skills.gathering.Herbalism;
import com.gmail.nossr50.skills.misc.Repair;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.repair.Salvage;
import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.Item;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.ModChecks;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
public class PlayerListener implements Listener {
private final mcMMO plugin;
public PlayerListener(final mcMMO plugin) {
@@ -65,18 +61,25 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerWorldChangeEvent(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
PlayerProfile PP = Users.getProfile(player);
if (PP.getGodMode()) {
if (!Permissions.getInstance().mcgod(player)) {
PP.toggleGodMode();
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
PlayerProfile profile = Users.getProfile(player);
if (profile == null) {
return;
}
if (profile.getGodMode()) {
if (!Permissions.mcgod(player)) {
profile.toggleGodMode();
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Forbidden"));
}
}
if (PP.inParty()) {
if (!Permissions.getInstance().party(player)) {
PP.removeParty();
if (profile.inParty()) {
if (!Permissions.party(player)) {
profile.removeParty();
player.sendMessage(LocaleLoader.getString("Party.Forbidden"));
}
}
@@ -89,9 +92,13 @@ public class PlayerListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerFish(PlayerFishEvent event) {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
int shakeUnlockLevel = advancedConfig.getShakeUnlockLevel();
Player player = event.getPlayer();
if (Permissions.getInstance().fishing(player)) {
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
if (Permissions.fishing(player)) {
State state = event.getState();
switch (state) {
@@ -100,7 +107,11 @@ public class PlayerListener implements Listener {
break;
case CAUGHT_ENTITY:
if (Users.getProfile(player).getSkillLevel(SkillType.FISHING) >= 150 && Permissions.getInstance().shakeMob(player)) {
if (!(event.getCaught() instanceof LivingEntity)) {
return;
}
if (Users.getProfile(player).getSkillLevel(SkillType.FISHING) >= shakeUnlockLevel && Permissions.shakeMob(player)) {
Fishing.shakeMob(event);
}
break;
@@ -118,8 +129,17 @@ public class PlayerListener implements Listener {
*/
@EventHandler(ignoreCancelled = true)
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
if (Users.getProfile(event.getPlayer()).getAbilityMode(AbilityType.BERSERK)) {
event.setCancelled(true);
if (event.getPlayer().hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
PlayerProfile profile = Users.getProfile(event.getPlayer());
if (profile == null) {
return;
}
if (profile.getAbilityMode(AbilityType.BERSERK)) {
event.setCancelled(true);
}
}
@@ -130,7 +150,8 @@ public class PlayerListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerLogin(PlayerLoginEvent event) {
Users.addUser(event.getPlayer());
if (event.getPlayer().hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
Users.addUser(event.getPlayer()).getProfile().actualizeRespawnATS();
}
/**
@@ -142,18 +163,12 @@ public class PlayerListener implements Listener {
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
/* GARBAGE COLLECTION */
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
//Remove Spout Stuff
if (Config.getInstance().spoutEnabled && SpoutStuff.playerHUDs.containsKey(player)) {
SpoutStuff.playerHUDs.remove(player);
}
/* GARBAGE COLLECTION */
//Bleed it out
BleedTimer.bleedOut(player);
//Schedule PlayerProfile removal 2 minutes after quitting
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RemoveProfileFromMemoryTask(player.getName()), 2400);
}
/**
@@ -165,19 +180,84 @@ public class PlayerListener implements Listener {
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (Permissions.getInstance().motd(player) && Config.getInstance().getMOTDEnabled()) {
player.sendMessage(ChatColor.GOLD+"Server is running "+ChatColor.GREEN+plugin.getName()+" "+plugin.getDescription().getVersion());
player.sendMessage(ChatColor.GOLD+"http://www.mcmmo.info"+ChatColor.DARK_AQUA+" - mcMMO Website");
//player.sendMessage(LocaleLoader.getString("mcMMO.MOTD", new Object[] {plugin.getDescription().getVersion()}));
//player.sendMessage(LocaleLoader.getString("mcMMO.Website"));
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(LocaleLoader.getString("MOTD.Version", new Object[] {plugin.getDescription().getVersion()}));
if (Config.getInstance().getHardcoreEnabled()) {
if (Config.getInstance().getHardcoreVampirismEnabled()) {
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.VampireOn"));
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Stats", new Object[] {Config.getInstance().getHardcoreDeathStatPenaltyPercentage()}));
player.sendMessage(LocaleLoader.getString("MOTD.Vampire.Stats", new Object[] {Config.getInstance().getHardcoreVampirismStatLeechPercentage()}));
}
else {
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.VampireOff"));
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Stats", new Object[] {Config.getInstance().getHardcoreDeathStatPenaltyPercentage()}));
}
}
if (Permissions.xpQuadruple(player)) {
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", new Object[] { 4 }) }));
}
else if (Permissions.xpTriple(player)) {
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", new Object[] { 3 }) }));
}
else if (Permissions.xpDoubleAndOneHalf(player)) {
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", new Object[] { 2.5 }) }));
}
else if (Permissions.xpDouble(player)) {
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", new Object[] { 2 }) }));
}
else if (Permissions.xpOneAndOneHalf(player)) {
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", new Object[] { 1.5 }) }));
}
if (Permissions.cooldownsHalved(player)) {
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.cooldowns.name"), LocaleLoader.getString("Perks.cooldowns.desc", new Object[] { "1/2" }) }));
}
else if (Permissions.cooldownsThirded(player)) {
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.cooldowns.name"), LocaleLoader.getString("Perks.cooldowns.desc", new Object[] { "1/3" }) }));
}
else if (Permissions.cooldownsQuartered(player)) {
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.cooldowns.name"), LocaleLoader.getString("Perks.cooldowns.desc", new Object[] { "1/4" }) }));
}
if (Permissions.activationTwelve(player)) {
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.activationtime.name"), LocaleLoader.getString("Perks.activationtime.desc", new Object[] { 12 }) }));
}
else if (Permissions.activationEight(player)) {
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.activationtime.name"), LocaleLoader.getString("Perks.activationtime.desc", new Object[] { 8 }) }));
}
else if (Permissions.activationFour(player)) {
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.activationtime.name"), LocaleLoader.getString("Perks.activationtime.desc", new Object[] { 4 }) }));
}
if (Permissions.luckyAcrobatics(player) || Permissions.luckyArchery(player) || Permissions.luckyAxes(player) || Permissions.luckyFishing(player) || Permissions.luckyHerbalism(player) || Permissions.luckyMining(player) || Permissions.luckyRepair(player) || Permissions.luckySwords(player) || Permissions.luckyTaming(player) || Permissions.luckyUnarmed(player) || Permissions.luckyWoodcutting(player)) {
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc.login") }));
}
player.sendMessage(LocaleLoader.getString("MOTD.Website", new Object[] {plugin.getDescription().getWebsite()}));
}
//THIS IS VERY BAD WAY TO DO THINGS, NEED BETTER WAY
if (XprateCommand.xpevent) {
if (XprateCommand.isXpEventRunning()) {
player.sendMessage(LocaleLoader.getString("XPRate.Event", new Object[] {Config.getInstance().xpGainMultiplier}));
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerRespawn(PlayerRespawnEvent event) {
if (event.getPlayer().hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
PlayerProfile profile = Users.getProfile(event.getPlayer());
if (profile != null) {
profile.actualizeRespawnATS();
}
}
/**
* Monitor PlayerInteract events.
*
@@ -186,37 +266,36 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.LOW)
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
Action action = event.getAction();
Block block = event.getClickedBlock();
ItemStack is = player.getItemInHand();
Material mat;
ItemStack inHand = player.getItemInHand();
Material material;
/* Fix for NPE on interacting with air */
if (block == null) {
mat = Material.AIR;
material = Material.AIR;
}
else {
mat = block.getType();
material = block.getType();
}
switch (action) {
case RIGHT_CLICK_BLOCK:
/* REPAIR CHECKS */
if (Permissions.getInstance().repair(player) && block.getTypeId() == Config.getInstance().getRepairAnvilId()) {
if (ItemChecks.isTool(is) || ItemChecks.isArmor(is)) {
Repair.repairCheck(player, is);
if (Permissions.repair(player) && block.getTypeId() == Config.getInstance().getRepairAnvilId()) {
if (mcMMO.repairManager.isRepairable(inHand)) {
mcMMO.repairManager.handleRepair(player, inHand);
event.setCancelled(true);
player.updateInventory();
}
else if (Config.getInstance().getToolModsEnabled() && ItemChecks.isCustomTool(is) && ModChecks.getToolFromItemStack(is).isRepairable()) {
Repair.repairCheck(player, is);
event.setCancelled(true);
player.updateInventory();
}
else if (Config.getInstance().getArmorModsEnabled() && ItemChecks.isCustomArmor(is) && ModChecks.getArmorFromItemStack(is).isRepairable()) {
Repair.repairCheck(player, is);
}
/* SALVAGE CHECKS */
if (Permissions.salvage(player) && block.getTypeId() == Config.getInstance().getSalvageAnvilId()) {
if (Salvage.isSalvageable(inHand)) {
final Location location = block.getLocation();
Salvage.handleSalvage(player, location, inHand);
event.setCancelled(true);
player.updateInventory();
}
@@ -224,7 +303,7 @@ public class PlayerListener implements Listener {
/* ACTIVATION CHECKS */
if (Config.getInstance().getAbilitiesEnabled() && BlockChecks.abilityBlockCheck(block)) {
if (!mat.equals(Material.DIRT) && !mat.equals(Material.GRASS) && !mat.equals(Material.SOIL)) {
if (!material.equals(Material.DIRT) && !material.equals(Material.GRASS) && !material.equals(Material.SOIL)) {
Skills.activationCheck(player, SkillType.HERBALISM);
}
@@ -237,8 +316,8 @@ public class PlayerListener implements Listener {
}
/* GREEN THUMB CHECK */
if (Permissions.getInstance().greenThumbBlocks(player) && BlockChecks.makeMossy(block) && is.getType().equals(Material.SEEDS)) {
Herbalism.greenThumbBlocks(is, player, block);
if (inHand.getType().equals(Material.SEEDS) && BlockChecks.makeMossy(block) && Permissions.greenThumbBlocks(player)) {
Herbalism.greenThumbBlocks(inHand, player, block);
}
/* ITEM CHECKS */
@@ -247,8 +326,9 @@ public class PlayerListener implements Listener {
}
/* BLAST MINING CHECK */
if (player.isSneaking() && Permissions.getInstance().blastMining(player) && is.getTypeId() == Config.getInstance().getDetonatorItemID()) {
BlastMining.detonate(event, player, plugin);
if (player.isSneaking() && inHand.getTypeId() == Config.getInstance().getDetonatorItemID() && Permissions.blastMining(player)) {
MiningManager miningManager = new MiningManager(player);
miningManager.detonate(event);
}
break;
@@ -270,8 +350,9 @@ public class PlayerListener implements Listener {
Item.itemChecks(player);
/* BLAST MINING CHECK */
if (player.isSneaking() && Permissions.getInstance().blastMining(player) && is.getTypeId() == Config.getInstance().getDetonatorItemID()) {
BlastMining.detonate(event, player, plugin);
if (player.isSneaking() && inHand.getTypeId() == Config.getInstance().getDetonatorItemID() && Permissions.blastMining(player)) {
MiningManager miningManager = new MiningManager(player);
miningManager.detonate(event);
}
break;
@@ -280,12 +361,16 @@ public class PlayerListener implements Listener {
case LEFT_CLICK_BLOCK:
/* CALL OF THE WILD CHECKS */
if (player.isSneaking() && Permissions.getInstance().taming(player)) {
if (is.getType().equals(Material.RAW_FISH)) {
Taming.animalSummon(EntityType.OCELOT, player, plugin);
if (player.isSneaking()) {
Material type = inHand.getType();
if (type == Material.RAW_FISH) {
TamingManager tamingManager = new TamingManager(player);
tamingManager.summonOcelot();
}
else if (is.getType().equals(Material.BONE)) {
Taming.animalSummon(EntityType.WOLF, player, plugin);
else if (type == Material.BONE) {
TamingManager tamingManager = new TamingManager(player);
tamingManager.summonWolf();
}
}
@@ -302,57 +387,60 @@ public class PlayerListener implements Listener {
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerChat(PlayerChatEvent event) {
public void onPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
PlayerProfile PP = Users.getProfile(player);
if (PP.getPartyChatMode()) {
if (!PP.inParty()) {
player.sendMessage("You're not in a party, type /p to leave party chat mode."); //TODO: Use mcLocale
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
PlayerProfile profile = Users.getProfile(player);
if (profile == null) {
return;
}
if (profile.getPartyChatMode()) {
Party party = profile.getParty();
if (party == null) {
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return;
}
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), PP.getParty(), event.getMessage());
String partyName = party.getName();
String playerName = player.getName();
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(playerName, partyName, event.getMessage());
plugin.getServer().getPluginManager().callEvent(chatEvent);
if (chatEvent.isCancelled()) {
return;
}
event.setMessage(chatEvent.getMessage());
plugin.getLogger().info("[P](" + partyName + ")" + "<" + playerName + "> " + chatEvent.getMessage());
Set<Player> intendedRecipients = new HashSet<Player>();
for (Player x : Party.getInstance().getOnlineMembers(player)) {
intendedRecipients.add(x);
for (Player member : party.getOnlineMembers()) {
member.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Prefix", new Object[] {playerName}) + chatEvent.getMessage());
}
ChatColor bracketColor = ChatColor.GREEN;
event.setFormat(bracketColor + "(" + ChatColor.WHITE + "%1$s" + bracketColor + ") %2$s");
event.getRecipients().retainAll(intendedRecipients);
} else if (PP.getAdminChatMode()) {
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), event.getMessage());
event.setCancelled(true);
}
else if (profile.getAdminChatMode()) {
String playerName = player.getName();
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(playerName, event.getMessage());
plugin.getServer().getPluginManager().callEvent(chatEvent);
if (chatEvent.isCancelled()) {
return;
}
event.setMessage(chatEvent.getMessage());
plugin.getLogger().info("[A]<" + playerName + "> " + chatEvent.getMessage());
Set<Player> intendedRecipients = new HashSet<Player>();
for (Player x : plugin.getServer().getOnlinePlayers()) {
if (x.isOp() || Permissions.getInstance().adminChat(x)) {
intendedRecipients.add(x);
for (Player otherPlayer : plugin.getServer().getOnlinePlayers()) {
if (Permissions.adminChat(otherPlayer) || otherPlayer.isOp()) {
otherPlayer.sendMessage(LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {playerName}) + chatEvent.getMessage());
}
}
ChatColor bracketColor = ChatColor.AQUA;
event.setFormat(bracketColor + "{" + ChatColor.WHITE + "%1$s" + bracketColor + "} %2$s");
event.getRecipients().retainAll(intendedRecipients);
event.setCancelled(true);
}
}
@@ -365,14 +453,15 @@ public class PlayerListener implements Listener {
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
String message = event.getMessage();
String command = message.substring(1).split(" ")[0];
String lowerCaseCommand = command.toLowerCase();
if (plugin.aliasMap.containsKey(command.toLowerCase())) {
if (plugin.commandIsAliased(lowerCaseCommand)) {
//We should find a better way to avoid string replacement where the alias is equals to the command
if (command.equals(plugin.aliasMap.get(command.toLowerCase()))) {
if (command.equals(plugin.getCommandAlias(lowerCaseCommand))) {
return;
}
event.setMessage(message.replace(command, plugin.aliasMap.get(command.toLowerCase())));
event.setMessage(message.replace(command, plugin.getCommandAlias(lowerCaseCommand)));
}
}
}

View File

@@ -19,7 +19,7 @@ public class SelfListener implements Listener {
public void onPlayerXpGain(McMMOPlayerXpGainEvent event) {
int xp = event.getXpGained();
if(xp < 0) {
if (xp < 0) {
try {
throw new Exception("Gained negative XP!");
}

View File

@@ -1,48 +0,0 @@
package com.gmail.nossr50.listeners;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.getspout.spoutapi.event.input.KeyPressedEvent;
import org.getspout.spoutapi.gui.ScreenType;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.popups.PopupMMO;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.Users;
public class SpoutInputListener implements Listener {
private mcMMO plugin;
public SpoutInputListener(mcMMO plugin) {
this.plugin = plugin;
}
/**
* Monitor Spout KeyPressed events.
*
* @param event The event to watch
*/
@EventHandler
public void onKeyPressedEvent(KeyPressedEvent event) {
SpoutPlayer sPlayer = event.getPlayer();
if (!sPlayer.isSpoutCraftEnabled() || sPlayer.getMainScreen().getActivePopup() != null || event.getScreenType() != ScreenType.GAME_SCREEN) {
return;
}
if (event.getKey() == SpoutStuff.keypress) {
if (!SpoutStuff.playerScreens.containsKey(sPlayer)) {
PopupMMO mmoPop = new PopupMMO(sPlayer, Users.getProfile(sPlayer), plugin);
SpoutStuff.playerScreens.put(sPlayer, mmoPop);
sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer));
sPlayer.getMainScreen().setDirty(true);
}
else {
sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer));
sPlayer.getMainScreen().setDirty(true);
}
}
}
}

View File

@@ -1,26 +1,26 @@
package com.gmail.nossr50.listeners;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.getspout.spoutapi.event.input.KeyPressedEvent;
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
import org.getspout.spoutapi.event.screen.ScreenCloseEvent;
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
import org.getspout.spoutapi.gui.Button;
import org.getspout.spoutapi.gui.ScreenType;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.HUDmmo;
import com.gmail.nossr50.config.SpoutConfig;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.SpoutHud;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.buttons.McmmoButton;
import com.gmail.nossr50.datatypes.popups.Menu;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.Users;
public class SpoutListener implements Listener {
//Why do we have this here? We never use it...
mcMMO plugin = null;
public SpoutListener(mcMMO pluginx) {
plugin = pluginx;
}
/**
* Monitor SpoutCraftEnable events.
*
@@ -28,19 +28,66 @@ public class SpoutListener implements Listener {
*/
@EventHandler
public void onSpoutCraftEnable(SpoutCraftEnableEvent event) {
SpoutPlayer sPlayer = event.getPlayer();
PlayerProfile PPs = Users.getProfile(sPlayer);
SpoutPlayer spoutPlayer = event.getPlayer();
McMMOPlayer mcMMOPlayer = Users.getPlayer(spoutPlayer);
PlayerProfile profile = mcMMOPlayer.getProfile();
//TODO: Add custom titles based on skills
if (Config.getInstance().getShowPowerLevelForSpout()) {
sPlayer.setTitle(sPlayer.getName()+ "\n" + ChatColor.YELLOW + "P" + ChatColor.GOLD + "lvl"
+ ChatColor.WHITE+"." + ChatColor.GREEN + String.valueOf(PPs.getPowerLevel()));
if (SpoutConfig.getInstance().getShowPowerLevel()) {
spoutPlayer.setTitle(LocaleLoader.getString("Spout.Title", new Object[] {spoutPlayer.getName(), mcMMOPlayer.getPowerLevel()}));
}
if (sPlayer.isSpoutCraftEnabled()) {
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin)); //Setup Party HUD stuff
PPs.toggleSpoutEnabled();
profile.setSpoutHud(new SpoutHud(mcMMOPlayer)); //Setup Party HUD stuff
}
/**
* Monitor Spout ButtonClick events.
*
* @param event The event to watch
*/
@EventHandler
public void onButtonClick(ButtonClickEvent event) {
Button button = event.getButton();
if (button instanceof McmmoButton) {
((McmmoButton) button).activate();
}
}
}
/**
* Monitor Spout ScreenClose events.
*
* @param event The event to watch
*/
@EventHandler
public void onScreenClose(ScreenCloseEvent event) {
if (event.getScreen() instanceof Menu) {
SpoutPlayer spoutPlayer = event.getPlayer();
Users.getProfile(spoutPlayer).getSpoutHud().onMenuClose();
spoutPlayer.getMainScreen().setDirty(true);
}
}
/**
* Monitor Spout KeyPressed events.
*
* @param event The event to watch
*/
@EventHandler
public void onKeyPressedEvent(KeyPressedEvent event) {
SpoutPlayer spoutPlayer = event.getPlayer();
if (spoutPlayer.getMainScreen().getActivePopup() != null || event.getScreenType() != ScreenType.GAME_SCREEN) {
return;
}
if (event.getKey() == SpoutStuff.keypress) {
SpoutHud spoutHud = Users.getProfile(spoutPlayer).getSpoutHud();
if (!spoutHud.isMenuOpened()) {
spoutHud.openMenu();
}
}
}
}

View File

@@ -1,91 +0,0 @@
package com.gmail.nossr50.listeners;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
import org.getspout.spoutapi.event.screen.ScreenCloseEvent;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.HUDType;
import com.gmail.nossr50.datatypes.HUDmmo;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.buttons.ButtonEscape;
import com.gmail.nossr50.datatypes.buttons.ButtonHUDStyle;
import com.gmail.nossr50.datatypes.buttons.ButtonPartyToggle;
import com.gmail.nossr50.datatypes.popups.PopupMMO;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.Users;
public class SpoutScreenListener implements Listener {
//Why do we have this here? We never use it...
mcMMO plugin = null;
public SpoutScreenListener(mcMMO pluginx) {
plugin = pluginx;
}
/**
* Monitor Spout ButtonClick events.
*
* @param event The event to watch
*/
@EventHandler
public void onButtonClick(ButtonClickEvent event) {
SpoutPlayer sPlayer = event.getPlayer();
PlayerProfile PP = Users.getProfile(sPlayer);
if (event.getButton() instanceof ButtonHUDStyle) {
if (SpoutStuff.playerHUDs.containsKey(sPlayer)) {
SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
SpoutStuff.playerHUDs.remove(sPlayer);
switch (PP.getHUDType()) {
case RETRO:
PP.setHUDType(HUDType.STANDARD);
break;
case STANDARD:
PP.setHUDType(HUDType.SMALL);
break;
case SMALL:
PP.setHUDType(HUDType.DISABLED);
break;
case DISABLED:
PP.setHUDType(HUDType.RETRO);
break;
default:
break;
}
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin));
SpoutStuff.playerScreens.get(sPlayer).updateButtons(PP);
}
}
else if (event.getButton() instanceof ButtonEscape) {
sPlayer.getMainScreen().closePopup();
}
else if (event.getButton() instanceof ButtonPartyToggle) {
PP.togglePartyHUD();
ButtonPartyToggle bpt = (ButtonPartyToggle) event.getButton();
bpt.updateText(PP);
SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
SpoutStuff.playerHUDs.get(sPlayer).initializeHUD(sPlayer);
}
}
/**
* Monitor Spout ScreenClose events.
*
* @param event The event to watch
*/
@EventHandler
public void onScreenClose(ScreenCloseEvent event) {
if (event.getScreen() instanceof PopupMMO) {
SpoutStuff.playerScreens.remove(event.getPlayer());
}
}
}

View File

@@ -1,24 +1,54 @@
package com.gmail.nossr50.listeners;
import java.io.File;
import java.util.ArrayList;
import org.bukkit.TreeType;
import org.bukkit.block.BlockState;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.event.world.WorldSaveEvent;
import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.event.world.WorldInitEvent;
import org.bukkit.event.world.WorldUnloadEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.blockstoreconversion.BlockStoreConversionMain;
public class WorldListener implements Listener {
@EventHandler
public void onWorldLoad(WorldLoadEvent event) {
File dataDir = new File(event.getWorld().getWorldFolder(), "mcmmo_data");
if(!dataDir.exists()) {
dataDir.mkdir();
ArrayList<BlockStoreConversionMain> converters = new ArrayList<BlockStoreConversionMain>();
@EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onStructureGrow(StructureGrowEvent event) {
TreeType species = event.getSpecies();
if (species == TreeType.BROWN_MUSHROOM || species == TreeType.RED_MUSHROOM) {
return;
}
if (mcMMO.placeStore.isTrue(event.getLocation().getBlock())) {
for (BlockState block : event.getBlocks()) {
mcMMO.placeStore.setFalse(block.getBlock());
}
}
}
@EventHandler
public void onWorldInit(WorldInitEvent event) {
File dataDir = new File(event.getWorld().getWorldFolder(), "mcmmo_data");
if (!dataDir.exists()) {
return;
}
if (mcMMO.p == null)
return;
mcMMO.p.getLogger().info("Converting block storage for " + event.getWorld().getName() + " to a new format.");
BlockStoreConversionMain converter = new BlockStoreConversionMain(event.getWorld());
converter.run();
converters.add(converter);
}
@EventHandler
@@ -26,18 +56,21 @@ public class WorldListener implements Listener {
mcMMO.placeStore.unloadWorld(event.getWorld());
}
// This gets called every 45 seconds, by default.
// The call can and does result in excessive lag, especially on larger servers.
//@EventHandler
//public void onWorldSave(WorldSaveEvent event) {
// mcMMO.placeStore.saveWorld(event.getWorld());
//}
@EventHandler
public void onWorldSave(WorldSaveEvent event) {
mcMMO.placeStore.saveWorld(event.getWorld());
public void onChunkUnload(ChunkUnloadEvent event) {
mcMMO.placeStore.chunkUnloaded(event.getChunk().getX(), event.getChunk().getZ(), event.getWorld());
}
@EventHandler
public void onChunkLoad(ChunkLoadEvent event) {
mcMMO.placeStore.chunkLoaded(event.getChunk().getX(), event.getChunk().getZ(), event.getChunk().getWorld());
}
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event) {
mcMMO.placeStore.chunkUnloaded(event.getChunk().getX(), event.getChunk().getZ(), event.getChunk().getWorld());
if (event.getChunk().getEntities().length > 0)
mcMMO.placeStore.loadChunk(event.getChunk().getX(), event.getChunk().getZ(), event.getWorld());
}
}

View File

@@ -75,6 +75,12 @@ public class LocaleLoader {
input = input.replaceAll("\\Q[[LIGHT_PURPLE]]\\E", ChatColor.LIGHT_PURPLE.toString());
input = input.replaceAll("\\Q[[YELLOW]]\\E", ChatColor.YELLOW.toString());
input = input.replaceAll("\\Q[[WHITE]]\\E", ChatColor.WHITE.toString());
input = input.replaceAll("\\Q[[BOLD]]\\E", ChatColor.BOLD.toString());
input = input.replaceAll("\\Q[[UNDERLINE]]\\E", ChatColor.UNDERLINE.toString());
input = input.replaceAll("\\Q[[ITALIC]]\\E", ChatColor.ITALIC.toString());
input = input.replaceAll("\\Q[[STRIKE]]\\E", ChatColor.STRIKETHROUGH.toString());
input = input.replaceAll("\\Q[[MAGIC]]\\E", ChatColor.MAGIC.toString());
input = input.replaceAll("\\Q[[RESET]]\\E", ChatColor.RESET.toString());
return input;
}

View File

@@ -1,72 +1,124 @@
package com.gmail.nossr50;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.skills.*;
import com.gmail.nossr50.commands.spout.*;
import com.gmail.nossr50.commands.mc.*;
import com.gmail.nossr50.commands.party.*;
import com.gmail.nossr50.commands.general.*;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.shatteredlands.shatt.backup.ZipLibrary;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;
import com.gmail.nossr50.commands.general.AddlevelsCommand;
import com.gmail.nossr50.commands.general.AddxpCommand;
import com.gmail.nossr50.commands.general.InspectCommand;
import com.gmail.nossr50.commands.general.McstatsCommand;
import com.gmail.nossr50.commands.general.MmoeditCommand;
import com.gmail.nossr50.commands.general.MmoupdateCommand;
import com.gmail.nossr50.commands.general.SkillResetCommand;
import com.gmail.nossr50.commands.general.XprateCommand;
import com.gmail.nossr50.commands.mc.McabilityCommand;
import com.gmail.nossr50.commands.mc.MccCommand;
import com.gmail.nossr50.commands.mc.McgodCommand;
import com.gmail.nossr50.commands.mc.McmmoCommand;
import com.gmail.nossr50.commands.mc.McpurgeCommand;
import com.gmail.nossr50.commands.mc.McrankCommand;
import com.gmail.nossr50.commands.mc.McrefreshCommand;
import com.gmail.nossr50.commands.mc.McremoveCommand;
import com.gmail.nossr50.commands.mc.MctopCommand;
import com.gmail.nossr50.commands.party.ACommand;
import com.gmail.nossr50.commands.party.AcceptCommand;
import com.gmail.nossr50.commands.party.InviteCommand;
import com.gmail.nossr50.commands.party.PCommand;
import com.gmail.nossr50.commands.party.PartyCommand;
import com.gmail.nossr50.commands.party.PtpCommand;
import com.gmail.nossr50.commands.skills.AcrobaticsCommand;
import com.gmail.nossr50.commands.skills.ArcheryCommand;
import com.gmail.nossr50.commands.skills.AxesCommand;
import com.gmail.nossr50.commands.skills.ExcavationCommand;
import com.gmail.nossr50.commands.skills.FishingCommand;
import com.gmail.nossr50.commands.skills.HerbalismCommand;
import com.gmail.nossr50.commands.skills.MiningCommand;
import com.gmail.nossr50.commands.skills.RepairCommand;
import com.gmail.nossr50.commands.skills.SwordsCommand;
import com.gmail.nossr50.commands.skills.TamingCommand;
import com.gmail.nossr50.commands.skills.UnarmedCommand;
import com.gmail.nossr50.commands.skills.WoodcuttingCommand;
import com.gmail.nossr50.commands.spout.MchudCommand;
import com.gmail.nossr50.commands.spout.XplockCommand;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.config.TreasuresConfig;
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
import com.gmail.nossr50.config.mods.CustomArmorConfig;
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
import com.gmail.nossr50.config.mods.CustomToolsConfig;
import com.gmail.nossr50.runnables.*;
import com.gmail.nossr50.util.Database;
import com.gmail.nossr50.util.Leaderboard;
import com.gmail.nossr50.util.Metrics;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.util.blockmeta.ChunkletManager;
import com.gmail.nossr50.util.blockmeta.ChunkletManagerFactory;
import com.gmail.nossr50.config.repair.RepairConfigManager;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.listeners.BlockListener;
import com.gmail.nossr50.listeners.EntityListener;
import com.gmail.nossr50.listeners.HardcoreListener;
import com.gmail.nossr50.listeners.PlayerListener;
import com.gmail.nossr50.listeners.WorldListener;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.BleedTimer;
import com.gmail.nossr50.runnables.MobStoreCleaner;
import com.gmail.nossr50.runnables.SaveTimer;
import com.gmail.nossr50.runnables.SkillMonitor;
import com.gmail.nossr50.runnables.SpoutStart;
import com.gmail.nossr50.runnables.UserPurgeTask;
import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.repair.RepairManagerFactory;
import com.gmail.nossr50.skills.repair.Repairable;
import com.gmail.nossr50.util.Anniversary;
import com.gmail.nossr50.util.Database;
import com.gmail.nossr50.util.Leaderboard;
import com.gmail.nossr50.util.Metrics;
import com.gmail.nossr50.util.Metrics.Graph;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
import net.shatteredlands.shatt.backup.ZipLibrary;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
public class mcMMO extends JavaPlugin {
private final PlayerListener playerListener = new PlayerListener(this);
private final BlockListener blockListener = new BlockListener(this);
private final EntityListener entityListener = new EntityListener(this);
private final WorldListener worldListener = new WorldListener();
private final HardcoreListener hardcoreListener = new HardcoreListener();
public HashMap<String, String> aliasMap = new HashMap<String, String>(); //Alias - Command
public HashMap<Integer, Player> tntTracker = new HashMap<Integer, Player>();
private HashMap<String, String> aliasMap = new HashMap<String, String>(); //Alias - Command
private HashMap<Integer, String> tntTracker = new HashMap<Integer, String>();
public static File versionFile;
public static Database database;
private static Database database;
public static mcMMO p;
public static ChunkletManager placeStore;
public static ChunkManager placeStore;
public static RepairManager repairManager;
/* Jar Stuff */
public File mcmmo;
public static File mcmmo;
//File Paths
public String mainDirectory, flatFileDirectory, usersFile, leaderboardDirectory, modDirectory;
private static String mainDirectory;
private static String flatFileDirectory;
private static String usersFile;
private static String modDirectory;
//Spout Check
public static boolean spoutEnabled;
/**
* Things to be run when the plugin is enabled.
*/
@Override
public void onEnable() {
p = this;
setupFilePaths();
@@ -74,68 +126,112 @@ public class mcMMO extends JavaPlugin {
//Force the loading of config files
Config configInstance = Config.getInstance();
TreasuresConfig.getInstance();
HiddenConfig.getInstance();
AdvancedConfig.getInstance();
List<Repairable> repairables = new ArrayList<Repairable>();
if (configInstance.getToolModsEnabled()) {
CustomToolsConfig.getInstance().load();
repairables.addAll(CustomToolsConfig.getInstance().getLoadedRepairables());
}
if (configInstance.getArmorModsEnabled()) {
CustomArmorConfig.getInstance().load();
repairables.addAll(CustomArmorConfig.getInstance().getLoadedRepairables());
}
if (configInstance.getBlockModsEnabled()) {
CustomBlocksConfig.getInstance().load();
CustomBlocksConfig.getInstance();
}
//Load repair configs, make manager, and register them at this time
RepairConfigManager rManager = new RepairConfigManager(this);
repairables.addAll(rManager.getLoadedRepairables());
repairManager = RepairManagerFactory.getRepairManager(repairables.size());
repairManager.registerRepairables(repairables);
//Check if Repair Anvil and Salvage Anvil have different itemID's
if (configInstance.getSalvageAnvilId() == configInstance.getRepairAnvilId()) {
getLogger().warning("Can't use the same itemID for Repair/Salvage Anvils!");
}
if (!configInstance.getUseMySQL()) {
Users.loadUsers();
}
PluginManager pm = getServer().getPluginManager();
PluginManager pluginManager = getServer().getPluginManager();
//Register events
pm.registerEvents(playerListener, this);
pm.registerEvents(blockListener, this);
pm.registerEvents(entityListener, this);
pm.registerEvents(worldListener, this);
pluginManager.registerEvents(playerListener, this);
pluginManager.registerEvents(blockListener, this);
pluginManager.registerEvents(entityListener, this);
pluginManager.registerEvents(worldListener, this);
if (configInstance.getHardcoreEnabled()) {
pm.registerEvents(hardcoreListener, this);
pluginManager.registerEvents(hardcoreListener, this);
}
PluginDescriptionFile pdfFile = getDescription();
//Setup the leaderboards
//Setup the leader boards
if (configInstance.getUseMySQL()) {
database = new Database(this);
database.createStructure();
}
else {
Leaderboard.makeLeaderboards();
Leaderboard.updateLeaderboards();
}
for (Player player : getServer().getOnlinePlayers()) {
Users.addUser(player); //In case of reload add all users back into PlayerProfile
}
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
getLogger().info("Version " + pdfFile.getVersion() + " is enabled!");
BukkitScheduler scheduler = getServer().getScheduler();
//Schedule Spout Activation 1 second after start-up
scheduler.scheduleSyncDelayedTask(this, new SpoutStart(this), 20);
//Periodic save timer (Saves every 10 minutes)
//Periodic save timer (Saves every 10 minutes by default)
scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(this), 0, configInstance.getSaveInterval() * 1200);
//Regen & Cooldown timer (Runs every second)
scheduler.scheduleSyncRepeatingTask(this, new SkillMonitor(this), 0, 20);
//Bleed timer (Runs every two seconds)
scheduler.scheduleSyncRepeatingTask(this, new BleedTimer(), 0, 40);
//Old & Powerless User remover
int purgeInterval = Config.getInstance().getPurgeInterval();
if (purgeInterval == 0) {
scheduler.scheduleSyncDelayedTask(this, new UserPurgeTask(), 40); //Start 2 seconds after startup.
}
else if (purgeInterval > 0) {
scheduler.scheduleSyncRepeatingTask(this, new UserPurgeTask(), 0, purgeInterval * 60L * 60L * 20L);
}
registerCommands();
if (configInstance.getStatsTrackingEnabled()) {
try {
Metrics metrics = new Metrics(this);
Graph graph = metrics.createGraph("Percentage of servers using timings");
if (pluginManager.useTimings()) {
graph.addPlotter(new Metrics.Plotter("Enabled") {
@Override
public int getValue() {
return 1;
}
});
}
else {
graph.addPlotter(new Metrics.Plotter("Disabled") {
@Override
public int getValue() {
return 1;
}
});
}
metrics.start();
}
catch (IOException e) {
@@ -144,30 +240,27 @@ public class mcMMO extends JavaPlugin {
}
// Get our ChunkletManager
placeStore = ChunkletManagerFactory.getChunkletManager();
placeStore = ChunkManagerFactory.getChunkManager();
// Automatically starts and stores itself
new MobStoreCleaner();
// Create Anniversary files
Anniversary anniversary = new Anniversary();
anniversary.createAnniversaryFile();
}
/**
* Setup the various storage file paths
*/
public void setupFilePaths() {
mcmmo = getFile();
mainDirectory = getDataFolder().getPath() + File.separator;
flatFileDirectory = mainDirectory + "FlatFileStuff" + File.separator;
usersFile = flatFileDirectory + "mcmmo.users";
leaderboardDirectory = flatFileDirectory + "Leaderboards" + File.separator;
modDirectory = mainDirectory + "ModConfigs" + File.separator;
}
/**
* Get profile of the player.
* </br>
* This function is designed for API usage.
*
* @param player Player whose profile to get
* @return the PlayerProfile object
*/
public PlayerProfile getPlayerProfile(Player player) {
return Users.getProfile(player);
}
/**
* Get profile of the player by name.
* </br>
@@ -176,38 +269,45 @@ public class mcMMO extends JavaPlugin {
* @param playerName Name of player whose profile to get
* @return the PlayerProfile object
*/
public PlayerProfile getPlayerProfileByName(String playerName) {
return Users.getProfileByName(playerName);
public PlayerProfile getPlayerProfile(String playerName) {
return Users.getProfile(playerName);
}
/**
* Get profile of the offline player.
* Get profile of the player.
* </br>
* This function is designed for API usage.
*
* @param player Offline player whose profile to get
* @param player player whose profile to get
* @return the PlayerProfile object
*/
public PlayerProfile getOfflinePlayerProfile(OfflinePlayer player) {
public PlayerProfile getPlayerProfile(OfflinePlayer player) {
return Users.getProfile(player);
}
/**
* Get profile of the player.
* </br>
* This function is designed for API usage.
*
* @param player player whose profile to get
* @return the PlayerProfile object
*/
@Deprecated
public PlayerProfile getPlayerProfile(Player player) {
return Users.getProfile(player);
}
/**
* Things to be run when the plugin is disabled.
*/
@Override
public void onDisable() {
//Make sure to save player information if the server shuts down
for (PlayerProfile x : Users.getProfiles().values()) {
x.save();
}
Users.saveAll(); //Make sure to save player information if the server shuts down
PartyManager.getInstance().saveParties();
getServer().getScheduler().cancelTasks(this); //This removes our tasks
//Save our metadata
placeStore.saveAll();
//Cleanup empty metadata stores
placeStore.cleanUp();
placeStore.saveAll(); //Save our metadata
placeStore.cleanUp(); //Cleanup empty metadata stores
//Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
try {
@@ -216,8 +316,10 @@ public class mcMMO extends JavaPlugin {
catch (IOException e) {
getLogger().severe(e.toString());
}
Anniversary anniversary = new Anniversary();
anniversary.saveAnniversaryFiles();
System.out.println("mcMMO was disabled."); //How informative!
getLogger().info("Was disabled."); //How informative!
}
/**
@@ -257,6 +359,9 @@ public class mcMMO extends JavaPlugin {
Config configInstance = Config.getInstance();
//mc* commands
if (configInstance.getCommandMCPurgeEnabled()) {
getCommand("mcpurge").setExecutor(new McpurgeCommand());
}
if (configInstance.getCommandMCRemoveEnabled()) {
getCommand("mcremove").setExecutor(new McremoveCommand(this));
}
@@ -284,11 +389,19 @@ public class mcMMO extends JavaPlugin {
if (configInstance.getCommandMCTopEnabled()) {
getCommand("mctop").setExecutor(new MctopCommand());
}
if(configInstance.getCommandMCRankEnabled()) {
getCommand("mcrank").setExecutor(new McrankCommand());
}
if (configInstance.getCommandMCStatsEnabled()) {
getCommand("mcstats").setExecutor(new McstatsCommand());
}
if (configInstance.getCommandSkillResetEnabled()) {
getCommand("skillreset").setExecutor(new SkillResetCommand());
}
//Party commands
if (configInstance.getCommandAcceptEnabled()) {
getCommand("accept").setExecutor(new AcceptCommand(this));
@@ -324,11 +437,11 @@ public class mcMMO extends JavaPlugin {
}
if (configInstance.getCommandMmoeditEnabled()) {
getCommand("mmoedit").setExecutor(new MmoeditCommand(this));
getCommand("mmoedit").setExecutor(new MmoeditCommand());
}
if (configInstance.getCommandInspectEnabled()) {
getCommand("inspect").setExecutor(new InspectCommand(this));
getCommand("inspect").setExecutor(new InspectCommand());
}
if (configInstance.getCommandXPRateEnabled()) {
@@ -342,223 +455,86 @@ public class mcMMO extends JavaPlugin {
getCommand("xplock").setExecutor(new XplockCommand());
}
getCommand("mchud").setExecutor(new MchudCommand(this));
}
/*
* Boilerplate Custom Config Stuff (Treasures)
*/
private FileConfiguration treasuresConfig = null;
private File treasuresConfigFile = null;
/**
* Reload the Treasures.yml file.
*/
public void reloadTreasuresConfig() {
if (treasuresConfigFile == null) {
treasuresConfigFile = new File(getDataFolder(), "treasures.yml");
}
treasuresConfig = YamlConfiguration.loadConfiguration(treasuresConfigFile);
if (isInJar("treasures.yml")) {
InputStream defConfigStream = getResource("treasures.yml");
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
treasuresConfig.setDefaults(defConfig);
}
getCommand("mchud").setExecutor(new MchudCommand());
}
/**
* Get the Treasures config information.
* Checks to see if the alias map contains the given key.
*
* @return the configuration object for treasures.yml
* @param command The command to check
* @return true if the command is in the map, false otherwise
*/
public FileConfiguration getTreasuresConfig() {
if (treasuresConfig == null) {
reloadTreasuresConfig();
}
return treasuresConfig;
public boolean commandIsAliased(String command) {
return aliasMap.containsKey(command);
}
/**
* Save the Treasures config informtion.
*/
public void saveTreasuresConfig() {
if (treasuresConfig == null || treasuresConfigFile == null) {
return;
}
try {
treasuresConfig.save(treasuresConfigFile);
}
catch (IOException ex) {
getLogger().severe("Could not save config to " + treasuresConfigFile + ex.toString());
}
}
/*
* Boilerplate Custom Config Stuff (Tools)
*/
private FileConfiguration toolsConfig = null;
private File toolsConfigFile = null;
/**
* Reload the Tools.yml file.
*/
public void reloadToolsConfig() {
if (toolsConfigFile == null) {
toolsConfigFile = new File(modDirectory, "tools.yml");
}
toolsConfig = YamlConfiguration.loadConfiguration(toolsConfigFile);
if (isInJar("tools.yml")) {
InputStream defConfigStream = getResource("tools.yml");
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
toolsConfig.setDefaults(defConfig);
}
}
/**
* Get the Tools config information.
* Get the alias of a given command.
*
* @return the configuration object for tools.yml
* @param command The command to retrieve the alias of
* @return the alias of the command
*/
public FileConfiguration getToolsConfig() {
if (toolsConfig == null) {
reloadToolsConfig();
}
return toolsConfig;
public String getCommandAlias(String command) {
return aliasMap.get(command);
}
/**
* Save the Tools config informtion.
*/
public void saveToolsConfig() {
if (toolsConfig == null || toolsConfigFile == null) {
return;
}
try {
toolsConfig.save(toolsConfigFile);
}
catch (IOException ex) {
getLogger().severe("Could not save config to " + toolsConfigFile + ex.toString());
}
}
/*
* Boilerplate Custom Config Stuff (Armor)
*/
private FileConfiguration armorConfig = null;
private File armorConfigFile = null;
/**
* Reload the Armor.yml file.
*/
public void reloadArmorConfig() {
if (armorConfigFile == null) {
armorConfigFile = new File(modDirectory, "armor.yml");
}
armorConfig = YamlConfiguration.loadConfiguration(armorConfigFile);
if (isInJar("armor.yml")) {
InputStream defConfigStream = getResource("armor.yml");
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
armorConfig.setDefaults(defConfig);
}
}
/**
* Get the Armor config information.
* Add a set of values to the TNT tracker.
*
* @return the configuration object for armor.yml
* @param tntID The EntityID of the TNT
* @param playerName The name of the detonating player
*/
public FileConfiguration getArmorConfig() {
if (armorConfig == null) {
reloadArmorConfig();
}
return armorConfig;
public void addToTNTTracker(int tntID, String playerName) {
tntTracker.put(tntID, playerName);
}
/**
* Save the Armor config informtion.
*/
public void saveArmorConfig() {
if (armorConfig == null || armorConfigFile == null) {
return;
}
try {
armorConfig.save(armorConfigFile);
}
catch (IOException ex) {
getLogger().severe("Could not save config to " + armorConfigFile + ex.toString());
}
}
/*
* Boilerplate Custom Config Stuff (Blocks)
*/
private FileConfiguration blocksConfig = null;
private File blocksConfigFile = null;
/**
* Reload the Blocks.yml file.
*/
public void reloadBlocksConfig() {
if (blocksConfigFile == null) {
blocksConfigFile = new File(modDirectory, "blocks.yml");
}
blocksConfig = YamlConfiguration.loadConfiguration(blocksConfigFile);
if (isInJar("blocks.yml")) {
InputStream defConfigStream = getResource("blocks.yml");
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
blocksConfig.setDefaults(defConfig);
}
}
/**
* Get the Blocks config information.
* Check to see if a given TNT Entity is tracked.
*
* @return the configuration object for blocks.yml
* @param tntID The EntityID of the TNT
* @return true if the TNT is being tracked, false otherwise
*/
public FileConfiguration getBlocksConfig() {
if (blocksConfig == null) {
reloadBlocksConfig();
}
return blocksConfig;
public boolean tntIsTracked(int tntID) {
return tntTracker.containsKey(tntID);
}
/**
* Save the Blocks config informtion.
* Get the player who detonated the TNT.
*
* @param tntID The EntityID of the TNT
* @return the Player who detonated it
*/
public void saveBlocksConfig() {
if (blocksConfig == null || blocksConfigFile == null) {
return;
}
try {
blocksConfig.save(blocksConfigFile);
}
catch (IOException ex) {
getLogger().severe("Could not save config to " + blocksConfigFile + ex.toString());
}
public Player getTNTPlayer(int tntID) {
return getServer().getPlayer(tntTracker.get(tntID));
}
public boolean isInJar(String resource) {
InputStream iStream = getResource(resource);
return iStream != null;
/**
* Remove TNT from the tracker after it explodes.
*
* @param tntID The EntityID of the TNT
*/
public void removeFromTNTTracker(int tntID) {
tntTracker.remove(tntID);
}
public static String getMainDirectory() {
return mainDirectory;
}
public static String getFlatFileDirectory() {
return flatFileDirectory;
}
public static String getUsersFile() {
return usersFile;
}
public static String getModDirectory() {
return modDirectory;
}
public static Database getPlayerDatabase() {
return database;
}
}

View File

@@ -1,650 +1,65 @@
package com.gmail.nossr50.party;
import java.io.BufferedReader;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Users;
public class Party {
public static String pluginPath;
public static String partyPlayersFile;
public static String partyLocksFile;
public static String partyPasswordsFile;
private List<String> members = new ArrayList<String>();
private String leader;
private String name;
private String password;
private boolean locked;
HashMap<String, HashMap<String, Boolean>> partyPlayers = new HashMap<String, HashMap<String, Boolean>>();
HashMap<String, Boolean> partyLocks = new HashMap<String, Boolean>();
HashMap<String, String> partyPasswords = new HashMap<String, String>();
private static mcMMO plugin;
private static volatile Party instance;
private Party() {
plugin = mcMMO.p;
pluginPath = plugin.getDataFolder().getPath();
partyPlayersFile = pluginPath + File.separator + "FlatFileStuff" + File.separator + "partyPlayers";
partyLocksFile = pluginPath + File.separator + "FlatFileStuff" + File.separator + "partyLocks";
partyPasswordsFile = pluginPath + File.separator + "FlatFileStuff" + File.separator + "partyPasswords";
new File(pluginPath + File.separator + "FlatFileStuff").mkdir();
loadParties();
public List<String> getMembers() {
return members;
}
public static Party getInstance() {
if (instance == null) {
instance = new Party();
}
return instance;
}
public List<Player> getOnlineMembers() {
Player[] onlinePlayers = mcMMO.p.getServer().getOnlinePlayers();
List<Player> onlineMembers = new ArrayList<Player>();
/**
* Check if two players are in the same party.
*
* @param playera The first player
* @param playerb The second player
* @return true if they are in the same party, false otherwise
*/
public boolean inSameParty(Player playera, Player playerb){
PlayerProfile PPa = Users.getProfile(playera);
PlayerProfile PPb = Users.getProfile(playerb);
if ((PPa.inParty() && PPb.inParty()) && (PPa.getParty().equals(PPb.getParty()))) {
return true;
}
else {
return false;
}
}
/**
* Get the number of players in this player's party.
*
* @param player The player to check
* @param players A list of players to
* @return the number of players in this player's party
*/
public int partyCount(Player player) {
if (player != null) {
return getAllMembers(player).size();
}
else {
return 0;
}
}
private void informPartyMembers(Player player) {
String playerName = player.getName();
if (player != null) {
for (Player p : getOnlineMembers(player)) {
if (p.getName() != playerName) {
p.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", new Object[] {playerName}));
}
}
}
}
/**
* Get a list of all online players in this player's party.
*
* @param player The player to check
* @return all online players in the player's party
*/
public ArrayList<Player> getOnlineMembers(Player player) {
ArrayList<Player> players = new ArrayList<Player>();
if (player != null) {
for (Player p : plugin.getServer().getOnlinePlayers()) {
if (inSameParty(player, p)) {
players.add(p);
}
for (Player onlinePlayer : onlinePlayers) {
if (members.contains(onlinePlayer.getName())) {
onlineMembers.add(onlinePlayer);
}
}
return players;
return onlineMembers;
}
/**
* Get a list of all online players in this party.
*
* @param partyName The party to check
* @return all online players in this party
*/
public ArrayList<Player> getOnlineMembers(String partyName) {
ArrayList<Player> players = new ArrayList<Player>();
for (Player p : plugin.getServer().getOnlinePlayers()) {
PlayerProfile PP = Users.getProfile(p);
if (PP.inParty()) {
if (PP.getParty().equalsIgnoreCase(partyName)) {
players.add(p);
}
}
}
return players;
}
/**
* Get a list of all players in this player's party.
*
* @param player The player to check
* @return all the players in the player's party
*/
public ArrayList<Player> getAllMembers(Player player) {
ArrayList<Player> players = new ArrayList<Player>();
HashMap<String, PlayerProfile> profiles = Users.getProfiles();
if (player != null) {
for (String name : profiles.keySet()) {
Player otherPlayer = profiles.get(name).getPlayer();
if (otherPlayer != null && inSameParty(otherPlayer, player)) {
players.add(otherPlayer);
}
}
}
return players;
}
/**
* Get a list of all current party names.
*
* @return the list of parties.
*/
public ArrayList<String> getParties() {
String location = plugin.usersFile;
ArrayList<String> parties = new ArrayList<String>();
try {
FileReader file = new FileReader(location);
BufferedReader in = new BufferedReader(file);
String line = "";
while ((line = in.readLine()) != null) {
String[] character = line.split(":");
String theparty = null;
//Party
if (character.length > 3) {
theparty = character[3];
}
if (!parties.contains(theparty)) {
parties.add(theparty);
}
}
in.close();
}
catch (Exception e) {
plugin.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
}
return parties;
}
/**
* Notify party members when the party owner changes.
*
* @param newOwnerName The name of the new party owner
*/
private void informPartyMembersOwnerChange(String newOwnerName) {
Player newOwner = plugin.getServer().getPlayer(newOwnerName);
if (newOwner != null) {
for (Player p : getOnlineMembers(newOwner)) {
if (p.getName() != newOwnerName) {
p.sendMessage(newOwnerName + " is the new party owner."); //TODO: Needs more locale
}
}
}
}
/**
* Notify party members when the a party member quits.
*
* @param player The player that quit
*/
private void informPartyMembersQuit(Player player) {
String playerName = player.getName();
if (player != null) {
for (Player p : getOnlineMembers(player)) {
if (p.getName() != playerName) {
p.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", new Object[] {playerName}));
}
}
}
}
/**
* Remove a player from a party.
*
* @param player The player to remove
* @param PP The profile of the player to remove
*/
public void removeFromParty(Player player, PlayerProfile PP) {
String party = PP.getParty();
String playerName = player.getName();
//Stop NPE... hopefully
if (!isParty(party) || !isInParty(player, PP)) {
addToParty(player, PP, party, false, null);
}
informPartyMembersQuit(player);
if (isPartyLeader(playerName, party)) {
if (isPartyLocked(party)) {
unlockParty(party);
}
}
partyPlayers.get(party).remove(playerName);
if (isPartyEmpty(party)) {
deleteParty(party);
}
PP.removeParty();
savePartyFile(partyPlayersFile, partyPlayers);
}
/**
* Add a player to a party.
*
* @param player The player to add to the party
* @param PP The profile of the player to add to the party
* @param newParty The party to add the player to
* @param invite true if the player was invited to this party, false otherwise
* @param password the password for this party, null if there was no password
*/
public void addToParty(Player player, PlayerProfile PP, String newParty, Boolean invite, String password) {
String playerName = player.getName();
//Fix for FFS
newParty = newParty.replace(":", ".");
//Don't care about passwords on invites
if (!invite) {
//Don't care about passwords if it isn't locked
if (isPartyLocked(newParty)) {
if (isPartyPasswordProtected(newParty)) {
if (password == null) {
player.sendMessage("This party requires a password. Use /party <party> <password> to join it."); //TODO: Needs more locale.
return;
}
else if(!password.equalsIgnoreCase(getPartyPassword(newParty))) {
player.sendMessage("Party password incorrect."); //TODO: Needs more locale.
return;
}
}
else {
player.sendMessage("Party is locked."); //TODO: Needs more locale.
return;
}
}
}
else {
PP.acceptInvite();
}
//New party?
if (!isParty(newParty)) {
putNestedEntry(partyPlayers, newParty, playerName, true);
//Get default locking behavior from config?
partyLocks.put(newParty, false);
partyPasswords.put(newParty, null);
saveParties();
}
else {
putNestedEntry(partyPlayers, newParty, playerName, false);
savePartyFile(partyPlayersFile, partyPlayers);
}
PP.setParty(newParty);
informPartyMembers(player);
if (!invite) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", new Object[]{ newParty }));
}
else {
player.sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", new Object[]{ PP.getParty() }));
}
}
private static <U,V,W> W putNestedEntry(HashMap<U, HashMap<V, W>> nest, U nestKey, V nestedKey, W nestedValue) {
HashMap<V,W> nested = nest.get(nestKey);
if (nested == null) {
nested = new HashMap<V,W>();
nest.put(nestKey, nested);
}
return nested.put(nestedKey, nestedValue);
}
/**
* Lock a party.
*
* @param partyName The party to lock
*/
public void lockParty(String partyName) {
partyLocks.put(partyName, true);
savePartyFile(partyLocksFile, partyLocks);
}
/**
* Unlock a party.
*
* @param partyName The party to unlock
*/
public void unlockParty(String partyName) {
partyLocks.put(partyName, false);
savePartyFile(partyLocksFile, partyLocks);
}
/**
* Delete a party.
*
* @param partyName The party to delete
*/
private void deleteParty(String partyName) {
partyPlayers.remove(partyName);
partyLocks.remove(partyName);
partyPasswords.remove(partyName);
saveParties();
}
/**
* Set the password for a party.
*
* @param partyName The party name
* @param password The new party password
*/
public void setPartyPassword(String partyName, String password) {
if (password.equalsIgnoreCase("\"\"")) { //What's with that password string?
password = null;
}
partyPasswords.put(partyName, password);
savePartyFile(partyPasswordsFile, partyPasswords);
}
/**
* Get the leader of a party.
*
* @param partyName The party name
* @return the leader of the party
*/
public Player getPartyLeader(String partyName) {
Player leader = null;
for (String name : partyPlayers.get(partyName).keySet()) {
if (partyPlayers.get(partyName).get(name)) {
leader = plugin.getServer().getPlayer(name);
break;
}
}
public String getLeader() {
return leader;
}
/**
* Set the leader of a party.
*
* @param partyName The party name
* @param playerName The name of the player to set as leader
*/
public void setPartyLeader(String partyName, String playerName) {
for (String name : partyPlayers.get(partyName).keySet()) {
if (name.equalsIgnoreCase(playerName)) {
partyPlayers.get(partyName).put(playerName, true);
informPartyMembersOwnerChange(playerName);
plugin.getServer().getPlayer(playerName).sendMessage("You are now the party owner."); //TODO: Needs more locale.
continue;
}
if (partyPlayers.get(partyName).get(name)) {
plugin.getServer().getPlayer(name).sendMessage("You are no longer party owner."); //TODO: Needs more locale.
partyPlayers.get(partyName).put(name, false);
}
}
public String getName() {
return name;
}
/**
* Get the password of a party.
*
* @param partyName The party name
* @return The password of this party
*/
public String getPartyPassword(String partyName) {
return partyPasswords.get(partyName);
public String getPassword() {
return password;
}
/**
* Check if a player can invite others to their party.
*
* @param player The player to check
* @param PP The profile of the given player
* @return true if the player can invite, false otherwise
*/
public boolean canInvite(Player player, PlayerProfile PP) {
String party = PP.getParty();
if (isPartyLocked(party) && !isPartyLeader(player.getName(), party)) {
return false;
}
else {
return true;
}
public boolean isLocked() {
return locked;
}
/**
* Check if a string is a valid party name.
*
* @param partyName The party name to check
* @return true if this is a valid party, false otherwise
*/
public boolean isParty(String partyName) {
return partyPlayers.containsKey(partyName);
public void setName(String name) {
this.name = name;
}
/**
* Check if a party is empty.
*
* @param partyName The party to check
* @return true if this party is empty, false otherwise
*/
public boolean isPartyEmpty(String partyName) {
return partyPlayers.get(partyName).isEmpty();
public void setLeader(String leader) {
this.leader = leader;
}
/**
* Check if a player is the party leader.
*
* @param playerName The player name to check
* @param partyName The party name to check
* @return true if the player is the party leader, false otherwise
*/
public boolean isPartyLeader(String playerName, String partyName) {
HashMap<String, Boolean> partyMembers = partyPlayers.get(partyName);
if (partyMembers != null) {
Boolean isLeader = partyMembers.get(playerName);
if (isLeader == null) {
return false;
}
else {
return isLeader;
}
}
else {
return false;
}
public void setPassword(String password) {
this.password = password;
}
/**
* Check if this party is locked.
*
* @param partyName The party to check
* @return true if this party is locked, false otherwise
*/
public boolean isPartyLocked(String partyName) {
Boolean isLocked = partyLocks.get(partyName);
if (isLocked == null) {
return false;
}
else {
return isLocked;
}
}
/**
* Check if this party is password protected.
*
* @param partyName The party to check
* @return true if this party is password protected, false otherwise
*/
public boolean isPartyPasswordProtected(String partyName) {
String password = partyPasswords.get(partyName);
if (password == null) {
return false;
}
else {
return true;
}
}
/**
* Check if a player is in the party reflected by their profile.
*
* @param player The player to check
* @param PP The profile of the player
* @return true if this player is in the right party, false otherwise
*/
public boolean isInParty(Player player, PlayerProfile PP) {
Map<String, Boolean> party = partyPlayers.get(PP.getParty());
if (party != null && party.containsKey(player.getName())) {
return true;
}
else {
return false;
}
}
/**
* Load all party related files.
*/
@SuppressWarnings("unchecked")
public void loadParties() {
if (new File(partyPlayersFile).exists()) {
try {
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyPlayersFile));
partyPlayers = (HashMap<String, HashMap<String, Boolean>>) obj.readObject();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (EOFException e) {
plugin.getLogger().info("partyPlayersFile empty.");
}
catch (IOException e) {
e.printStackTrace();
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
if (new File(partyLocksFile).exists()) {
try {
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyLocksFile));
partyLocks = (HashMap<String, Boolean>) obj.readObject();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (EOFException e) {
plugin.getLogger().info("partyLocksFile empty.");
}
catch (IOException e) {
e.printStackTrace();
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
if (new File(partyPasswordsFile).exists()) {
try {
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyPasswordsFile));
this.partyPasswords = (HashMap<String, String>) obj.readObject();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (EOFException e) {
plugin.getLogger().info("partyPasswordsFile empty.");
}
catch (IOException e) {
e.printStackTrace();
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
/**
* Save all party-related files.
*/
private void saveParties() {
savePartyFile(partyPlayersFile, partyPlayers);
savePartyFile(partyLocksFile, partyLocks);
savePartyFile(partyPasswordsFile, partyPasswords);
}
/**
* Save a party-related file.
*
* @param fileName The filename to save as
* @param partyData The Hashmap with the party data
*/
private void savePartyFile(String fileName, Object partyData) {
try {
new File(fileName).createNewFile();
ObjectOutputStream obj = new ObjectOutputStream(new FileOutputStream(fileName));
obj.writeObject(partyData);
obj.close();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
public void setLocked(boolean locked) {
this.locked = locked;
}
}

View File

@@ -0,0 +1,430 @@
package com.gmail.nossr50.party;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Users;
public class PartyManager {
private static String partiesFilePath;
private static List<Party> parties = new ArrayList<Party>();
private static mcMMO plugin;
private static PartyManager instance;
private PartyManager() {
plugin = mcMMO.p;
partiesFilePath = plugin.getDataFolder().getPath() + File.separator + "FlatFileStuff" + File.separator + "parties.yml";
loadParties();
}
public static PartyManager getInstance() {
if (instance == null) {
instance = new PartyManager();
}
return instance;
}
/**
* Check if two players are in the same party.
*
* @param firstPlayer The first player
* @param secondPlayer The second player
* @return true if they are in the same party, false otherwise
*/
public boolean inSameParty(Player firstPlayer, Player secondPlayer) {
PlayerProfile firstProfile = Users.getProfile(firstPlayer);
PlayerProfile secondProfile = Users.getProfile(secondPlayer);
if (firstProfile == null || secondProfile == null) {
return false;
}
Party firstParty = firstProfile.getParty();
Party secondParty = secondProfile.getParty();
if (firstParty == null || secondParty == null || firstParty != secondParty) {
return false;
}
return true;
}
/**
* Notify party members when a player joins
*
* @param playerName The name of the player that joins
* @param party The concerned party
*/
private void informPartyMembersJoin(String playerName, Party party) {
for (Player member : party.getOnlineMembers()) {
if (member.getName().equals(playerName)) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", new Object[] {playerName}));
}
}
}
/**
* Notify party members when a party member quits.
*
* @param playerName The name of the player that quits
* @param party The concerned party
*/
private void informPartyMembersQuit(String playerName, Party party) {
for (Player member : party.getOnlineMembers()) {
if (member.getName().equals(playerName)) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", new Object[] {playerName}));
}
}
}
/**
* Get a list of all players in this player's party.
*
* @param player The player to check
* @return all the players in the player's party
*/
public List<String> getAllMembers(Player player) {
Party party = Users.getProfile(player).getParty();
if (party == null) {
return null;
}
return party.getMembers();
}
/**
* Get a list of all online players in this party.
*
* @param partyName The party to check
* @return all online players in this party
*/
public List<Player> getOnlineMembers(String partyName) {
Party party = getParty(partyName);
if (party == null) {
return null;
}
return party.getOnlineMembers();
}
/**
* Get a list of all online players in this party.
*
* @param player The player to check
* @return all online players in this party
*/
public List<Player> getOnlineMembers(Player player) {
return getOnlineMembers(player.getName());
}
/**
* Retrieve a party by its name
*
* @param partyName The party name
* @return the existing party, null otherwise
*/
public Party getParty(String partyName) {
for (Party party : parties) {
if (party.getName().equals(partyName)) {
return party;
}
}
return null;
}
/**
* Retrieve a party by a member name
*
* @param playerName The member name
* @return the existing party, null otherwise
*/
public Party getPlayerParty(String playerName) {
for (Party party : parties) {
if (party.getMembers().contains(playerName)) {
return party;
}
}
return null;
}
/**
* Get a list of all current parties.
*
* @return the list of parties.
*/
public List<Party> getParties() {
return parties;
}
/**
* Remove a player from a party.
*
* @param playerName The name of the player to remove
* @param party The party
*/
public void removeFromParty(String playerName, Party party) {
List<String> members = party.getMembers();
members.remove(playerName);
if (members.isEmpty()) {
parties.remove(party);
}
else {
if (party.getLeader().equals(playerName)) {
party.setLocked(false);
}
informPartyMembersQuit(playerName, party);
}
PlayerProfile playerProfile = Users.getProfile(playerName);
if (playerProfile != null) {
playerProfile.removeParty();
}
}
/**
* Add a player to a party.
*
* @param player The player to add to the party
* @param playerProfile The profile of the player to add to the party
* @param partyName The party to add the player to
* @param password the password for this party, null if there was no password
*/
public void joinParty(Player player, PlayerProfile playerProfile, String partyName, String password) {
partyName = partyName.replace(".", "");
Party party = getParty(partyName);
String playerName = player.getName();
if (party == null) {
party = new Party();
party.setName(partyName);
party.setLeader(playerName);
if (password != null) {
party.setPassword(password);
party.setLocked(true);
}
parties.add(party);
}
else if (!checkJoinability(player, party, password)) {
return;
}
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", new Object[]{party.getName()}));
addToParty(player.getName(), playerProfile, party);
}
/**
* Check if a player can join a party
*
* @param player The player trying to join a party
* @param playerProfile The profile of the player
* @param party The party
* @param password The password provided by the player
* @return true if the player can join the party
*/
public boolean checkJoinability(Player player, Party party, String password) {
//Don't care about passwords if it isn't locked
if (party.isLocked()) {
String partyPassword = party.getPassword();
if (partyPassword != null) {
if (password == null) {
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
return false;
}
else if (!password.equals(partyPassword)) {
player.sendMessage(LocaleLoader.getString("Party.Password.Incorrect"));
return false;
}
}
else {
player.sendMessage(LocaleLoader.getString("Party.Locked"));
return false;
}
}
return true;
}
/**
* Accept a party invitation
*
* @param player The player to add to the party
* @param playerProfile The profile of the player
*/
public void joinInvitedParty(Player player, PlayerProfile playerProfile) {
Party invite = playerProfile.getInvite();
if (!parties.contains(invite)) {
parties.add(invite);
}
player.sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", new Object[]{invite.getName()}));
playerProfile.removeInvite();
addToParty(player.getName(), playerProfile, invite);
}
/**
* Add a player to a party
*
* @param playerName The name of the player to add to a party
* @param playerProfile The profile of the player
* @param party The party
*/
public void addToParty(String playerName, PlayerProfile playerProfile, Party party) {
informPartyMembersJoin(playerName, party);
playerProfile.setParty(party);
party.getMembers().add(playerName);
}
/**
* Get the leader of a party.
*
* @param partyName The party name
* @return the leader of the party
*/
public String getPartyLeader(String partyName) {
Party party = getParty(partyName);
if (party == null) {
return null;
}
return party.getLeader();
}
/**
* Set the leader of a party.
*
* @param playerName The name of the player to set as leader
* @param party The party
*/
public void setPartyLeader(String playerName, Party party) {
String leaderName = party.getLeader();
for (Player member : party.getOnlineMembers()) {
if (member.getName().equals(playerName)) {
member.sendMessage(LocaleLoader.getString("Party.Owner.Player"));
}
else if (member.equals(leaderName)) {
member.sendMessage(LocaleLoader.getString("Party.Owner.NotLeader"));
}
else {
member.sendMessage(LocaleLoader.getString("Party.Owner.New", new Object[] {playerName}));
}
}
party.setLeader(playerName);
}
/**
* Check if a player can invite others to their party.
*
* @param player The player to check
* @param playerProfile The profile of the given player
* @return true if the player can invite
*/
public boolean canInvite(Player player, PlayerProfile playerProfile) {
Party party = playerProfile.getParty();
if (party == null || (party.isLocked() && !party.getLeader().equals(player.getName()))) {
return false;
}
return true;
}
/**
* Check if a string is a valid party name.
*
* @param partyName The party name to check
* @return true if this is a valid party, false otherwise
*/
public boolean isParty(String partyName) {
for (Party party : parties) {
if (party.getName().equals(partyName)) {
return true;
}
}
return false;
}
/**
* Load party file.
*/
private void loadParties() {
File file = new File(partiesFilePath);
if (!file.exists()) {
return;
}
YamlConfiguration partiesFile = new YamlConfiguration();
try {
partiesFile.load(file);
} catch (Exception e) {
e.printStackTrace();
}
for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) {
Party party = new Party();
party.setName(partyName);
party.setLeader(partiesFile.getString(partyName + ".Leader"));
party.setPassword(partiesFile.getString(partyName + ".Password"));
party.setLocked(partiesFile.getBoolean(partyName + ".Locked"));
party.getMembers().addAll(partiesFile.getStringList(partyName + ".Members"));
parties.add(party);
}
}
/**
* Save party file.
*/
public void saveParties() {
File file = new File(partiesFilePath);
if (file.exists()) {
file.delete();
}
YamlConfiguration partiesFile = new YamlConfiguration();
for (Party party : parties) {
String partyName = party.getName();
partiesFile.set(partyName + ".Leader", party.getLeader());
partiesFile.set(partyName + ".Password", party.getPassword());
partiesFile.set(partyName + ".Locked", party.isLocked());
partiesFile.set(partyName + ".Members", party.getMembers());
try {
partiesFile.save(new File(partiesFilePath));
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More