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

Compare commits

...

435 Commits

Author SHA1 Message Date
riking
4f273ad6b4 Fixes for importing profiles while the server is running
- Have the active database return unloaded profiles during import (this triggers the giant warning messages)
 - Reload the users AFTER the conversion is complete, not BEFORE
2013-12-10 15:20:23 -08:00
riking
2aec4a69ea Database conversion bug: Integral division in output format 2013-12-10 14:56:07 -08:00
Glitchfinder
06c9ea7068 Minecraft handles block drop chances internally.
Fixes #1678
2013-12-08 12:49:43 -08:00
TfT_02
c88583c1c0 Use Matcher.quoteReplacement here!
Fixes #1676 - for real this time
2013-12-08 17:07:45 +01:00
TfT_02
d2b6838453 Fix config.yml formatting 2013-12-08 11:40:09 +01:00
TfT_02
c9f1f8f662 Fixed bug where party chat broke if the display name contained special characters
Fixes #1676
2013-12-08 11:35:02 +01:00
TfT_02
7a08343304 Actually keep all weeks, not just from the past year
Week numbers are obviously the same every year, we need to check the
year as well as the week number to determine if we should keep the
backup file or not.
2013-12-07 13:18:14 +01:00
riking
3b1bb3e08a Minor changes to Tree Feller - use a HashSet, move comment
LinkedHashSet doesn't actually do anything for us - we were never using the consistent ordering it promises, and openjdk-7 doesn't even provide that consistent ordering. Better to just not use it.
2013-12-06 23:55:26 -08:00
TfT_02
07cafd4866 Fixed bug where disabling hardcore mode for specific skills didn't work
Fixes #1661
2013-12-03 22:15:23 +01:00
GJ
48821a710f Fixed bug with cooldown donor perks 2013-12-02 08:30:45 -05:00
GJ
30a1b333b9 Need a space here. 2013-12-02 08:18:28 -05:00
GJ
696bf71962 Remove unused import 2013-12-02 08:13:53 -05:00
t00thpick1
2d577e92f1 AntiTheft option for Disarm Ability 2013-12-01 19:08:22 -05:00
Luuk Jacobs
86b92b5b30 add alias to mcscoreboard 2013-11-27 00:35:58 +01:00
GJ
24c1dec046 Fix missing import & broken build.
That's what I get for editing through Github's web UI...
2013-11-25 09:32:16 -05:00
GJ
6c478a26c4 Fix issue with custom axes not working with Tree Feller.
Most custom materials don't properly report their max durability, so we need to use our repairable manager to handle them instead.
2013-11-25 09:29:41 -05:00
t00thpick1
2d3da6daf8 Space not underscore 2013-11-24 18:01:05 -05:00
t00thpick1
de3b2b8024 Damage should probably actually be fatal I would think. 2013-11-23 12:34:14 -05:00
t00thpick1
02a064ffc6 These need spaces to be called pretty 2013-11-23 00:45:12 -05:00
t00thpick1
cb5303ce4d These strings return with Spaces, not underscores 2013-11-23 00:42:43 -05:00
t00thpick1
c0dee19cb0 Missed a refactor :P Also, javadoc event 2013-11-22 12:48:53 -05:00
t00thpick1
870987bba7 SecondaryAbility's API additions 2013-11-22 12:32:23 -05:00
riking
5d63a4b910 Run PlayerProfileSaveTask async, as intended 2013-11-21 12:41:26 -08:00
riking
3236ee5ec9 Harden save() method by making a defensive copy 2013-11-21 11:17:24 -08:00
riking
12ed2ac07b Have ExperienceCommand and SkillresetCommand explicitly handle 'all' 2013-11-19 18:56:47 -08:00
t00thpick1
729f3b1df9 There is no usage of this method in which "all" will not cause NPE's 2013-11-19 21:00:29 -05:00
TfT_02
ee1be3599c .length doesn't start at 0 2013-11-18 21:01:41 +01:00
TfT_02
12a6aca8cd Assume that block data = 0 if there isn't one in the config 2013-11-18 20:48:37 +01:00
TfT_02
2b81b8daeb Fix Commands.Scoreboard.Timer locale string
Closes #1626
2013-11-18 19:56:29 +01:00
GJ
5edbdec151 Actually fix broken locale string. 2013-11-15 07:25:50 -05:00
GJ
eaa38c11b8 Fix broken locale string.
Fixes #1615
2013-11-13 09:47:13 -05:00
GJ
e904e34556 Update Korean translation
Closes PR #1613 from @wolfdate25
2013-11-12 08:15:58 -05:00
TfT_02
445f805bb8 Set the treasure drop after using .clone()
Fixes #1603
2013-11-12 12:49:16 +01:00
t00thpick1
df77b9d0ed Parenthesis 2013-11-10 13:56:15 -05:00
t00thpick1
29f2525b58 Tend toward the smaller values, and configurable maximum for horse jump strength 2013-11-10 13:54:45 -05:00
TfT_02
5a68c7a335 Fixed bug which prevented gaining Acrobatics XP 2013-11-10 00:52:30 +01:00
GJ
69ef7f40d8 Command cleanup. 2013-11-08 23:14:11 +01:00
GJ
d1d6b80676 Allow repair of items without a recipe. 2013-11-08 10:52:43 -05:00
GJ
dfe83ff497 Fix divide by zero bug
Minimum Level & Minimum Quantity were accidentally flipped.
2013-11-07 09:13:56 -05:00
riking
e5acf6d936 Also clone fishing treasures, use alternate Wool method
The alternate wool method is testing, the treasure clone is there to stay ;)
2013-11-06 21:34:16 -08:00
riking
bca0ca6766 Fix Shake poisoning the treasure cache with Wither skeletons
The returned ItemStack is modified for both Sheep and Skeletons, so a copy should be returned.
2013-11-06 21:03:13 -08:00
GJ
f17b5faaf6 Parenthesis are good. 2013-11-06 14:52:19 -05:00
GJ
f20fa571f1 Update changelog. 2013-11-06 11:56:50 -05:00
GJ
b90d1c31c7 Updated localization files
Includes new Portuguese (Brazil) translation provided by @FabioZumbi12
in #1585

Includes new Korean translation provided by @wolfwork in #1258
2013-11-06 09:48:05 -05:00
GJ
cf56ca35eb Tweaked durability handling slightly.
Now routes everything through one function to handle enchants and max
durability. Use max durability from RepairableManager by default to
account for mod tools.
2013-11-06 08:45:20 -05:00
TfT_02
c31f5b5782 Account for Unbreaking enchantment when using abilities 2013-11-05 14:51:54 +01:00
GJ
af98c8eb59 Best way to handle minimum quantities.
Check repair function first, assuming the item isn't null, otherwise
check the config. If not found, check config.
2013-11-04 11:01:14 -05:00
TfT_02
3a10b2d83c Make sure we're not setting a bite chance > 1.0
Fixes #1592
2013-11-04 10:32:05 +01:00
TfT_02
32e7c48fd8 Change this message to something that makes sense
The old message was confusing see #1593
2013-11-03 22:49:39 +01:00
Glitchfinder
af578870c7 Defaulted quantities should be defaulted everywhere.
Fixes #1581
2013-11-03 09:40:04 -08:00
TfT_02
cd470d5497 Fix a NPE which occured when there was no backups folder 2013-11-03 14:09:41 +01:00
TfT_02
a9c5e2a04f Don't send a message to the console if no backups were deleted 2013-11-02 21:50:49 +01:00
TfT_02
0196fd8447 Fix the update checker 2013-11-02 21:49:20 +01:00
TfT_02
b1458840e7 Permissions should be lowercase 2013-11-02 19:29:36 +01:00
TfT_02
1fea786669 Added bypass permission for finding Fishing traps 2013-11-02 19:25:02 +01:00
TfT_02
6f9a57751e We can't schedule tasks in onDisable() 2013-11-01 17:39:03 +01:00
GJ
2e1c585005 Fix issue with updating players that are offline. 2013-11-01 12:38:40 -04:00
GJ
811626e67b Cleanup. 2013-11-01 11:54:51 -04:00
TfT_02
cdfd81a67a Cleanup ZipLibrary class 2013-11-01 16:44:03 +01:00
TfT_02
408b8b2107 Added automatic cleanup of backups folder
By default mcMMO keeps the following files:
 * All files from the last 24 hours
 * Daily backups of the past week
 * Weekly backups of the past months

Adds #1574
2013-11-01 16:43:56 +01:00
GJ
6d5f3a52f4 Don't process chat if the mcMMOPlayer is null.
The player should ALWAYS be online when chatting, but depending on
external plugins and applications, this is not always properly
implemented. Fixes #1578
2013-11-01 09:30:10 -04:00
GJ
2cdf08de9f Allow offline players for chat events.
This fixes issues with plugins or applications that rely on JSONAPI to
chat. Fixes #1578
2013-11-01 09:12:06 -04:00
GJ
71141a0f8d Minimum quantity should default to 2.
Fixes #1581
2013-11-01 08:22:14 -04:00
TfT_02
bded936af5 Cleanup our imports 2013-10-31 22:30:05 +01:00
GJ
caaac232d7 Cleanup CombatUtils.
Opting to stick with the if-else rather than the switch statement,
because I think it's slightly easier to read.
2013-10-31 15:03:06 -04:00
GJ
a9d51dad34 Clean up Smelting checks.
Now uses recipes to check if an item is the result of smelting.
2013-10-31 14:29:06 -04:00
GJ
88296da0af Removed MCPC+ workaround.
This has been fixed by MCPC+ starting with build 112.

Addresses #1549
2013-10-31 13:28:54 -04:00
GJ
de3c4f8fd7 Smelting now works with custom ores.
Also fixed exploit where smelting XP could be awarded for some
non-smeltable materials.
2013-10-31 13:25:06 -04:00
GJ
1785bab504 Fix bug with Salvage config value.
After our renames and updates, Salvage was not reading the config value
for the anvil material properly.
2013-10-31 09:09:52 -04:00
GJ
41da32cd1b Added options to disable various sound effects.
Fixes #1577
2013-10-31 09:03:29 -04:00
GJ
93d586592e Move these checks up.
These checks need to happen sooner because they may impact config
loading, specifically the MCPC+ check.

Fixes #1549
2013-10-31 08:15:30 -04:00
Glitchfinder
d6c6c75157 Experience is occasionally zero or cast to zero.
Fixes #1575 and fixes #1576
2013-10-30 15:49:47 -07:00
GJ
4889769522 Workaround MCPC+ shortcomings for now.
Fixes #1549
2013-10-30 15:33:37 -04:00
TfT_02
6c70de6a58 Also backup experience.yml 2013-10-30 12:33:34 +01:00
GJ
fd9154e009 Fixed bug with toggle commands not properly displaying the success message. 2013-10-29 11:45:27 -04:00
GJ
97b9214d6e Wrap these inside McMMOPlayer for easier access. 2013-10-29 11:02:57 -04:00
GJ
a8d1376533 More minor cleanup. 2013-10-29 10:01:30 -04:00
GJ
3be443c63c Cleanup some XP functions, remove unused scoreboard values, minor refactoring. 2013-10-29 09:49:41 -04:00
GJ
cc2c9eb21d Move this to the skill itself. 2013-10-28 16:32:40 -04:00
GJ
9b3ae5c729 These belong in their managers, not in McMMOPlayer 2013-10-28 16:14:52 -04:00
GJ
ccb7fc5886 Remove, don't just comment out. 2013-10-28 16:04:55 -04:00
GJ
60d69e3cc4 Create wrapper to handle all PTP data. 2013-10-28 15:49:48 -04:00
riking
f64f62492f Reinstate static color list, clarify intent 2013-10-28 12:47:25 -07:00
GJ
3fe936306b Oops. 2013-10-28 15:19:47 -04:00
GJ
c79f8043ad Use proper functions where they exist, and move functions to better locations. 2013-10-28 15:12:24 -04:00
GJ
8369ae4616 Don't use a class variable here. 2013-10-28 14:14:20 -04:00
GJ
4715688fe8 Update changelog. 2013-10-28 14:07:41 -04:00
GJ
62e03a4ef5 Black is hard to read. 2013-10-28 13:58:34 -04:00
GJ
9ef3c721df Formatting cleanup from the scoreboard update. Also handle skill permissions differently. 2013-10-28 13:04:46 -04:00
TfT_02
f55039ac6b Earn XP when using Shake
Adds #1564
2013-10-28 17:38:03 +01:00
TfT_02
be792a1052 Fix exploitPrevention() and add Javadocs 2013-10-28 15:39:47 +01:00
GJ
c612036db3 Don't try to find a treasure if there aren't any.
Fixes #1572
2013-10-28 08:52:55 -04:00
GJ
ad4ee6f402 Cleanup exploit prevention method. 2013-10-28 08:17:06 -04:00
TfT_02
49a5bd2ba6 We can move this check to exploitPrevention() 2013-10-26 00:50:31 +02:00
GJ
8aac6a992b Back to active development. 2013-10-25 17:11:54 -04:00
GJ
5da66f05d4 Update pom.xml for 1.4.07 release 2013-10-25 17:11:04 -04:00
GJ
134e0db2e9 Cleanup more of Riking's mess. 2013-10-25 17:07:56 -04:00
GJ
b3415ee2f4 Cleanup some of Riking's mess. 2013-10-25 17:05:36 -04:00
TfT_02
14175a6dfd Don't complain about missing Guide strings 2013-10-25 22:16:18 +02:00
TfT_02
7b3fb46a9a Improved AFK Acrobatics prevention mechanism 2013-10-25 22:02:39 +02:00
Kane York
0aea165a8f Add note about temporary dev build setup to README 2013-10-25 11:46:29 -07:00
riking
17b7a9bf10 Add message to /mcscoreboard time [n] 2013-10-25 11:41:21 -07:00
riking
bd611ee11c Add message to /mcscoreboard keep when a board is not shown 2013-10-25 11:39:24 -07:00
riking
c6ca65f5c9 Create a utility method in SkillUtils to easily check ability cooldowns 2013-10-25 09:49:02 -07:00
riking
95f15e68fe New and Improved Scoreboard System
- Scoreboards now AUTO-UPDATE
 - Scoreboards now COME IN COLOR
 - If you want, they can come in EVERY COLOR (Config setting)
 - Scoreboards can be displayed alongside chat output!
 - Prevention of denial of service to SQL via spamming /mctop using a cooldown
 - Added /mccooldown command to show cooldowns for all available skills
2013-10-25 09:49:02 -07:00
TfT_02
89dabaeb43 Hook location cleanup 2013-10-24 23:14:23 +02:00
TfT_02
c2e100b1e3 Use hook location in Master Angler 2013-10-24 21:19:24 +02:00
GJ
9f33c6cef1 Use addUnsafeEnchantment instead of addEnchantment
Since the enchantment was already present on the item, there's no need to check if it's valid. This also avoids any errors that may occur when trying to repair an item with non-standard enchants.

Fixes #1561
2013-10-22 09:57:13 -04:00
GJ
7e241e3993 Useless else statement. 2013-10-21 13:15:41 -04:00
GJ
bc51505150 More cleanup. 2013-10-21 08:31:35 -04:00
TfT_02
e0599a0dea Subtract XP with Hardcore mode
Adds #1529
2013-10-20 20:02:16 +02:00
TfT_02
d410251595 Changed kraken default behavior
It will no longer broadcast chat messages globally by default, as well as strike lightning on it's target. Instead it will spawn explosion effects.
2013-10-20 17:04:50 +02:00
TfT_02
810c74dc2a Fixed bug which prevented players from leveling up
Any affected players will get their levels back when they gain some
more XP in that particular skill.
2013-10-19 14:08:04 +02:00
TfT_02
100f2c7e56 Added a warning message if the server is running NoCheatPlus without CompatNoCheatPlus 2013-10-19 00:27:07 +02:00
TfT_02
e13e5295e8 Notify about updates if user is running dev1 and beta1 is available 2013-10-18 17:25:21 +02:00
TfT_02
b100b7bcc7 Gravity's Updater version 2.0 2013-10-18 16:58:12 +02:00
TfT_02
f4ff8518c2 Cleanup progress feedback 2013-10-18 16:43:37 +02:00
riking
dbd27b641e Give periodic status messages to the console in conversion 2013-10-18 16:40:44 +02:00
TfT_02
4a428a47af Fix bug with HolidayManager and some cleanup 2013-10-18 16:24:01 +02:00
GJ
3252137ed7 Update locale files. 2013-10-18 10:20:38 -04:00
GJ
68c4b99d1b Oops. 2013-10-18 10:16:51 -04:00
GJ
f282891d0a More info for armor errors. 2013-10-18 10:15:23 -04:00
GJ
7f4e3fedb3 Need different methods for mod files and regular files. 2013-10-18 10:12:55 -04:00
GJ
2042e0cdbd How did I not realize this would loop forever... 2013-10-18 10:02:11 -04:00
GJ
2662fee9fb ACTUALLY use the proper path. 2013-10-18 10:02:10 -04:00
TfT_02
e8e2dcff46 -levelsChanged instead of - levelsChanged 2013-10-18 15:26:15 +02:00
TfT_02
3b09012b35 Also use getServer() here as well 2013-10-18 15:26:14 +02:00
GJ
a774733af4 Use proper path 2013-10-18 09:23:10 -04:00
GJ
4a7e1e2b94 Update pom.xml to fix resource issues. 2013-10-18 08:54:07 -04:00
GJ
b8c1f868f5 Event updates 2013-10-18 08:54:06 -04:00
GJ
3f56a8fbcf Importing Bukkit.java is bad, always use getServer() instead 2013-10-18 08:54:05 -04:00
Bestle
d8e86d0fc7 Fix logic error in fireworkParticleShower
If a player is inside a vehicle, the y position of the spawned firework should be modified, not the x
2013-10-18 12:59:21 +01:00
TfT_02
e125700b43 Fixed Fishing ability "Shake" 2013-10-18 12:25:49 +02:00
t00thpick1
819a1c62ed Merge pull request #1550 from Bestle/master
Add missing ignoreCancelled checks - MERGE COMMIT HAHAHAHA
2013-10-17 16:38:38 -07:00
Bestle
4bc446e306 Add missing ignoreCancelled checks
If a plugin cancels a piston retract or extend event, mcMMO still considers that block or blocks to have moved.

This allow players to gain xp and double drops from blocks that they shouldn't. Checking for cancelled events fixes this.
2013-10-17 21:05:29 +01:00
TfT_02
7f2f15d88e Revert "Don't forget to include the mod files!"
This reverts commit be4736fffd.
2013-10-16 01:41:31 +02:00
TfT_02
be4736fffd Don't forget to include the mod files!
Fixes #1546
2013-10-16 01:38:09 +02:00
riking
b4f4de4628 Get all logs in Tree Feller, and optimize performance
Tree Feller has been shown, both anecdotally and with timings, to put a strain on the server, and therefore is worthy of the effort of optimization.
Prior to this change, on jungle trees, Tree Feller would take around 20-40 milliseconds to process a Jungle Tree after the JIT kicked in, and around 15-25 milliseconds for a normal tree.

Additionally, logs would be left up in the air for jungle trees.

After this change, Tree Feller takes 2-5 milliseconds on normal trees, and 10-15 milliseconds on jungle trees, and no logs are left up in the air.
2013-10-16 00:59:11 +02:00
TfT_02
b9c652ef2b This check shouldn't be inverted
Fixes #1545
2013-10-16 00:57:56 +02:00
GJ
bf4e8d43ea Because the entity that exploded might be null (or might not be TNT) 2013-10-15 13:10:29 -04:00
GJ
468fbdab56 SkillUtils cleanup, EventUtils creation
Move some functions in SkillUtils to more relevant locations.

Begin work on utility class to handle all event calls.
2013-10-15 13:03:33 -04:00
GJ
309dfd50cd Revert change to smoke particle handling
Have to do it this way, because not all block directions are valid for
smoke
2013-10-15 08:38:59 -04:00
riking
44e3e4d1e1 Localize several command results
Also don't nullcheck the null-guarded mcMMOPlayer in PartyManager
2013-10-14 20:48:36 +02:00
riking
476f426590 Remove RepairableManagerFactory until we actually need it
Let's hold off on the factory pattern until we actually offer choices.
2013-10-14 20:48:35 +02:00
riking
766f1f4127 Oh! So that's why it's never used here 2013-10-14 20:48:35 +02:00
riking
b3cf9bf839 When an error occurs updating the leaderboards, print out the current player name if possible 2013-10-14 09:53:42 -07:00
GJ
056f7cc93b Nicer handling of some particle effect code. 2013-10-14 11:29:25 -04:00
TfT_02
741f629ab8 Don't spawn fireworks under a boat (for real this time)
Fixes #1534
2013-10-14 17:07:15 +02:00
TfT_02
dd64c4008b Account for Master Angler config values in /fishing
Fixes #1537
2013-10-14 16:28:48 +02:00
TfT_02
3a5de8e2ce This should be on LOWEST 2013-10-14 09:28:16 +02:00
TfT_02
2d78c0738d Color party leader names only once 2013-10-12 20:50:42 +02:00
TfT_02
77617ebee2 Add bow to fishing treasures 2013-10-12 20:29:52 +02:00
TfT_02
67e9d9c535 Fishing TNT traps should not destroy blocks 2013-10-12 03:30:10 +02:00
TfT_02
800786111c Fix apostrophe issues
Fixes #1523
2013-10-12 02:41:13 +02:00
TfT_02
ed8197bd50 Remove level based bonus from Master Angler
Let's try this another way, instead of removing this passive ability all togheter I think it would be nice to keep the boat/biome catch rate boost. The level based boost was out of hand and counter-intuitive as it made leveling easier on high skill levels.
2013-10-12 02:41:13 +02:00
TfT_02
82f8c4ce36 Fishing Treasure Hunter overhaul 2013-10-12 02:41:13 +02:00
TfT_02
b1cf7d0348 Fire FakeBlockBreakEvent when using Hylian Luck
Fixes #1528
2013-10-11 23:47:42 +02:00
GJ
ae77313007 We forgot one...
Fixes #1527
2013-10-11 15:46:34 -04:00
TfT_02
49cbaad47f Clean up advanced.yml comments and keys 2013-10-11 16:22:30 +02:00
TfT_02
1d96ed72dc Move Acrobatics XP settings to experience.yml 2013-10-11 15:18:57 +02:00
TfT_02
ec378d046f Reformat advanced.yml making the keys consistent 2013-10-11 15:18:56 +02:00
GJ
a25dc24c6c No reason to have this many functions... 2013-10-11 15:18:56 +02:00
TfT_02
68eb51a3d0 Removed Shake_UnlockLevel config option
because it is no longer needed.
2013-10-11 15:18:56 +02:00
TfT_02
2eda3a9c83 Add extra tiers! Every ability now has 8 tiers 2013-10-11 15:18:55 +02:00
GJ
ad8e200a84 Make sure we update the blocks config after this too. 2013-10-09 11:45:49 -04:00
GJ
0c83bf2a80 Improve our drop handling. 2013-10-09 11:44:45 -04:00
GJ
6eaec5ffab We don't need this anymore. 2013-10-09 10:27:06 -04:00
GJ
8a2c5fb051 Check 0 first. 2013-10-09 10:26:51 -04:00
GJ
9485869014 Move these functions to SkillType. 2013-10-09 09:20:32 -04:00
GJ
e1bf55b077 Backup old mod configs & replace with new. 2013-10-08 13:10:09 -04:00
GJ
81140824e4 Backup and replace updated treasures.yml file. 2013-10-07 13:09:46 -04:00
GJ
d5545de81f Backup & replace the repair config files that have been updated. 2013-10-07 13:04:36 -04:00
GJ
8632baed27 No reason to handle this ourselves, Bukkit does it for us. 2013-10-07 11:54:23 -04:00
GJ
9aaea7e44f Fix old files if they exist. 2013-10-07 10:43:22 -04:00
GJ
c2f8f4d016 User data is now saved in flatfile, not FlatFileStuff 2013-10-07 10:33:14 -04:00
GJ
5131e74349 Save mod config files to "mods" rather than "ModConfigs", mirror directory structure inside the jar file. 2013-10-07 10:32:40 -04:00
GJ
3927427b5b Refactor all our repairable stuff into a special package. 2013-10-07 10:23:04 -04:00
TfT_02
4aef4c63fc Split the locale skill guides into seperate sections
This will make it easier for translators to keep up with translating our skill guides. Closes #560
2013-10-07 16:05:11 +02:00
GJ
fb4777e7f0 Added XP boost to Acrobatics when wearing Boots of Feather Falling.
Adds #1098
2013-10-07 09:53:32 -04:00
GJ
d8f3a54f9b Compiler throws warnings all over the place about our close methods, this one is no different. 2013-10-07 07:56:13 -04:00
GJ
de964a3a60 This naming bothers me. 2013-10-07 07:53:42 -04:00
t00thpick1
ce3bc07aa8 Reasonably sure this needs to be this way 2013-10-06 17:46:45 -04:00
TfT_02
5a6bb363cf Don't spawn fireworks under the player if they're in a vehicle 2013-10-06 12:08:22 +02:00
TfT_02
3f9c98d72e Update changelog & minor formatting fixes 2013-10-06 10:25:28 +02:00
riking
96b54387fe SQL database - split loadProfile to have retry flag
Instead of assuming that newUser() worked as intended, we cycle back around into the method.
This also removes the possibility of infinite loops from the writeMissingRows() code path.
2013-10-06 10:09:09 +02:00
riking
70eb67dd6a Flatfile loadProfile - place newUser() inside of try block
This fixes incorrect behavior in the edge-case where an IOException occurs when reading (but not writing) the flatfile database.
2013-10-06 10:09:09 +02:00
riking
77f9f40065 Do not save an un-loaded PlayerProfile 2013-10-06 10:09:09 +02:00
riking
14ae1a69c4 Attempt clean recovery from an unloaded PlayerProfile
This change should cause McMMOPlayer to create a graceful recovery when the database is temporarily unavailable.
When a McMMOPlayer is constructed and recieves an unloaded PlayerProfile, it schedules a task to re-attempt profile retrieval. This task can run for a maximum of 5 seconds, after which a second warning is printed indicating that it has given up (and a message given to the user).
2013-10-06 10:09:09 +02:00
riking
c9858dfd49 Do not mark a PlayerProfile as clean if it failed to save
DatabaseManager.saveUser() now returns a success value, which is used by PlayerProfile to determine whether or not it should be considered clean.
2013-10-06 10:09:09 +02:00
riking
f75fe3cc89 Potential fix for loss of data due to SQL connection dropping
The idea behind this change is to send a ping every hour, which is shorter than the driver's 'dead connection' threshold of 8 hours.

As a side effect, this also will fix a subset of the situations where the MySQL server is restarted.
2013-10-06 10:09:08 +02:00
TfT_02
c19ccbccac Use only 1 extra durability by default, instead of 2 2013-10-06 10:08:06 +02:00
TfT_02
2f90e533a5 Improve validation messages of treasures.yml 2013-10-06 09:51:33 +02:00
Kane York
0cd0919447 /mcconvert: Fix mismatched type in list.remove() call
The databaseTypes collection is a List<String>, so attempting to remove a DatabaseType object will have no effect.
2013-10-05 14:07:06 -07:00
TfT_02
e8b886fcc6 This check somehow got removed 2013-10-05 01:18:51 +02:00
GJ
b8e937a234 ALWAYS remove pots broken by swords. 2013-10-04 13:16:41 -04:00
GJ
eb2e0d3abf Fixed Hylian Luck not working at all.
Fixes #1508
2013-10-04 10:27:18 -04:00
GJ
3365da7f8d MCPC+ checks, notify server owners that they're missing out. 2013-10-04 09:50:49 -04:00
TfT_02
a0e37a4a09 I forgot to invert this check 2013-10-03 22:04:39 +02:00
GJ
5541c15753 Try/catch was stupid. 2013-10-02 09:07:30 -04:00
GJ
f87110749e ACTUALLY fix the NPE here. 2013-10-02 09:03:09 -04:00
GJ
a0ef0d5708 Check vanilla's maxDurability here as well, just to be safe.
Fixes #1504
2013-10-02 08:56:48 -04:00
TfT_02
2e2abcd645 Handle this nicer 2013-10-02 10:42:06 +02:00
TfT_02
6baf820afa Cleanup and formatting 2013-10-01 22:14:29 +02:00
Kane York
288287badf Add holiday celebration for the console 2013-10-01 22:06:51 +02:00
TfT_02
ca4feca073 Cleanup changelog.txt a bit 2013-10-01 15:09:45 +02:00
GJ
7c9356955e ACTUALLY handle SQL passwords (or other fields) with '#' in them properly. 2013-09-30 16:17:44 -04:00
GJ
57541ec233 This can never be null, and there's no reason to pass that as a variable. 2013-09-30 14:19:07 -04:00
TfT_02
9c6d1ce020 Fixing these infinite recursing methods
Oops, that was silly. Thanks @t00thpick1
2013-09-30 19:38:22 +02:00
TfT_02
c72ead9d0a Prevent breaking other plugins who use this API 2013-09-30 19:03:44 +02:00
TfT_02
4262a1b2a5 Added two more treasures to Excavation 2013-09-30 16:24:21 +02:00
TfT_02
eb589b6e78 Renamed some config options in the Commands section.
The following keys have been renamed:
* General => Generic
* p => partychat
* a => adminchat
2013-09-30 15:43:37 +02:00
GJ
98e5e53fda Ignore "#" in SQL passwords. 2013-09-30 08:36:32 -04:00
TfT_02
00918fbdc1 Change this back, getPlayerExact() is faster 2013-09-30 14:04:34 +02:00
TfT_02
5ad0f2c624 Do a little bit of localebending 2013-09-30 11:32:35 +02:00
TfT_02
babb9baa2b Handle joining disbanded parties properly 2013-09-30 11:22:15 +02:00
TfT_02
45143836e5 Fixed /party kick
Fixes #1499
2013-09-30 10:39:33 +02:00
TfT_02
ceacd7dc52 Fixed /party disband 2013-09-30 10:39:14 +02:00
TfT_02
6eb255632f Clean this up a little bit 2013-09-30 10:24:36 +02:00
TfT_02
3a37d0e092 Fixing an error due to confusingly named check
Refactored healthBarEnabled to healthBarPluginEnabled to avoid this
from happening again.
2013-09-29 23:57:13 +02:00
TfT_02
4c7fb1854d addRawXP should use float instead of int 2013-09-29 15:48:11 +02:00
TfT_02
763cff6898 Fixed a bug where Repair wasn't asking for confirmation 2013-09-28 19:46:47 +02:00
riking
fa34d06341 Clear child skill FamilyTree on reload 2013-09-27 15:46:19 -07:00
TfT_02
1ca53da0e2 Also try to count recipe ingredients regardless of repairMaterial
when the normal counting and the config value result in 0

Fixes #1484
2013-09-27 13:42:50 +02:00
TfT_02
57dfa00541 Fixed a NPE when an invalid repair material was entered
#1484
2013-09-27 10:46:54 +02:00
TfT_02
36ae84eada Update README.md 2013-09-26 23:06:07 +02:00
GJ
7f290504ad Set random jump strength for horses as well. 2013-09-26 10:43:45 -04:00
GJ
92b4be9a01 We don't use these parts of the updater. 2013-09-26 09:39:13 -04:00
GJ
8cb8dea642 Move Updater to independent package due to custom changes being overwritten by other plugins using the updater. 2013-09-26 09:37:31 -04:00
GJ
a63f745c73 Add custom mobs automatically as they're killed. 2013-09-26 15:06:36 +02:00
GJ
4a0fee5796 Use class names to better find custom entities. 2013-09-26 15:06:21 +02:00
GJ
cf90236e57 Redo blocks.yml
** YOU WILL NEED TO UPDATE THIS FILE **
2013-09-26 15:06:21 +02:00
GJ
fc6c7bb1de Rework custom tool config.
** YOU WILL NEED TO UPDATE YOUR CONFIG TO THE NEW FORMAT **
2013-09-26 15:06:21 +02:00
GJ
1b92131ce9 Added Carrot on a Stick, and Flint & Steel to repair.vanilla.yml 2013-09-26 14:58:31 +02:00
GJ
792ecd6aad Rework armor.yml to take item names instead of IDs in advance of 1.7 changes.
** YOU WILL NEED TO REDO YOUR armor.yml FILE **
2013-09-26 14:58:30 +02:00
TfT_02
933b6f278b Disable partial name matching for offline players by default
#1482
2013-09-25 14:26:24 +02:00
TfT_02
45dfc13ebd Match playernames using OfflinePlayers instead
Fixes #1482
2013-09-24 11:40:53 +02:00
dddeeefff
1254ab232a Add randomized Horse appearance to Call Of The Wild 2013-09-23 22:29:02 +02:00
dddeeefff
b49e56c857 Added missing COTW message when there are too many Horses nearby 2013-09-23 22:29:01 +02:00
TfT_02
d5bd9a1693 Fixed some small mistakes in CommandUtils 2013-09-23 20:22:41 +02:00
GJ
9b60cd96f9 Don't need these keys with the new format either. 2013-09-23 10:33:50 -04:00
TfT_02
0a05ed98d0 Updated to the new format! 2013-09-22 23:28:09 +02:00
TfT_02
6a3a564bd4 Use cooldownExpired here as well. 2013-09-22 23:28:09 +02:00
TfT_02
3828f78480 Fixed respawn cooldown checks
Thanks @Riking for pointing this out!
2013-09-22 23:28:08 +02:00
Travis Ralston
239d7e33cb Revert "Metrics be dead"
This reverts commit 0a9fd4a92e.
2013-09-22 12:33:01 -06:00
TfT_02
b8c479549c Disable our healthbars when the plugin "HealthBar" is found
Adds #1477
2013-09-22 16:55:02 +02:00
t00thpick1
0a9fd4a92e Metrics be dead 2013-09-20 22:23:38 -04:00
TfT_02
4c96161acb Don't throw errors about dropped columns 2013-09-20 21:39:20 +02:00
TfT_02
ce7a7a31a7 A bit of cleaning up 2013-09-20 00:15:22 +02:00
TfT_02
834e26b44e Minor improvements 2013-09-19 21:47:12 +02:00
GJ
f71b302f6f Don't need this anymore. 2013-09-19 15:19:16 -04:00
GJ
566a381e95 Remove debug message, use recipe method for salvage. 2013-09-19 15:17:19 -04:00
GJ
5d7d779a49 Changed format of repair.vanilla.yml. **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT** 2013-09-19 11:02:47 -04:00
GJ
59a35b170c Oh yeah, that's why. 2013-09-18 15:42:54 -04:00
GJ
14eb473355 Why we were making this so complicated, I'll never know. 2013-09-18 14:55:17 -04:00
GJ
a8e23e08ee Remove HudType from Flatfile records. 2013-09-18 11:54:23 -04:00
GJ
15f5dcf860 Removed HudType references from the database. 2013-09-18 09:57:28 -04:00
GJ
9be9908a22 Remove unused imports. 2013-09-18 09:39:54 -04:00
GJ
446b6c107b Remove empty lines from FlatFile - the plugin will not enable if these are present. 2013-09-18 08:34:47 -04:00
GJ
5a3f8ad15f Add COTW info for horses to the Taming command. 2013-09-17 14:13:11 -04:00
GJ
3a2c6a0827 We can have ' again! 2013-09-17 14:09:39 -04:00
GJ
e865acd871 Fix locale parsing issues.
Fixes #1463
2013-09-17 14:03:00 -04:00
TfT_02
4a0e1ba444 Fix a small boo boo 2013-09-16 23:26:06 +02:00
GJ
1a88b0b944 Better way to handle ink sacks, allows for dropping of multiple types. 2013-09-16 12:48:08 -04:00
GJ
e0592b3f62 Don't try to ever pull the mcMMOPlayer here.
Fixes #1466
2013-09-16 12:12:31 -04:00
GJ
1ec55c2d7e Remove the last bits of Spout from our code. 2013-09-16 12:05:39 -04:00
GJ
6427a7dcdf Fix issues with Skulls in treasures.yml 2013-09-16 11:45:57 -04:00
TfT_02
7bac0e2ca5 Dropped SpoutPlugin support
Because SpoutPlugin is not being updated to 1.6.x and mcMMO 1.4.07 does
not support any CB version below 1.6.x SpoutPlugin support is no longer
needed.
https://blog.spout.org/minecraft-1-6-and-the-legacy-finale/
2013-09-16 16:48:42 +02:00
GJ
e8bc2475c3 Add sound for level-up even when not using Spout. 2013-09-16 09:52:09 -04:00
GJ
816b08b14a Make sure the attacker is a valid player too.
Fixes #1464
2013-09-16 08:53:55 -04:00
GJ
64e1448782 Added ability to give items names & lore through treasures.yml.
Adds #1419
2013-09-15 21:09:32 -04:00
TfT_02
ae0a27991b Register when the config files were last updated 2013-09-15 23:10:35 +02:00
TfT_02
f1b82dcbe6 Fixed regex of version string parsing 2013-09-15 23:09:06 +02:00
TfT_02
bfbd50d8f4 Fix another wrong default Material name 2013-09-15 22:52:59 +02:00
GJ
de07316261 Just in case there's something broken in the file. 2013-09-15 16:49:41 -04:00
GJ
eae196c6a1 Fix wrong default material name. 2013-09-15 16:48:05 -04:00
GJ
8af41975ff Don't keep trying to load if they've got an old file. 2013-09-15 16:09:41 -04:00
GJ
957bbbc9b2 Warn if treasures.yml is outdated. 2013-09-15 15:59:29 -04:00
TfT_02
17faf1561f Refactor to getMaxLength 2013-09-15 21:45:16 +02:00
TfT_02
ec6419f0ff Fix formatting of the new Updater 2013-09-15 21:45:16 +02:00
GJ
f6e60bebcc Fix dropping sideways logs and leaf blocks.
Fixes #1460
2013-09-15 15:09:48 -04:00
GJ
797ac20567 Added Horses to the "Shake" ability.
Witches no longer drop water bottles from Shake, since they no longer drop them in Vanilla.
Changed format of treasures.yml.

**YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
2013-09-15 01:07:04 -04:00
GJ
3bc029a0de Make Updater work with our versioning setup. 2013-09-13 11:46:55 -04:00
GJ
4eba33a1c6 Use doubles in config.yml where appropriate. Change item IDs to item names
in light of upcoming Minecraft changes that will remove access to item
IDs.
2013-09-13 09:52:52 -04:00
GJ
800a452d62 Remove use of deprecated function. 2013-09-13 09:11:34 -04:00
GJ
177604e94a Condense this into one function. 2013-09-13 08:11:32 -04:00
GJ
088015dd4d Switch to H31ix's updater for security reasons. 2013-09-13 00:59:07 -04:00
t00thpick1
0f2d0aee5f Fix NPE on /addxp 2013-09-12 21:21:00 -04:00
t00thpick1
1004e2a32b These duplicate checks are handled in config validation. 2013-09-12 20:52:26 -04:00
t00thpick1
5c2b523f7a Allow less than one percentages for hardcore losses 2013-09-12 20:52:26 -04:00
GJ
de42063171 Fixed a bug where Kraken messages couldn't be disabled.
Fixes #1174
2013-09-12 15:53:43 -04:00
GJ
a49d373af0 Back to active development. 2013-09-12 14:28:51 -04:00
GJ
0095f7f9c7 Update pom.xml for 1.4.07 beta release (finally!) 2013-09-12 14:20:18 -04:00
GJ
f53820e4de Update changelog. 2013-09-12 14:18:52 -04:00
GJ
25e4700ef9 Changed various values to double in advanced.yml for the sake of consistency. 2013-09-12 14:18:13 -04:00
GJ
58c7dcb705 Fix issues with double damage, double death messages, and other damage oddities.
Fixes #1450
2013-09-12 11:52:34 -04:00
GJ
44626c36a9 Nerfed Archery damage to eliminate constant one-hit kills 2013-09-11 11:43:06 -04:00
TfT_02
cfd5bfe2c4 Deal skillShot bonus damage properly 2013-09-11 17:08:59 +02:00
t00thpick1
f7928787dc Skill shot should be after deflect check 2013-09-11 10:17:24 -04:00
GJ
d6630a0eb5 Prevent multiple events from being fired. 2013-09-11 08:51:51 -04:00
GJ
af39e84aef Actually remove /mmoupdate, fix usage strings for /mcconvert, fix tab completion
Fixes #1451
2013-09-10 15:47:47 -04:00
TfT_02
93fe2ff504 Cleanup our imports 2013-09-10 15:28:11 +02:00
GJ
b42f2d4073 Refactor, plus store these values rather than checking them twice. 2013-09-10 08:38:06 -04:00
TfT_02
c5c231920d Cleaning up the changelog and comments 2013-09-09 23:19:59 +02:00
GJ
89ddf8c4fa Fixed issues with dealing damage to Entities 2013-09-09 20:41:06 +02:00
GJ
71ab678945 Fix bug where mcMMO damage wasn't awarding XP.
Fixes #1400
2013-09-09 12:00:37 -04:00
GJ
14daee3b1b Fixed a bug where squid were not awarding XP. 2013-09-09 10:46:26 -04:00
GJ
d2bbbb0fe7 More deprecation fixes. 2013-09-05 16:36:02 -04:00
GJ
fd8d9b02a9 Begin trying to remove newly-deprecated "magic numbers" 2013-09-05 14:55:08 -04:00
GJ
a639a37637 Add per-skill XP boost perks.
Fixes #1412
2013-09-03 09:24:58 -04:00
GJ
7eec53d621 Added Horses to Taming. 2013-08-30 14:25:46 -04:00
GJ
7523afffb5 Updated permissions for more control over Call of the Wild. 2013-08-30 13:50:34 -04:00
GJ
2c8b9334b6 THis should stay false. 2013-08-28 13:13:34 -04:00
GJ
d41ccf9072 Don't loop forever if not connected. 2013-08-28 13:12:24 -04:00
GJ
c98d298cf1 Actually make use of the checkConnected calls. 2013-08-28 11:44:58 -04:00
GJ
73d0b377ae Reduce code duplication. Also verify that our target is alive before trying to damage them.
Fixes #1403
2013-08-28 11:29:30 -04:00
TfT_02
df29306a1f Cleanup Javadocs and fix StackOverflowError 2013-08-26 22:09:29 +02:00
GJ
435522415d This is better too. 2013-08-26 12:20:56 -04:00
GJ
a17d1d3a2f More cleanup to PartyManager. 2013-08-26 11:55:35 -04:00
GJ
94a5bef62c Cleaning up PartyManager 2013-08-26 08:39:24 -04:00
GJ
2cd9a5658e Remove unused import 2013-08-26 08:39:24 -04:00
TfT_02
3c5bd3cedd Fix a NPE in MobHealthDisplayUpdateTask
Band aid for broken isValid() function.
Fixes #1396
2013-08-25 17:35:41 +02:00
GJ
8e02b57369 Align these. 2013-08-23 14:52:21 -04:00
GJ
935b8b7bc4 Update localization files. Adds Estonian translations for some strings. 2013-08-23 14:29:01 -04:00
TfT_02
9c54f8fd11 Fix Javadocs issues 2013-08-23 20:14:13 +02:00
GJ
6bfc1b84de Let's do this the right way. 2013-08-23 20:14:13 +02:00
TfT_02
59f545d5ce Fixed FakeEntityDamageByEntityEvent not getting fired 2013-08-23 20:14:13 +02:00
GJ
23983422e0 Cleanup & remove code duplication. 2013-08-23 14:08:16 -04:00
TfT_02
956bf2d763 Added McMMOPlayerLevelDownEvent and McMMOPlayerLevelChangeEvent 2013-08-23 19:54:30 +02:00
TfT_02
964b2636fb Move experience related settings from config.yml to experience.yml 2013-08-23 19:37:44 +02:00
GJ
490bc195d8 We don't care about teleports to the same spot. 2013-08-23 08:58:23 -04:00
TfT_02
0ce41150c6 Vampirism can now be enabled without having Skill Death Penalty enabled 2013-08-22 22:54:05 +02:00
TfT_02
0455416dec Reorganized Hardcore locale strings 2013-08-22 22:54:05 +02:00
TfT_02
a6e7febf77 Hardcore mode can now be toggled for each skill individually 2013-08-22 22:54:05 +02:00
GJ
ede0757d83 Remove /mmoupdate and replace with /mcconvert database 2013-08-22 22:33:06 +02:00
GJ
8282d84b16 Validate, and nicer loading. 2013-08-22 22:22:19 +02:00
GJ
223649ec28 Formatting and localizing. 2013-08-22 22:22:19 +02:00
TfT_02
68e433b3b7 Added new ExperienceFormula config and /mcconvert command 2013-08-22 22:22:19 +02:00
GJ
1a51b93ec9 Another quick check to avoid issues with NPCs. 2013-08-22 14:45:30 -04:00
GJ
c31ffa5ab4 Remove unused import. 2013-08-22 13:51:01 -04:00
TfT_02
ca6bee07ea Fix formatting 2013-08-22 00:37:48 +02:00
TfT_02
9acaa7b126 We're expecting a null object here as well. 2013-08-21 16:48:08 +02:00
gmcferrin
2bae937b28 Don't throw a warning if we're expecting a null object. 2013-08-21 14:20:12 +00:00
TfT_02
51bf989418 Counter Attack now only activates when the player is blocking
Closes #1018
2013-08-20 23:23:49 +02:00
GJ
07dd460d78 Validate in a seperate function. 2013-08-20 15:51:12 -04:00
GJ
045d74fb9d These were basically the same function. 2013-08-20 15:15:42 -04:00
GJ
c8c76f4174 Put this function in a better place. 2013-08-20 15:12:38 -04:00
GJ
83c4d09093 Fix formatting 2013-08-20 15:08:10 -04:00
GJ
50ef8d9610 Improvements to mcMMOPlayer lookup. 2013-08-20 14:10:49 -04:00
GJ
98c6abad36 No reason to cast here. 2013-08-19 15:14:33 -04:00
GJ
62146480db Hardcoding this is a bad idea. 2013-08-19 15:12:08 -04:00
TfT_02
6518d192ec Improved partial name matcher
Fixes #1164
2013-08-19 10:37:04 +02:00
TfT_02
3fe9cfee74 Slightly improved update checker feedback 2013-08-18 18:04:20 +02:00
T00thpick1
d495054eb5 Config Validation 2013-08-18 02:42:13 -04:00
T00thpick1
ce80636141 Min value for IronArm configurable 2013-08-18 02:38:57 -04:00
TfT_02
fe93be66ad Changed the color of party leader names in Party chat 2013-08-17 13:53:46 +02:00
TfT_02
1f712063bf Admin and Party chat prefixes are now customizable
Closes #578
2013-08-17 12:18:29 +02:00
TfT_02
560c3860b4 Fixed bug which allowed players to bypass fishing's exploit prevention
Fixes #1319
2013-08-17 10:11:46 +02:00
TfT_02
36f1a2d78a Changed the way Repair hands out XP
Closes #373
2013-08-15 20:50:19 +02:00
TfT_02
3ddd8d2056 Added API to get a players rank on the leaderboards 2013-08-13 09:37:45 +02:00
TfT_02
5441fcc374 Fix broken Dodge_DamageModifier config node
Also fix a derp with the validation of
Arcane_Forging.Keep_Enchants.Chance
2013-08-11 15:55:25 +02:00
TfT_02
1d83784820 Arcane Forging downgrade chance can also be 0
Fixes #1367
2013-08-11 09:26:02 +02:00
TfT_02
fb5bab6e92 String values are compared using '.equals()' not '==' 2013-08-10 22:24:13 +02:00
TfT_02
90fcf35c34 Javadocs cleanup 2013-08-10 20:10:45 +02:00
TfT_02
4ff6b5fbc7 Don't try to register listeners when mcMMO was disabled 2013-08-10 19:33:21 +02:00
TfT_02
ead1398132 Super Breaker & Giga Driller now use more durability
A configurable amount is added to the vanilla durability loss.

Use `Abilities.Tools.Durability_Loss` to disable (set to 0) or set it
to -1 for no durability loss while using abilities. Closes #1363
2013-08-09 22:21:45 +02:00
TfT_02
6330c4a69e Move the noErrorsInConfig check to Misc 2013-08-09 19:10:03 +02:00
TfT_02
dcc18049a1 Removed Abilities.Tools.Durability_Loss_Enabled
Set Abilities.Tools.Durability_Loss to 0 to disable instead.
Addresses #1357
2013-08-09 18:13:22 +02:00
TfT_02
fcb8909a54 Kick interval can be disabled with '-1'
Fixes #1356
2013-08-09 13:36:04 +02:00
TfT_02
37e3bfe7d9 Fixed formatting 2013-08-07 19:58:49 +02:00
riking
d61b837dcf Implement checkStructure() 2013-08-07 19:49:00 +02:00
riking
f079e22789 Use provided last-saved information for purge.
The new method, OfflinePlayer.getLastPlayed(), is used as a backup for when the data is unparsable.
TODO check if StringUtils is available here
2013-08-07 19:45:27 +02:00
TfT_02
1f53c62ced Added McMMOPlayerDeathPenaltyEvent
Called when a player dies and mcMMO tries to invoke Hardcore mode or
Vampirism
2013-08-07 01:21:52 +02:00
TfT_02
9fb4e0988b Save / load party itemshare category states.
Closes #1336
2013-08-07 00:38:17 +02:00
TfT_02
d8bbe459b9 Fix minor Javadoc errors 2013-08-07 00:15:51 +02:00
TfT_02
8bd7526b43 String values are compared using '.equals()' not '==' 2013-08-06 21:48:09 +02:00
TfT_02
24b1485555 Validate advanced.yml settings 2013-08-06 21:37:19 +02:00
TfT_02
7683dfc436 Move validation to proper location 2013-08-06 21:27:16 +02:00
TfT_02
ccbffca278 Validate config.yml settings 2013-08-06 21:17:14 +02:00
Glitchfinder
aeaab43f44 Fixing a multitude of reported NPEs. 2013-08-04 12:15:01 -07:00
Glitchfinder
a2450d2d07 If a variable can be null, check it before using it. 2013-08-04 11:48:44 -07:00
T00thpick1
c85bd8ab70 One more last try 2013-08-04 11:56:37 -04:00
T00thpick1
3f6bce0fc6 One last try 2013-08-04 11:51:34 -04:00
T00thpick1
e566b20e2b This might be important 2013-08-04 11:38:52 -04:00
T00thpick1
f37a7d759a Hack around nms bug 2013-08-04 11:34:04 -04:00
T00thpick1
d1341b0be0 Would help if I actualized the value... Fix dupe bug for realz 2013-08-04 11:05:53 -04:00
T00thpick1
4ea3d690db Fix Dupe bug...... why was this overlooked? 2013-08-03 11:37:29 -04:00
TfT_02
d5dc9895e4 Move Blast Mining activation check to MONITOR priority
Fixes #1331
2013-08-02 21:11:58 +02:00
Glitchfinder
b1fc72e8a9 When a variable can be null, check it before using it. Fixes #1308. 2013-08-01 08:47:14 -07:00
GJ
7479a02220 Update changelog. 2013-07-30 15:23:32 -04:00
GJ
d1bf48ad79 Fix bug where teleport location was never reset if warmup was set to 0
for Chimera Wing.

Fixes #1323
2013-07-30 15:20:18 -04:00
GJ
a345737b8b Add more detailed error messages on SQL connection failure.
Fixes #1322
2013-07-30 15:09:22 -04:00
GJ
c501ebb357 Clean up after our experience commands. Fixes #1324 2013-07-30 14:47:11 -04:00
GJ
15e0570a8c Else if > if 2013-07-29 08:45:30 -04:00
GJ
09e77c8c94 Move break event to the initial check. 2013-07-29 08:29:10 -04:00
TfT_02
f5c58f3679 Added config option for Acrobatics teleport cooldown,
also updated the changelog.
2013-07-29 00:57:43 +02:00
GJ
ddcbe64db6 Fix some possible issues with handler priority, more javadoc work. 2013-07-28 13:55:48 -04:00
GJ
c5137eb884 Begin work on cleaning up our listeners and their Javadocs. 2013-07-25 14:52:21 -04:00
GJ
e073eca458 Validation is important. 2013-07-24 20:29:32 -04:00
GJ
78f2e0a064 Check the range in a seperate function 2013-07-24 14:13:58 -04:00
TfT_02
df2defe969 Added extra settings for Call of the Wild
* Requested in issue #910
* Adds a setting to configure the range check
* Adds a setting to summon multiple pets with one summon
2013-07-24 20:01:26 +02:00
TfT_02
6d4a2feaae Slighty changed a Green Thumb string
Make this fit on one line in the chat window
2013-07-24 20:01:26 +02:00
GJ
8939fc09b3 Patch potential exploit relating to teleportation and acrobatics. 2013-07-24 13:57:53 -04:00
GJ
e0e574c19e Fix a potential issue with PTP and Chimera Wing teleportation cooldowns. 2013-07-24 13:50:33 -04:00
GJ
02126c93b9 This function is never used. 2013-07-24 12:35:28 -04:00
GJ
37671bad9a We already have the mcMMOPlayer here. 2013-07-24 12:30:02 -04:00
TfT_02
0e8ce005d7 This is also a change 2013-07-24 16:10:26 +02:00
GJ
584a225d6e Only get the mcMMOPlayer once. 2013-07-24 09:37:45 -04:00
riking
736359056f Add checkConnected() calls to re-establish dead SQL connections 2013-07-23 15:03:19 -07:00
TfT_02
bf2e527e72 Fixed NPE with Beast Lore
Fixes #1289
2013-07-22 11:35:48 +02:00
TfT_02
be7992d541 Disable all abilities when a player quits
Fixes #1295
2013-07-22 11:25:56 +02:00
TfT_02
435eb7f8b9 Added new experience curve option 2013-07-21 23:14:42 +02:00
GJ
001f1dbd3c Fix issue with truncating things that don't need truncating. 2013-07-17 13:45:31 -04:00
GJ
7b5372a985 Temporary fix for MCPC+ entity issues. This change will be reverted
after the fix is made in MCPC+.

Fixes #1197
2013-07-17 10:29:42 -04:00
GJ
1647ef4fae Fixed issue where locale strings could cause the scoreboard header to be
longer than 16 characters.

Fixes #1278
2013-07-17 08:18:54 -04:00
GJ
ee86f8244f Put ShareMode in its own class. 2013-07-15 09:56:45 -04:00
GJ
e518b58b23 Better way to do locale strings there. 2013-07-15 09:48:14 -04:00
GJ
5af1164b5c Tweak ShareHandler a bit. 2013-07-15 09:40:07 -04:00
GJ
c9aba059e2 Don't provide direct access to the players map. 2013-07-15 09:14:23 -04:00
GJ
dc9469c0cc Refactor to match standards set for where datatypes should be located. 2013-07-15 08:44:13 -04:00
TfT_02
696e82e622 Add missing Axes locale string
* Somehow, the message notifying a player that he was struck by Skull
Splitter wasn't in the locale files anymore.
 * Re-added this string and renamed it.
 * Fixes #1271
2013-07-15 13:18:13 +02:00
TfT_02
18a5ec73d7 Fixed Level up announcement
Fixes #1270
2013-07-14 10:58:51 +02:00
TfT_02
83ee8dd3f8 Update README.md
* Updated the about section so its similar with BukkitDev
 * Updated required libraries list, we're using EMetrics instead of Metrics
2013-07-11 20:53:35 +02:00
GJ
04224b309a Add snow to excavation. No treasures will drop from snow by default,
but they can be added to the treasures.yml file by specifying

"Drops_From:
	Snow: true"

Adds #1229
2013-07-11 14:41:23 -04:00
GJ
01a1cf5765 Update changelog. 2013-07-11 13:22:44 -04:00
GJ
8fdf4042bb Tweaked for readability. 2013-07-11 13:22:14 -04:00
GJ
621969459a Use profile instead of mcMMOPlayer 2013-07-11 13:19:04 -04:00
T00thpick1
6fe1c85592 Save on logout 2013-07-11 13:16:51 -04:00
T00thpick1
79346d92d7 Only save on changes 2013-07-11 13:16:42 -04:00
GJ
24ceeb626b Updated localization files 2013-07-11 13:03:38 -04:00
GJ
68727496ad Useless casting and elses. 2013-07-11 12:49:01 -04:00
GJ
d07b67b5bf Health and damage are now doubles, not ints. 2013-07-11 12:43:36 -04:00
GJ
4dc9c97978 Build from LATEST again. 2013-07-11 12:26:31 -04:00
GJ
99916f99fd Back to new development 2013-07-11 12:25:21 -04:00
GJ
4a5307f47b New 1.4.06 release before work starts on adding new features from 1.6 2013-07-11 12:09:24 -04:00
GJ
69aead58a7 Using getPlayerExact is faster. 2013-07-08 19:15:44 -04:00
576 changed files with 16049 additions and 12131 deletions

View File

@@ -7,7 +7,106 @@ Key:
! Change ! Change
- Removal - Removal
Version 1.4.06-dev Version 1.4.08-dev
+ Added SecondaryAbilityType enum, and new SecondaryAbilityWeightedActivationCheckEvent, fired when a secondary ability checkes its activation chances
+ Added the possibility to gain experience when using Fishing "Shake"
+ Added config options to disable various sound effects
+ Smelting now works with custom ores - add smelting XP value to blocks.yml, or it will default to 1/10th of normal XP.
+ Added automatic cleanup of backups folder.
+ Added bypass permission for finding Fishing traps
= Fixed bug where LeafBlower permissions were ignored
= Fixed bug with toggle commands not properly displaying the success message.
= Fixed IllegalArgumentException caused by an empty Fishing treasure category
= Fixed bug with Salvage not reading the config value for the anvil material.
= Fixed exploit where you could receive smelting XP for improper items
= Fixed bug where the Unbreaking enchantment was ignored when using "Super Breaker" or "Giga Drill Breaker"
= Fixed bug which prevented players from gaining Acrobatics XP when the setting 'Prevent_XP_After_Teleport' was set to false
= Fixed bug where cooldown donor perks were reducing more than expected
= Fixed bug where disabling hardcore mode for specific skills didn't work
= Fixed bug which caused the backup cleanup to delete old backups while it should have kept those
= Fixed bug where party chat broke if the display name contained special characters
! Updated localization files
! Changed AxesCritical to CriticalHit in config file
! Changed several secondary ability permissions(deprecated versions still exist)
Version 1.4.07
+ Added XP boost to Acrobatics when wearing Boots of Feather Falling
+ Added SQL Database can now recover from a dropped connection without losing data. (Thanks Riking!)
+ Added more tiers to Fishing, Repair and Smelting!
+ Added Carrot on a Stick and Flint & Steel to repair.vanilla.yml
+ Added horses to the "Shake" ability
+ Added ability to summon horses via "Call of the Wild" using apples
+ Added XP gain to Taming for horses
+ Added new permission nodes to allow more control over Taming and "Call of the Wild"
+ Added new experience.yml config file! Moved all experience related settings from config.yml to experience.yml
+ Added support for EXPONENTIAL formula curves to experience.yml
+ Added new /mcconvert command to convert players levels and experience from one formula curve to another.
+ Added snow to Excavation blocks
+ Added new experience curve option. Cumulative curve, calculates experience needed for next level using power level.
+ Added extra settings to config.yml for "Call of the Wild" (Taming)
+ Added a 5 second cooldown after teleporting before Acrobatics XP can be earned. Plus a config option to disable
+ Added new API methods to ExperienceAPI to get a players rank on the leaderboards
+ Added new McMMOPlayerDeathPenaltyEvent, fired when a player dies and would lose levels
+ Added new McMMOPlayerLevelChangeEvent, fired when a players level changes
+ Added new McMMOPlayerLevelDownEvent, fired when a player loses levels
+ Added ability to give custom names to items in treasures.yml - use the key "Custom_Name" to set, expects a string.
+ Added ability to give lore to items in treasures.yml - use the key "Lore" to set, expects a list of strings.
+ Added Quartz and Name Tags to the default Excavation treasures
+ Added a warning message if the server is running NoCheatPlus without CompatNoCheatPlus
+ Added cooldown to commands with heavy database access to prevent denial of service
+ Added /mcscoreboard keep, to keep the scoreboard up forever
+ Added Rainbow Mode to scoreboards
+ Added new /mccooldowns command to show all ability cooldowns
+ Commands may now both print text and display a scoreboard
+ Killing a custom entity will automatically add it to the custom entity config file with default values.
= Fixed bug which allowed players to bypass fishing's exploit prevention
= Fixed bug where FakeEntityDamageByEntityEvent wasn't being fired
= Fixed bug with "Skull Splitter" not finding the locale string
= Fixed issue where locale strings could cause the scoreboard header to be longer than 16 characters.
= Fixed a bug with "Beast Lore" when the entity had no owner but was tamed.
= Fixed a bug where AbilityDeactivateEvent would throw an error if the player logged out before his ability ran out.
= Fixed a bug where LevelUpEvent would be called for an offline player.
= Fixed a bug where teleport location was never reset if warmup was set to 0 for "Chimaera Wing".
= Fixed a bug where the "Dodge" DamageModifier wasn't being read from advanced.yml
= Fixed a bug where squid were not awarding XP.
= Fixed a bug where Combat XP was granted within 5 seconds for respawned players
= Fixed a bug where wrong feedback messages were being send when using a command on an offline player
= Fixed a bug where players were able to gain Herbalism XP in mine carts, even though Prevent_AFK_Leveling was enabled
= Fixed a bug where players would get hit by fireworks if they leveled up while in a boat
! Changed Fishing "Treasure Hunter" and "Magic Hunter" drop percentages
! Changed format of mod config files. (blocks.yml, tools.yml, armor.yml and entities.yml) **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
! Changed format of treasures.yml. **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
! Changed format of repair.vanilla.yml. **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
! Changed default XP multiplier for repairing shears
! Changed "Shake" drops for Witches. They no longer drop water bottles, since they no longer drop them in Vanilla.
! Changed fishing exploit prevention, by default it will no longer send global sounds, effects and messages.
! Changed Hardcore modes, they will also subtract experience
! Changed various values to double in advanced.yml for the sake of consistency.
! Nerfed Fishing "Master Angler" (removed skill level based bonus) and also made the modifiers configurable
! Nerfed Archery damage to eliminate constant one-hit kills.
! Changed the way Repair hands out XP, also added config options to control Repair XP
! Changed Swords "Counter Attack" ability from passive to active. Blocking is required to activate.
! Hardcore modes can now be toggled for each skill individually
! Vampirism can now be enabled without having Skill Death Penalty enabled
! Admin and Party chat prefixes are now customizable
! Changed the color of party leader names in Party chat
! Improved "Tree Feller" algorithm (Thanks Riking!)
! Improved AFK Acrobatics prevention mechanism
! Improved profile saving
! Improved partial name matcher
! Improved update checker
! Updated localization files
! Party item share category states are now saved when the server shuts down.
! When using "Super Breaker" or "Giga Driller" abilities extra tool durability is used (again)
! Mob healthbars are automatically disabled when the plugin "HealthBar" is found
! Massively improved scoreboard handling
! Reworked scoreboard configuration (config.yml) - **you will need to update**
- The /mmoupdate command has been removed. It is replaced by /mcconvert database
- Removed Abilities.Tools.Durability_Loss_Enabled, set Abilities.Tools.Durability_Loss to 0 to disable instead.
- Removed Skills.Fishing.Shake_UnlockLevel from advanced.yml, now using Skills.Fishing.Rank_Levels.Rank_1 instead.
- Removed SpoutPlugin support
Version 1.4.06
+ Added "Ice Fishing" ability to Fishing + Added "Ice Fishing" ability to Fishing
+ Added global scoreboards to track skill rankings (display using /mctop) + Added global scoreboards to track skill rankings (display using /mctop)
+ Added per-player scoreboard displays for the /inspect, /mcrank, /mcstats, and /<skillname> commands + Added per-player scoreboard displays for the /inspect, /mcrank, /mcstats, and /<skillname> commands

View File

@@ -2,12 +2,10 @@
## The RPG lovers mod ## The RPG lovers mod
### Dev builds ### Dev builds
Our latest development builds are available [here](http://ci.mcmmo.info). Our latest development builds are available ~~[here](http://ci.mcmmo.info)~~. Unfortunately, the mcMMO site is down; a temporary dev build location is hosted [here](http://ci.ecocitycraft.com/job/mcMMO/).
### Brief Description ### 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. The goal of mcMMO is to take core Minecraft game mechanics and expand them into add an extensive and quality RPG experience. Everything in mcMMO has been carefully thought out and is constantly being improved upon. Currently, mcMMO adds thirteen unique skills to train and level in. Each of these skills is highly customizable through our configuration files, allowing server admins to tweak mcMMO to best suit the needs of his or her server. Know that the mcMMO team is dedicated to providing an ever-evolving experience, and that we carefully read all feedback and bug reports in order to evaluate and balance the mechanics of mcMMO in every update.
If you want an original RPG experience like no other mod out there, mcMMO is for you.
## About the Team ## About the Team
@@ -31,17 +29,18 @@ mcMMO is currently developed by a team of individuals from all over the world.
(https://github.com/TfT-02) (https://github.com/TfT-02)
[![t00thpick1](http://www.gravatar.com/avatar/ee23c7794a0c40120c3474287c7bce06.png)] [![t00thpick1](http://www.gravatar.com/avatar/ee23c7794a0c40120c3474287c7bce06.png)]
(https://github.com/t00thpick1) (https://github.com/t00thpick1)
[![riking](https://1.gravatar.com/avatar/aca9f37e569ac3a63929920035a91ba4.png)]
(https://github.com/riking)
## Compiling ## Compiling
mcMMO uses Maven 3 to manage dependancies, packaging, and shading of necessary classes; Maven 3 is required to compile mcMMO. mcMMO uses Maven 3 to manage dependancies, packaging, and shading of necessary classes; Maven 3 is required to compile mcMMO.
The typical command used to build mcMMO is: mvn clean package install The typical command used to build mcMMO is: `mvn clean package install`
Required Libraries: Required Libraries:
* Spout API
* JUnit * JUnit
* Metrics * EMetrics
* Bukkit * Bukkit
http://dev.bukkit.org/server-mods/mcmmo for more up to date information. http://dev.bukkit.org/server-mods/mcmmo for more up to date information.

View File

@@ -1,11 +1,11 @@
# #
# Repair configuration
# Last updated on ${project.version}-b${BUILD_NUMBER}
#
# Any file named repair.*.yml in the mcmmmo folder will be loaded as a repair config # 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" # All repair configs have a main section titled "Repairables"
# Afterwards, all sub-items are considered a Repairable to be loaded # Afterwards, all sub-items are considered a Repairable to be loaded. The names of each subitem should be the exact material name.
# The bare minimum of a Repairable is that it have an ItemId, a RepairMaterialId, and a MaximumDurability # The bare minimum of a Repairable is that it have a RepairMaterial 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. # ItemType: This is the type of item to be repaired, this is only important to permissions.
## Valid values are ARMOR, TOOL, and OTHER. ## Valid values are ARMOR, TOOL, and OTHER.
@@ -15,7 +15,7 @@
## Valid values are STRING, LEATHER, WOOD, STONE, IRON, GOLD, DIAMOND, and OTHER ## Valid values are STRING, LEATHER, WOOD, STONE, IRON, GOLD, DIAMOND, and OTHER
## This defaults to OTHER. ## This defaults to OTHER.
# #
# RepairMaterialId: This is the id of the item used to repair this repairable. # RepairMaterial: This is the material name of the item used to repair this repairable.
## This is required to be set. ## This is required to be set.
# #
# RepairMaterialMetadata: This is the metadata of the item used to repair this repairable. # RepairMaterialMetadata: This is the metadata of the item used to repair this repairable.
@@ -26,7 +26,7 @@
## This is required to be set. ## This is required to be set.
# #
# MinimumLevel: This is the minimum repair level needed to repair this item. # MinimumLevel: This is the minimum repair level needed to repair this item.
## Valid values are > 0 ## Valid values are => 0
## This defaults to 0 ## This defaults to 0
# #
# MinimumQuantity: This is the minimum number of items needed to repair this item ignoring all other repair bonuses. # MinimumQuantity: This is the minimum number of items needed to repair this item ignoring all other repair bonuses.
@@ -42,32 +42,19 @@
# #
### ###
Repairables: Repairables:
ChainHelmet: #
ItemId: 302 # Chainmail repairables
ItemType: ARMOR ###
RepairMaterialId: 51 # Armor
MaximumDurability: 165 CHAINMAIL_HELMET:
MinimumQuantity: 5 RepairMaterial: FIRE
XpMultiplier: 2 XpMultiplier: 2
ChainChest: CHAINMAIL_CHESTPLATE:
ItemId: 303 RepairMaterial: FIRE
ItemType: ARMOR
RepairMaterialId: 51
MaximumDurability: 240
MinimumQuantity: 8
XpMultiplier: 2 XpMultiplier: 2
ChainLegs: CHAINMAIL_LEGGINGS:
ItemId: 304 RepairMaterial: FIRE
ItemType: ARMOR
RepairMaterialId: 51
MaximumDurability: 225
MinimumQuantity: 7
XpMultiplier: 2 XpMultiplier: 2
ChainBoots: CHAINMAIL_BOOTS:
ItemId: 305 RepairMaterial: FIRE
ItemType: ARMOR
RepairMaterialId: 51
RepairMaterialMetadata: -1
MaximumDurability: 195
MinimumQuantity: 4
XpMultiplier: 2 XpMultiplier: 2

55
pom.xml
View File

@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId> <groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId> <artifactId>mcMMO</artifactId>
<version>1.4.06-dev6</version> <version>1.4.08-dev1</version>
<name>mcMMO</name> <name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url> <url>https://github.com/mcMMO-Dev/mcMMO</url>
<issueManagement> <issueManagement>
@@ -22,38 +22,6 @@
<include>.jenkins</include> <include>.jenkins</include>
</includes> </includes>
</resource> </resource>
<resource>
<targetPath>resources</targetPath>
<filtering>false</filtering>
<directory>${basedir}/src/main/resources/xpbar/</directory>
<includes>
<include>xpbar*.png</include>
</includes>
</resource>
<resource>
<targetPath>resources</targetPath>
<filtering>false</filtering>
<directory>${basedir}/src/main/resources/healthbar/</directory>
<includes>
<include>health*.png</include>
</includes>
</resource>
<resource>
<targetPath>resources</targetPath>
<filtering>false</filtering>
<directory>${basedir}/src/main/resources/skillicon/</directory>
<includes>
<include>*.png</include>
</includes>
</resource>
<resource>
<targetPath>resources</targetPath>
<filtering>false</filtering>
<directory>${basedir}/src/main/resources/sound/</directory>
<includes>
<include>*.wav</include>
</includes>
</resource>
<resource> <resource>
<targetPath>com/gmail/nossr50/locale</targetPath> <targetPath>com/gmail/nossr50/locale</targetPath>
<filtering>true</filtering> <filtering>true</filtering>
@@ -62,6 +30,14 @@
<include>locale*.properties</include> <include>locale*.properties</include>
</includes> </includes>
</resource> </resource>
<resource>
<targetPath>mods</targetPath>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources/mods</directory>
<includes>
<include>*.yml</include>
</includes>
</resource>
</resources> </resources>
<plugins> <plugins>
<plugin> <plugin>
@@ -132,10 +108,6 @@
<id>bukkit-repo</id> <id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public/</url> <url>http://repo.bukkit.org/content/groups/public/</url>
</repository> </repository>
<repository>
<id>spout-repo</id>
<url>http://nexus.spout.org/content/groups/public/</url>
</repository>
<repository> <repository>
<id>Plugin MetricsExtension</id> <id>Plugin MetricsExtension</id>
<url>http://repo.turt2live.com</url> <url>http://repo.turt2live.com</url>
@@ -145,13 +117,6 @@
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId> <artifactId>bukkit</artifactId>
<version>1.5.2-R1.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.getspout</groupId>
<artifactId>spoutplugin</artifactId>
<version>LATEST</version> <version>LATEST</version>
<type>jar</type> <type>jar</type>
<scope>compile</scope> <scope>compile</scope>
@@ -179,6 +144,6 @@
</properties> </properties>
<ciManagement> <ciManagement>
<system>Jenkins</system> <system>Jenkins</system>
<url>ci.mcmmo.org</url> <url>http://ci.ecocitycraft.com/job/mcMMO</url>
</ciManagement> </ciManagement>
</project> </project>

View File

@@ -50,34 +50,34 @@ public final class AbilityAPI {
} }
public static void resetCooldowns(Player player) { public static void resetCooldowns(Player player) {
UserManager.getPlayer(player).getProfile().resetCooldowns(); UserManager.getPlayer(player).resetCooldowns();
} }
public static void setBerserkCooldown(Player player, long cooldown) { public static void setBerserkCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.BERSERK, cooldown); UserManager.getPlayer(player).setAbilityDATS(AbilityType.BERSERK, cooldown);
} }
public static void setGigaDrillBreakerCooldown(Player player, long cooldown) { public static void setGigaDrillBreakerCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.GIGA_DRILL_BREAKER, cooldown); UserManager.getPlayer(player).setAbilityDATS(AbilityType.GIGA_DRILL_BREAKER, cooldown);
} }
public static void setGreenTerraCooldown(Player player, long cooldown) { public static void setGreenTerraCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.GREEN_TERRA, cooldown); UserManager.getPlayer(player).setAbilityDATS(AbilityType.GREEN_TERRA, cooldown);
} }
public static void setSerratedStrikesCooldown(Player player, long cooldown) { public static void setSerratedStrikesCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.SERRATED_STRIKES, cooldown); UserManager.getPlayer(player).setAbilityDATS(AbilityType.SERRATED_STRIKES, cooldown);
} }
public static void setSkullSplitterCooldown(Player player, long cooldown) { public static void setSkullSplitterCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.SKULL_SPLITTER, cooldown); UserManager.getPlayer(player).setAbilityDATS(AbilityType.SKULL_SPLITTER, cooldown);
} }
public static void setSuperBreakerCooldown(Player player, long cooldown) { public static void setSuperBreakerCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.SUPER_BREAKER, cooldown); UserManager.getPlayer(player).setAbilityDATS(AbilityType.SUPER_BREAKER, cooldown);
} }
public static void setTreeFellerCooldown(Player player, long cooldown) { public static void setTreeFellerCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.TREE_FELLER, cooldown); UserManager.getPlayer(player).setAbilityDATS(AbilityType.TREE_FELLER, cooldown);
} }
} }

View File

@@ -5,8 +5,8 @@ import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.chat.ChatManager; import com.gmail.nossr50.chat.ChatManager;
import com.gmail.nossr50.chat.ChatManagerFactory; import com.gmail.nossr50.chat.ChatManagerFactory;
import com.gmail.nossr50.chat.ChatMode;
import com.gmail.nossr50.chat.PartyChatManager; import com.gmail.nossr50.chat.PartyChatManager;
import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
@@ -76,7 +76,7 @@ public final class ChatAPI {
* @return true if the player is using party chat, false otherwise * @return true if the player is using party chat, false otherwise
*/ */
public static boolean isUsingPartyChat(Player player) { public static boolean isUsingPartyChat(Player player) {
return UserManager.getPlayer(player).getPartyChatMode(); return UserManager.getPlayer(player).isChatEnabled(ChatMode.PARTY);
} }
/** /**
@@ -86,7 +86,7 @@ public final class ChatAPI {
* @return true if the player is using party chat, false otherwise * @return true if the player is using party chat, false otherwise
*/ */
public static boolean isUsingPartyChat(String playerName) { public static boolean isUsingPartyChat(String playerName) {
return UserManager.getPlayer(playerName).getPartyChatMode(); return UserManager.getPlayer(playerName).isChatEnabled(ChatMode.PARTY);
} }
/** /**
@@ -96,7 +96,7 @@ public final class ChatAPI {
* @return true if the player is using admin chat, false otherwise * @return true if the player is using admin chat, false otherwise
*/ */
public static boolean isUsingAdminChat(Player player) { public static boolean isUsingAdminChat(Player player) {
return UserManager.getPlayer(player).getAdminChatMode(); return UserManager.getPlayer(player).isChatEnabled(ChatMode.ADMIN);
} }
/** /**
@@ -106,7 +106,7 @@ public final class ChatAPI {
* @return true if the player is using admin chat, false otherwise * @return true if the player is using admin chat, false otherwise
*/ */
public static boolean isUsingAdminChat(String playerName) { public static boolean isUsingAdminChat(String playerName) {
return UserManager.getPlayer(playerName).getAdminChatMode(); return UserManager.getPlayer(playerName).isChatEnabled(ChatMode.ADMIN);
} }
/** /**
@@ -115,7 +115,7 @@ public final class ChatAPI {
* @param player The player to toggle party chat on. * @param player The player to toggle party chat on.
*/ */
public static void togglePartyChat(Player player) { public static void togglePartyChat(Player player) {
UserManager.getPlayer(player).togglePartyChat(); UserManager.getPlayer(player).toggleChat(ChatMode.PARTY);
} }
/** /**
@@ -124,7 +124,7 @@ public final class ChatAPI {
* @param playerName The name of the player to toggle party chat on. * @param playerName The name of the player to toggle party chat on.
*/ */
public static void togglePartyChat(String playerName) { public static void togglePartyChat(String playerName) {
UserManager.getPlayer(playerName).togglePartyChat(); UserManager.getPlayer(playerName).toggleChat(ChatMode.PARTY);
} }
/** /**
@@ -133,7 +133,7 @@ public final class ChatAPI {
* @param player The player to toggle admin chat on. * @param player The player to toggle admin chat on.
*/ */
public static void toggleAdminChat(Player player) { public static void toggleAdminChat(Player player) {
UserManager.getPlayer(player).toggleAdminChat(); UserManager.getPlayer(player).toggleChat(ChatMode.ADMIN);
} }
/** /**
@@ -142,7 +142,7 @@ public final class ChatAPI {
* @param playerName The name of the player to toggle party chat on. * @param playerName The name of the player to toggle party chat on.
*/ */
public static void toggleAdminChat(String playerName) { public static void toggleAdminChat(String playerName) {
UserManager.getPlayer(playerName).toggleAdminChat(); UserManager.getPlayer(playerName).toggleChat(ChatMode.ADMIN);
} }
private static ChatManager getPartyChatManager(Plugin plugin, String party) { private static ChatManager getPartyChatManager(Plugin plugin, String party) {

View File

@@ -8,6 +8,7 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.api.exceptions.InvalidPlayerException; import com.gmail.nossr50.api.exceptions.InvalidPlayerException;
import com.gmail.nossr50.api.exceptions.InvalidSkillException; import com.gmail.nossr50.api.exceptions.InvalidSkillException;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.skills.child.FamilyTree; import com.gmail.nossr50.skills.child.FamilyTree;
@@ -47,6 +48,11 @@ public final class ExperienceAPI {
return !skill.isChildSkill(); return !skill.isChildSkill();
} }
@Deprecated
public static void addRawXP(Player player, String skillType, int XP) {
addRawXP(player, skillType, (float) XP);
}
/** /**
* Adds raw XP to the player. * Adds raw XP to the player.
* </br> * </br>
@@ -58,10 +64,15 @@ public final class ExperienceAPI {
* *
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
*/ */
public static void addRawXP(Player player, String skillType, int XP) { public static void addRawXP(Player player, String skillType, float XP) {
UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), XP); UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), XP);
} }
@Deprecated
public static void addRawXPOffline(String playerName, String skillType, int XP) {
addRawXPOffline(playerName, skillType, (float) XP);
}
/** /**
* Adds raw XP to an offline player. * Adds raw XP to an offline player.
* </br> * </br>
@@ -74,8 +85,8 @@ public final class ExperienceAPI {
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
*/ */
public static void addRawXPOffline(String playerName, String skillType, int XP) { public static void addRawXPOffline(String playerName, String skillType, float XP) {
addOfflineXP(playerName, getSkillType(skillType), XP); addOfflineXP(playerName, getSkillType(skillType), (int) Math.floor(XP));
} }
/** /**
@@ -90,7 +101,7 @@ public final class ExperienceAPI {
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
*/ */
public static void addMultipliedXP(Player player, String skillType, int XP) { public static void addMultipliedXP(Player player, String skillType, int XP) {
UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier())); UserManager.getPlayer(player).applyXpGain(getSkillType(skillType), (int) (XP * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
} }
/** /**
@@ -106,7 +117,7 @@ public final class ExperienceAPI {
* @throws InvalidPlayerException if the given player does not exist in the database * @throws InvalidPlayerException if the given player does not exist in the database
*/ */
public static void addMultipliedXPOffline(String playerName, String skillType, int XP) { public static void addMultipliedXPOffline(String playerName, String skillType, int XP) {
addOfflineXP(playerName, getSkillType(skillType), (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier())); addOfflineXP(playerName, getSkillType(skillType), (int) (XP * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
} }
/** /**
@@ -123,7 +134,7 @@ public final class ExperienceAPI {
public static void addModifiedXP(Player player, String skillType, int XP) { public static void addModifiedXP(Player player, String skillType, int XP) {
SkillType skill = getSkillType(skillType); SkillType skill = getSkillType(skillType);
UserManager.getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier())); UserManager.getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
} }
/** /**
@@ -141,7 +152,7 @@ public final class ExperienceAPI {
public static void addModifiedXPOffline(String playerName, String skillType, int XP) { public static void addModifiedXPOffline(String playerName, String skillType, int XP) {
SkillType skill = getSkillType(skillType); SkillType skill = getSkillType(skillType);
addOfflineXP(playerName, skill, (int) (XP / skill.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier())); addOfflineXP(playerName, skill, (int) (XP / skill.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
} }
/** /**
@@ -173,7 +184,7 @@ public final class ExperienceAPI {
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static int getXP(Player player, String skillType) { public static int getXP(Player player, String skillType) {
return UserManager.getPlayer(player).getProfile().getSkillXpLevel(getNonChildSkillType(skillType)); return UserManager.getPlayer(player).getSkillXpLevel(getNonChildSkillType(skillType));
} }
/** /**
@@ -206,7 +217,7 @@ public final class ExperienceAPI {
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static float getXPRaw(Player player, String skillType) { public static float getXPRaw(Player player, String skillType) {
return UserManager.getPlayer(player).getProfile().getSkillXpLevelRaw(getNonChildSkillType(skillType)); return UserManager.getPlayer(player).getSkillXpLevelRaw(getNonChildSkillType(skillType));
} }
/** /**
@@ -239,7 +250,7 @@ public final class ExperienceAPI {
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static int getXPToNextLevel(Player player, String skillType) { public static int getXPToNextLevel(Player player, String skillType) {
return UserManager.getPlayer(player).getProfile().getXpToLevel(getNonChildSkillType(skillType)); return UserManager.getPlayer(player).getXpToLevel(getNonChildSkillType(skillType));
} }
/** /**
@@ -312,7 +323,7 @@ public final class ExperienceAPI {
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
*/ */
public static void addLevel(Player player, String skillType, int levels) { public static void addLevel(Player player, String skillType, int levels) {
UserManager.getPlayer(player).getProfile().addLevels(getSkillType(skillType), levels); UserManager.getPlayer(player).addLevels(getSkillType(skillType), levels);
} }
/** /**
@@ -358,7 +369,7 @@ public final class ExperienceAPI {
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
*/ */
public static int getLevel(Player player, String skillType) { public static int getLevel(Player player, String skillType) {
return UserManager.getPlayer(player).getProfile().getSkillLevel(getSkillType(skillType)); return UserManager.getPlayer(player).getSkillLevel(getSkillType(skillType));
} }
/** /**
@@ -403,7 +414,7 @@ public final class ExperienceAPI {
int powerLevel = 0; int powerLevel = 0;
PlayerProfile profile = getOfflineProfile(playerName); PlayerProfile profile = getOfflineProfile(playerName);
for (SkillType type : SkillType.nonChildSkills()) { for (SkillType type : SkillType.NON_CHILD_SKILLS) {
powerLevel += profile.getSkillLevel(type); powerLevel += profile.getSkillLevel(type);
} }
@@ -435,6 +446,40 @@ public final class ExperienceAPI {
return Config.getInstance().getPowerLevelCap(); return Config.getInstance().getPowerLevelCap();
} }
/**
* Get the position on the leaderboard of a player.
* </br>
* This function is designed for API usage.
*
* @param playerName The name of the player to check
* @param skillType The skill to check
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill
*
* @return the position on the leaderboard
*/
public static int getPlayerRankSkill(String playerName, String skillType) {
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(getNonChildSkillType(skillType));
}
/**
* Get the position on the power level leaderboard of a player.
* </br>
* This function is designed for API usage.
*
* @param playerName The name of the player to check
*
* @throws InvalidPlayerException if the given player does not exist in the database
*
* @return the position on the power level leaderboard
*/
public static int getPlayerRankOverall(String playerName) {
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(null);
}
/** /**
* Sets the level of a player in a specific skill type. * Sets the level of a player in a specific skill type.
* </br> * </br>
@@ -447,7 +492,7 @@ public final class ExperienceAPI {
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
*/ */
public static void setLevel(Player player, String skillType, int skillLevel) { public static void setLevel(Player player, String skillType, int skillLevel) {
UserManager.getPlayer(player).getProfile().modifySkill(getSkillType(skillType), skillLevel); UserManager.getPlayer(player).modifySkill(getSkillType(skillType), skillLevel);
} }
/** /**
@@ -479,7 +524,7 @@ public final class ExperienceAPI {
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static void setXP(Player player, String skillType, int newValue) { public static void setXP(Player player, String skillType, int newValue) {
UserManager.getPlayer(player).getProfile().setSkillXpLevel(getNonChildSkillType(skillType), newValue); UserManager.getPlayer(player).setSkillXpLevel(getNonChildSkillType(skillType), newValue);
} }
/** /**
@@ -512,7 +557,7 @@ public final class ExperienceAPI {
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static void removeXP(Player player, String skillType, int xp) { public static void removeXP(Player player, String skillType, int xp) {
UserManager.getPlayer(player).getProfile().removeXp(getNonChildSkillType(skillType), xp); UserManager.getPlayer(player).removeXp(getNonChildSkillType(skillType), xp);
} }
/** /**
@@ -537,18 +582,7 @@ public final class ExperienceAPI {
private static void addOfflineXP(String playerName, SkillType skill, int XP) { private static void addOfflineXP(String playerName, SkillType skill, int XP) {
PlayerProfile profile = getOfflineProfile(playerName); PlayerProfile profile = getOfflineProfile(playerName);
if (skill.isChildSkill()) { profile.addXp(skill, XP);
Set<SkillType> parentSkills = FamilyTree.getParents(skill);
for (SkillType parentSkill : parentSkills) {
profile.setSkillXpLevel(parentSkill, profile.getSkillLevel(parentSkill) + (XP / parentSkills.size()));
}
profile.save();
return;
}
profile.setSkillXpLevel(skill, profile.getSkillXpLevel(skill) + XP);
profile.save(); profile.save();
} }

View File

@@ -77,13 +77,12 @@ public final class PartyAPI {
*/ */
public static void addToParty(Player player, String partyName) { public static void addToParty(Player player, String partyName) {
Party party = PartyManager.getParty(partyName); Party party = PartyManager.getParty(partyName);
String playerName = player.getName();
if (party == null) { if (party == null) {
party = new Party(playerName, partyName); party = new Party(player.getName(), partyName);
} }
PartyManager.addToParty(playerName, UserManager.getPlayer(player), party); PartyManager.addToParty(UserManager.getPlayer(player), party);
} }
/** /**
@@ -94,7 +93,7 @@ public final class PartyAPI {
* @param player The player to remove * @param player The player to remove
*/ */
public static void removeFromParty(Player player) { public static void removeFromParty(Player player) {
PartyManager.removeFromParty(player, UserManager.getPlayer(player).getParty()); PartyManager.removeFromParty(UserManager.getPlayer(player));
} }
/** /**

View File

@@ -1,29 +0,0 @@
package com.gmail.nossr50.api;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.spout.SpoutConfig;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
import com.gmail.nossr50.util.player.UserManager;
public class SpoutHudAPI {
private SpoutHudAPI() {}
/**
* Disable the mcMMO XP bar for a player.
* </br>
* This function is designed for API usage.
*/
public static void disableXpBar(Player player) {
UserManager.getPlayer(player).getProfile().setHudType(HudType.DISABLED);
}
/**
* Disable the mcMMO XP bar for the server.
* </br>
* This function is designed for API usage.
*/
public static void disableXpBar() {
SpoutConfig.getInstance().setXPBarEnabled(false);
}
}

View File

@@ -1,53 +0,0 @@
package com.gmail.nossr50.api;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.skills.ToolType;
public final class SpoutToolsAPI {
public static final List<ItemStack> spoutSwords = new ArrayList<ItemStack>();
public static final List<ItemStack> spoutAxes = new ArrayList<ItemStack>();
public static final List<ItemStack> spoutPickaxes = new ArrayList<ItemStack>();
public static final List<ItemStack> spoutHoes = new ArrayList<ItemStack>();
public static final List<ItemStack> spoutShovels = new ArrayList<ItemStack>();
private SpoutToolsAPI() {}
/**
* Add a custom Spout tool to mcMMO for XP gain & ability use.
* </br>
* 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

@@ -7,7 +7,7 @@ import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
public class AdminChatManager extends ChatManager { public class AdminChatManager extends ChatManager {
protected AdminChatManager(Plugin plugin) { protected AdminChatManager(Plugin plugin) {
super(plugin, Config.getInstance().getAdminDisplayNames(), "Commands.AdminChat.Prefix"); super(plugin, Config.getInstance().getAdminDisplayNames(), Config.getInstance().getAdminChatPrefix());
} }
@Override @Override

View File

@@ -11,6 +11,7 @@ public abstract class ChatManager {
protected boolean useDisplayNames; protected boolean useDisplayNames;
protected String chatPrefix; protected String chatPrefix;
protected String senderName;
protected String displayName; protected String displayName;
protected String message; protected String message;
@@ -27,8 +28,9 @@ public abstract class ChatManager {
return; return;
} }
displayName = useDisplayNames ? event.getDisplayName() : event.getSender(); senderName = event.getSender();
message = LocaleLoader.getString(chatPrefix, displayName) + event.getMessage(); displayName = useDisplayNames ? event.getDisplayName() : senderName;
message = LocaleLoader.formatString(chatPrefix, displayName) + " " + event.getMessage();
sendMessage(); sendMessage();
} }

View File

@@ -4,6 +4,8 @@ import java.util.HashMap;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.datatypes.chat.ChatMode;
public class ChatManagerFactory { public class ChatManagerFactory {
private static final HashMap<Plugin, AdminChatManager> adminChatManagers = new HashMap<Plugin, AdminChatManager>(); private static final HashMap<Plugin, AdminChatManager> adminChatManagers = new HashMap<Plugin, AdminChatManager>();
private static final HashMap<Plugin, PartyChatManager> partyChatManagers = new HashMap<Plugin, PartyChatManager>(); private static final HashMap<Plugin, PartyChatManager> partyChatManagers = new HashMap<Plugin, PartyChatManager>();

View File

@@ -1,70 +0,0 @@
package com.gmail.nossr50.chat;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
public enum ChatMode {
ADMIN(LocaleLoader.getString("Commands.AdminChat.On"), LocaleLoader.getString("Commands.AdminChat.Off")),
PARTY(LocaleLoader.getString("Commands.Party.Chat.On"), LocaleLoader.getString("Commands.Party.Chat.Off"));
private String enabledMessage;
private String disabledMessage;
private ChatMode(String enabledMessage, String disabledMessage) {
this.enabledMessage = enabledMessage;
this.disabledMessage = disabledMessage;
}
public boolean isEnabled(McMMOPlayer mcMMOPlayer) {
switch (this) {
case ADMIN:
return mcMMOPlayer.getAdminChatMode();
case PARTY:
return mcMMOPlayer.getPartyChatMode();
default:
return false;
}
}
public void disable(McMMOPlayer mcMMOPlayer) {
switch (this) {
case ADMIN:
mcMMOPlayer.setAdminChat(false);
return;
case PARTY:
mcMMOPlayer.setPartyChat(false);
return;
default:
return;
}
}
public void enable(McMMOPlayer mcMMOPlayer) {
switch (this) {
case ADMIN:
mcMMOPlayer.setAdminChat(true);
mcMMOPlayer.setPartyChat(false);
return;
case PARTY:
mcMMOPlayer.setPartyChat(true);
mcMMOPlayer.setAdminChat(false);
return;
default:
return;
}
}
public String getEnabledMessage() {
return enabledMessage;
}
public String getDisabledMessage() {
return disabledMessage;
}
}

View File

@@ -1,5 +1,9 @@
package com.gmail.nossr50.chat; package com.gmail.nossr50.chat;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@@ -11,7 +15,7 @@ public class PartyChatManager extends ChatManager {
private Party party; private Party party;
protected PartyChatManager(Plugin plugin) { protected PartyChatManager(Plugin plugin) {
super(plugin, Config.getInstance().getPartyDisplayNames(), "Commands.Party.Chat.Prefix"); super(plugin, Config.getInstance().getPartyDisplayNames(), Config.getInstance().getPartyChatPrefix());
} }
public void setParty(Party party) { public void setParty(Party party) {
@@ -25,6 +29,10 @@ public class PartyChatManager extends ChatManager {
@Override @Override
protected void sendMessage() { protected void sendMessage() {
if (Config.getInstance().getPartyChatColorLeaderName() && senderName.equalsIgnoreCase(party.getLeader())) {
message = message.replaceFirst(Pattern.quote(displayName), ChatColor.GOLD + Matcher.quoteReplacement(displayName) + ChatColor.RESET);
}
for (Player member : party.getOnlineMembers()) { for (Player member : party.getOnlineMembers()) {
member.sendMessage(message); member.sendMessage(message);
} }

View File

@@ -7,13 +7,14 @@ import java.util.Set;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public class KrakenCommand implements TabExecutor { public class KrakenCommand implements TabExecutor {
@@ -30,7 +31,7 @@ public class KrakenCommand implements TabExecutor {
return true; return true;
} }
UserManager.getPlayer((Player) sender).getFishingManager().unleashTheKraken(); UserManager.getPlayer(sender.getName()).getFishingManager().unleashTheKraken();
return true; return true;
case 1: case 1:
@@ -39,9 +40,10 @@ public class KrakenCommand implements TabExecutor {
return true; return true;
} }
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]); String playerName = Misc.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
if (!CommandUtils.checkPlayerExistence(sender, args[0], mcMMOPlayer)) { if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
return true; return true;
} }
@@ -57,7 +59,7 @@ public class KrakenCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
Set<String> playerNames = UserManager.getPlayers().keySet(); Set<String> playerNames = UserManager.getPlayerNames();
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size())); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default: default:
return ImmutableList.of(); return ImmutableList.of();

View File

@@ -2,6 +2,7 @@ package com.gmail.nossr50.commands;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
@@ -17,13 +18,13 @@ public class McabilityCommand extends ToggleCommand {
} }
@Override @Override
protected void applyCommandAction() { protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
player.sendMessage(LocaleLoader.getString("Commands.Ability." + (mcMMOPlayer.getAbilityUse() ? "Off" : "On"))); mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Ability." + (mcMMOPlayer.getAbilityUse() ? "Off" : "On")));
mcMMOPlayer.toggleAbilityUse(); mcMMOPlayer.toggleAbilityUse();
} }
@Override @Override
protected void sendSuccessMessage(CommandSender sender) { protected void sendSuccessMessage(CommandSender sender, String playerName) {
sender.sendMessage("Ability use has been toggled for " + player.getName()); // TODO: Localize sender.sendMessage(LocaleLoader.getString("Commands.Ability.Toggle", playerName));
} }
} }

View File

@@ -0,0 +1,93 @@
package com.gmail.nossr50.commands;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.database.ConvertDatabaseCommand;
import com.gmail.nossr50.commands.experience.ConvertExperienceCommand;
import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.google.common.collect.ImmutableList;
public class McconvertCommand implements TabExecutor {
private static final List<String> FORMULA_TYPES;
private static final List<String> DATABASE_TYPES;
private static final List<String> SUBCOMMANDS = ImmutableList.of("database", "experience");
private CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand();
private CommandExecutor experienceConvertCommand = new ConvertExperienceCommand();
static {
ArrayList<String> formulaTypes = new ArrayList<String>();
ArrayList<String> databaseTypes = new ArrayList<String>();
for (FormulaType type : FormulaType.values()) {
formulaTypes.add(type.toString());
}
for (DatabaseType type : DatabaseType.values()) {
databaseTypes.add(type.toString());
}
// Custom stuff
databaseTypes.remove(DatabaseType.CUSTOM.toString());
if (mcMMO.getDatabaseManager().getDatabaseType() == DatabaseType.CUSTOM) {
databaseTypes.add(DatabaseManagerFactory.getCustomDatabaseManagerClass().getName());
}
Collections.sort(formulaTypes);
Collections.sort(databaseTypes);
FORMULA_TYPES = ImmutableList.copyOf(formulaTypes);
DATABASE_TYPES = ImmutableList.copyOf(databaseTypes);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) {
return databaseConvertCommand.onCommand(sender, command, label, args);
}
else if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[1].equalsIgnoreCase("exp")) {
return experienceConvertCommand.onCommand(sender, command, label, args);
}
return false;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
return StringUtil.copyPartialMatches(args[0], SUBCOMMANDS, new ArrayList<String>(SUBCOMMANDS.size()));
case 2:
if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) {
return StringUtil.copyPartialMatches(args[0], DATABASE_TYPES, new ArrayList<String>(DATABASE_TYPES.size()));
}
if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[0].equalsIgnoreCase("exp")) {
return StringUtil.copyPartialMatches(args[0], FORMULA_TYPES, new ArrayList<String>(FORMULA_TYPES.size()));
}
return ImmutableList.of();
default:
return ImmutableList.of();
}
}
}

View File

@@ -2,6 +2,7 @@ package com.gmail.nossr50.commands;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
@@ -17,13 +18,13 @@ public class McgodCommand extends ToggleCommand {
} }
@Override @Override
protected void applyCommandAction() { protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
player.sendMessage(LocaleLoader.getString("Commands.GodMode." + (mcMMOPlayer.getGodMode() ? "Disabled" : "Enabled"))); mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.GodMode." + (mcMMOPlayer.getGodMode() ? "Disabled" : "Enabled")));
mcMMOPlayer.toggleGodMode(); mcMMOPlayer.toggleGodMode();
} }
@Override @Override
protected void sendSuccessMessage(CommandSender sender) { protected void sendSuccessMessage(CommandSender sender, String playerName) {
sender.sendMessage("God mode has been toggled for " + player.getName()); // TODO: Localize sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Toggle", playerName));
} }
} }

View File

@@ -4,14 +4,13 @@ import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.party.PartySubcommandType; import com.gmail.nossr50.commands.party.PartySubcommandType;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.HolidayManager;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.spout.SpoutUtils;
public class McmmoCommand implements CommandExecutor { public class McmmoCommand implements CommandExecutor {
@Override @Override
@@ -28,16 +27,12 @@ public class McmmoCommand implements CommandExecutor {
sender.sendMessage(mcSplit); sender.sendMessage(mcSplit);
if (Config.getInstance().getDonateMessageEnabled()) { if (Config.getInstance().getDonateMessageEnabled()) {
if (mcMMO.isSpoutEnabled() && sender instanceof Player) {
SpoutUtils.sendDonationNotification((Player) sender);
}
else {
sender.sendMessage(LocaleLoader.getString("MOTD.Donate")); sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal"); sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
} }
}
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion())); sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
HolidayManager.anniversaryCheck(sender);
return true; return true;
case 1: case 1:

View File

@@ -2,6 +2,7 @@ package com.gmail.nossr50.commands;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
@@ -17,17 +18,17 @@ public class McrefreshCommand extends ToggleCommand {
} }
@Override @Override
protected void applyCommandAction() { protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
mcMMOPlayer.setRecentlyHurt(0); mcMMOPlayer.setRecentlyHurt(0);
mcMMOPlayer.getProfile().resetCooldowns(); mcMMOPlayer.resetCooldowns();
mcMMOPlayer.resetToolPrepMode(); mcMMOPlayer.resetToolPrepMode();
mcMMOPlayer.resetAbilityMode(); mcMMOPlayer.resetAbilityMode();
player.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh")); mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
} }
@Override @Override
protected void sendSuccessMessage(CommandSender sender) { protected void sendSuccessMessage(CommandSender sender, String playerName) {
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", player.getName())); sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", playerName));
} }
} }

View File

@@ -6,20 +6,17 @@ import java.util.List;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public class McscoreboardCommand implements TabExecutor { public class McscoreboardCommand implements TabExecutor {
private static final List<String> SCOREBOARD_TYPES = ImmutableList.of("clear", "rank", "stats", "top"); private static final List<String> FIRST_ARGS = ImmutableList.of("keep", "time", "clear");
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
@@ -27,94 +24,49 @@ public class McscoreboardCommand implements TabExecutor {
return true; return true;
} }
Player player = (Player) sender;
switch (args.length) { switch (args.length) {
case 0:
clearScoreboard(player);
return true;
case 1: case 1:
if (args[0].equalsIgnoreCase("clear")) { if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) {
clearScoreboard(player); ScoreboardManager.clearBoard(sender.getName());
} sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Clear"));
else if (args[0].equalsIgnoreCase("rank")) {
if (!Config.getInstance().getMcrankScoreboardEnabled()) {
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
return true; return true;
} }
ScoreboardManager.setupPlayerScoreboard(player.getName()); if (args[0].equalsIgnoreCase("keep")) {
ScoreboardManager.enablePlayerRankScoreboard(player); if (!Config.getInstance().getAllowKeepBoard()) {
} sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
else if (args[0].equalsIgnoreCase("stats")) {
if (!Config.getInstance().getMcstatsScoreboardsEnabled()) {
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
return true; return true;
} }
ScoreboardManager.setupPlayerScoreboard(player.getName()); if (!ScoreboardManager.isBoardShown(sender.getName())) {
ScoreboardManager.enablePlayerStatsScoreboard(UserManager.getPlayer(player)); sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.NoBoard"));
}
else if (args[0].equalsIgnoreCase("top")) {
if (!Config.getInstance().getMctopScoreboardEnabled()) {
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
return true; return true;
} }
ScoreboardManager.enableGlobalStatsScoreboard(player, "all", 1); ScoreboardManager.keepBoard(sender.getName());
} sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Keep"));
else { return true;
return false;
} }
return true; return help(sender);
case 2: case 2:
if (!args[0].equalsIgnoreCase("top")) { if (args[0].equalsIgnoreCase("time") || args[0].equalsIgnoreCase("timer")) {
return false; if (CommandUtils.isInvalidInteger(sender, args[1])) {
}
if (!Config.getInstance().getMctopScoreboardEnabled()) {
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
return true; return true;
} }
if (StringUtils.isInt(args[1])) { int time = Math.abs(Integer.parseInt(args[1]));
ScoreboardManager.enableGlobalStatsScoreboard(player, "all", Math.abs(Integer.parseInt(args[1])));
ScoreboardManager.setRevertTimer(sender.getName(), time);
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Timer", time));
return true; return true;
} }
if (CommandUtils.isInvalidSkill(sender, args[1])) { return help(sender);
return true;
}
ScoreboardManager.enableGlobalStatsScoreboard(player, args[1], 1);
return true;
case 3:
if (!args[0].equalsIgnoreCase("top")) {
return false;
}
if (!Config.getInstance().getMctopScoreboardEnabled()) {
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
return true;
}
if (CommandUtils.isInvalidSkill(sender, args[1])) {
return true;
}
if (CommandUtils.isInvalidInteger(sender, args[2])) {
return true;
}
ScoreboardManager.enableGlobalStatsScoreboard(player, args[1], Math.abs(Integer.parseInt(args[2])));
return true;
default: default:
return false; return help(sender);
} }
} }
@@ -122,20 +74,17 @@ public class McscoreboardCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
return StringUtil.copyPartialMatches(args[0], SCOREBOARD_TYPES, new ArrayList<String>(SCOREBOARD_TYPES.size())); return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList<String>(FIRST_ARGS.size()));
case 2:
if (args[0].equalsIgnoreCase("top")) {
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
}
// Fallthrough
default: default:
return ImmutableList.of(); return ImmutableList.of();
} }
} }
private void clearScoreboard(Player player) { private boolean help(CommandSender sender) {
player.setScoreboard(mcMMO.p.getServer().getScoreboardManager().getMainScoreboard()); sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.0"));
player.sendMessage("Your scoreboard has been cleared!"); //TODO: Locale sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.1"));
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.2"));
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.3"));
return true;
} }
} }

View File

@@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.MobHealthbarType; import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
@@ -39,16 +39,14 @@ public class MobhealthCommand implements TabExecutor {
switch (args.length) { switch (args.length) {
case 1: case 1:
PlayerProfile playerProfile = UserManager.getPlayer((Player) sender).getProfile();
try { try {
MobHealthbarType type = MobHealthbarType.valueOf(args[0].toUpperCase().trim()); MobHealthbarType type = MobHealthbarType.valueOf(args[0].toUpperCase().trim());
playerProfile.setMobHealthbarType(type); UserManager.getPlayer((Player) sender).getProfile().setMobHealthbarType(type);
sender.sendMessage("Display type changed to: " + type); //TODO: Localize sender.sendMessage(LocaleLoader.getString("Commands.Healthbars.Changed." + type.name()));
return true; return true;
} }
catch (IllegalArgumentException ex) { catch (IllegalArgumentException ex) {
sender.sendMessage("Invalid type!"); //TODO: Localize sender.sendMessage(LocaleLoader.getString("Commands.Healthbars.Invalid"));
return true; return true;
} }

View File

@@ -7,19 +7,16 @@ import java.util.Set;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public abstract class ToggleCommand implements TabExecutor { public abstract class ToggleCommand implements TabExecutor {
protected McMMOPlayer mcMMOPlayer;
protected Player player;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
@@ -33,10 +30,7 @@ public abstract class ToggleCommand implements TabExecutor {
return true; return true;
} }
player = (Player) sender; applyCommandAction(UserManager.getPlayer(sender.getName()));
mcMMOPlayer = UserManager.getPlayer(player);
applyCommandAction();
return true; return true;
case 1: case 1:
@@ -45,20 +39,19 @@ public abstract class ToggleCommand implements TabExecutor {
return true; return true;
} }
mcMMOPlayer = UserManager.getPlayer(args[0]); String playerName = Misc.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
if (!CommandUtils.checkPlayerExistence(sender, args[0], mcMMOPlayer)) { if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
return true; return true;
} }
player = mcMMOPlayer.getPlayer(); if (CommandUtils.isOffline(sender, mcMMOPlayer.getPlayer())) {
if (CommandUtils.isOffline(sender, player)) {
return true; return true;
} }
applyCommandAction(); applyCommandAction(mcMMOPlayer);
sendSuccessMessage(sender); sendSuccessMessage(sender, playerName);
return true; return true;
default: default:
@@ -70,7 +63,7 @@ public abstract class ToggleCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
Set<String> playerNames = UserManager.getPlayers().keySet(); Set<String> playerNames = UserManager.getPlayerNames();
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size())); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default: default:
return ImmutableList.of(); return ImmutableList.of();
@@ -79,6 +72,6 @@ public abstract class ToggleCommand implements TabExecutor {
protected abstract boolean hasOtherPermission(CommandSender sender); protected abstract boolean hasOtherPermission(CommandSender sender);
protected abstract boolean hasSelfPermission(CommandSender sender); protected abstract boolean hasSelfPermission(CommandSender sender);
protected abstract void applyCommandAction(); protected abstract void applyCommandAction(McMMOPlayer mcMMOPlayer);
protected abstract void sendSuccessMessage(CommandSender sender); protected abstract void sendSuccessMessage(CommandSender sender, String playerName);
} }

View File

@@ -9,7 +9,7 @@ import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
@@ -18,11 +18,7 @@ import com.gmail.nossr50.util.commands.CommandUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public class XprateCommand implements TabExecutor { public class XprateCommand implements TabExecutor {
private double originalRate; private final double ORIGINAL_XP_RATE = ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier();
public XprateCommand() {
originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
@@ -42,7 +38,7 @@ public class XprateCommand implements TabExecutor {
mcMMO.p.toggleXpEventEnabled(); mcMMO.p.toggleXpEventEnabled();
} }
Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate); ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(ORIGINAL_XP_RATE);
return true; return true;
case 2: case 2:
@@ -66,7 +62,7 @@ public class XprateCommand implements TabExecutor {
} }
int newXpRate = Integer.parseInt(args[0]); int newXpRate = Integer.parseInt(args[0]);
Config.getInstance().setExperienceGainsGlobalMultiplier(newXpRate); ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
if (mcMMO.p.isXPEventEnabled()) { if (mcMMO.p.isXPEventEnabled()) {
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.0")); mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.0"));

View File

@@ -2,7 +2,7 @@ package com.gmail.nossr50.commands.chat;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.gmail.nossr50.chat.ChatMode; import com.gmail.nossr50.datatypes.chat.ChatMode;
public class AdminChatCommand extends ChatCommand { public class AdminChatCommand extends ChatCommand {
public AdminChatCommand() { public AdminChatCommand() {

View File

@@ -12,7 +12,7 @@ import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.chat.ChatManager; import com.gmail.nossr50.chat.ChatManager;
import com.gmail.nossr50.chat.ChatManagerFactory; import com.gmail.nossr50.chat.ChatManagerFactory;
import com.gmail.nossr50.chat.ChatMode; import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
@@ -21,9 +21,8 @@ import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public abstract class ChatCommand implements TabExecutor { public abstract class ChatCommand implements TabExecutor {
protected ChatMode chatMode; private ChatMode chatMode;
protected ChatManager chatManager; protected ChatManager chatManager;
private McMMOPlayer mcMMOPlayer;
public ChatCommand(ChatMode chatMode) { public ChatCommand(ChatMode chatMode) {
this.chatMode = chatMode; this.chatMode = chatMode;
@@ -32,19 +31,21 @@ public abstract class ChatCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
McMMOPlayer mcMMOPlayer;
switch (args.length) { switch (args.length) {
case 0: case 0:
if (CommandUtils.noConsoleUsage(sender)) { if (CommandUtils.noConsoleUsage(sender)) {
return true; return true;
} }
mcMMOPlayer = UserManager.getPlayer((Player) sender); mcMMOPlayer = UserManager.getPlayer(sender.getName());
if (chatMode.isEnabled(mcMMOPlayer)) { if (mcMMOPlayer.isChatEnabled(chatMode)) {
disableChatMode(sender); disableChatMode(mcMMOPlayer, sender);
} }
else { else {
enableChatMode(sender); enableChatMode(mcMMOPlayer, sender);
} }
return true; return true;
@@ -55,9 +56,7 @@ public abstract class ChatCommand implements TabExecutor {
return true; return true;
} }
mcMMOPlayer = UserManager.getPlayer((Player) sender); enableChatMode(UserManager.getPlayer(sender.getName()), sender);
enableChatMode(sender);
return true; return true;
} }
@@ -66,9 +65,7 @@ public abstract class ChatCommand implements TabExecutor {
return true; return true;
} }
mcMMOPlayer = UserManager.getPlayer((Player) sender); disableChatMode(UserManager.getPlayer(sender.getName()), sender);
disableChatMode(sender);
return true; return true;
} }
@@ -108,23 +105,23 @@ public abstract class ChatCommand implements TabExecutor {
protected abstract void handleChatSending(CommandSender sender, String[] args); protected abstract void handleChatSending(CommandSender sender, String[] args);
private void enableChatMode(CommandSender sender) { private void enableChatMode(McMMOPlayer mcMMOPlayer, CommandSender sender) {
if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) { if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return; return;
} }
chatMode.enable(mcMMOPlayer); mcMMOPlayer.enableChat(chatMode);
sender.sendMessage(chatMode.getEnabledMessage()); sender.sendMessage(chatMode.getEnabledMessage());
} }
private void disableChatMode(CommandSender sender) { private void disableChatMode(McMMOPlayer mcMMOPlayer, CommandSender sender) {
if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) { if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return; return;
} }
chatMode.disable(mcMMOPlayer); mcMMOPlayer.disableChat(chatMode);
sender.sendMessage(chatMode.getDisabledMessage()); sender.sendMessage(chatMode.getDisabledMessage());
} }
} }

View File

@@ -3,8 +3,8 @@ package com.gmail.nossr50.commands.chat;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.chat.ChatMode;
import com.gmail.nossr50.chat.PartyChatManager; import com.gmail.nossr50.chat.PartyChatManager;
import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;

View File

@@ -0,0 +1,60 @@
package com.gmail.nossr50.commands.database;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.database.DatabaseManager;
import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.database.DatabaseConversionTask;
import com.gmail.nossr50.util.player.UserManager;
public class ConvertDatabaseCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
DatabaseType previousType = DatabaseType.getDatabaseType(args[1]);
DatabaseType newType = mcMMO.getDatabaseManager().getDatabaseType();
if (previousType == newType || (newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1]))) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Same", newType.toString()));
return true;
}
DatabaseManager oldDatabase = DatabaseManagerFactory.createDatabaseManager(previousType);
if (previousType == DatabaseType.CUSTOM) {
Class<?> clazz;
try {
clazz = Class.forName(args[1]);
if (!DatabaseManager.class.isAssignableFrom(clazz)) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
return true;
}
oldDatabase = DatabaseManagerFactory.createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz);
}
catch (Throwable e) {
e.printStackTrace();
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
return true;
}
}
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Start", previousType.toString(), newType.toString()));
UserManager.saveAll();
new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(mcMMO.p);
return true;
default:
return false;
}
}
}

View File

@@ -11,6 +11,7 @@ import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
@@ -21,15 +22,17 @@ public class McremoveCommand implements TabExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
if (UserManager.getPlayer(args[0]) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(args[0], false))) { String playerName = Misc.getMatchedPlayerName(args[0]);
if (UserManager.getPlayer(playerName, true) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false))) {
return true; return true;
} }
if (mcMMO.getDatabaseManager().removeUser(args[0])) { if (mcMMO.getDatabaseManager().removeUser(playerName)) {
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0])); sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", playerName));
} }
else { else {
sender.sendMessage(args[0] + " could not be removed from the database."); // Pretty sure this should NEVER happen. sender.sendMessage(playerName + " could not be removed from the database."); // Pretty sure this should NEVER happen.
} }
return true; return true;
@@ -43,7 +46,7 @@ public class McremoveCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
Set<String> playerNames = UserManager.getPlayers().keySet(); Set<String> playerNames = UserManager.getPlayerNames();
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size())); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default: default:
return ImmutableList.of(); return ImmutableList.of();

View File

@@ -9,29 +9,26 @@ import org.bukkit.command.TabExecutor;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.database.DatabaseManagerFactory; import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public class MmoshowdbCommand implements TabExecutor { public class MmoshowdbCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length != 0) { switch (args.length) {
return false; case 0:
}
else {
Class<?> clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass(); Class<?> clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass();
if (clazz != null) { if (clazz != null) {
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", clazz.getName())); sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", clazz.getName()));
return true; return true;
} }
else {
if (Config.getInstance().getUseMySQL()) { sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (Config.getInstance().getUseMySQL() ? "sql" : "flatfile")));
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", "sql"));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", "flatfile"));
}
return true; return true;
}
default:
return false;
} }
} }

View File

@@ -1,138 +0,0 @@
package com.gmail.nossr50.commands.database;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.database.DatabaseManager;
import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.database.ConversionTask;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
public class MmoupdateCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
String argType = args[0];
String oldType = validateName(sender, args[0]);
if (oldType == null) {
return true;
}
String newType = getCurrentDb();
if (newType.equals(oldType)) {
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Same", argType));
return true;
}
DatabaseManager oldDb;
if (oldType == "sql") {
oldDb = DatabaseManagerFactory.createSQLDatabaseManager();
}
else if (oldType == "flatfile") {
oldDb = DatabaseManagerFactory.createFlatfileDatabaseManager();
}
else try {
@SuppressWarnings("unchecked")
Class<? extends DatabaseManager> clazz = (Class<? extends DatabaseManager>) Class.forName(oldType);
oldDb = DatabaseManagerFactory.createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz);
oldType = clazz.getSimpleName(); // For pretty-printing; we have the database now
}
catch (Throwable e) {
return false;
}
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Start", oldType, newType));
// Convert the online players right away, without waiting
// first, flush out the current data
UserManager.saveAll();
UserManager.clearAll();
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
// Get the profile from the old database and save it in the new
PlayerProfile profile = oldDb.loadPlayerProfile(player.getName(), false);
if (profile.isLoaded()) {
mcMMO.getDatabaseManager().saveUser(profile);
}
// Reload from the current database via UserManager
UserManager.addUser(player);
}
// Schedule the task for all users
new ConversionTask(oldDb, sender, oldType, newType).runTaskAsynchronously(mcMMO.p);
return true;
default:
break;
}
return false;
}
/**
* @return null - if type not recognized / class not found
* empty string - if type is same as current
* normalized string - if type is recognized
*/
private String validateName(CommandSender sender, String type) {
if (type.equalsIgnoreCase("sql") || type.equalsIgnoreCase("mysql")) {
return "sql";
}
if (type.equalsIgnoreCase("flatfile") || type.equalsIgnoreCase("file")) {
return "flatfile";
}
try {
Class<?> clazz = Class.forName(type);
if (!DatabaseManager.class.isAssignableFrom(clazz)) {
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.InvalidType", type));
return null;
}
return type;
}
catch (Exception e) {
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.InvalidType", type));
return null;
}
}
private String getCurrentDb() {
if (DatabaseManagerFactory.getCustomDatabaseManagerClass() != null) {
return DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName();
}
if (Config.getInstance().getUseMySQL()) {
return "sql";
}
else {
return "flatfile";
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
Class<?> clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass();
if (clazz != null) {
return ImmutableList.of("flatfile", "sql", clazz.getName());
}
return ImmutableList.of("flatfile", "sql");
}
}

View File

@@ -1,13 +1,13 @@
package com.gmail.nossr50.commands.experience; package com.gmail.nossr50.commands.experience;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
public class AddlevelsCommand extends ExperienceCommand { public class AddlevelsCommand extends ExperienceCommand {
@Override @Override
@@ -21,21 +21,25 @@ public class AddlevelsCommand extends ExperienceCommand {
} }
@Override @Override
protected void handleCommand(SkillType skill) { protected void handleCommand(Player player, PlayerProfile profile, SkillType skill, int value) {
float xpRemoved = profile.getSkillXpLevelRaw(skill);
profile.addLevels(skill, value); profile.addLevels(skill, value);
if (player != null) { if (player == null) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value)); profile.save();
return;
} }
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, true);
} }
@Override @Override
protected void handlePlayerMessageAll() { protected void handlePlayerMessageAll(Player player, int value) {
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", value)); player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", value));
} }
@Override @Override
protected void handlePlayerMessageSkill() { protected void handlePlayerMessageSkill(Player player, int value, SkillType skill) {
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, SkillUtils.getSkillName(skill))); player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, skill.getName()));
} }
} }

View File

@@ -1,11 +1,13 @@
package com.gmail.nossr50.commands.experience; package com.gmail.nossr50.commands.experience;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.player.UserManager;
public class AddxpCommand extends ExperienceCommand { public class AddxpCommand extends ExperienceCommand {
@Override @Override
@@ -19,22 +21,23 @@ public class AddxpCommand extends ExperienceCommand {
} }
@Override @Override
protected void handleCommand(SkillType skill) { protected void handleCommand(Player player, PlayerProfile profile, SkillType skill, int value) {
if (player != null) { if (player != null) {
mcMMOPlayer.applyXpGain(skill, value); UserManager.getPlayer(player).applyXpGain(skill, value);
} }
else { else {
profile.addExperience(skill, value); profile.addXp(skill, value);
profile.save();
} }
} }
@Override @Override
protected void handlePlayerMessageAll() { protected void handlePlayerMessageAll(Player player, int value) {
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", value)); player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", value));
} }
@Override @Override
protected void handlePlayerMessageSkill() { protected void handlePlayerMessageSkill(Player player, int value, SkillType skill) {
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, SkillUtils.getSkillName(skill))); player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getName()));
} }
} }

View File

@@ -0,0 +1,49 @@
package com.gmail.nossr50.commands.experience;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.database.FormulaConversionTask;
import com.gmail.nossr50.util.player.UserManager;
public class ConvertExperienceCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
FormulaType previousType = mcMMO.getFormulaManager().getPreviousFormulaType();
FormulaType newType = FormulaType.getFormulaType(args[1].toUpperCase());
if (newType == FormulaType.UNKNOWN) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Invalid"));
return true;
}
if (previousType == newType) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Same", newType.toString()));
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Start", previousType.toString(), newType.toString()));
UserManager.saveAll();
UserManager.clearAll();
new FormulaConversionTask(sender, newType).runTaskLater(mcMMO.p, 1);
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
UserManager.addUser(player);
}
return true;
default:
return false;
}
}
}

View File

@@ -15,21 +15,13 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public abstract class ExperienceCommand implements TabExecutor { public abstract class ExperienceCommand implements TabExecutor {
protected McMMOPlayer mcMMOPlayer;
protected Player player;
protected PlayerProfile profile;
protected boolean allSkills;
protected SkillType skill;
protected int value;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
@@ -47,12 +39,7 @@ public abstract class ExperienceCommand implements TabExecutor {
return true; return true;
} }
player = (Player) sender; editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), SkillType.getSkill(args[0]), Integer.parseInt(args[1]));
mcMMOPlayer = UserManager.getPlayer(player);
profile = mcMMOPlayer.getProfile();
editValues();
allSkills = false;
return true; return true;
case 3: case 3:
@@ -65,27 +52,32 @@ public abstract class ExperienceCommand implements TabExecutor {
return true; return true;
} }
mcMMOPlayer = UserManager.getPlayer(args[0]); SkillType skill;
if (args[1].equalsIgnoreCase("all")) {
skill = null;
} else {
skill = SkillType.getSkill(args[1]);
}
int value = Integer.parseInt(args[2]);
String playerName = Misc.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) { if (mcMMOPlayer == null) {
profile = mcMMO.getDatabaseManager().loadPlayerProfile(args[0], false); PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false);
if (CommandUtils.unloadedProfile(sender, profile)) { if (CommandUtils.unloadedProfile(sender, profile)) {
return true; return true;
} }
editValues(); editValues(null, profile, skill, value);
profile.save(); // Since this is a temporary profile, we save it here.
} }
else { else {
profile = mcMMOPlayer.getProfile(); editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, value);
player = mcMMOPlayer.getPlayer();
editValues();
} }
handleSenderMessage(sender, args[0]); handleSenderMessage(sender, playerName, skill);
allSkills = false;
return true; return true;
default: default:
@@ -97,7 +89,7 @@ public abstract class ExperienceCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
Set<String> playerNames = UserManager.getPlayers().keySet(); Set<String> playerNames = UserManager.getPlayerNames();
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size())); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
case 2: case 2:
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size())); return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
@@ -108,64 +100,42 @@ public abstract class ExperienceCommand implements TabExecutor {
protected abstract boolean permissionsCheckSelf(CommandSender sender); protected abstract boolean permissionsCheckSelf(CommandSender sender);
protected abstract boolean permissionsCheckOthers(CommandSender sender); protected abstract boolean permissionsCheckOthers(CommandSender sender);
protected abstract void handleCommand(SkillType skill); protected abstract void handleCommand(Player player, PlayerProfile profile, SkillType skill, int value);
protected abstract void handlePlayerMessageAll(); protected abstract void handlePlayerMessageAll(Player player, int value);
protected abstract void handlePlayerMessageSkill(); protected abstract void handlePlayerMessageSkill(Player player, int value, SkillType skill);
private boolean validateArguments(CommandSender sender, String skillName, String value) { private boolean validateArguments(CommandSender sender, String skillName, String value) {
if (isInvalidInteger(sender, value) || isInvalidSkill(sender, skillName)) { if (CommandUtils.isInvalidInteger(sender, value) || (!skillName.equalsIgnoreCase("all") && CommandUtils.isInvalidSkill(sender, skillName))) {
return false; return false;
} }
return true; return true;
} }
private boolean isInvalidInteger(CommandSender sender, String value) { protected static void handleSenderMessage(CommandSender sender, String playerName, SkillType skill) {
if (CommandUtils.isInvalidInteger(sender, value)) { if (skill == null) {
return true;
}
this.value = Integer.parseInt(value);
return false;
}
protected boolean isInvalidSkill(CommandSender sender, String skillName) {
if (skillName.equalsIgnoreCase("all")) {
allSkills = true;
return false;
}
else if (CommandUtils.isInvalidSkill(sender, skillName)) {
return true;
}
skill = SkillType.getSkill(skillName);
return false;
}
protected void handleSenderMessage(CommandSender sender, String playerName) {
if (allSkills) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName)); sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
} }
else { else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillUtils.getSkillName(skill), playerName)); sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName));
} }
} }
protected void editValues() { protected void editValues(Player player, PlayerProfile profile, SkillType skill, int value) {
if (allSkills) { if (skill == null) {
for (SkillType skillType : SkillType.values()) { for (SkillType skillType : SkillType.values()) {
handleCommand(skillType); handleCommand(player, profile, skillType, value);
} }
if (player != null) { if (player != null) {
handlePlayerMessageAll(); handlePlayerMessageAll(player, value);
} }
} }
else { else {
handleCommand(skill); handleCommand(player, profile, skill, value);
if (player != null) { if (player != null) {
handlePlayerMessageSkill(); handlePlayerMessageSkill(player, value, skill);
} }
} }
} }

View File

@@ -1,13 +1,13 @@
package com.gmail.nossr50.commands.experience; package com.gmail.nossr50.commands.experience;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
public class MmoeditCommand extends ExperienceCommand { public class MmoeditCommand extends ExperienceCommand {
@Override @Override
@@ -21,21 +21,31 @@ public class MmoeditCommand extends ExperienceCommand {
} }
@Override @Override
protected void handleCommand(SkillType skill) { protected void handleCommand(Player player, PlayerProfile profile, SkillType skill, int value) {
int skillLevel = profile.getSkillLevel(skill);
float xpRemoved = profile.getSkillXpLevelRaw(skill);
profile.modifySkill(skill, value); profile.modifySkill(skill, value);
if (player != null) { if (player == null) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value - profile.getSkillLevel(skill))); profile.save();
return;
} }
if (value == skillLevel) {
return;
}
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, value > skillLevel);
} }
@Override @Override
protected void handlePlayerMessageAll() { protected void handlePlayerMessageAll(Player player, int value) {
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", value)); player.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", value));
} }
@Override @Override
protected void handlePlayerMessageSkill() { protected void handlePlayerMessageSkill(Player player, int value, SkillType skill) {
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", SkillUtils.getSkillName(skill), value)); player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skill.getName(), value));
} }
} }

View File

@@ -1,82 +1,88 @@
package com.gmail.nossr50.commands.experience; package com.gmail.nossr50.commands.experience;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils; import com.google.common.collect.ImmutableList;
public class SkillresetCommand extends ExperienceCommand {
private CommandSender sender;
private Command command;
private int argsLength;
/**
* This class mirrors the structure of ExperienceCommand, except the
* value/quantity argument is removed.
*/
public class SkillresetCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
this.command = command;
this.sender = sender;
argsLength = args.length;
switch (args.length) { switch (args.length) {
case 1: case 1:
if (CommandUtils.noConsoleUsage(sender)) { if (CommandUtils.noConsoleUsage(sender)) {
return true; return true;
} }
if (!Permissions.skillreset(sender)) { if (!permissionsCheckSelf(sender)) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return true; return true;
} }
if (isInvalidSkill(sender, args[0])) { if (!validateArguments(sender, args[0])) {
return true; return true;
} }
player = (Player) sender; editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), SkillType.getSkill(args[0]));
mcMMOPlayer = UserManager.getPlayer(player);
profile = mcMMOPlayer.getProfile();
editValues();
return true; return true;
case 2: case 2:
if (!Permissions.skillresetOthers(sender)) { if (!permissionsCheckOthers(sender)) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return true; return true;
} }
if (isInvalidSkill(sender, args[1])) { if (!validateArguments(sender, args[1])) {
return true; return true;
} }
mcMMOPlayer = UserManager.getPlayer(args[0]); SkillType skill;
if (args[1].equalsIgnoreCase("all")) {
skill = null;
}
else {
skill = SkillType.getSkill(args[1]);
}
String playerName = Misc.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) { if (mcMMOPlayer == null) {
profile = mcMMO.getDatabaseManager().loadPlayerProfile(args[0], false); PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false);
if (CommandUtils.unloadedProfile(sender, profile)) { if (CommandUtils.unloadedProfile(sender, profile)) {
return true; return true;
} }
editValues(); editValues(null, profile, skill);
profile.save(); // Since this is a temporary profile, we save it here.
} }
else { else {
profile = mcMMOPlayer.getProfile(); editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill);
player = mcMMOPlayer.getPlayer();
editValues();
} }
handleSenderMessage(sender, args[0]); handleSenderMessage(sender, playerName, skill);
return true; return true;
default: default:
@@ -85,36 +91,81 @@ public class SkillresetCommand extends ExperienceCommand {
} }
@Override @Override
protected boolean permissionsCheckSelf(CommandSender sender) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return false; switch (args.length) {
case 1:
Set<String> playerNames = UserManager.getPlayerNames();
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
case 2:
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
default:
return ImmutableList.of();
}
} }
@Override protected void handleCommand(Player player, PlayerProfile profile, SkillType skill) {
protected boolean permissionsCheckOthers(CommandSender sender) { int levelsRemoved = profile.getSkillLevel(skill);
return false; float xpRemoved = profile.getSkillXpLevelRaw(skill);
}
@Override
protected void handleCommand(SkillType skill) {
if (argsLength == 1 && !Permissions.skillreset(sender, skill) || (argsLength == 2 && !Permissions.skillresetOthers(sender, skill))) {
sender.sendMessage(command.getPermissionMessage());
return;
}
profile.modifySkill(skill, 0); profile.modifySkill(skill, 0);
if (player != null) { if (player == null) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, 0 - profile.getSkillLevel(skill))); profile.save();
} return;
} }
@Override EventUtils.handleLevelChangeEvent(player, skill, levelsRemoved, xpRemoved, false);
protected void handlePlayerMessageAll() { }
protected boolean permissionsCheckSelf(CommandSender sender) {
return Permissions.skillreset(sender);
}
protected boolean permissionsCheckOthers(CommandSender sender) {
return Permissions.skillresetOthers(sender);
}
protected void handlePlayerMessageAll(Player player) {
player.sendMessage(LocaleLoader.getString("Commands.Reset.All")); player.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
} }
@Override protected void handlePlayerMessageSkill(Player player, SkillType skill) {
protected void handlePlayerMessageSkill() { player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skill.getName()));
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", SkillUtils.getSkillName(skill))); }
private boolean validateArguments(CommandSender sender, String skillName) {
if (CommandUtils.isInvalidSkill(sender, skillName) && !skillName.equalsIgnoreCase("all")) {
return false;
}
return true;
}
protected static void handleSenderMessage(CommandSender sender, String playerName, SkillType skill) {
if (skill == null) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName));
}
}
protected void editValues(Player player, PlayerProfile profile, SkillType skill) {
if (skill == null) {
for (SkillType skillType : SkillType.values()) {
handleCommand(player, profile, skillType);
}
if (player != null) {
handlePlayerMessageAll(player);
}
}
else {
handleCommand(player, profile, skill);
if (player != null) {
handlePlayerMessageSkill(player, skill);
}
}
} }
} }

View File

@@ -1,41 +1,65 @@
package com.gmail.nossr50.commands.hardcore; package com.gmail.nossr50.commands.hardcore;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
public class HardcoreCommand extends HardcoreModeCommand { public class HardcoreCommand extends HardcoreModeCommand {
@Override @Override
protected void disable() { protected boolean checkTogglePermissions(CommandSender sender) {
Config.getInstance().setHardcoreEnabled(false);
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Disabled"));
}
@Override
protected void enable() {
Config.getInstance().setHardcoreEnabled(true);
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Enabled"));
}
@Override
protected boolean checkTogglePermissions() {
return Permissions.hardcoreToggle(sender); return Permissions.hardcoreToggle(sender);
} }
@Override @Override
protected boolean checkModifyPermissions() { protected boolean checkModifyPermissions(CommandSender sender) {
return Permissions.hardcoreModify(sender); return Permissions.hardcoreModify(sender);
} }
@Override @Override
protected boolean checkEnabled() { protected boolean checkEnabled(SkillType skill) {
return Config.getInstance().getHardcoreEnabled(); if (skill == null) {
for (SkillType skillType : SkillType.values()) {
if (!skillType.getHardcoreStatLossEnabled()) {
return false;
}
}
return true;
}
return skill.getHardcoreStatLossEnabled();
} }
@Override @Override
protected void modify() { protected void enable(SkillType skill) {
Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercent); toggle(true, skill);
sender.sendMessage(LocaleLoader.getString("Hardcore.PercentageChanged", percent.format(newPercent / 100D))); }
@Override
protected void disable(SkillType skill) {
toggle(false, skill);
}
@Override
protected void modify(CommandSender sender, double newPercentage) {
Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercentage);
sender.sendMessage(LocaleLoader.getString("Hardcore.DeathStatLoss.PercentageChanged", percent.format(newPercentage / 100.0D)));
}
private void toggle(boolean enable, SkillType skill) {
if (skill == null) {
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
skillType.setHardcoreStatLossEnabled(enable);
}
}
else {
skill.setHardcoreStatLossEnabled(enable);
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.DeathStatLoss.Name"), (skill == null ? "all skills" : skill.getName())));
} }
} }

View File

@@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
@@ -16,30 +17,22 @@ import com.gmail.nossr50.util.commands.CommandUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public abstract class HardcoreModeCommand implements TabExecutor { public abstract class HardcoreModeCommand implements TabExecutor {
protected CommandSender sender; protected final DecimalFormat percent = new DecimalFormat("##0.00%");
protected double newPercent;
protected DecimalFormat percent;
public HardcoreModeCommand() {
percent = new DecimalFormat("##0.00%");
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 0: case 0:
this.sender = sender; if (!checkTogglePermissions(sender)) {
if (!checkTogglePermissions()) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return true; return true;
} }
if (checkEnabled()) { if (checkEnabled(null)) {
disable(); disable(null);
} }
else { else {
enable(); enable(null);
} }
return true; return true;
@@ -51,7 +44,7 @@ public abstract class HardcoreModeCommand implements TabExecutor {
return true; return true;
} }
enable(); enable(null);
return true; return true;
} }
@@ -61,11 +54,11 @@ public abstract class HardcoreModeCommand implements TabExecutor {
return true; return true;
} }
disable(); disable(null);
return true; return true;
} }
if (isInvalidPercentage(sender, args[0])) { if (CommandUtils.isInvalidDouble(sender, args[0])) {
return true; return true;
} }
@@ -74,7 +67,41 @@ public abstract class HardcoreModeCommand implements TabExecutor {
return true; return true;
} }
modify(); modify(sender, Double.parseDouble(args[0]));
return true;
case 2:
if (CommandUtils.isInvalidSkill(sender, args[0])) {
return true;
}
SkillType skill = SkillType.getSkill(args[0]);
if (!CommandUtils.isChildSkill(sender, skill)) {
return true;
}
if (CommandUtils.shouldEnableToggle(args[1])) {
if (!Permissions.hardcoreToggle(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
enable(skill);
return true;
}
if (CommandUtils.shouldDisableToggle(args[1])) {
if (!Permissions.hardcoreToggle(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
enable(skill);
return true;
}
return true; return true;
default: default:
@@ -96,19 +123,10 @@ public abstract class HardcoreModeCommand implements TabExecutor {
} }
} }
protected abstract boolean checkTogglePermissions(); protected abstract boolean checkTogglePermissions(CommandSender sender);
protected abstract boolean checkModifyPermissions(); protected abstract boolean checkModifyPermissions(CommandSender sender);
protected abstract boolean checkEnabled(); protected abstract boolean checkEnabled(SkillType skill);
protected abstract void enable(); protected abstract void enable(SkillType skill);
protected abstract void disable(); protected abstract void disable(SkillType skill);
protected abstract void modify(); protected abstract void modify(CommandSender sender, double newPercentage);
private boolean isInvalidPercentage(CommandSender sender, String value) {
if (CommandUtils.isInvalidDouble(sender, value)) {
return true;
}
newPercent = Double.parseDouble(value);
return false;
}
} }

View File

@@ -1,41 +1,65 @@
package com.gmail.nossr50.commands.hardcore; package com.gmail.nossr50.commands.hardcore;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
public class VampirismCommand extends HardcoreModeCommand { public class VampirismCommand extends HardcoreModeCommand {
@Override @Override
protected boolean checkTogglePermissions() { protected boolean checkTogglePermissions(CommandSender sender) {
return Permissions.vampirismToggle(sender); return Permissions.vampirismToggle(sender);
} }
@Override @Override
protected boolean checkModifyPermissions() { protected boolean checkModifyPermissions(CommandSender sender) {
return Permissions.vampirismModify(sender); return Permissions.vampirismModify(sender);
} }
@Override @Override
protected boolean checkEnabled() { protected boolean checkEnabled(SkillType skill) {
return Config.getInstance().getHardcoreVampirismEnabled(); if (skill == null) {
for (SkillType skillType : SkillType.values()) {
if (!skillType.getHardcoreVampirismEnabled()) {
return false;
}
}
return true;
}
return skill.getHardcoreVampirismEnabled();
} }
@Override @Override
protected void enable() { protected void enable(SkillType skill) {
Config.getInstance().setHardcoreVampirismEnabled(true); toggle(true, skill);
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Enabled"));
} }
@Override @Override
protected void disable() { protected void disable(SkillType skill) {
Config.getInstance().setHardcoreVampirismEnabled(false); toggle(false, skill);
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Disabled"));
} }
@Override @Override
protected void modify() { protected void modify(CommandSender sender, double newPercentage) {
Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercent); Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercentage);
sender.sendMessage(LocaleLoader.getString("Vampirism.PercentageChanged", percent.format(newPercent / 100D))); sender.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.PercentageChanged", percent.format(newPercentage / 100.0D)));
}
private void toggle(boolean enable, SkillType skill) {
if (skill == null) {
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
skillType.setHardcoreVampirismEnabled(enable);
}
}
else {
skill.setHardcoreVampirismEnabled(enable);
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), (skill == null ? "all skills" : skill)));
} }
} }

View File

@@ -24,11 +24,11 @@ public class PartyAcceptCommand implements CommandExecutor {
} }
// Changing parties // Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), mcMMOPlayer.getPartyInvite().getName())) { if (!PartyManager.changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) {
return true; return true;
} }
PartyManager.joinInvitedParty(player, mcMMOPlayer); PartyManager.joinInvitedParty(mcMMOPlayer);
return true; return true;
default: default:

View File

@@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
public class PartyChangeOwnerCommand implements CommandExecutor { public class PartyChangeOwnerCommand implements CommandExecutor {
@@ -16,13 +17,14 @@ public class PartyChangeOwnerCommand implements CommandExecutor {
switch (args.length) { switch (args.length) {
case 2: case 2:
Party playerParty = UserManager.getPlayer((Player) sender).getParty(); Party playerParty = UserManager.getPlayer((Player) sender).getParty();
String targetName = Misc.getMatchedPlayerName(args[1]);
if (!playerParty.getMembers().contains(args[1])) { if (!playerParty.getMembers().contains(targetName)) {
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1])); sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
return true; return true;
} }
PartyManager.setPartyLeader(args[1], playerParty); PartyManager.setPartyLeader(targetName, playerParty);
return true; return true;
default: default:

View File

@@ -10,24 +10,22 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
public class PartyChangePasswordCommand implements CommandExecutor { public class PartyChangePasswordCommand implements CommandExecutor {
private Party playerParty;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
playerParty = UserManager.getPlayer((Player) sender).getParty(); Party party = UserManager.getPlayer((Player) sender).getParty();
switch (args.length) { switch (args.length) {
case 1: case 1:
unprotectParty(sender); unprotectParty(party, sender);
return true; return true;
case 2: case 2:
if (args[1].equalsIgnoreCase("clear") || args[1].equalsIgnoreCase("reset")) { if (args[1].equalsIgnoreCase("clear") || args[1].equalsIgnoreCase("reset")) {
unprotectParty(sender); unprotectParty(party, sender);
return true; return true;
} }
protectParty(sender, args[1]); protectParty(party, sender, args[1]);
return true; return true;
default: default:
@@ -37,15 +35,15 @@ public class PartyChangePasswordCommand implements CommandExecutor {
} }
} }
private void unprotectParty(CommandSender sender) { private void unprotectParty(Party party, CommandSender sender) {
playerParty.setLocked(true); party.setLocked(true);
playerParty.setPassword(null); party.setPassword(null);
sender.sendMessage(LocaleLoader.getString("Party.Password.Removed")); sender.sendMessage(LocaleLoader.getString("Party.Password.Removed"));
} }
private void protectParty(CommandSender sender, String password) { private void protectParty(Party party, CommandSender sender, String password) {
playerParty.setLocked(true); party.setLocked(true);
playerParty.setPassword(password); party.setPassword(password);
sender.sendMessage(LocaleLoader.getString("Party.Password.Set", password)); sender.sendMessage(LocaleLoader.getString("Party.Password.Set", password));
} }
} }

View File

@@ -20,12 +20,10 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public class PartyCommand implements TabExecutor { public class PartyCommand implements TabExecutor {
private McMMOPlayer mcMMOPlayer;
private Player player;
private static final List<String> PARTY_SUBCOMMANDS; private static final List<String> PARTY_SUBCOMMANDS;
private static final List<String> EXPSHARE_COMPLETIONS = ImmutableList.of("none", "equal"); private static final List<String> EXPSHARE_COMPLETIONS = ImmutableList.of("none", "equal");
private static final List<String> ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc"); private static final List<String> ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc");
@@ -70,13 +68,13 @@ public class PartyCommand implements TabExecutor {
return true; return true;
} }
player = (Player) sender; Player player = (Player) sender;
mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (args.length < 1) { if (args.length < 1) {
if (!mcMMOPlayer.inParty()) { if (!mcMMOPlayer.inParty()) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return printUsage(); return printUsage(player);
} }
return partyInfoCommand.onCommand(sender, command, label, args); return partyInfoCommand.onCommand(sender, command, label, args);
@@ -85,7 +83,7 @@ public class PartyCommand implements TabExecutor {
PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]); PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]);
if (subcommand == null) { if (subcommand == null) {
return printUsage(); return printUsage(player);
} }
// Can't use this for lock/unlock since they're handled by the same command // Can't use this for lock/unlock since they're handled by the same command
@@ -110,7 +108,7 @@ public class PartyCommand implements TabExecutor {
// Party member commands // Party member commands
if (!mcMMOPlayer.inParty()) { if (!mcMMOPlayer.inParty()) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return printUsage(); return printUsage(player);
} }
switch (subcommand) { switch (subcommand) {
@@ -176,7 +174,7 @@ public class PartyCommand implements TabExecutor {
case INVITE: case INVITE:
case KICK: case KICK:
case OWNER: case OWNER:
Set<String> playerNames = UserManager.getPlayers().keySet(); Set<String> playerNames = UserManager.getPlayerNames();
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size())); return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
case EXPSHARE: case EXPSHARE:
return StringUtil.copyPartialMatches(args[1], EXPSHARE_COMPLETIONS, new ArrayList<String>(EXPSHARE_COMPLETIONS.size())); return StringUtil.copyPartialMatches(args[1], EXPSHARE_COMPLETIONS, new ArrayList<String>(EXPSHARE_COMPLETIONS.size()));
@@ -191,7 +189,7 @@ public class PartyCommand implements TabExecutor {
List<String> matches = StringUtil.copyPartialMatches(args[1], PtpCommand.TELEPORT_SUBCOMMANDS, new ArrayList<String>(PtpCommand.TELEPORT_SUBCOMMANDS.size())); List<String> matches = StringUtil.copyPartialMatches(args[1], PtpCommand.TELEPORT_SUBCOMMANDS, new ArrayList<String>(PtpCommand.TELEPORT_SUBCOMMANDS.size()));
if (matches.size() == 0) { if (matches.size() == 0) {
playerNames = UserManager.getPlayers().keySet(); playerNames = UserManager.getPlayerNames();
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size())); return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
} }
@@ -210,7 +208,7 @@ public class PartyCommand implements TabExecutor {
} }
} }
private boolean printUsage() { private boolean printUsage(Player player) {
player.sendMessage(LocaleLoader.getString("Party.Help.0", "/party join")); player.sendMessage(LocaleLoader.getString("Party.Help.0", "/party join"));
player.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create")); player.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create"));
player.sendMessage(LocaleLoader.getString("Party.Help.2", "/party ?")); player.sendMessage(LocaleLoader.getString("Party.Help.2", "/party ?"));

View File

@@ -5,7 +5,6 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
@@ -17,22 +16,20 @@ public class PartyCreateCommand implements CommandExecutor {
switch (args.length) { switch (args.length) {
case 2: case 2:
case 3: case 3:
Party newParty = PartyManager.getParty(args[1]);
Player player = (Player) sender; Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
// Check to see if the party exists, and if it does cancel creating a new party // Check to see if the party exists, and if it does cancel creating a new party
if (PartyManager.checkPartyExistence(player, newParty, args[1])) { if (PartyManager.checkPartyExistence(player, args[1])) {
return true; return true;
} }
// Changing parties // Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), args[1])) { if (!PartyManager.changeOrJoinParty(mcMMOPlayer, args[1])) {
return true; return true;
} }
PartyManager.createParty(player, mcMMOPlayer, args[1], getPassword(args)); PartyManager.createParty(mcMMOPlayer, args[1], getPassword(args));
return true; return true;
default: default:

View File

@@ -7,16 +7,13 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.ShareHandler;
import com.gmail.nossr50.party.ShareHandler.ShareMode;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
public class PartyExpShareCommand implements CommandExecutor { public class PartyExpShareCommand implements CommandExecutor {
private Party playerParty;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!Config.getInstance().getExpShareEnabled()) { if (!Config.getInstance().getExpShareEnabled()) {
@@ -26,13 +23,13 @@ public class PartyExpShareCommand implements CommandExecutor {
switch (args.length) { switch (args.length) {
case 2: case 2:
playerParty = UserManager.getPlayer((Player) sender).getParty(); Party party = UserManager.getPlayer((Player) sender).getParty();
if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) { if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) {
handleChangingShareMode(ShareMode.NONE); handleChangingShareMode(party, ShareMode.NONE);
} }
else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || CommandUtils.shouldEnableToggle(args[1])) { else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || CommandUtils.shouldEnableToggle(args[1])) {
handleChangingShareMode(ShareMode.EQUAL); handleChangingShareMode(party, ShareMode.EQUAL);
} }
else { else {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "<NONE | EQUAL>")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "<NONE | EQUAL>"));
@@ -46,12 +43,12 @@ public class PartyExpShareCommand implements CommandExecutor {
} }
} }
private void handleChangingShareMode(ShareHandler.ShareMode mode) { private void handleChangingShareMode(Party party, ShareMode mode) {
playerParty.setXpShareMode(mode); party.setXpShareMode(mode);
String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString()))); String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
for (Player member : playerParty.getOnlineMembers()) { for (Player member : party.getOnlineMembers()) {
member.sendMessage(changeModeMessage); member.sendMessage(changeModeMessage);
} }
} }

View File

@@ -1,7 +1,6 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@@ -10,45 +9,43 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.party.ShareHandler;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
public class PartyInfoCommand implements CommandExecutor { public class PartyInfoCommand implements CommandExecutor {
private Player player;
private Party playerParty;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 0: case 0:
case 1: case 1:
player = (Player) sender; Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
playerParty = mcMMOPlayer.getParty(); Party party = mcMMOPlayer.getParty();
displayPartyHeader(); displayPartyHeader(player, party);
displayShareModeInfo(); displayShareModeInfo(party, player);
displayMemberInfo(); displayMemberInfo(player, mcMMOPlayer, party);
return true; return true;
default: default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "info")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "info"));
return true; return true;
} }
} }
private String createMembersList() { private String createMembersList(Party party) {
StringBuilder memberList = new StringBuilder(); StringBuilder memberList = new StringBuilder();
for (String memberName : playerParty.getMembers()) { for (String memberName : party.getMembers()) {
OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberName); Player member = mcMMO.p.getServer().getPlayerExact(memberName);
if (playerParty.getLeader().equalsIgnoreCase(memberName)) { if (party.getLeader().equalsIgnoreCase(memberName)) {
memberList.append(ChatColor.GOLD); memberList.append(ChatColor.GOLD);
} }
else if (member.isOnline()) { else if (member != null) {
memberList.append(ChatColor.WHITE); memberList.append(ChatColor.WHITE);
} }
else { else {
@@ -61,10 +58,10 @@ public class PartyInfoCommand implements CommandExecutor {
return memberList.toString(); return memberList.toString();
} }
private void displayShareModeInfo() { private void displayShareModeInfo(Party party, Player player) {
boolean xpShareEnabled = Config.getInstance().getExpShareEnabled(); boolean xpShareEnabled = Config.getInstance().getExpShareEnabled();
boolean itemShareEnabled = Config.getInstance().getItemShareEnabled(); boolean itemShareEnabled = Config.getInstance().getItemShareEnabled();
boolean itemSharingActive = (playerParty.getItemShareMode() != ShareHandler.ShareMode.NONE); boolean itemSharingActive = (party.getItemShareMode() != ShareMode.NONE);
if (!xpShareEnabled && !itemShareEnabled) { if (!xpShareEnabled && !itemShareEnabled) {
return; return;
@@ -75,11 +72,11 @@ public class PartyInfoCommand implements CommandExecutor {
String separator = ""; String separator = "";
if (xpShareEnabled) { if (xpShareEnabled) {
expShareInfo = LocaleLoader.getString("Commands.Party.ExpShare", playerParty.getXpShareMode().toString()); expShareInfo = LocaleLoader.getString("Commands.Party.ExpShare", party.getXpShareMode().toString());
} }
if (itemShareEnabled) { if (itemShareEnabled) {
itemShareInfo = LocaleLoader.getString("Commands.Party.ItemShare", playerParty.getItemShareMode().toString()); itemShareInfo = LocaleLoader.getString("Commands.Party.ItemShare", party.getItemShareMode().toString());
} }
if (xpShareEnabled && itemShareEnabled) { if (xpShareEnabled && itemShareEnabled) {
@@ -87,28 +84,23 @@ public class PartyInfoCommand implements CommandExecutor {
} }
player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + expShareInfo + separator + itemShareInfo); player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + expShareInfo + separator + itemShareInfo);
if (itemSharingActive) { if (itemSharingActive) {
player.sendMessage(LocaleLoader.getString("Commands.Party.ItemShareCategories", playerParty.getItemShareCategories())); player.sendMessage(LocaleLoader.getString("Commands.Party.ItemShareCategories", party.getItemShareCategories()));
} }
} }
private void displayPartyHeader() { private void displayPartyHeader(Player player, Party party) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Header")); player.sendMessage(LocaleLoader.getString("Commands.Party.Header"));
player.sendMessage(LocaleLoader.getString("Commands.Party.Status", party.getName(), LocaleLoader.getString("Party.Status." + (party.isLocked() ? "Locked" : "Unlocked"))));
if (playerParty.isLocked()) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Status", playerParty.getName(), LocaleLoader.getString("Party.Status.Locked")));
}
else {
player.sendMessage(LocaleLoader.getString("Commands.Party.Status", playerParty.getName(), LocaleLoader.getString("Party.Status.Unlocked")));
}
} }
private void displayMemberInfo() { private void displayMemberInfo(Player player, McMMOPlayer mcMMOPlayer, Party party) {
int membersNear = PartyManager.getNearMembers(player, playerParty, Config.getInstance().getPartyShareRange()).size(); int membersNear = PartyManager.getNearMembers(mcMMOPlayer).size();
int membersOnline = playerParty.getOnlineMembers().size() - 1; int membersOnline = party.getOnlineMembers().size() - 1;
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header")); player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", membersNear, membersOnline)); player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", membersNear, membersOnline));
player.sendMessage(createMembersList()); player.sendMessage(createMembersList(party));
} }
} }

View File

@@ -9,6 +9,7 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
@@ -17,15 +18,17 @@ public class PartyInviteCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 2: case 2:
McMMOPlayer mcMMOTarget = UserManager.getPlayer(args[1]); String targetName = Misc.getMatchedPlayerName(args[1]);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName, true);
if (!CommandUtils.checkPlayerExistence(sender, args[1], mcMMOTarget)) { if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false; return false;
} }
Player target = mcMMOTarget.getPlayer(); Player target = mcMMOTarget.getPlayer();
Player player = (Player) sender; Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
String playerName = player.getName();
if (player.equals(target)) { if (player.equals(target)) {
sender.sendMessage(LocaleLoader.getString("Party.Invite.Self")); sender.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
@@ -33,21 +36,20 @@ public class PartyInviteCommand implements CommandExecutor {
} }
if (PartyManager.inSameParty(player, target)) { if (PartyManager.inSameParty(player, target)) {
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", target.getName())); sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
return true; return true;
} }
Party playerParty = mcMMOPlayer.getParty(); if (!PartyManager.canInvite(mcMMOPlayer)) {
if (!PartyManager.canInvite(player, playerParty)) {
player.sendMessage(LocaleLoader.getString("Party.Locked")); player.sendMessage(LocaleLoader.getString("Party.Locked"));
return true; return true;
} }
Party playerParty = mcMMOPlayer.getParty();
mcMMOTarget.setPartyInvite(playerParty); mcMMOTarget.setPartyInvite(playerParty);
sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getName(), player.getName())); target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getName(), playerName));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1")); target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
return true; return true;

View File

@@ -8,15 +8,13 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.ItemShareType; import com.gmail.nossr50.datatypes.party.ItemShareType;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.ShareHandler.ShareMode;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
public class PartyItemShareCommand implements CommandExecutor { public class PartyItemShareCommand implements CommandExecutor {
private Party playerParty;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!Config.getInstance().getItemShareEnabled()) { if (!Config.getInstance().getItemShareEnabled()) {
@@ -24,9 +22,10 @@ public class PartyItemShareCommand implements CommandExecutor {
return true; return true;
} }
Party party = UserManager.getPlayer((Player) sender).getParty();
switch (args.length) { switch (args.length) {
case 2: case 2:
playerParty = UserManager.getPlayer((Player) sender).getParty();
ShareMode mode = ShareMode.getShareMode(args[1].toUpperCase()); ShareMode mode = ShareMode.getShareMode(args[1].toUpperCase());
if (mode == null) { if (mode == null) {
@@ -34,11 +33,10 @@ public class PartyItemShareCommand implements CommandExecutor {
return true; return true;
} }
handleChangingShareMode(mode); handleChangingShareMode(party, mode);
return true; return true;
case 3: case 3:
playerParty = UserManager.getPlayer((Player) sender).getParty();
boolean toggle = false; boolean toggle = false;
if (CommandUtils.shouldEnableToggle(args[2])) { if (CommandUtils.shouldEnableToggle(args[2])) {
@@ -53,7 +51,7 @@ public class PartyItemShareCommand implements CommandExecutor {
} }
try { try {
handleToggleItemShareCategory(ItemShareType.valueOf(args[1].toUpperCase()), toggle); handleToggleItemShareCategory(party, ItemShareType.valueOf(args[1].toUpperCase()), toggle);
} }
catch (IllegalArgumentException ex) { catch (IllegalArgumentException ex) {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
@@ -68,22 +66,22 @@ public class PartyItemShareCommand implements CommandExecutor {
} }
} }
private void handleChangingShareMode(ShareMode mode) { private void handleChangingShareMode(Party party, ShareMode mode) {
playerParty.setItemShareMode(mode); party.setItemShareMode(mode);
String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString()))); String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
for (Player member : playerParty.getOnlineMembers()) { for (Player member : party.getOnlineMembers()) {
member.sendMessage(changeModeMessage); member.sendMessage(changeModeMessage);
} }
} }
private void handleToggleItemShareCategory(ItemShareType type, boolean toggle) { private void handleToggleItemShareCategory(Party party, ItemShareType type, boolean toggle) {
playerParty.setSharingDrops(type, toggle); party.setSharingDrops(type, toggle);
String toggleMessage = LocaleLoader.getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(type.toString()), toggle ? "enabled" : "disabled"); String toggleMessage = LocaleLoader.getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(type.toString()), toggle ? "enabled" : "disabled");
for (Player member : playerParty.getOnlineMembers()) { for (Player member : party.getOnlineMembers()) {
member.sendMessage(toggleMessage); member.sendMessage(toggleMessage);
} }
} }

View File

@@ -9,30 +9,38 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
public class PartyJoinCommand implements CommandExecutor { public class PartyJoinCommand implements CommandExecutor {
private McMMOPlayer mcMMOTarget;
private Player target;
private Party targetParty;
private McMMOPlayer mcMMOPlayer;
private Player player;
private Party playerParty;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 2: case 2:
case 3: case 3:
// Verify target exists and is in a different party than the player String targetName = Misc.getMatchedPlayerName(args[1]);
if (!canJoinParty(sender, args[1])) { McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return true; return true;
} }
mcMMOPlayer = UserManager.getPlayer((Player) sender); Player target = mcMMOTarget.getPlayer();
player = mcMMOPlayer.getPlayer();
if (!mcMMOTarget.inParty()) {
sender.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
Party targetParty = mcMMOTarget.getParty();
if (player.equals(target) || (mcMMOPlayer.inParty() && mcMMOPlayer.getParty().equals(targetParty))) {
sender.sendMessage(LocaleLoader.getString("Party.Join.Self"));
return true;
}
String password = getPassword(args); String password = getPassword(args);
@@ -41,12 +49,15 @@ public class PartyJoinCommand implements CommandExecutor {
return true; return true;
} }
String partyName = targetParty.getName();
// Changing parties // Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, playerParty, targetParty.getName())) { if (!PartyManager.changeOrJoinParty(mcMMOPlayer, partyName)) {
return true; return true;
} }
PartyManager.joinParty(player, mcMMOPlayer, targetParty, password); player.sendMessage(LocaleLoader.getString("Commands.Party.Join", partyName));
PartyManager.addToParty(mcMMOPlayer, targetParty);
return true; return true;
default: default:
@@ -62,32 +73,4 @@ public class PartyJoinCommand implements CommandExecutor {
return null; return null;
} }
private boolean canJoinParty(CommandSender sender, String targetName) {
mcMMOTarget = UserManager.getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;
}
target = mcMMOTarget.getPlayer();
if (!mcMMOTarget.inParty()) {
sender.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName));
return false;
}
player = (Player) sender;
mcMMOPlayer = UserManager.getPlayer(player);
playerParty = mcMMOPlayer.getParty();
targetParty = mcMMOTarget.getParty();
if (player.equals(target) || (mcMMOPlayer.inParty() && playerParty.equals(targetParty))) {
sender.sendMessage(LocaleLoader.getString("Party.Join.Self"));
return false;
}
return true;
}
} }

View File

@@ -22,7 +22,7 @@ public class PartyKickCommand implements CommandExecutor {
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]); OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]);
if (!playerParty.getMembers().contains(target.getName())) { if (!playerParty.getMembers().contains(target.getName())) {
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1])); sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", target.getName()));
return true; return true;
} }
@@ -34,6 +34,7 @@ public class PartyKickCommand implements CommandExecutor {
return true; return true;
} }
PartyManager.processPartyLeaving(UserManager.getPlayer(onlineTarget));
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName)); onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
} }

View File

@@ -12,19 +12,15 @@ import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
public class PartyLockCommand implements CommandExecutor { public class PartyLockCommand implements CommandExecutor {
private Party playerParty;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
playerParty = UserManager.getPlayer((Player) sender).getParty();
switch (args.length) { switch (args.length) {
case 1: case 1:
if (args[0].equalsIgnoreCase("lock")) { if (args[0].equalsIgnoreCase("lock")) {
lockParty(sender, command.getPermissionMessage()); togglePartyLock(sender, true);
} }
else if (args[0].equalsIgnoreCase("unlock")) { else if (args[0].equalsIgnoreCase("unlock")) {
unlockParty(sender, command.getPermissionMessage()); togglePartyLock(sender, false);
} }
return true; return true;
@@ -36,10 +32,10 @@ public class PartyLockCommand implements CommandExecutor {
} }
if (CommandUtils.shouldEnableToggle(args[1])) { if (CommandUtils.shouldEnableToggle(args[1])) {
lockParty(sender, command.getPermissionMessage()); togglePartyLock(sender, true);
} }
else if (CommandUtils.shouldDisableToggle(args[1])) { else if (CommandUtils.shouldDisableToggle(args[1])) {
unlockParty(sender, command.getPermissionMessage()); togglePartyLock(sender, false);
} }
else { else {
sendUsageStrings(sender); sendUsageStrings(sender);
@@ -53,46 +49,25 @@ public class PartyLockCommand implements CommandExecutor {
} }
} }
/**
* Handle locking a party.
*/
private void lockParty(CommandSender sender, String permissionMessage) {
if (!Permissions.partySubcommand(sender, PartySubcommandType.LOCK)) {
sender.sendMessage(permissionMessage);
return;
}
if (playerParty.isLocked()) {
sender.sendMessage(LocaleLoader.getString("Party.IsLocked"));
return;
}
playerParty.setLocked(true);
sender.sendMessage(LocaleLoader.getString("Party.Locked"));
}
/**
* Handle unlocking a party.
*
* @return true if party is successfully unlocked, false otherwise.
*/
private void unlockParty(CommandSender sender, String permissionMessage) {
if (!Permissions.partySubcommand(sender, PartySubcommandType.UNLOCK)) {
sender.sendMessage(permissionMessage);
return;
}
if (!playerParty.isLocked()) {
sender.sendMessage(LocaleLoader.getString("Party.IsntLocked"));
return;
}
playerParty.setLocked(false);
sender.sendMessage(LocaleLoader.getString("Party.Unlocked"));
}
private void sendUsageStrings(CommandSender sender) { private void sendUsageStrings(CommandSender sender) {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "lock", "[on|off]")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "lock", "[on|off]"));
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "unlock")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "unlock"));
} }
private void togglePartyLock(CommandSender sender, boolean lock) {
Party party = UserManager.getPlayer((Player) sender).getParty();
if (!Permissions.partySubcommand(sender, lock ? PartySubcommandType.LOCK : PartySubcommandType.UNLOCK)) {
sender.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
return;
}
if (lock ? party.isLocked() : !party.isLocked()) {
sender.sendMessage(LocaleLoader.getString("Party." + (lock ? "IsLocked" : "IsntLocked")));
return;
}
party.setLocked(lock);
sender.sendMessage(LocaleLoader.getString("Party." + (lock ? "Locked" : "Unlocked")));
}
} }

View File

@@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
@@ -17,13 +18,14 @@ public class PartyQuitCommand implements CommandExecutor {
switch (args.length) { switch (args.length) {
case 1: case 1:
Player player = (Player) sender; Player player = (Player) sender;
Party playerParty = UserManager.getPlayer(player).getParty(); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
Party playerParty = mcMMOPlayer.getParty();
if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) { if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) {
return true; return true;
} }
PartyManager.removeFromParty(player, playerParty); PartyManager.removeFromParty(mcMMOPlayer);
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave")); sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
return true; return true;

View File

@@ -30,10 +30,9 @@ public class PartyRenameCommand implements CommandExecutor {
} }
Player player = mcMMOPlayer.getPlayer(); Player player = mcMMOPlayer.getPlayer();
Party newParty = PartyManager.getParty(newPartyName);
// Check to see if the party exists, and if it does cancel renaming the party // Check to see if the party exists, and if it does cancel renaming the party
if (PartyManager.checkPartyExistence(player, newParty, newPartyName)) { if (PartyManager.checkPartyExistence(player, newPartyName)) {
return true; return true;
} }

View File

@@ -3,9 +3,8 @@ package com.gmail.nossr50.commands.party.teleport;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
@@ -18,17 +17,16 @@ public class PtpAcceptAnyCommand implements CommandExecutor {
return true; return true;
} }
Player player = (Player) sender; PartyTeleportRecord ptpRecord = UserManager.getPlayer(sender.getName()).getPartyTeleportRecord();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (mcMMOPlayer.getPtpConfirmRequired()) { if (ptpRecord.isConfirmRequired()) {
player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled")); sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled"));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Enabled")); sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Enabled"));
} }
mcMMOPlayer.togglePtpConfirmRequired(); ptpRecord.toggleConfirmRequired();
return true; return true;
} }
} }

View File

@@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
@@ -22,21 +22,21 @@ public class PtpAcceptCommand implements CommandExecutor {
} }
Player player = (Player) sender; Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); PartyTeleportRecord ptpRecord = UserManager.getPlayer(player).getPartyTeleportRecord();
if (!mcMMOPlayer.hasPtpRequest()) { if (!ptpRecord.hasRequest()) {
player.sendMessage(LocaleLoader.getString("Commands.ptp.NoRequests")); player.sendMessage(LocaleLoader.getString("Commands.ptp.NoRequests"));
return true; return true;
} }
if ((mcMMOPlayer.getPtpTimeout() + Config.getInstance().getPTPCommandTimeout()) * Misc.TIME_CONVERSION_FACTOR < System.currentTimeMillis()) { if ((ptpRecord.getTimeout() + Config.getInstance().getPTPCommandTimeout()) * Misc.TIME_CONVERSION_FACTOR < System.currentTimeMillis()) {
mcMMOPlayer.removePtpRequest(); ptpRecord.removeRequest();
player.sendMessage(LocaleLoader.getString("Commands.ptp.RequestExpired")); player.sendMessage(LocaleLoader.getString("Commands.ptp.RequestExpired"));
return true; return true;
} }
Player target = mcMMOPlayer.getPtpRequest(); Player target = ptpRecord.getRequestor();
mcMMOPlayer.removePtpRequest(); ptpRecord.removeRequest();
if (!PtpCommand.canTeleport(sender, player, target.getName())) { if (!PtpCommand.canTeleport(sender, player, target.getName())) {
return true; return true;

View File

@@ -13,22 +13,21 @@ import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.items.TeleportationWarmup; import com.gmail.nossr50.runnables.items.TeleportationWarmup;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public class PtpCommand implements TabExecutor { public class PtpCommand implements TabExecutor {
private static Player target;
private static McMMOPlayer mcMMOTarget;
public static final List<String> TELEPORT_SUBCOMMANDS = ImmutableList.of("toggle", "accept", "acceptany", "acceptall"); public static final List<String> TELEPORT_SUBCOMMANDS = ImmutableList.of("toggle", "accept", "acceptany", "acceptall");
private CommandExecutor ptpToggleCommand = new PtpToggleCommand(); private CommandExecutor ptpToggleCommand = new PtpToggleCommand();
@@ -76,10 +75,10 @@ public class PtpCommand implements TabExecutor {
} }
int ptpCooldown = Config.getInstance().getPTPCommandCooldown(); int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
long lastTeleport = mcMMOPlayer.getLastTeleport(); long ptpLastUse = mcMMOPlayer.getPartyTeleportRecord().getLastUse();
if (ptpCooldown > 0) { if (ptpCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player); int timeRemaining = SkillUtils.calculateTimeLeft(ptpLastUse * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player);
if (timeRemaining > 0) { if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", timeRemaining)); player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", timeRemaining));
@@ -87,7 +86,7 @@ public class PtpCommand implements TabExecutor {
} }
} }
sendTeleportRequest(sender, player, args[0]); sendTeleportRequest(sender, player, Misc.getMatchedPlayerName(args[0]));
return true; return true;
default: default:
@@ -102,7 +101,7 @@ public class PtpCommand implements TabExecutor {
List<String> matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<String>(TELEPORT_SUBCOMMANDS.size())); List<String> matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<String>(TELEPORT_SUBCOMMANDS.size()));
if (matches.size() == 0) { if (matches.size() == 0) {
Set<String> playerNames = UserManager.getPlayers().keySet(); Set<String> playerNames = UserManager.getPlayerNames();
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size())); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
} }
@@ -117,13 +116,18 @@ public class PtpCommand implements TabExecutor {
return; return;
} }
if (!mcMMOTarget.getPtpConfirmRequired()) { McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
Player target = mcMMOTarget.getPlayer();
PartyTeleportRecord ptpRecord = mcMMOTarget.getPartyTeleportRecord();
if (!ptpRecord.isConfirmRequired()) {
handleTeleportWarmup(player, target); handleTeleportWarmup(player, target);
return; return;
} }
mcMMOTarget.setPtpRequest(player); ptpRecord.setRequestor(player);
mcMMOTarget.actualizePtpTimeout(); ptpRecord.actualizeTimeout();
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
@@ -132,14 +136,13 @@ public class PtpCommand implements TabExecutor {
} }
protected static boolean canTeleport(CommandSender sender, Player player, String targetName) { protected static boolean canTeleport(CommandSender sender, Player player, String targetName) {
mcMMOTarget = UserManager.getPlayer(targetName); McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false; return false;
} }
target = mcMMOTarget.getPlayer(); Player target = mcMMOTarget.getPlayer();
targetName = target.getName();
if (player.equals(target)) { if (player.equals(target)) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self")); player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
@@ -151,7 +154,7 @@ public class PtpCommand implements TabExecutor {
return false; return false;
} }
if (!mcMMOTarget.getPtpEnabled()) { if (!mcMMOTarget.getPartyTeleportRecord().isEnabled()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", targetName)); player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", targetName));
return false; return false;
} }
@@ -166,7 +169,7 @@ public class PtpCommand implements TabExecutor {
protected static void handleTeleportWarmup(Player teleportingPlayer, Player targetPlayer) { protected static void handleTeleportWarmup(Player teleportingPlayer, Player targetPlayer) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
mcMMOTarget = UserManager.getPlayer(targetPlayer); McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetPlayer);
long warmup = Config.getInstance().getPTPCommandWarmup(); long warmup = Config.getInstance().getPTPCommandWarmup();
@@ -177,25 +180,7 @@ public class PtpCommand implements TabExecutor {
new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup); new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup);
} }
else { else {
handlePartyTeleportEvent(teleportingPlayer, targetPlayer); EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
} }
} }
public static void handlePartyTeleportEvent(Player teleportingPlayer, Player targetPlayer) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(teleportingPlayer, targetPlayer, mcMMOPlayer.getParty().getName());
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
teleportingPlayer.teleport(targetPlayer);
teleportingPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Player", targetPlayer.getName()));
targetPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Target", teleportingPlayer.getName()));
mcMMOPlayer.actualizeRecentlyHurt();
}
} }

View File

@@ -3,9 +3,8 @@ package com.gmail.nossr50.commands.party.teleport;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
@@ -18,17 +17,16 @@ public class PtpToggleCommand implements CommandExecutor {
return true; return true;
} }
Player player = (Player) sender; PartyTeleportRecord ptpRecord = UserManager.getPlayer(sender.getName()).getPartyTeleportRecord();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (mcMMOPlayer.getPtpEnabled()) { if (ptpRecord.isEnabled()) {
player.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled")); sender.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled"));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled")); sender.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled"));
} }
mcMMOPlayer.togglePtpUse(); ptpRecord.toggleEnabled();
return true; return true;
} }
} }

View File

@@ -16,6 +16,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
@@ -28,44 +29,42 @@ public class InspectCommand implements TabExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) { String playerName = Misc.getMatchedPlayerName(args[0]);
ScoreboardManager.setupPlayerScoreboard(sender.getName()); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) { if (mcMMOPlayer == null) {
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(args[0], false); // Temporary Profile PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); // Temporary Profile
if (CommandUtils.inspectOffline(sender, profile, Permissions.inspectOffline(sender))) { if (CommandUtils.inspectOffline(sender, profile, Permissions.inspectOffline(sender))) {
return true; return true;
} }
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) { if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
ScoreboardManager.enablePlayerInspectScoreboardOffline((Player) sender, profile); ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile);
if (!Config.getInstance().getInspectUseChat()) {
return true; return true;
} }
}
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", args[0])); sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering")); sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
CommandUtils.displaySkill(sender, profile, SkillType.EXCAVATION); for (SkillType skill : SkillType.GATHERING_SKILLS) {
CommandUtils.displaySkill(sender, profile, SkillType.FISHING); sender.sendMessage(CommandUtils.displaySkill(profile, skill));
CommandUtils.displaySkill(sender, profile, SkillType.HERBALISM); }
CommandUtils.displaySkill(sender, profile, SkillType.MINING);
CommandUtils.displaySkill(sender, profile, SkillType.WOODCUTTING);
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat")); sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
CommandUtils.displaySkill(sender, profile, SkillType.AXES); for (SkillType skill : SkillType.COMBAT_SKILLS) {
CommandUtils.displaySkill(sender, profile, SkillType.ARCHERY); sender.sendMessage(CommandUtils.displaySkill(profile, skill));
CommandUtils.displaySkill(sender, profile, SkillType.SWORDS); }
CommandUtils.displaySkill(sender, profile, SkillType.TAMING);
CommandUtils.displaySkill(sender, profile, SkillType.UNARMED);
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc")); sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
CommandUtils.displaySkill(sender, profile, SkillType.ACROBATICS); for (SkillType skill : SkillType.MISC_SKILLS) {
CommandUtils.displaySkill(sender, profile, SkillType.REPAIR); sender.sendMessage(CommandUtils.displaySkill(profile, skill));
}
} }
else { else {
Player target = mcMMOPlayer.getPlayer(); Player target = mcMMOPlayer.getPlayer();
@@ -80,10 +79,13 @@ public class InspectCommand implements TabExecutor {
return true; return true;
} }
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) { if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
ScoreboardManager.enablePlayerInspectScoreboardOnline((Player) sender, mcMMOPlayer); ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile());
if (!Config.getInstance().getInspectUseChat()) {
return true; return true;
} }
}
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName())); sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
CommandUtils.printGatheringSkills(target, sender); CommandUtils.printGatheringSkills(target, sender);
@@ -103,7 +105,7 @@ public class InspectCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
Set<String> playerNames = UserManager.getPlayers().keySet(); Set<String> playerNames = UserManager.getPlayerNames();
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size())); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default: default:
return ImmutableList.of(); return ImmutableList.of();

View File

@@ -0,0 +1,70 @@
package com.gmail.nossr50.commands.player;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList;
public class MccooldownCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
switch (args.length) {
case 0:
Player player = (Player) sender;
if (Config.getInstance().getCooldownUseBoard()) {
ScoreboardManager.enablePlayerCooldownScoreboard(player);
if (!Config.getInstance().getCooldownUseChat()) {
return true;
}
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header"));
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
for (AbilityType ability : AbilityType.values()) {
if (!ability.getPermissions(player)) {
continue;
}
int seconds = mcMMOPlayer.calculateTimeRemaining(ability);
if (seconds <= 0) {
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getName()));
}
else {
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getName(), seconds));
}
}
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return ImmutableList.of();
}
}

View File

@@ -13,11 +13,13 @@ import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask; import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public class McrankCommand implements TabExecutor { public class McrankCommand implements TabExecutor {
@@ -34,13 +36,7 @@ public class McrankCommand implements TabExecutor {
return true; return true;
} }
if (Config.getInstance().getMcrankScoreboardEnabled()) {
ScoreboardManager.setupPlayerScoreboard(sender.getName());
ScoreboardManager.enablePlayerRankScoreboard((Player) sender);
}
else {
display(sender, sender.getName()); display(sender, sender.getName());
}
return true; return true;
@@ -50,13 +46,14 @@ public class McrankCommand implements TabExecutor {
return true; return true;
} }
String playerName = args[0]; String playerName = Misc.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
if (mcMMOPlayer != null) { if (mcMMOPlayer != null) {
playerName = mcMMOPlayer.getPlayer().getName(); Player player = mcMMOPlayer.getPlayer();
playerName = player.getName();
if (CommandUtils.tooFar(sender, mcMMOPlayer.getPlayer(), Permissions.mcrankFar(sender))) { if (CommandUtils.tooFar(sender, player, Permissions.mcrankFar(sender))) {
return true; return true;
} }
} }
@@ -64,13 +61,7 @@ public class McrankCommand implements TabExecutor {
return true; return true;
} }
if (sender instanceof Player && Config.getInstance().getMcrankScoreboardEnabled()) {
ScoreboardManager.setupPlayerScoreboard(sender.getName());
ScoreboardManager.enablePlayerRankScoreboardOthers((Player) sender, playerName);
}
else {
display(sender, playerName); display(sender, playerName);
}
return true; return true;
default: default:
@@ -82,7 +73,7 @@ public class McrankCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
Set<String> playerNames = UserManager.getPlayers().keySet(); Set<String> playerNames = UserManager.getPlayerNames();
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size())); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default: default:
return ImmutableList.of(); return ImmutableList.of();
@@ -90,6 +81,20 @@ public class McrankCommand implements TabExecutor {
} }
private void display(CommandSender sender, String playerName) { private void display(CommandSender sender, String playerName) {
new McrankCommandAsyncTask(playerName, sender).runTaskAsynchronously(mcMMO.p); if (sender instanceof Player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
return;
}
mcMMOPlayer.actualizeDatabaseATS();
}
boolean useBoard = (sender instanceof Player) && (Config.getInstance().getRankUseBoard());
boolean useChat = useBoard ? Config.getInstance().getRankUseChat() : true;
new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
} }
} }

View File

@@ -8,11 +8,11 @@ import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public class McstatsCommand implements TabExecutor { public class McstatsCommand implements TabExecutor {
@@ -25,13 +25,15 @@ public class McstatsCommand implements TabExecutor {
switch (args.length) { switch (args.length) {
case 0: case 0:
Player player = (Player) sender; Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (Config.getInstance().getMcstatsScoreboardsEnabled()) { if (Config.getInstance().getStatsUseBoard()) {
ScoreboardManager.setupPlayerScoreboard(player.getName()); ScoreboardManager.enablePlayerStatsScoreboard(player);
ScoreboardManager.enablePlayerStatsScoreboard(mcMMOPlayer);
if (!Config.getInstance().getStatsUseChat()) {
return true;
} }
else { }
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats")); player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote")); player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
@@ -47,7 +49,6 @@ public class McstatsCommand implements TabExecutor {
else { else {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel())); player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
} }
}
return true; return true;

View File

@@ -11,36 +11,41 @@ import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask; import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public class MctopCommand implements TabExecutor { public class MctopCommand implements TabExecutor {
private SkillType skill;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
SkillType skill = null;
switch (args.length) { switch (args.length) {
case 0: case 0:
display(1, "ALL", sender, command); display(1, skill, sender, command);
return true; return true;
case 1: case 1:
if (StringUtils.isInt(args[0])) { if (StringUtils.isInt(args[0])) {
display(Math.abs(Integer.parseInt(args[0])), "ALL", sender, command); display(Math.abs(Integer.parseInt(args[0])), skill, sender, command);
return true; return true;
} }
if (!extractSkill(sender, args[0])) { skill = extractSkill(sender, args[0]);
if (skill == null) {
return true; return true;
} }
display(1, skill.toString(), sender, command); display(1, skill, sender, command);
return true; return true;
case 2: case 2:
@@ -48,11 +53,13 @@ public class MctopCommand implements TabExecutor {
return true; return true;
} }
if (!extractSkill(sender, args[0])) { skill = extractSkill(sender, args[0]);
if (skill == null) {
return true; return true;
} }
display(Math.abs(Integer.parseInt(args[1])), skill.toString(), sender, command); display(Math.abs(Integer.parseInt(args[1])), skill, sender, command);
return true; return true;
default: default:
@@ -70,35 +77,44 @@ public class MctopCommand implements TabExecutor {
} }
} }
private void display(int page, String skill, CommandSender sender, Command command) { private void display(int page, SkillType skill, CommandSender sender, Command command) {
if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, this.skill)) { if (skill != null && !Permissions.mctop(sender, skill)) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return; return;
} }
if (sender instanceof Player && Config.getInstance().getMctopScoreboardEnabled()) { if (sender instanceof Player) {
ScoreboardManager.enableGlobalStatsScoreboard((Player) sender, skill, page); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
return;
} }
else {
mcMMOPlayer.actualizeDatabaseATS();
}
display(page, skill, sender); display(page, skill, sender);
} }
private void display(int page, SkillType skill, CommandSender sender) {
boolean useBoard = (sender instanceof Player) && (Config.getInstance().getTopUseBoard());
boolean useChat = useBoard ? Config.getInstance().getTopUseChat() : true;
new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
} }
private void display(int page, String query, CommandSender sender) { private SkillType extractSkill(CommandSender sender, String skillName) {
new MctopCommandAsyncTask(page, query, sender).runTaskAsynchronously(mcMMO.p);
}
private boolean extractSkill(CommandSender sender, String skillName) {
if (CommandUtils.isInvalidSkill(sender, skillName)) { if (CommandUtils.isInvalidSkill(sender, skillName)) {
return false; return null;
} }
skill = SkillType.getSkill(skillName); SkillType skill = SkillType.getSkill(skillName);
if (CommandUtils.isChildSkill(sender, skill)) { if (CommandUtils.isChildSkill(sender, skill)) {
return false; return null;
} }
return true; return skill;
} }
} }

View File

@@ -1,8 +1,13 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.acrobatics.Acrobatics;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
public class AcrobaticsCommand extends SkillCommand { public class AcrobaticsCommand extends SkillCommand {
@@ -22,75 +27,71 @@ public class AcrobaticsCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// DODGE // DODGE
if (canDodge) { if (canDodge) {
String[] dodgeStrings = calculateAbilityDisplayValues(Acrobatics.dodgeMaxBonusLevel, Acrobatics.dodgeMaxChance); String[] dodgeStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.DODGE, isLucky);
dodgeChance = dodgeStrings[0]; dodgeChance = dodgeStrings[0];
dodgeChanceLucky = dodgeStrings[1]; dodgeChanceLucky = dodgeStrings[1];
} }
// ROLL // ROLL
if (canRoll) { if (canRoll) {
String[] rollStrings = calculateAbilityDisplayValues(Acrobatics.rollMaxBonusLevel, Acrobatics.rollMaxChance); String[] rollStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.ROLL, isLucky);
rollChance = rollStrings[0]; rollChance = rollStrings[0];
rollChanceLucky = rollStrings[1]; rollChanceLucky = rollStrings[1];
} }
// GRACEFUL ROLL // GRACEFUL ROLL
if (canGracefulRoll) { if (canGracefulRoll) {
String[] gracefulRollStrings = calculateAbilityDisplayValues(Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollMaxChance); String[] gracefulRollStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.GRACEFUL_ROLL, isLucky);
gracefulRollChance = gracefulRollStrings[0]; gracefulRollChance = gracefulRollStrings[0];
gracefulRollChanceLucky = gracefulRollStrings[1]; gracefulRollChanceLucky = gracefulRollStrings[1];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canDodge = Permissions.dodge(player); canDodge = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.DODGE);
canRoll = Permissions.roll(player); canRoll = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.ROLL);
canGracefulRoll = Permissions.gracefulRoll(player); canGracefulRoll = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.GRACEFUL_ROLL);
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canDodge || canGracefulRoll || canRoll; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canRoll) { if (canRoll) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1")));
} }
if (canGracefulRoll) { if (canGracefulRoll) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.2"), LocaleLoader.getString("Acrobatics.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.2"), LocaleLoader.getString("Acrobatics.Effect.3")));
} }
if (canDodge) { if (canDodge) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.4"), LocaleLoader.getString("Acrobatics.Effect.5"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.4"), LocaleLoader.getString("Acrobatics.Effect.5")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canDodge || canGracefulRoll || canRoll; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canRoll) { if (canRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", rollChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", rollChanceLucky) : "")); messages.add(LocaleLoader.getString("Acrobatics.Roll.Chance", rollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", rollChanceLucky) : ""));
} }
if (canGracefulRoll) { if (canGracefulRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", gracefulRollChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", gracefulRollChanceLucky) : "")); messages.add(LocaleLoader.getString("Acrobatics.Roll.GraceChance", gracefulRollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", gracefulRollChanceLucky) : ""));
} }
if (canDodge) { if (canDodge) {
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", dodgeChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", dodgeChanceLucky) : "")); messages.add(LocaleLoader.getString("Acrobatics.DodgeChance", dodgeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dodgeChanceLucky) : ""));
} }
return messages;
} }
} }

View File

@@ -1,5 +1,11 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.archery.Archery; import com.gmail.nossr50.skills.archery.Archery;
@@ -21,7 +27,7 @@ public class ArcheryCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// SKILL SHOT // SKILL SHOT
if (canSkillShot) { if (canSkillShot) {
double bonus = (skillValue / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage; double bonus = (skillValue / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage;
@@ -30,65 +36,61 @@ public class ArcheryCommand extends SkillCommand {
// DAZE // DAZE
if (canDaze) { if (canDaze) {
String[] dazeStrings = calculateAbilityDisplayValues(Archery.dazeMaxBonusLevel, Archery.dazeMaxBonus); String[] dazeStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.DAZE, isLucky);
dazeChance = dazeStrings[0]; dazeChance = dazeStrings[0];
dazeChanceLucky = dazeStrings[1]; dazeChanceLucky = dazeStrings[1];
} }
// RETRIEVE // RETRIEVE
if (canRetrieve) { if (canRetrieve) {
String[] retrieveStrings = calculateAbilityDisplayValues(Archery.retrieveMaxBonusLevel, Archery.retrieveMaxChance); String[] retrieveStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.RETRIEVE, isLucky);
retrieveChance = retrieveStrings[0]; retrieveChance = retrieveStrings[0];
retrieveChanceLucky = retrieveStrings[1]; retrieveChanceLucky = retrieveStrings[1];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canSkillShot = Permissions.bonusDamage(player, skill); canSkillShot = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SKILL_SHOT);
canDaze = Permissions.daze(player); canDaze = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.DAZE);
canRetrieve = Permissions.arrowRetrieval(player); canRetrieve = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.RETRIEVE);
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canSkillShot || canDaze || canRetrieve; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canSkillShot) { if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1")));
} }
if (canDaze) { if (canDaze) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3", Archery.dazeModifier))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3", Archery.dazeModifier)));
} }
if (canRetrieve) { if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canSkillShot || canDaze || canRetrieve; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canSkillShot) { if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", skillShotBonus)); messages.add(LocaleLoader.getString("Archery.Combat.SkillshotBonus", skillShotBonus));
} }
if (canDaze) { if (canDaze) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", dazeChanceLucky) : "")); messages.add(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dazeChanceLucky) : ""));
} }
if (canRetrieve) { if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", retrieveChanceLucky) : "")); messages.add(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", retrieveChanceLucky) : ""));
} }
return messages;
} }
} }

View File

@@ -1,5 +1,11 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.axes.Axes; import com.gmail.nossr50.skills.axes.Axes;
@@ -8,14 +14,14 @@ import com.gmail.nossr50.util.Permissions;
public class AxesCommand extends SkillCommand { public class AxesCommand extends SkillCommand {
private String critChance; private String critChance;
private String critChanceLucky; private String critChanceLucky;
private float bonusDamage; private double axeMasteryDamage;
private float impactDamage; private double impactDamage;
private String skullSplitterLength; private String skullSplitterLength;
private String skullSplitterLengthEndurance; private String skullSplitterLengthEndurance;
private boolean canSkullSplitter; private boolean canSkullSplitter;
private boolean canCritical; private boolean canCritical;
private boolean canBonusDamage; private boolean canAxeMastery;
private boolean canImpact; private boolean canImpact;
private boolean canGreaterImpact; private boolean canGreaterImpact;
@@ -24,96 +30,92 @@ public class AxesCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// IMPACT // ARMOR IMPACT
if (canImpact) { if (canImpact) {
impactDamage = 1 + (skillValue / Axes.impactIncreaseLevel); impactDamage = 1 + (skillValue / Axes.impactIncreaseLevel);
} }
// SKULL SPLITTER // SKULL SPLITTER
if (canSkullSplitter) { if (canSkullSplitter) {
String[] skullSplitterStrings = calculateLengthDisplayValues(); String[] skullSplitterStrings = calculateLengthDisplayValues(player, skillValue);
skullSplitterLength = skullSplitterStrings[0]; skullSplitterLength = skullSplitterStrings[0];
skullSplitterLengthEndurance = skullSplitterStrings[1]; skullSplitterLengthEndurance = skullSplitterStrings[1];
} }
// CRITICAL STRIKES // CRITICAL HIT
if (canCritical) { if (canCritical) {
String[] criticalStrikeStrings = calculateAbilityDisplayValues(Axes.criticalHitMaxBonusLevel, Axes.criticalHitMaxChance); String[] criticalHitStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.CRITICAL_HIT, isLucky);
critChance = criticalStrikeStrings[0]; critChance = criticalHitStrings[0];
critChanceLucky = criticalStrikeStrings[1]; critChanceLucky = criticalHitStrings[1];
} }
// AXE MASTERY // AXE MASTERY
if (canBonusDamage) { if (canAxeMastery) {
bonusDamage = Math.min(skillValue / (Axes.bonusDamageMaxBonusLevel / Axes.bonusDamageMaxBonus), Axes.bonusDamageMaxBonus); axeMasteryDamage = Math.min(skillValue / (Axes.axeMasteryMaxBonusLevel / Axes.axeMasteryMaxBonus), Axes.axeMasteryMaxBonus);
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canSkullSplitter = Permissions.skullSplitter(player); canSkullSplitter = Permissions.skullSplitter(player);
canCritical = Permissions.criticalStrikes(player); canCritical = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.CRITICAL_HIT);
canBonusDamage = Permissions.bonusDamage(player, skill); canAxeMastery = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.AXE_MASTERY);
canImpact = Permissions.armorImpact(player); canImpact = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.ARMOR_IMPACT);
canGreaterImpact = Permissions.greaterImpact(player); canGreaterImpact = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.GREATER_IMPACT);
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canSkullSplitter) { if (canSkullSplitter) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.0"), LocaleLoader.getString("Axes.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.0"), LocaleLoader.getString("Axes.Effect.1")));
} }
if (canCritical) { if (canCritical) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.2"), LocaleLoader.getString("Axes.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.2"), LocaleLoader.getString("Axes.Effect.3")));
} }
if (canBonusDamage) { if (canAxeMastery) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.4"), LocaleLoader.getString("Axes.Effect.5"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.4"), LocaleLoader.getString("Axes.Effect.5")));
} }
if (canImpact) { if (canImpact) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.6"), LocaleLoader.getString("Axes.Effect.7"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.6"), LocaleLoader.getString("Axes.Effect.7")));
} }
if (canGreaterImpact) { if (canGreaterImpact) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.8"), LocaleLoader.getString("Axes.Effect.9"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.8"), LocaleLoader.getString("Axes.Effect.9")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact; List<String> messages = new ArrayList<String>();
}
@Override if (canAxeMastery) {
protected void statsDisplay() { messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", axeMasteryDamage)));
if (canBonusDamage) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", bonusDamage)));
} }
if (canImpact) { if (canImpact) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", impactDamage))); messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", impactDamage)));
} }
if (canGreaterImpact) { if (canGreaterImpact) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", Axes.greaterImpactBonusDamage))); messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", Axes.greaterImpactBonusDamage)));
} }
if (canCritical) { if (canCritical) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", critChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", critChanceLucky) : "")); messages.add(LocaleLoader.getString("Axes.Combat.CritChance", critChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", critChanceLucky) : ""));
} }
if (canSkullSplitter) { if (canSkullSplitter) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", skullSplitterLengthEndurance) : "")); messages.add(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", skullSplitterLengthEndurance) : ""));
} }
return messages;
} }
} }

View File

@@ -1,5 +1,11 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
@@ -16,48 +22,44 @@ public class ExcavationCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// GIGA DRILL BREAKER // GIGA DRILL BREAKER
if (canGigaDrill) { if (canGigaDrill) {
String gigaDrillStrings[] = calculateLengthDisplayValues(); String gigaDrillStrings[] = calculateLengthDisplayValues(player, skillValue);
gigaDrillBreakerLength = gigaDrillStrings[0]; gigaDrillBreakerLength = gigaDrillStrings[0];
gigaDrillBreakerLengthEndurance = gigaDrillStrings[1]; gigaDrillBreakerLengthEndurance = gigaDrillStrings[1];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canGigaDrill = Permissions.gigaDrillBreaker(player); canGigaDrill = Permissions.gigaDrillBreaker(player);
canTreasureHunt = Permissions.excavationTreasureHunter(player); canTreasureHunt = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.EXCAVATION_TREASURE_HUNTER);
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canGigaDrill || canTreasureHunt; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canGigaDrill) { if (canGigaDrill) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.0"), LocaleLoader.getString("Excavation.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.0"), LocaleLoader.getString("Excavation.Effect.1")));
} }
if (canTreasureHunt) { if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canGigaDrill; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canGigaDrill) { if (canGigaDrill) {
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", gigaDrillBreakerLengthEndurance) : "")); messages.add(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", gigaDrillBreakerLengthEndurance) : ""));
} }
return messages;
} }
} }

View File

@@ -1,25 +1,42 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.treasure.TreasureConfig;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.treasure.Rarity;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.fishing.Fishing; import com.gmail.nossr50.skills.fishing.Fishing;
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
public class FishingCommand extends SkillCommand { public class FishingCommand extends SkillCommand {
private int lootTier; private int lootTier;
private String magicChance;
private String magicChanceLucky;
private String chanceRaining = "";
private String shakeChance; private String shakeChance;
private String shakeChanceLucky; private String shakeChanceLucky;
private int fishermansDietRank; private int fishermansDietRank;
private String biteChance; private String biteChance;
private String trapTreasure;
private String commonTreasure;
private String uncommonTreasure;
private String rareTreasure;
private String epicTreasure;
private String legendaryTreasure;
private String recordTreasure;
private String magicChance;
private boolean canTreasureHunt; private boolean canTreasureHunt;
private boolean canMagicHunt; private boolean canMagicHunt;
private boolean canShake; private boolean canShake;
@@ -32,140 +49,161 @@ public class FishingCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
boolean isStorming = player.getWorld().hasStorm(); boolean isStorming = player.getWorld().hasStorm();
// TREASURE HUNTER // TREASURE HUNTER
if (canTreasureHunt) { if (canTreasureHunt) {
lootTier = mcMMOPlayer.getFishingManager().getLootTier(); lootTier = fishingManager.getLootTier();
double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier();
if (isStorming) { // Item drop rates
chanceRaining = LocaleLoader.getString("Fishing.Chance.Raining"); trapTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.TRAP) / 100.0);
enchantChance *= 1.1D; commonTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON) / 100.0);
uncommonTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON) / 100.0);
rareTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE) / 100.0);
epicTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC) / 100.0);
legendaryTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY) / 100.0);
recordTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD) / 100.0);
// Magic hunter drop rates
double totalEnchantChance = 0;
for (Rarity rarity : Rarity.values()) {
if (rarity != Rarity.TRAP || rarity != Rarity.RECORD) {
totalEnchantChance += TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, rarity);
}
} }
String[] treasureHunterStrings = calculateAbilityDisplayValues(enchantChance); magicChance = percent.format(totalEnchantChance / 100.0);
magicChance = treasureHunterStrings[0];
magicChanceLucky = treasureHunterStrings[1];
} }
// SHAKE // SHAKE
if (canShake) { if (canShake) {
String[] shakeStrings = calculateAbilityDisplayValues(UserManager.getPlayer(player).getFishingManager().getShakeProbability()); String[] shakeStrings = calculateAbilityDisplayValues(UserManager.getPlayer(player).getFishingManager().getShakeProbability(), isLucky);
shakeChance = shakeStrings[0]; shakeChance = shakeStrings[0];
shakeChanceLucky = shakeStrings[1]; shakeChanceLucky = shakeStrings[1];
} }
// FISHERMAN'S DIET // FISHERMAN'S DIET
if (canFishermansDiet) { if (canFishermansDiet) {
fishermansDietRank = calculateRank(Fishing.fishermansDietMaxLevel, Fishing.fishermansDietRankLevel1); fishermansDietRank = calculateRank(skillValue, Fishing.fishermansDietMaxLevel, Fishing.fishermansDietRankLevel1);
} }
// MASTER ANGLER // MASTER ANGLER
if (canMasterAngler) { if (canMasterAngler) {
double rawBiteChance = ((Math.max((skillValue / 200.0), 1.0)) / (isStorming ? 300 : 500)); double rawBiteChance = 1.0 / (isStorming ? 300 : 500);
Biome biome = player.getLocation().getBlock().getBiome(); Location location = fishingManager.getHookLocation();
if (location == null) {
location = player.getLocation();
}
Biome biome = location.getBlock().getBiome();
if (biome == Biome.RIVER || biome == Biome.OCEAN) { if (biome == Biome.RIVER || biome == Biome.OCEAN) {
rawBiteChance = rawBiteChance * 2.0; rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
} }
if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) { if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) {
rawBiteChance = rawBiteChance * 2.0; rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier();
} }
biteChance = calculateAbilityDisplayValues(rawBiteChance * 100.0)[0]; biteChance = calculateAbilityDisplayValues(rawBiteChance * 100.0, isLucky)[0];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canTreasureHunt = Permissions.fishingTreasureHunter(player); canTreasureHunt = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FISHING_TREASURE_HUNTER);
canMagicHunt = Permissions.magicHunter(player); canMagicHunt = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.MAGIC_HUNTER);
canShake = Permissions.shake(player); canShake = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SHAKE);
canFishermansDiet = Permissions.fishermansDiet(player); canFishermansDiet = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FISHERMANS_DIET);
canMasterAngler = Permissions.masterAngler(player); canMasterAngler = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.MASTER_ANGLER);
canIceFish = Permissions.iceFishing(player); canIceFish = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.ICE_FISHING);
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet || canIceFish; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canTreasureHunt) { if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1")));
} }
if (canMagicHunt) { if (canMagicHunt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3")));
}
if (canShake) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5")));
}
if (canFishermansDiet) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7")));
}
if (canMasterAngler) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9")));
} }
if (canIceFish) { if (canIceFish) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.10"), LocaleLoader.getString("Fishing.Effect.11"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.10"), LocaleLoader.getString("Fishing.Effect.11")));
}
} }
@Override
protected boolean statsHeaderPermissions() {
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet || canIceFish;
}
@Override
protected void statsDisplay() {
if (canMasterAngler) { if (canMasterAngler) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Chance", biteChance)); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9")));
}
if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", lootTier));
}
if (canMagicHunt) {
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", magicChanceLucky) : ""));
} }
if (canShake) { if (canShake) {
int unlockLevel = AdvancedConfig.getInstance().getShakeUnlockLevel(); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5")));
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", unlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", shakeChanceLucky) : ""));
}
} }
if (canFishermansDiet) { if (canFishermansDiet) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank)); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7")));
}
return messages;
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
if (canTreasureHunt) {
messages.add(LocaleLoader.getString("Fishing.Ability.Rank", lootTier, Tier.EIGHT.toNumerical()));
messages.add(LocaleLoader.getString("Fishing.Ability.TH.DropRate", trapTreasure, commonTreasure, uncommonTreasure, rareTreasure, epicTreasure, legendaryTreasure, recordTreasure));
}
if (canMagicHunt) {
messages.add(LocaleLoader.getString("Fishing.Ability.TH.MagicRate", magicChance));
} }
if (canIceFish) { if (canIceFish) {
int unlockLevel = AdvancedConfig.getInstance().getIceFishingUnlockLevel(); int unlockLevel = AdvancedConfig.getInstance().getIceFishingUnlockLevel();
if (skillValue < unlockLevel) { if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.1", unlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.1", unlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.IceFishing")); messages.add(LocaleLoader.getString("Fishing.Ability.IceFishing"));
} }
} }
if (canMasterAngler) {
int unlockLevel = AdvancedConfig.getInstance().getMasterAnglerUnlockLevel();
if (skillValue < unlockLevel) {
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.2", unlockLevel)));
}
else {
messages.add(LocaleLoader.getString("Fishing.Ability.Chance", biteChance));
}
}
if (canShake) {
int unlockLevel = AdvancedConfig.getInstance().getFishingTierLevel(Tier.ONE);
if (skillValue < unlockLevel) {
messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", unlockLevel)));
}
else {
messages.add(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shakeChanceLucky) : ""));
}
}
if (canFishermansDiet) {
messages.add(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
}
return messages;
} }
} }

View File

@@ -1,7 +1,12 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import org.bukkit.Material; import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.herbalism.Herbalism; import com.gmail.nossr50.skills.herbalism.Herbalism;
@@ -34,132 +39,128 @@ public class HerbalismCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// GREEN TERRA // GREEN TERRA
if (canGreenTerra) { if (canGreenTerra) {
String[] greenTerraStrings = calculateLengthDisplayValues(); String[] greenTerraStrings = calculateLengthDisplayValues(player, skillValue);
greenTerraLength = greenTerraStrings[0]; greenTerraLength = greenTerraStrings[0];
greenTerraLengthEndurance = greenTerraStrings[1]; greenTerraLengthEndurance = greenTerraStrings[1];
} }
// FARMERS DIET // FARMERS DIET
if (canFarmersDiet) { if (canFarmersDiet) {
farmersDietRank = calculateRank(Herbalism.farmersDietMaxLevel, Herbalism.farmersDietRankLevel1); farmersDietRank = calculateRank(skillValue, Herbalism.farmersDietMaxLevel, Herbalism.farmersDietRankLevel1);
} }
// GREEN THUMB // GREEN THUMB
if (canGreenThumbBlocks || canGreenThumbPlants) { if (canGreenThumbBlocks || canGreenThumbPlants) {
greenThumbStage = calculateRank(Herbalism.greenThumbStageMaxLevel, Herbalism.greenThumbStageChangeLevel); greenThumbStage = calculateRank(skillValue, Herbalism.greenThumbStageMaxLevel, Herbalism.greenThumbStageChangeLevel);
String[] greenThumbStrings = calculateAbilityDisplayValues(Herbalism.greenThumbMaxLevel, Herbalism.greenThumbMaxChance); String[] greenThumbStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.GREEN_THUMB_PLANT, isLucky);
greenThumbChance = greenThumbStrings[0]; greenThumbChance = greenThumbStrings[0];
greenThumbChanceLucky = greenThumbStrings[1]; greenThumbChanceLucky = greenThumbStrings[1];
} }
// DOUBLE DROPS // DOUBLE DROPS
if (canDoubleDrop) { if (canDoubleDrop) {
String[] doubleDropStrings = calculateAbilityDisplayValues(Herbalism.doubleDropsMaxLevel, Herbalism.doubleDropsMaxChance); String[] doubleDropStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.HERBALISM_DOUBLE_DROPS, isLucky);
doubleDropChance = doubleDropStrings[0]; doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1]; doubleDropChanceLucky = doubleDropStrings[1];
} }
// HYLIAN LUCK // HYLIAN LUCK
if (hasHylianLuck) { if (hasHylianLuck) {
String[] hylianLuckStrings = calculateAbilityDisplayValues(Herbalism.hylianLuckMaxLevel, Herbalism.hylianLuckMaxChance); String[] hylianLuckStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.HYLIAN_LUCK, isLucky);
hylianLuckChance = hylianLuckStrings[0]; hylianLuckChance = hylianLuckStrings[0];
hylianLuckChanceLucky = hylianLuckStrings[1]; hylianLuckChanceLucky = hylianLuckStrings[1];
} }
// SHROOM THUMB // SHROOM THUMB
if (canShroomThumb) { if (canShroomThumb) {
String[] shroomThumbStrings = calculateAbilityDisplayValues(Herbalism.shroomThumbMaxLevel, Herbalism.shroomThumbMaxChance); String[] shroomThumbStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.SHROOM_THUMB, isLucky);
shroomThumbChance = shroomThumbStrings[0]; shroomThumbChance = shroomThumbStrings[0];
shroomThumbChanceLucky = shroomThumbStrings[1]; shroomThumbChanceLucky = shroomThumbStrings[1];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
hasHylianLuck = Permissions.hylianLuck(player); hasHylianLuck = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HYLIAN_LUCK);
canGreenTerra = Permissions.greenTerra(player); canGreenTerra = Permissions.greenTerra(player);
canGreenThumbPlants = Permissions.greenThumbPlant(player, Material.CROPS) || Permissions.greenThumbPlant(player, Material.CARROT) || Permissions.greenThumbPlant(player, Material.POTATO) || Permissions.greenThumbPlant(player, Material.NETHER_WARTS) || Permissions.greenThumbPlant(player, Material.COCOA); canGreenThumbPlants = Permissions.greenThumbPlant(player, Material.CROPS) || Permissions.greenThumbPlant(player, Material.CARROT) || Permissions.greenThumbPlant(player, Material.POTATO) || Permissions.greenThumbPlant(player, Material.NETHER_WARTS) || Permissions.greenThumbPlant(player, Material.COCOA);
canGreenThumbBlocks = Permissions.greenThumbBlock(player, Material.DIRT) || Permissions.greenThumbBlock(player, Material.COBBLESTONE) || Permissions.greenThumbBlock(player, Material.COBBLE_WALL) || Permissions.greenThumbBlock(player, Material.SMOOTH_BRICK); canGreenThumbBlocks = Permissions.greenThumbBlock(player, Material.DIRT) || Permissions.greenThumbBlock(player, Material.COBBLESTONE) || Permissions.greenThumbBlock(player, Material.COBBLE_WALL) || Permissions.greenThumbBlock(player, Material.SMOOTH_BRICK);
canFarmersDiet = Permissions.farmersDiet(player); canFarmersDiet = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FARMERS_DIET);
canDoubleDrop = Permissions.doubleDrops(player, skill) && !skill.getDoubleDropsDisabled(); canDoubleDrop = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HERBALISM_DOUBLE_DROPS) && !skill.getDoubleDropsDisabled();
canShroomThumb = Permissions.shroomThumb(player); canShroomThumb = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SHROOM_THUMB);
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canGreenTerra || canDoubleDrop || canFarmersDiet || canGreenThumbBlocks || canGreenThumbPlants || canShroomThumb; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canGreenTerra) { if (canGreenTerra) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1")));
} }
if (canGreenThumbPlants) { if (canGreenThumbPlants) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3")));
} }
if (canGreenThumbBlocks) { if (canGreenThumbBlocks) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.4"), LocaleLoader.getString("Herbalism.Effect.5"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.4"), LocaleLoader.getString("Herbalism.Effect.5")));
} }
if (canFarmersDiet) { if (canFarmersDiet) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.6"), LocaleLoader.getString("Herbalism.Effect.7"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.6"), LocaleLoader.getString("Herbalism.Effect.7")));
} }
if (hasHylianLuck) { if (hasHylianLuck) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.10"), LocaleLoader.getString("Herbalism.Effect.11"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.10"), LocaleLoader.getString("Herbalism.Effect.11")));
} }
if (canShroomThumb) { if (canShroomThumb) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.12"), LocaleLoader.getString("Herbalism.Effect.13"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.12"), LocaleLoader.getString("Herbalism.Effect.13")));
} }
if (canDoubleDrop) { if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canGreenTerra || canDoubleDrop || canFarmersDiet || canGreenThumbBlocks || canGreenThumbPlants || canShroomThumb; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canGreenTerra) { if (canGreenTerra) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", greenTerraLengthEndurance) : "")); messages.add(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", greenTerraLengthEndurance) : ""));
} }
if (canGreenThumbBlocks || canGreenThumbPlants) { if (canGreenThumbBlocks || canGreenThumbPlants) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", greenThumbChanceLucky) : "")); messages.add(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", greenThumbChanceLucky) : ""));
} }
if (canGreenThumbPlants) { if (canGreenThumbPlants) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", greenThumbStage)); messages.add(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", greenThumbStage));
} }
if (canFarmersDiet) { if (canFarmersDiet) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.FD", farmersDietRank)); messages.add(LocaleLoader.getString("Herbalism.Ability.FD", farmersDietRank));
} }
if (hasHylianLuck) { if (hasHylianLuck) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", hylianLuckChanceLucky) : "")); messages.add(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", hylianLuckChanceLucky) : ""));
} }
if (canShroomThumb) { if (canShroomThumb) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", shroomThumbChanceLucky) : "")); messages.add(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shroomThumbChanceLucky) : ""));
} }
if (canDoubleDrop) { if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : "")); messages.add(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
} }
return messages;
} }
} }

View File

@@ -1,11 +1,18 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.mining.Mining; import com.gmail.nossr50.skills.mining.BlastMining.Tier;
import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
public class MiningCommand extends SkillCommand { public class MiningCommand extends SkillCommand {
private String doubleDropChance; private String doubleDropChance;
@@ -31,24 +38,24 @@ public class MiningCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// SUPER BREAKER // SUPER BREAKER
if (canSuperBreaker) { if (canSuperBreaker) {
String[] superBreakerStrings = calculateLengthDisplayValues(); String[] superBreakerStrings = calculateLengthDisplayValues(player, skillValue);
superBreakerLength = superBreakerStrings[0]; superBreakerLength = superBreakerStrings[0];
superBreakerLengthEndurance = superBreakerStrings[1]; superBreakerLengthEndurance = superBreakerStrings[1];
} }
// DOUBLE DROPS // DOUBLE DROPS
if (canDoubleDrop) { if (canDoubleDrop) {
String[] doubleDropStrings = calculateAbilityDisplayValues(Mining.doubleDropsMaxLevel, Mining.doubleDropsMaxChance); String[] doubleDropStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.MINING_DOUBLE_DROPS, isLucky);
doubleDropChance = doubleDropStrings[0]; doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1]; doubleDropChanceLucky = doubleDropStrings[1];
} }
// BLAST MINING // BLAST MINING
if (canBlast || canDemoExpert || canBiggerBombs) { if (canBlast || canDemoExpert || canBiggerBombs) {
MiningManager miningManager = mcMMOPlayer.getMiningManager(); MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
blastMiningRank = miningManager.getBlastMiningTier(); blastMiningRank = miningManager.getBlastMiningTier();
bonusTNTDrops = miningManager.getDropMultiplier(); bonusTNTDrops = miningManager.getDropMultiplier();
@@ -60,90 +67,86 @@ public class MiningCommand extends SkillCommand {
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canBiggerBombs = Permissions.biggerBombs(player); canBiggerBombs = Permissions.biggerBombs(player);
canBlast = Permissions.remoteDetonation(player); canBlast = Permissions.remoteDetonation(player);
canDemoExpert = Permissions.demolitionsExpertise(player); canDemoExpert = Permissions.demolitionsExpertise(player);
canDoubleDrop = Permissions.doubleDrops(player, skill) && !skill.getDoubleDropsDisabled(); canDoubleDrop = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.MINING_DOUBLE_DROPS) && !skill.getDoubleDropsDisabled();
canSuperBreaker = Permissions.superBreaker(player); canSuperBreaker = Permissions.superBreaker(player);
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canBiggerBombs || canBlast || canDemoExpert || canDoubleDrop || canSuperBreaker; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canSuperBreaker) { if (canSuperBreaker) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.0"), LocaleLoader.getString("Mining.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.0"), LocaleLoader.getString("Mining.Effect.1")));
} }
if (canDoubleDrop) { if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.2"), LocaleLoader.getString("Mining.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.2"), LocaleLoader.getString("Mining.Effect.3")));
} }
if (canBlast) { if (canBlast) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.4"), LocaleLoader.getString("Mining.Effect.5"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.4"), LocaleLoader.getString("Mining.Effect.5")));
} }
if (canBiggerBombs) { if (canBiggerBombs) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.6"), LocaleLoader.getString("Mining.Effect.7"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.6"), LocaleLoader.getString("Mining.Effect.7")));
} }
if (canDemoExpert) { if (canDemoExpert) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.8"), LocaleLoader.getString("Mining.Effect.9"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.8"), LocaleLoader.getString("Mining.Effect.9")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canBiggerBombs || canBlast || canDemoExpert || canDoubleDrop || canSuperBreaker; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canDoubleDrop) { if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : "")); messages.add(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
} }
if (canSuperBreaker) { if (canSuperBreaker) {
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", superBreakerLengthEndurance) : "")); messages.add(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", superBreakerLengthEndurance) : ""));
} }
if (canBlast) { if (canBlast) {
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank1(); int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.ONE);
if (skillValue < unlockLevel) { if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", unlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", unlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops))); messages.add(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, Tier.EIGHT.toNumerical(), LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
} }
} }
if (canBiggerBombs) { if (canBiggerBombs) {
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank2(); int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.TWO);
if (skillValue < unlockLevel) { if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", unlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", unlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Mining.Blast.Radius.Increase", blastRadiusIncrease)); messages.add(LocaleLoader.getString("Mining.Blast.Radius.Increase", blastRadiusIncrease));
} }
} }
if (canDemoExpert) { if (canDemoExpert) {
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank4(); int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.FOUR);
if (skillValue < unlockLevel) { if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", unlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", unlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Mining.Effect.Decrease", blastDamageDecrease)); messages.add(LocaleLoader.getString("Mining.Effect.Decrease", blastDamageDecrease));
} }
} }
return messages;
} }
} }

View File

@@ -1,15 +1,22 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.repair.ArcaneForging; import com.gmail.nossr50.skills.repair.ArcaneForging;
import com.gmail.nossr50.skills.repair.ArcaneForging.Tier;
import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.RepairManager; import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.repair.Repairable; import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
public class RepairCommand extends SkillCommand { public class RepairCommand extends SkillCommand {
private String repairMasteryBonus; private String repairMasteryBonus;
@@ -39,12 +46,12 @@ public class RepairCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// We're using pickaxes here, not the best but it works // We're using pickaxes here, not the best but it works
Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE.getId()); Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE);
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLD_PICKAXE.getId()); Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLD_PICKAXE);
Repairable ironRepairable = mcMMO.getRepairableManager().getRepairable(Material.IRON_PICKAXE.getId()); Repairable ironRepairable = mcMMO.getRepairableManager().getRepairable(Material.IRON_PICKAXE);
Repairable stoneRepairable = mcMMO.getRepairableManager().getRepairable(Material.STONE_PICKAXE.getId()); Repairable stoneRepairable = mcMMO.getRepairableManager().getRepairable(Material.STONE_PICKAXE);
// TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0 // TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel(); diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
@@ -59,18 +66,18 @@ public class RepairCommand extends SkillCommand {
// SUPER REPAIR // SUPER REPAIR
if (canSuperRepair) { if (canSuperRepair) {
String[] superRepairStrings = calculateAbilityDisplayValues(Repair.superRepairMaxBonusLevel, Repair.superRepairMaxChance); String[] superRepairStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.SUPER_REPAIR, isLucky);
superRepairChance = superRepairStrings[0]; superRepairChance = superRepairStrings[0];
superRepairChanceLucky = superRepairStrings[1]; superRepairChanceLucky = superRepairStrings[1];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canSuperRepair = Permissions.superRepair(player); canSuperRepair = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SUPER_REPAIR);
canMasterRepair = Permissions.repairMastery(player); canMasterRepair = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.REPAIR_MASTERY);
canArcaneForge = Permissions.arcaneForging(player); canArcaneForge = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.ARCANE_FORGING);
canSalvage = Permissions.salvage(player); canSalvage = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SALVAGE);
canRepairDiamond = Permissions.repairDiamond(player); canRepairDiamond = Permissions.repairDiamond(player);
canRepairGold = Permissions.repairGold(player); canRepairGold = Permissions.repairGold(player);
canRepairIron = Permissions.repairIron(player); canRepairIron = Permissions.repairIron(player);
@@ -82,78 +89,76 @@ public class RepairCommand extends SkillCommand {
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canArcaneForge || canSalvage || canRepairDiamond || canRepairGold || canRepairIron || canMasterRepair || canRepairStone || canSuperRepair || canRepairString || canRepairWood || canRepairLeather; List<String> messages = new ArrayList<String>();
if (canRepairLeather || canRepairString || canRepairWood || canRepairStone || canRepairIron || canRepairGold || canRepairDiamond) {
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1")));
} }
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1")));
if (canMasterRepair) { if (canMasterRepair) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3")));
} }
if (canSuperRepair) { if (canSuperRepair) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5")));
} }
/* Repair Level Requirements */ /* Repair Level Requirements */
if (canRepairStone && stoneLevel > 0) { if (canRepairStone && stoneLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.14", stoneLevel), LocaleLoader.getString("Repair.Effect.15"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.14", stoneLevel), LocaleLoader.getString("Repair.Effect.15")));
} }
if (canRepairIron && ironLevel > 0) { if (canRepairIron && ironLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.12", ironLevel), LocaleLoader.getString("Repair.Effect.13"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.12", ironLevel), LocaleLoader.getString("Repair.Effect.13")));
} }
if (canRepairGold && goldLevel > 0) { if (canRepairGold && goldLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.10", goldLevel), LocaleLoader.getString("Repair.Effect.11"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.10", goldLevel), LocaleLoader.getString("Repair.Effect.11")));
} }
if (canRepairDiamond && diamondLevel > 0) { if (canRepairDiamond && diamondLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.6", diamondLevel), LocaleLoader.getString("Repair.Effect.7"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.6", diamondLevel), LocaleLoader.getString("Repair.Effect.7")));
} }
if (canSalvage && Repair.salvageUnlockLevel > 0) { if (canSalvage && Repair.salvageUnlockLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.16", Repair.salvageUnlockLevel), LocaleLoader.getString("Repair.Effect.17"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.16", Repair.salvageUnlockLevel), LocaleLoader.getString("Repair.Effect.17")));
} }
if (canArcaneForge) { if (canArcaneForge) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canArcaneForge || canMasterRepair || canSuperRepair; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canMasterRepair) { if (canMasterRepair) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", repairMasteryBonus)); messages.add(LocaleLoader.getString("Repair.Skills.Mastery", repairMasteryBonus));
} }
if (canSuperRepair) { if (canSuperRepair) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", superRepairChanceLucky) : "")); messages.add(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", superRepairChanceLucky) : ""));
} }
if (canArcaneForge) { if (canArcaneForge) {
RepairManager repairManager = mcMMOPlayer.getRepairManager(); RepairManager repairManager = UserManager.getPlayer(player).getRepairManager();
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank())); messages.add(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank(), Tier.EIGHT.toNumerical()));
if (ArcaneForging.arcaneForgingEnchantLoss) { if (ArcaneForging.arcaneForgingEnchantLoss) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : repairManager.getKeepEnchantChance()))); messages.add(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : repairManager.getKeepEnchantChance())));
} }
if (ArcaneForging.arcaneForgingDowngrades) { if (ArcaneForging.arcaneForgingDowngrades) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : repairManager.getDowngradeEnchantChance()))); messages.add(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : repairManager.getDowngradeEnchantChance())));
} }
} }
return messages;
} }
} }

View File

@@ -13,7 +13,7 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.child.FamilyTree; import com.gmail.nossr50.skills.child.FamilyTree;
@@ -23,21 +23,12 @@ import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public abstract class SkillCommand implements TabExecutor { public abstract class SkillCommand implements TabExecutor {
protected SkillType skill; protected SkillType skill;
protected String skillName; private String skillName;
protected Player player;
protected PlayerProfile profile;
protected McMMOPlayer mcMMOPlayer;
protected float skillValue;
protected boolean isLucky;
protected boolean hasEndurance;
protected DecimalFormat percent = new DecimalFormat("##0.00%"); protected DecimalFormat percent = new DecimalFormat("##0.00%");
protected DecimalFormat decimal = new DecimalFormat("##0.00"); protected DecimalFormat decimal = new DecimalFormat("##0.00");
@@ -46,7 +37,7 @@ public abstract class SkillCommand implements TabExecutor {
public SkillCommand(SkillType skill) { public SkillCommand(SkillType skill) {
this.skill = skill; this.skill = skill;
skillName = SkillUtils.getSkillName(skill); skillName = skill.getName();
skillGuideCommand = new SkillGuideCommand(skill); skillGuideCommand = new SkillGuideCommand(skill);
} }
@@ -56,31 +47,26 @@ public abstract class SkillCommand implements TabExecutor {
return true; return true;
} }
player = (Player) sender;
mcMMOPlayer = UserManager.getPlayer(player);
switch (args.length) { switch (args.length) {
case 0: case 0:
profile = mcMMOPlayer.getProfile(); Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
skillValue = profile.getSkillLevel(skill); boolean isLucky = Permissions.lucky(player, skill);
isLucky = Permissions.lucky(sender, skill); boolean hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0);
hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0); float skillValue = mcMMOPlayer.getSkillLevel(skill);
permissionsCheck(); permissionsCheck(player);
dataCalculations(); dataCalculations(player, skillValue, isLucky);
if (Config.getInstance().getSkillUseBoard()) {
ScoreboardManager.enablePlayerSkillScoreboard(player, skill);
}
if (!skill.isChildSkill()) { if (!skill.isChildSkill()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName)); player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString())))); player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, mcMMOPlayer.getSkillXpLevel(skill), mcMMOPlayer.getXpToLevel(skill)));
if (Config.getInstance().getSkillScoreboardEnabled()) {
ScoreboardManager.setupPlayerScoreboard(player.getName());
ScoreboardManager.enablePlayerSkillScoreboard(mcMMOPlayer, skill);
}
else {
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, profile.getSkillXpLevel(skill), profile.getXpToLevel(skill)));
}
} }
else { else {
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child"))); player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child")));
@@ -91,21 +77,34 @@ public abstract class SkillCommand implements TabExecutor {
Set<SkillType> parents = FamilyTree.getParents(skill); Set<SkillType> parents = FamilyTree.getParents(skill);
for (SkillType parent : parents) { for (SkillType parent : parents) {
player.sendMessage(SkillUtils.getSkillName(parent) + " - " + LocaleLoader.getString("Effects.Level", profile.getSkillLevel(parent), profile.getSkillXpLevel(parent), profile.getXpToLevel(parent))); player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent)));
} }
} }
if (effectsHeaderPermissions()) { List<String> effectMessages = effectsDisplay();
if (!effectMessages.isEmpty()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects"))); player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects")));
if (isLucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.Lucky.Name"), LocaleLoader.getString("Perks.Lucky.Desc", skillName)));
} }
effectsDisplay(); for (String message : effectMessages) {
player.sendMessage(message);
}
}
if (statsHeaderPermissions()) { List<String> statsMessages = statsDisplay(player, skillValue, hasEndurance, isLucky);
if (!statsMessages.isEmpty()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Commands.Stats.Self"))); player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Commands.Stats.Self")));
}
statsDisplay(); for (String message : statsMessages) {
player.sendMessage(message);
}
}
player.sendMessage(LocaleLoader.getString("Guides.Available", skillName, skillName.toLowerCase())); player.sendMessage(LocaleLoader.getString("Guides.Available", skillName, skillName.toLowerCase()));
return true; return true;
@@ -125,11 +124,11 @@ public abstract class SkillCommand implements TabExecutor {
} }
} }
protected int calculateRank(int maxLevel, int rankChangeLevel) { protected int calculateRank(float skillValue, int maxLevel, int rankChangeLevel) {
return Math.min((int) skillValue, maxLevel) / rankChangeLevel; return Math.min((int) skillValue, maxLevel) / rankChangeLevel;
} }
protected String[] calculateAbilityDisplayValues(double chance) { protected String[] calculateAbilityDisplayValues(double chance, boolean isLucky) {
String[] displayValues = new String[2]; String[] displayValues = new String[2];
displayValues[0] = percent.format(Math.min(chance, 100.0D) / 100.0D); displayValues[0] = percent.format(Math.min(chance, 100.0D) / 100.0D);
@@ -138,12 +137,14 @@ public abstract class SkillCommand implements TabExecutor {
return displayValues; return displayValues;
} }
protected String[] calculateAbilityDisplayValues(int maxBonusLevel, double maxChance) { protected String[] calculateAbilityDisplayValues(float skillValue, SecondaryAbility skillAbility, boolean isLucky) {
return calculateAbilityDisplayValues((maxChance / maxBonusLevel) * Math.min(skillValue, maxBonusLevel)); int maxBonusLevel = AdvancedConfig.getInstance().getMaxBonusLevel(skillAbility);
return calculateAbilityDisplayValues((AdvancedConfig.getInstance().getMaxChance(skillAbility) / maxBonusLevel) * Math.min(skillValue, maxBonusLevel), isLucky);
} }
protected String[] calculateLengthDisplayValues() { protected String[] calculateLengthDisplayValues(Player player, float skillValue) {
int maxLength = skill.getAbility().getMaxTicks(); int maxLength = skill.getAbility().getMaxLength();
int length = 2 + (int) (skillValue / AdvancedConfig.getInstance().getAbilityLength()); int length = 2 + (int) (skillValue / AdvancedConfig.getInstance().getAbilityLength());
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength); int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
@@ -154,22 +155,11 @@ public abstract class SkillCommand implements TabExecutor {
return new String[] { String.valueOf(length), String.valueOf(enduranceLength) }; return new String[] { String.valueOf(length), String.valueOf(enduranceLength) };
} }
protected void luckyEffectsDisplay() { protected abstract void dataCalculations(Player player, float skillValue, boolean isLucky);
if (isLucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix"); protected abstract void permissionsCheck(Player player);
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", skillName)));
} protected abstract List<String> effectsDisplay();
}
protected abstract List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky);
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,7 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@@ -9,19 +10,16 @@ import org.bukkit.command.CommandSender;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
public class SkillGuideCommand implements CommandExecutor { public class SkillGuideCommand implements CommandExecutor {
private String header; private String header;
private String[] guide; private ArrayList<String> guide;
private String invalidPage; private String invalidPage = LocaleLoader.getString("Guides.Page.Invalid");
public SkillGuideCommand(SkillType skillType) { public SkillGuideCommand(SkillType skill) {
header = LocaleLoader.getString("Guides.Header", SkillUtils.getSkillName(skillType)); header = LocaleLoader.getString("Guides.Header", skill.getName());
guide = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skillType.toString())).split("\n"); guide = getGuide(skill);
invalidPage = LocaleLoader.getString("Guides.Page.Invalid");
} }
@Override @Override
@@ -59,7 +57,7 @@ public class SkillGuideCommand implements CommandExecutor {
} }
private int getTotalPageNumber() { private int getTotalPageNumber() {
return (int) Math.ceil(guide.length / 8.0); return (int) Math.ceil(guide.size() / 8.0);
} }
private void sendGuide(CommandSender sender, int pageNumber) { private void sendGuide(CommandSender sender, int pageNumber) {
@@ -68,23 +66,46 @@ public class SkillGuideCommand implements CommandExecutor {
} }
} }
private ArrayList<String> grabPageContents(int pagenum) { private ArrayList<String> grabPageContents(int page) {
int pageIndexStart = 8 * (pagenum - 1); // Determine what string to start at int pageIndexStart = 8 * (page - 1); // Determine what string to start at
ArrayList<String> allStrings = new ArrayList<String>(); ArrayList<String> allStrings = new ArrayList<String>();
allStrings.add(header); allStrings.add(header);
// Add targeted strings // Add targeted strings
while (allStrings.size() < 9) { while (allStrings.size() < 9) {
if (pageIndexStart + allStrings.size() > guide.length) { if (pageIndexStart + allStrings.size() > guide.size()) {
allStrings.add(""); allStrings.add("");
} }
else { else {
allStrings.add(guide[pageIndexStart + (allStrings.size() - 1)]); allStrings.add(guide.get(pageIndexStart + (allStrings.size() - 1)));
} }
} }
allStrings.add("Page " + pagenum + " of " + getTotalPageNumber()); allStrings.add("Page " + page + " of " + getTotalPageNumber());
return allStrings; return allStrings;
} }
private ArrayList<String> getGuide(SkillType skill) {
ArrayList<String> guide = new ArrayList<String>();
for (int i = 0; i < 10; i++) {
String[] section = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skill.toString()) + ".Section." + i).split("\n");
if (section[0].startsWith("!")) {
break;
}
guide.addAll(Arrays.asList(section));
if (section.length < 8) {
for (int blankLine = 8 - section.length; blankLine > 0; blankLine--) {
guide.add("");
}
}
}
return guide;
}
} }

View File

@@ -1,10 +1,18 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.smelting.Smelting; import com.gmail.nossr50.skills.smelting.Smelting;
import com.gmail.nossr50.skills.smelting.Smelting.Tier;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
public class SmeltingCommand extends SkillCommand { public class SmeltingCommand extends SkillCommand {
private String burnTimeModifier; private String burnTimeModifier;
@@ -23,7 +31,7 @@ public class SmeltingCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// FUEL EFFICIENCY // FUEL EFFICIENCY
if (canFuelEfficiency) { if (canFuelEfficiency) {
burnTimeModifier = decimal.format(1 + ((skillValue / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier)); burnTimeModifier = decimal.format(1 + ((skillValue / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier));
@@ -31,86 +39,82 @@ public class SmeltingCommand extends SkillCommand {
// SECOND SMELT // SECOND SMELT
if (canSecondSmelt) { if (canSecondSmelt) {
String[] secondSmeltStrings = calculateAbilityDisplayValues(Smelting.secondSmeltMaxLevel, Smelting.secondSmeltMaxChance); String[] secondSmeltStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.SECOND_SMELT, isLucky);
secondSmeltChance = secondSmeltStrings[0]; secondSmeltChance = secondSmeltStrings[0];
secondSmeltChanceLucky = secondSmeltStrings[1]; secondSmeltChanceLucky = secondSmeltStrings[1];
} }
// FLUX MINING // FLUX MINING
if (canFluxMine) { if (canFluxMine) {
String[] fluxMiningStrings = calculateAbilityDisplayValues(Smelting.fluxMiningChance); String[] fluxMiningStrings = calculateAbilityDisplayValues(Smelting.fluxMiningChance, isLucky);
fluxMiningChance = fluxMiningStrings[0]; fluxMiningChance = fluxMiningStrings[0];
fluxMiningChanceLucky = fluxMiningStrings[1]; fluxMiningChanceLucky = fluxMiningStrings[1];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canFuelEfficiency = Permissions.fuelEfficiency(player); canFuelEfficiency = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FUEL_EFFICIENCY);
canSecondSmelt = Permissions.doubleDrops(player, skill); canSecondSmelt = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SECOND_SMELT);
canFluxMine = Permissions.fluxMining(player); canFluxMine = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FLUX_MINING);
canVanillaXPBoost = Permissions.vanillaXpBoost(player, skill); canVanillaXPBoost = Permissions.vanillaXpBoost(player, skill);
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canFluxMine || canFuelEfficiency || canSecondSmelt || canVanillaXPBoost; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canFuelEfficiency) { if (canFuelEfficiency) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.0"), LocaleLoader.getString("Smelting.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.0"), LocaleLoader.getString("Smelting.Effect.1")));
} }
if (canSecondSmelt) { if (canSecondSmelt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.2"), LocaleLoader.getString("Smelting.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.2"), LocaleLoader.getString("Smelting.Effect.3")));
} }
if (canVanillaXPBoost) { if (canVanillaXPBoost) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.4"), LocaleLoader.getString("Smelting.Effect.5"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.4"), LocaleLoader.getString("Smelting.Effect.5")));
} }
if (canFluxMine) { if (canFluxMine) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.6"), LocaleLoader.getString("Smelting.Effect.7"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.6"), LocaleLoader.getString("Smelting.Effect.7")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canFluxMine || canFuelEfficiency || canSecondSmelt || canVanillaXPBoost; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canFuelEfficiency) { if (canFuelEfficiency) {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FuelEfficiency", burnTimeModifier)); messages.add(LocaleLoader.getString("Smelting.Ability.FuelEfficiency", burnTimeModifier));
} }
if (canSecondSmelt) { if (canSecondSmelt) {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", secondSmeltChanceLucky) : "")); messages.add(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", secondSmeltChanceLucky) : ""));
} }
if (canVanillaXPBoost) { if (canVanillaXPBoost) {
int unlockLevel = AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level(); int unlockLevel = AdvancedConfig.getInstance().getSmeltingRankLevel(Tier.ONE);
if (skillValue < unlockLevel) { if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", unlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", unlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.VanillaXPBoost", mcMMOPlayer.getSmeltingManager().getVanillaXpMultiplier())); messages.add(LocaleLoader.getString("Smelting.Ability.VanillaXPBoost", UserManager.getPlayer(player).getSmeltingManager().getVanillaXpMultiplier()));
} }
} }
if (canFluxMine) { if (canFluxMine) {
if (skillValue < Smelting.fluxMiningUnlockLevel) { if (skillValue < Smelting.fluxMiningUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.1", Smelting.fluxMiningUnlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.1", Smelting.fluxMiningUnlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", fluxMiningChanceLucky) : "")); messages.add(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", fluxMiningChanceLucky) : ""));
} }
} }
return messages;
} }
} }

View File

@@ -1,13 +1,20 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.swords.Swords; import com.gmail.nossr50.skills.swords.Swords;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
public class SwordsCommand extends SkillCommand { public class SwordsCommand extends SkillCommand {
private String counterAttackChance; private String counterChance;
private String counterAttackChanceLucky; private String counterChanceLucky;
private int bleedLength; private int bleedLength;
private String bleedChance; private String bleedChance;
private String bleedChanceLucky; private String bleedChanceLucky;
@@ -23,80 +30,76 @@ public class SwordsCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// SERRATED STRIKES // SERRATED STRIKES
if (canSerratedStrike) { if (canSerratedStrike) {
String[] serratedStrikesStrings = calculateLengthDisplayValues(); String[] serratedStrikesStrings = calculateLengthDisplayValues(player, skillValue);
serratedStrikesLength = serratedStrikesStrings[0]; serratedStrikesLength = serratedStrikesStrings[0];
serratedStrikesLengthEndurance = serratedStrikesStrings[1]; serratedStrikesLengthEndurance = serratedStrikesStrings[1];
} }
// BLEED // BLEED
if (canBleed) { if (canBleed) {
bleedLength = (skillValue >= Swords.bleedMaxBonusLevel) ? Swords.bleedMaxTicks : Swords.bleedBaseTicks; bleedLength = (skillValue >= AdvancedConfig.getInstance().getMaxBonusLevel(SecondaryAbility.BLEED)) ? Swords.bleedMaxTicks : Swords.bleedBaseTicks;
String[] bleedStrings = calculateAbilityDisplayValues(Swords.bleedMaxBonusLevel, Swords.bleedMaxChance); String[] bleedStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.BLEED, isLucky);
bleedChance = bleedStrings[0]; bleedChance = bleedStrings[0];
bleedChanceLucky = bleedStrings[1]; bleedChanceLucky = bleedStrings[1];
} }
// COUNTER ATTACK // COUNTER
if (canCounter) { if (canCounter) {
String[] counterAttackStrings = calculateAbilityDisplayValues(Swords.counterAttackMaxBonusLevel, Swords.counterAttackMaxChance); String[] counterStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.COUNTER, isLucky);
counterAttackChance = counterAttackStrings[0]; counterChance = counterStrings[0];
counterAttackChanceLucky = counterAttackStrings[1]; counterChanceLucky = counterStrings[1];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canBleed = Permissions.bleed(player); canBleed = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.BLEED);
canCounter = Permissions.counterAttack(player); canCounter = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.COUNTER);
canSerratedStrike = Permissions.serratedStrikes(player); canSerratedStrike = Permissions.serratedStrikes(player);
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canBleed || canCounter || canSerratedStrike; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canCounter) { if (canCounter) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.0"), LocaleLoader.getString("Swords.Effect.1", percent.format(1.0D / Swords.counterAttackModifier)))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.0"), LocaleLoader.getString("Swords.Effect.1", percent.format(1.0D / Swords.counterAttackModifier))));
} }
if (canSerratedStrike) { if (canSerratedStrike) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.2"), LocaleLoader.getString("Swords.Effect.3", percent.format(1.0D / Swords.serratedStrikesModifier)))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.2"), LocaleLoader.getString("Swords.Effect.3", percent.format(1.0D / Swords.serratedStrikesModifier))));
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.4"), LocaleLoader.getString("Swords.Effect.5", Swords.serratedStrikesBleedTicks))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.4"), LocaleLoader.getString("Swords.Effect.5", Swords.serratedStrikesBleedTicks)));
} }
if (canBleed) { if (canBleed) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.6"), LocaleLoader.getString("Swords.Effect.7"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.6"), LocaleLoader.getString("Swords.Effect.7")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canBleed || canCounter || canSerratedStrike; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canCounter) { if (canCounter) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", counterAttackChanceLucky) : "")); messages.add(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", counterChanceLucky) : ""));
} }
if (canBleed) { if (canBleed) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", bleedLength)); messages.add(LocaleLoader.getString("Swords.Combat.Bleed.Length", bleedLength));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note")); messages.add(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", bleedChanceLucky) : "")); messages.add(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", bleedChanceLucky) : ""));
} }
if (canSerratedStrike) { if (canSerratedStrike) {
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", serratedStrikesLengthEndurance) : "")); messages.add(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", serratedStrikesLengthEndurance) : ""));
} }
return messages;
} }
} }

View File

@@ -1,6 +1,13 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.taming.Taming; import com.gmail.nossr50.skills.taming.Taming;
@@ -25,138 +32,135 @@ public class TamingCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
if (canGore) { if (canGore) {
String[] goreStrings = calculateAbilityDisplayValues(Taming.goreMaxBonusLevel, Taming.goreMaxChance); String[] goreStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.GORE, isLucky);
goreChance = goreStrings[0]; goreChance = goreStrings[0];
goreChanceLucky = goreStrings[1]; goreChanceLucky = goreStrings[1];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canBeastLore = Permissions.beastLore(player); canBeastLore = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.BEAST_LORE);
canCallWild = Permissions.callOfTheWild(player); canCallWild = Permissions.callOfTheWild(player, EntityType.HORSE) || Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT);
canEnvironmentallyAware = Permissions.environmentallyAware(player); canEnvironmentallyAware = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.ENVIROMENTALLY_AWARE);
canFastFood = Permissions.fastFoodService(player); canFastFood = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FAST_FOOD);
canGore = Permissions.gore(player); canGore = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.GORE);
canSharpenedClaws = Permissions.sharpenedClaws(player); canSharpenedClaws = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SHARPENED_CLAWS);
canShockProof = Permissions.shockProof(player); canShockProof = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SHOCK_PROOF);
canThickFur = Permissions.thickFur(player); canThickFur = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.THICK_FUR);
canHolyHound = Permissions.holyHound(player); canHolyHound = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HOLY_HOUND);
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canBeastLore || canCallWild || canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur || canHolyHound; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canBeastLore) { if (canBeastLore) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1")));
} }
if (canGore) { if (canGore) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.2"), LocaleLoader.getString("Taming.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.2"), LocaleLoader.getString("Taming.Effect.3")));
} }
if (canSharpenedClaws) { if (canSharpenedClaws) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.4"), LocaleLoader.getString("Taming.Effect.5"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.4"), LocaleLoader.getString("Taming.Effect.5")));
} }
if (canEnvironmentallyAware) { if (canEnvironmentallyAware) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.6"), LocaleLoader.getString("Taming.Effect.7"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.6"), LocaleLoader.getString("Taming.Effect.7")));
} }
if (canThickFur) { if (canThickFur) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.8"), LocaleLoader.getString("Taming.Effect.9"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.8"), LocaleLoader.getString("Taming.Effect.9")));
} }
if (canShockProof) { if (canShockProof) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.10"), LocaleLoader.getString("Taming.Effect.11"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.10"), LocaleLoader.getString("Taming.Effect.11")));
} }
if (canFastFood) { if (canFastFood) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17")));
} }
if (canHolyHound) { if (canHolyHound) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.18"), LocaleLoader.getString("Taming.Effect.19"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.18"), LocaleLoader.getString("Taming.Effect.19")));
} }
if (canCallWild) { if (canCallWild) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13")));
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWOcelotCost())); messages.add(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWOcelotCost()));
player.sendMessage(LocaleLoader.getString("Taming.Effect.15", Config.getInstance().getTamingCOTWWolfCost())); messages.add(LocaleLoader.getString("Taming.Effect.15", Config.getInstance().getTamingCOTWWolfCost()));
messages.add(LocaleLoader.getString("Taming.Effect.20", Config.getInstance().getTamingCOTWHorseCost()));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur || canHolyHound; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canFastFood) { if (canFastFood) {
if (skillValue < Taming.fastFoodServiceUnlockLevel) { if (skillValue < Taming.fastFoodServiceUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.4", Taming.fastFoodServiceUnlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.4", Taming.fastFoodServiceUnlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9", percent.format(Taming.fastFoodServiceActivationChance / 100D)))); messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9", percent.format(Taming.fastFoodServiceActivationChance / 100D))));
} }
} }
if (canEnvironmentallyAware) { if (canEnvironmentallyAware) {
if (skillValue < Taming.environmentallyAwareUnlockLevel) { if (skillValue < Taming.environmentallyAwareUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.0", Taming.environmentallyAwareUnlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.0", Taming.environmentallyAwareUnlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1"))); messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1")));
} }
} }
if (canThickFur) { if (canThickFur) {
if (skillValue < Taming.thickFurUnlockLevel) { if (skillValue < Taming.thickFurUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.1", Taming.thickFurUnlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.1", Taming.thickFurUnlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3", Taming.thickFurModifier))); messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3", Taming.thickFurModifier)));
} }
} }
if (canHolyHound) { if (canHolyHound) {
if (skillValue < Taming.holyHoundUnlockLevel) { if (skillValue < Taming.holyHoundUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.5", Taming.holyHoundUnlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.5", Taming.holyHoundUnlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.10"), LocaleLoader.getString("Taming.Ability.Bonus.11"))); messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.10"), LocaleLoader.getString("Taming.Ability.Bonus.11")));
} }
} }
if (canShockProof) { if (canShockProof) {
if (skillValue < Taming.shockProofUnlockLevel) { if (skillValue < Taming.shockProofUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.2", Taming.shockProofUnlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.2", Taming.shockProofUnlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5", Taming.shockProofModifier))); messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5", Taming.shockProofModifier)));
} }
} }
if (canSharpenedClaws) { if (canSharpenedClaws) {
if (skillValue < Taming.sharpenedClawsUnlockLevel) { if (skillValue < Taming.sharpenedClawsUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.3", Taming.sharpenedClawsUnlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.3", Taming.sharpenedClawsUnlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7", Taming.sharpenedClawsBonusDamage))); messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7", Taming.sharpenedClawsBonusDamage)));
} }
} }
if (canGore) { if (canGore) {
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", goreChanceLucky) : "")); messages.add(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", goreChanceLucky) : ""));
} }
return messages;
} }
} }

View File

@@ -1,5 +1,11 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.unarmed.Unarmed; import com.gmail.nossr50.skills.unarmed.Unarmed;
@@ -14,11 +20,11 @@ public class UnarmedCommand extends SkillCommand {
private String disarmChanceLucky; private String disarmChanceLucky;
private String ironGripChance; private String ironGripChance;
private String ironGripChanceLucky; private String ironGripChanceLucky;
private int ironArmBonus; private double ironArmBonus;
private boolean canBerserk; private boolean canBerserk;
private boolean canDisarm; private boolean canDisarm;
private boolean canBonusDamage; private boolean canIronArm;
private boolean canDeflect; private boolean canDeflect;
private boolean canIronGrip; private boolean canIronGrip;
@@ -27,105 +33,103 @@ public class UnarmedCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// BERSERK // BERSERK
if (canBerserk) { if (canBerserk) {
String[] berserkStrings = calculateLengthDisplayValues(); String[] berserkStrings = calculateLengthDisplayValues(player, skillValue);
berserkLength = berserkStrings[0]; berserkLength = berserkStrings[0];
berserkLengthEndurance = berserkStrings[1]; berserkLengthEndurance = berserkStrings[1];
} }
// DISARM // DISARM
if (canDisarm) { if (canDisarm) {
String[] disarmStrings = calculateAbilityDisplayValues(Unarmed.disarmMaxBonusLevel, Unarmed.disarmMaxChance); String[] disarmStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.DISARM, isLucky);
disarmChance = disarmStrings[0]; disarmChance = disarmStrings[0];
disarmChanceLucky = disarmStrings[1]; disarmChanceLucky = disarmStrings[1];
} }
// DEFLECT // DEFLECT
if (canDeflect) { if (canDeflect) {
String[] deflectStrings = calculateAbilityDisplayValues(Unarmed.deflectMaxBonusLevel, Unarmed.deflectMaxChance); String[] deflectStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.DEFLECT, isLucky);
deflectChance = deflectStrings[0]; deflectChance = deflectStrings[0];
deflectChanceLucky = deflectStrings[1]; deflectChanceLucky = deflectStrings[1];
} }
// IRON ARM // IRON ARM
if (canBonusDamage) { if (canIronArm) {
ironArmBonus = Math.min(3 + ((int) skillValue / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage); ironArmBonus = Math.min(3 + ((int) skillValue / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage);
} }
// IRON GRIP // IRON GRIP
if (canIronGrip) { if (canIronGrip) {
String[] ironGripStrings = calculateAbilityDisplayValues(Unarmed.ironGripMaxBonusLevel, Unarmed.ironGripMaxChance); String[] ironGripStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.IRON_GRIP, isLucky);
ironGripChance = ironGripStrings[0]; ironGripChance = ironGripStrings[0];
ironGripChanceLucky = ironGripStrings[1]; ironGripChanceLucky = ironGripStrings[1];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canBerserk = Permissions.berserk(player); canBerserk = Permissions.berserk(player);
canBonusDamage = Permissions.bonusDamage(player, skill); canIronArm = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.IRON_ARM);
canDeflect = Permissions.arrowDeflect(player); canDeflect = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.DEFLECT);
canDisarm = Permissions.disarm(player); canDisarm = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.DISARM);
canIronGrip = Permissions.ironGrip(player); canIronGrip = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.IRON_GRIP);
// TODO: Apparently we forgot about block cracker?
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canBerserk || canBonusDamage || canDeflect || canDisarm || canIronGrip; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canBerserk) { if (canBerserk) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1")));
} }
// TODO: Apparently we forgot about block cracker?
if (canDisarm) { if (canDisarm) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.2"), LocaleLoader.getString("Unarmed.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.2"), LocaleLoader.getString("Unarmed.Effect.3")));
} }
if (canBonusDamage) { if (canIronArm) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.4"), LocaleLoader.getString("Unarmed.Effect.5"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.4"), LocaleLoader.getString("Unarmed.Effect.5")));
} }
if (canDeflect) { if (canDeflect) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7")));
} }
if (canIronGrip) { if (canIronGrip) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.8"), LocaleLoader.getString("Unarmed.Effect.9"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.8"), LocaleLoader.getString("Unarmed.Effect.9")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canBerserk || canBonusDamage || canDeflect || canDisarm || canIronGrip; List<String> messages = new ArrayList<String>();
}
@Override if (canIronArm) {
protected void statsDisplay() { messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", ironArmBonus)));
if (canBonusDamage) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", ironArmBonus)));
} }
if (canDeflect) { if (canDeflect) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", deflectChanceLucky) : "")); messages.add(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", deflectChanceLucky) : ""));
} }
if (canDisarm) { if (canDisarm) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", disarmChanceLucky) : "")); messages.add(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", disarmChanceLucky) : ""));
} }
if (canIronGrip) { if (canIronGrip) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", ironGripChanceLucky) : "")); messages.add(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", ironGripChanceLucky) : ""));
} }
if (canBerserk) { if (canBerserk) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", berserkLengthEndurance) : "")); messages.add(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", berserkLengthEndurance) : ""));
} }
return messages;
} }
} }

View File

@@ -1,9 +1,14 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.woodcutting.Woodcutting;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
public class WoodcuttingCommand extends SkillCommand { public class WoodcuttingCommand extends SkillCommand {
@@ -21,75 +26,71 @@ public class WoodcuttingCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// TREE FELLER // TREE FELLER
if (canTreeFell) { if (canTreeFell) {
String[] treeFellerStrings = calculateLengthDisplayValues(); String[] treeFellerStrings = calculateLengthDisplayValues(player, skillValue);
treeFellerLength = treeFellerStrings[0]; treeFellerLength = treeFellerStrings[0];
treeFellerLengthEndurance = treeFellerStrings[1]; treeFellerLengthEndurance = treeFellerStrings[1];
} }
// DOUBLE DROPS // DOUBLE DROPS
if (canDoubleDrop) { if (canDoubleDrop) {
String[] doubleDropStrings = calculateAbilityDisplayValues(Woodcutting.doubleDropsMaxLevel, Woodcutting.doubleDropsMaxChance); String[] doubleDropStrings = calculateAbilityDisplayValues(skillValue, SecondaryAbility.WOODCUTTING_DOUBLE_DROPS, isLucky);
doubleDropChance = doubleDropStrings[0]; doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1]; doubleDropChanceLucky = doubleDropStrings[1];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canTreeFell = Permissions.treeFeller(player); canTreeFell = Permissions.treeFeller(player);
canDoubleDrop = Permissions.doubleDrops(player, skill) && !skill.getDoubleDropsDisabled(); canDoubleDrop = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.WOODCUTTING_DOUBLE_DROPS) && !skill.getDoubleDropsDisabled();
canLeafBlow = Permissions.leafBlower(player); canLeafBlow = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.LEAF_BLOWER);
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canDoubleDrop || canLeafBlow || canTreeFell; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canTreeFell) { if (canTreeFell) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1")));
} }
if (canLeafBlow) { if (canLeafBlow) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3")));
} }
if (canDoubleDrop) { if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canDoubleDrop || canLeafBlow || canTreeFell; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canLeafBlow) { if (canLeafBlow) {
int leafBlowerUnlockLevel = AdvancedConfig.getInstance().getLeafBlowUnlockLevel(); int leafBlowerUnlockLevel = AdvancedConfig.getInstance().getLeafBlowUnlockLevel();
if (skillValue < leafBlowerUnlockLevel) { if (skillValue < leafBlowerUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Woodcutting.Ability.Locked.0", leafBlowerUnlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Woodcutting.Ability.Locked.0", leafBlowerUnlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1"))); messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1")));
} }
} }
if (canDoubleDrop) { if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : "")); messages.add(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
} }
if (canTreeFell) { if (canTreeFell) {
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", treeFellerLengthEndurance) : "")); messages.add(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", treeFellerLengthEndurance) : ""));
} }
return messages;
} }
} }

View File

@@ -1,57 +0,0 @@
package com.gmail.nossr50.commands.spout;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.google.common.collect.ImmutableList;
public class MchudCommand extends SpoutCommand {
private static final List<String> HUD_TYPES;
static {
ArrayList<String> types = new ArrayList<String>();
for (HudType type : HudType.values()) {
types.add(type.toString());
}
Collections.sort(types);
HUD_TYPES = ImmutableList.copyOf(types);
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
return StringUtil.copyPartialMatches(args[0], HUD_TYPES, new ArrayList<String>(HUD_TYPES.size()));
default:
return ImmutableList.of();
}
}
@Override
protected boolean noArguments(Command command, CommandSender sender, String[] args) {
return false;
}
@Override
protected boolean oneArgument(Command command, CommandSender sender, String[] args) {
try {
playerProfile.setHudType(HudType.valueOf(args[0].toUpperCase().trim()));
spoutHud.initializeXpBar();
spoutHud.updateXpBar();
return true;
}
catch (IllegalArgumentException ex) {
sender.sendMessage(LocaleLoader.getString("Commands.mchud.Invalid"));
return true;
}
}
}

View File

@@ -1,54 +0,0 @@
package com.gmail.nossr50.commands.spout;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.spout.SpoutConfig;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
public abstract class SpoutCommand implements TabExecutor {
protected PlayerProfile playerProfile;
protected McMMOHud spoutHud;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
if (!mcMMO.isSpoutEnabled() || !SpoutConfig.getInstance().getXPBarEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
return true;
}
playerProfile = UserManager.getPlayer((Player) sender).getProfile();
spoutHud = playerProfile.getSpoutHud();
if (spoutHud == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
return true;
}
switch (args.length) {
case 0:
return noArguments(command, sender, args);
case 1:
return oneArgument(command, sender, args);
default:
return false;
}
}
protected abstract boolean noArguments(Command command, CommandSender sender, String[] args);
protected abstract boolean oneArgument(Command command, CommandSender sender, String[] args);
}

View File

@@ -1,89 +0,0 @@
package com.gmail.nossr50.commands.spout;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.google.common.collect.ImmutableList;
public class XplockCommand extends SpoutCommand {
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
List<String> matches = StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
if (matches.size() == 0) {
return StringUtil.copyPartialMatches(args[0], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
}
return matches;
default:
return ImmutableList.of();
}
}
@Override
protected boolean noArguments(Command command, CommandSender sender, String[] args) {
if (spoutHud.getXpBarLocked()) {
unlockXpBar(sender);
return true;
}
lockXpBar(sender, spoutHud.getLastGained());
return true;
}
@Override
protected boolean oneArgument(Command command, CommandSender sender, String[] args) {
if (CommandUtils.shouldEnableToggle(args[0])) {
lockXpBar(sender, spoutHud.getLastGained());
return true;
}
if (CommandUtils.shouldDisableToggle(args[0])) {
unlockXpBar(sender);
return true;
}
if (CommandUtils.isInvalidSkill(sender, args[0])) {
return true;
}
SkillType skill = SkillType.getSkill(args[0]);
if (CommandUtils.isChildSkill(sender, skill)) {
return true;
}
if (!Permissions.xplock(sender, skill)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
lockXpBar(sender, skill);
return true;
}
private void lockXpBar(CommandSender sender, SkillType skill) {
if (skill != null) {
spoutHud.setXpBarLocked(true);
spoutHud.setSkillLock(skill);
spoutHud.updateXpBar();
sender.sendMessage(LocaleLoader.getString("Commands.xplock.locked", SkillUtils.getSkillName(skill)));
}
}
private void unlockXpBar(CommandSender sender) {
spoutHud.setXpBarLocked(false);
sender.sendMessage(LocaleLoader.getString("Commands.xplock.unlocked"));
}
}

View File

@@ -1,10 +1,23 @@
package com.gmail.nossr50.config; package com.gmail.nossr50.config;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.skills.fishing.Fishing;
import com.gmail.nossr50.skills.mining.BlastMining;
import com.gmail.nossr50.skills.repair.ArcaneForging;
import com.gmail.nossr50.skills.smelting.Smelting;
import com.gmail.nossr50.util.StringUtils;
public class AdvancedConfig extends AutoUpdateConfigLoader { public class AdvancedConfig extends AutoUpdateConfigLoader {
private static AdvancedConfig instance; private static AdvancedConfig instance;
private AdvancedConfig() { private AdvancedConfig() {
super("advanced.yml"); super("advanced.yml");
validate();
} }
public static AdvancedConfig getInstance() { public static AdvancedConfig getInstance() {
@@ -16,280 +29,734 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
} }
@Override @Override
protected void loadKeys() {} protected boolean validateKeys() {
// Validate all the settings!
List<String> reason = new ArrayList<String>();
/* GENERAL */ /* GENERAL */
public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); } if (getAbilityLength() < 1) {
public int getEnchantBuff() { reason.add("Skills.General.Ability.IncreaseLevel should be at least 1!");
int buff = config.getInt("Skills.General.Ability_EnchantBuff", 5); }
return (buff <= 0) ? 1 : buff;
if (getEnchantBuff() < 1) {
reason.add("Skills.General.Ability.EnchantBuff should be at least 1!");
} }
/* ACROBATICS */ /* ACROBATICS */
public double getDodgeChanceMax() { return config.getDouble("Skills.Acrobatics.Dodge_ChanceMax", 20.0D); } if (getMaxChance(SecondaryAbility.DODGE) < 1) {
public int getDodgeMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Dodge_MaxBonusLevel", 800); } reason.add("Skills.Acrobatics.Dodge.ChanceMax should be at least 1!");
public int getDodgeDamageModifier() { return config.getInt("Skills.Acrobatics.Dodge_DamageModifer", 2); } }
public double getRollChanceMax() { return config.getDouble("Skills.Acrobatics.Roll_ChanceMax", 100.0D); } if (getMaxBonusLevel(SecondaryAbility.DODGE) < 1) {
public int getRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Roll_MaxBonusLevel", 1000); } reason.add("Skills.Acrobatics.Dodge.MaxBonusLevel should be at least 1!");
public int getRollDamageThreshold() { return config.getInt("Skills.Acrobatics.Roll_DamageThreshold", 7); } }
public double getGracefulRollChanceMax() { return config.getDouble("Skills.Acrobatics.GracefulRoll_ChanceMax", 100.0D); } if (getDodgeDamageModifier() <= 1) {
public int getGracefulRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.GracefulRoll_MaxBonusLevel", 500); } reason.add("Skills.Acrobatics.Dodge.DamageModifier should be greater than 1!");
public int getGracefulRollDamageThreshold() { return config.getInt("Skills.Acrobatics.GracefulRoll_DamageThreshold", 14); } }
public int getDodgeXPModifier() { return config.getInt("Skills.Acrobatics.Dodge_XP_Modifier", 120); } if (getMaxChance(SecondaryAbility.ROLL) < 1) {
public int getRollXPModifier() { return config.getInt("Skills.Acrobatics.Roll_XP_Modifier", 80); } reason.add("Skills.Acrobatics.Roll.ChanceMax should be at least 1!");
public int getFallXPModifier() { return config.getInt("Skills.Acrobatics.Fall_XP_Modifier", 120); } }
if (getMaxBonusLevel(SecondaryAbility.ROLL) < 1) {
reason.add("Skills.Acrobatics.Roll.MaxBonusLevel should be at least 1!");
}
if (getRollDamageThreshold() < 0) {
reason.add("Skills.Acrobatics.Roll.DamageThreshold should be at least 0!");
}
if (getMaxChance(SecondaryAbility.GRACEFUL_ROLL) < 1) {
reason.add("Skills.Acrobatics.GracefulRoll.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SecondaryAbility.GRACEFUL_ROLL) < 1) {
reason.add("Skills.Acrobatics.GracefulRoll.MaxBonusLevel should be at least 1!");
}
if (getGracefulRollDamageThreshold() < 0) {
reason.add("Skills.Acrobatics.GracefulRoll.DamageThreshold should be at least 0!");
}
/* ARCHERY */ /* ARCHERY */
public int getSkillShotIncreaseLevel() { return config.getInt("Skills.Archery.SkillShot_IncreaseLevel", 50); } if (getSkillShotIncreaseLevel() < 1) {
public double getSkillShotIncreasePercentage() { return config.getDouble("Skills.Archery.SkillShot_IncreasePercentage", 0.1D); } reason.add("Skills.Archery.SkillShot.IncreaseLevel should be at least 1!");
public double getSkillShotBonusMax() { return config.getDouble("Skills.Archery.SkillShot_MaxBonus", 2.0D); } }
public double getDazeBonusMax() { return config.getDouble("Skills.Archery.Daze_MaxChance", 50.0D); } if (getSkillShotIncreasePercentage() <= 0) {
public int getDazeMaxBonusLevel() { return config.getInt("Skills.Archery.Daze_MaxBonusLevel", 1000); } reason.add("Skills.Archery.SkillShot.IncreasePercentage should be greater than 0!");
public int getDazeModifier() { return config.getInt("Skills.Archery.Daze_BonusDamage", 4); } }
public double getRetrieveChanceMax() { return config.getDouble("Skills.Archery.Retrieve_MaxBonus", 100.0D); } if (getSkillShotBonusMax() < 0) {
public int getRetrieveMaxBonusLevel() { return config.getInt("Skills.Archery.Retrieve_MaxBonusLevel", 1000); } reason.add("Skills.Archery.SkillShot.MaxBonus should be at least 0!");
}
public double getForceMultiplier() { return config.getDouble("Skills.Archery.Force_Multiplier", 2.0D); } if (getMaxChance(SecondaryAbility.DAZE) < 1) {
reason.add("Skills.Acrobatics.Daze.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SecondaryAbility.DAZE) < 1) {
reason.add("Skills.Acrobatics.Daze.MaxBonusLevel should be at least 1!");
}
if (getDazeModifier() < 0) {
reason.add("Skills.Acrobatics.Daze.BonusDamage should be at least 0!");
}
if (getMaxChance(SecondaryAbility.RETRIEVE) < 1) {
reason.add("Skills.Acrobatics.Retrieve.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SecondaryAbility.RETRIEVE) < 1) {
reason.add("Skills.Acrobatics.Retrieve.MaxBonusLevel should be at least 1!");
}
if (getForceMultiplier() < 0) {
reason.add("Skills.Acrobatics.ForceMultiplier should be at least 0!");
}
/* AXES */ /* AXES */
public int getBonusDamageAxesBonusMax() { return config.getInt("Skills.Axes.DamageIncrease_MaxBonus", 4); } if (getAxeMasteryBonusMax() < 1) {
public int getBonusDamageAxesMaxBonusLevel() { return config.getInt("Skills.Axes.DamageIncrease_MaxBonusLevel", 200); } reason.add("Skills.Axes.AxeMastery.MaxBonus should be at least 1!");
}
public double getAxesCriticalChance() { return config.getDouble("Skills.Axes.AxesCritical_MaxChance", 37.50D); } if (getAxeMasteryMaxBonusLevel() < 1) {
public int getAxesCriticalMaxBonusLevel() { return config.getInt("Skills.Axes.AxesCritical_MaxBonusLevel", 750); } reason.add("Skills.Axes.AxeMastery.MaxBonusLevel should be at least 1!");
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); } if (getMaxChance(SecondaryAbility.CRITICAL_HIT) < 1) {
public double getGreaterImpactModifier() { return config.getDouble("Skills.Axes.GreaterImpact_KnockbackModifier", 1.5); } reason.add("Skills.Axes.CriticalHit.ChanceMax should be at least 1!");
public int getGreaterImpactBonusDamage() { return config.getInt("Skills.Axes.GreaterImpact_BonusDamage", 2); } }
public int getArmorImpactIncreaseLevel() { return config.getInt("Skills.Axes.ArmorImpact_IncreaseLevel", 50); } if (getMaxBonusLevel(SecondaryAbility.CRITICAL_HIT) < 1) {
public double getImpactChance() { return config.getDouble("Skills.Axes.ArmorImpact_Chance", 25.0D); } reason.add("Skills.Axes.CriticalHit.MaxBonusLevel should be at least 1!");
public double getArmorImpactMaxDurabilityDamage() { return config.getDouble("Skills.Axes.ArmorImpact_MaxPercentageDurabilityDamage", 20.0D); } }
public int getSkullSplitterModifier() { return config.getInt("Skills.Axes.SkullSplitter_DamagerModifier", 2); } if (getCriticalHitPVPModifier() < 1) {
reason.add("Skills.Axes.CriticalHit.PVP_Modifier should be at least 1!");
}
if (getCriticalHitPVEModifier() < 1) {
reason.add("Skills.Axes.CriticalHit.PVE_Modifier should be at least 1!");
}
if (getGreaterImpactChance() < 1) {
reason.add("Skills.Axes.GreaterImpact.Chance should be at least 1!");
}
if (getGreaterImpactModifier() < 1) {
reason.add("Skills.Axes.GreaterImpact.KnockbackModifier should be at least 1!");
}
if (getGreaterImpactBonusDamage() < 1) {
reason.add("Skills.Axes.GreaterImpact.BonusDamage should be at least 1!");
}
if (getArmorImpactIncreaseLevel() < 1) {
reason.add("Skills.Axes.ArmorImpact.IncreaseLevel should be at least 1!");
}
if (getImpactChance() < 1) {
reason.add("Skills.Axes.ArmorImpact.Chance should be at least 1!");
}
if (getArmorImpactMaxDurabilityDamage() < 1) {
reason.add("Skills.Axes.ArmorImpact.MaxPercentageDurabilityDamage should be at least 1!");
}
if (getSkullSplitterModifier() < 1) {
reason.add("Skills.Axes.SkullSplitter.DamagerModifier should be at least 1!");
}
/* FISHING */
List<Fishing.Tier> fishingTierList = Arrays.asList(Fishing.Tier.values());
for (Fishing.Tier tier : fishingTierList) {
if (getFishingTierLevel(tier) < 0) {
reason.add("Skills.Fishing.Rank_Levels.Rank_" + tier.toNumerical() + " should be at least 0!");
}
if (getShakeChance(tier) < 0) {
reason.add("Skills.Fishing.Shake_Chance.Rank_" + tier.toNumerical() + " should be at least 0!");
}
if (getFishingVanillaXPModifier(tier) < 0) {
reason.add("Skills.Fishing.VanillaXPMultiplier.Rank_" + tier.toNumerical() + " should be at least 0!");
}
if (tier != Fishing.Tier.EIGHT) {
Fishing.Tier nextTier = fishingTierList.get(fishingTierList.indexOf(tier) - 1);
if (getFishingTierLevel(tier) >= getFishingTierLevel(nextTier)) {
reason.add("Skills.Fishing.Rank_Levels.Rank_" + tier.toNumerical() + " should be less than Skills.Fishing.Rank_Levels.Rank_" + nextTier.toNumerical() + "!");
}
if (getShakeChance(tier) > getShakeChance(nextTier)) {
reason.add("Skills.Fishing.Shake_Chance.Rank_" + tier.toNumerical() + " should be less than or equal to Skills.Fishing.Shake_Chance.Rank_" + nextTier.toNumerical() + "!");
}
if (getFishingVanillaXPModifier(tier) > getFishingVanillaXPModifier(nextTier)) {
reason.add("Skills.Fishing.VanillaXPMultiplier.Rank_" + tier.toNumerical() + " should be less than or equal to Skills.Fishing.VanillaXPMultiplier.Rank_" + nextTier.toNumerical() + "!");
}
}
}
if (getFishermanDietRankChange() < 1) {
reason.add("Skills.Fishing.FishermansDiet.RankChange should be at least 1!");
}
if (getIceFishingUnlockLevel() < 1) {
reason.add("Skills.Fishing.IceFishing.UnlockLevel should be at least 1!");
}
if (getMasterAnglerUnlockLevel() < 1) {
reason.add("Skills.Fishing.MasterAngler.UnlockLevel should be at least 1!");
}
if (getMasterAnglerBoatModifier() < 1) {
reason.add("Skills.Fishing.MasterAngler.BoatModifier should be at least 1!");
}
if (getMasterAnglerBiomeModifier() < 1) {
reason.add("Skills.Fishing.MasterAngler.BiomeModifier should be at least 1!");
}
/* HERBALISM */
if (getFarmerDietRankChange() < 1) {
reason.add("Skills.Herbalism.FarmersDiet.RankChange should be at least 1!");
}
if (getGreenThumbStageChange() < 1) {
reason.add("Skills.Herbalism.GreenThumb.StageChange should be at least 1!");
}
if (getMaxChance(SecondaryAbility.GREEN_THUMB_PLANT) < 1) {
reason.add("Skills.Herbalism.GreenThumb.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SecondaryAbility.GREEN_THUMB_PLANT) < 1) {
reason.add("Skills.Herbalism.GreenThumb.MaxBonusLevel should be at least 1!");
}
if (getMaxChance(SecondaryAbility.HERBALISM_DOUBLE_DROPS) < 1) {
reason.add("Skills.Herbalism.DoubleDrops.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SecondaryAbility.HERBALISM_DOUBLE_DROPS) < 1) {
reason.add("Skills.Herbalism.DoubleDrops.MaxBonusLevel should be at least 1!");
}
if (getMaxChance(SecondaryAbility.HYLIAN_LUCK) < 1) {
reason.add("Skills.Herbalism.HylianLuck.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SecondaryAbility.HYLIAN_LUCK) < 1) {
reason.add("Skills.Herbalism.HylianLuck.MaxBonusLevel should be at least 1!");
}
if (getMaxChance(SecondaryAbility.SHROOM_THUMB) < 1) {
reason.add("Skills.Herbalism.ShroomThumb.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SecondaryAbility.SHROOM_THUMB) < 1) {
reason.add("Skills.Herbalism.ShroomThumb.MaxBonusLevel should be at least 1!");
}
/* MINING */
if (getMaxChance(SecondaryAbility.MINING_DOUBLE_DROPS) < 1) {
reason.add("Skills.Mining.DoubleDrops.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SecondaryAbility.MINING_DOUBLE_DROPS) < 1) {
reason.add("Skills.Mining.DoubleDrops.MaxBonusLevel should be at least 1!");
}
List<BlastMining.Tier> blastMiningTierList = Arrays.asList(BlastMining.Tier.values());
for (BlastMining.Tier tier : blastMiningTierList) {
if (getBlastMiningRankLevel(tier) < 0) {
reason.add("Skills.Mining.BlastMining.Rank_Levels.Rank_" + tier.toNumerical() + " should be at least 0!");
}
if (getBlastDamageDecrease(tier) < 0) {
reason.add("Skills.Mining.BlastMining.BlastDamageDecrease.Rank_" + tier.toNumerical() + " should be at least 0!");
}
if (getOreBonus(tier) < 0) {
reason.add("Skills.Mining.BlastMining.OreBonus.Rank_" + tier.toNumerical() + " should be at least 0!");
}
if (getDebrisReduction(tier) < 0) {
reason.add("Skills.Mining.BlastMining.DebrisReduction.Rank_" + tier.toNumerical() + " should be at least 0!");
}
if (getDropMultiplier(tier) < 0) {
reason.add("Skills.Mining.BlastMining.DropMultiplier.Rank_" + tier.toNumerical() + " should be at least 0!");
}
if (getBlastRadiusModifier(tier) < 0) {
reason.add("Skills.Mining.BlastMining.BlastRadiusModifier.Rank_" + tier.toNumerical() + " should be at least 0!");
}
if (tier != BlastMining.Tier.EIGHT) {
BlastMining.Tier nextTier = blastMiningTierList.get(blastMiningTierList.indexOf(tier) - 1);
if (getBlastMiningRankLevel(tier) >= getBlastMiningRankLevel(nextTier)) {
reason.add("Skills.Mining.BlastMining.Rank_Levels.Rank_" + tier.toNumerical() + " should be less than Skills.Mining.BlastMining.Rank_Levels.Rank_" + nextTier.toNumerical() + "!");
}
if (getBlastDamageDecrease(tier) > getBlastDamageDecrease(nextTier)) {
reason.add("Skills.Mining.BlastMining.BlastDamageDecrease.Rank_" + tier.toNumerical() + " should be less than or equal to Skills.Mining.BlastMining.BlastDamageDecrease.Rank_" + nextTier.toNumerical() + "!");
}
if (getOreBonus(tier) > getOreBonus(nextTier)) {
reason.add("Skills.Mining.BlastMining.OreBonus.Rank_" + tier.toNumerical() + " should be less than or equal to Skills.Mining.BlastMining.OreBonus.Rank_" + nextTier.toNumerical() + "!");
}
if (getDebrisReduction(tier) > getDebrisReduction(nextTier)) {
reason.add("Skills.Mining.BlastMining.DebrisReduction.Rank_" + tier.toNumerical() + " should be less than or equal to Skills.Mining.BlastMining.DebrisReduction.Rank_" + nextTier.toNumerical() + "!");
}
if (getDropMultiplier(tier) > getDropMultiplier(nextTier)) {
reason.add("Skills.Mining.BlastMining.DropMultiplier.Rank_" + tier.toNumerical() + " should be less than or equal to Skills.Mining.BlastMining.DropMultiplier.Rank_" + nextTier.toNumerical() + "!");
}
if (getBlastRadiusModifier(tier) > getBlastRadiusModifier(nextTier)) {
reason.add("Skills.Mining.BlastMining.BlastRadiusModifier.Rank_" + tier.toNumerical() + " should be less than or equal to Skills.Mining.BlastMining.BlastRadiusModifier.Rank_" + nextTier.toNumerical() + "!");
}
}
}
/* REPAIR */
if (getRepairMasteryMaxBonus() < 1) {
reason.add("Skills.Repair.RepairMastery.MaxBonusPercentage should be at least 1!");
}
if (getRepairMasteryMaxLevel() < 1) {
reason.add("Skills.Repair.RepairMastery.MaxBonusLevel should be at least 1!");
}
if (getMaxChance(SecondaryAbility.SUPER_REPAIR) < 1) {
reason.add("Skills.Repair.SuperRepair.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SecondaryAbility.SUPER_REPAIR) < 1) {
reason.add("Skills.Repair.SuperRepair.MaxBonusLevel should be at least 1!");
}
if (getSalvageUnlockLevel() < 1) {
reason.add("Skills.Repair.Salvage.UnlockLevel should be at least 1!");
}
List<ArcaneForging.Tier> arcaneForgingTierList = Arrays.asList(ArcaneForging.Tier.values());
for (ArcaneForging.Tier tier : arcaneForgingTierList) {
if (getArcaneForgingRankLevel(tier) < 0) {
reason.add("Skills.Repair.ArcaneForging.Rank_Levels.Rank_" + tier.toNumerical() + " should be at least 0!");
}
if (getArcaneForgingDowngradeChance(tier) < 0 || getArcaneForgingDowngradeChance(tier) > 100) {
reason.add("Skills.Repair.ArcaneForging.Downgrades.Chance.Rank_" + tier.toNumerical() + " only accepts values from 0 to 100!");
}
if (getArcaneForgingKeepEnchantsChance(tier) < 0 || getArcaneForgingKeepEnchantsChance(tier) > 100) {
reason.add("Skills.Repair.ArcaneForging.Keep_Enchants.Chance.Rank_" + tier.toNumerical() + " only accepts values from 0 to 100!");
}
if (tier != ArcaneForging.Tier.EIGHT) {
ArcaneForging.Tier nextTier = arcaneForgingTierList.get(arcaneForgingTierList.indexOf(tier) - 1);
if (getArcaneForgingRankLevel(tier) >= getArcaneForgingRankLevel(nextTier)) {
reason.add("Skills.Repair.ArcaneForging.Rank_Levels.Rank_" + tier.toNumerical() + " should be less than Skills.Repair.ArcaneForging.Rank_Levels.Rank_" + nextTier.toNumerical() + "!");
}
if (getArcaneForgingDowngradeChance(nextTier) > getArcaneForgingDowngradeChance(tier)) {
reason.add("Skills.Repair.ArcaneForging.Downgrades.Chance.Rank_" + nextTier.toNumerical() + " should be less than or equal to Skills.Repair.ArcaneForging.Downgrades.Chance.Rank_" + tier.toNumerical() + "!");
}
if (getArcaneForgingKeepEnchantsChance(tier) > getArcaneForgingKeepEnchantsChance(nextTier)) {
reason.add("Skills.Repair.ArcaneForging.Keep_Enchants.Chance.Rank_" + tier.toNumerical() + " should be less than or equal to Skills.Repair.ArcaneForging.Keep_Enchants.Chance.Rank_" + nextTier.toNumerical() + "!");
}
}
}
/* SMELTING */
if (getBurnModifierMaxLevel() < 1) {
reason.add("Skills.Smelting.FuelEfficiency.MaxBonusLevel should be at least 1!");
}
if (getBurnTimeMultiplier() < 1) {
reason.add("Skills.Smelting.FuelEfficiency.Multiplier should be at least 1!");
}
if (getMaxBonusLevel(SecondaryAbility.SECOND_SMELT) < 1) {
reason.add("Skills.Smelting.SecondSmelt.MaxBonusLevel should be at least 1!");
}
if (getMaxChance(SecondaryAbility.SECOND_SMELT) < 1) {
reason.add("Skills.Smelting.SecondSmelt.ChanceMax should be at least 1!");
}
if (getFluxMiningUnlockLevel() < 1) {
reason.add("Skills.Smelting.FluxMining.UnlockLevel should be at least 1!");
}
if (getFluxMiningChance() < 1) {
reason.add("Skills.Smelting.FluxMining.Chance should be at least 1!");
}
List<Smelting.Tier> smeltingTierList = Arrays.asList(Smelting.Tier.values());
for (Smelting.Tier tier : smeltingTierList) {
if (getSmeltingRankLevel(tier) < 0) {
reason.add("Skills.Smelting.Rank_Levels.Rank_" + tier.toNumerical() + " should be at least 0!");
}
if (getSmeltingVanillaXPBoostMultiplier(tier) < 1) {
reason.add("Skills.Smelting.VanillaXPMultiplier.Rank_" + tier.toNumerical() + " should be at least 1!");
}
if (tier != Smelting.Tier.EIGHT) {
Smelting.Tier nextTier = smeltingTierList.get(smeltingTierList.indexOf(tier) - 1);
if (getSmeltingRankLevel(tier) >= getSmeltingRankLevel(nextTier)) {
reason.add("Skills.Smelting.Rank_Levels.Rank_" + tier.toNumerical() + " should be less than Skills.Smelting.Rank_Levels.Rank_" + nextTier.toNumerical() + "!");
}
if (getSmeltingVanillaXPBoostMultiplier(tier) > getSmeltingRankLevel(nextTier)) {
reason.add("Skills.Smelting.VanillaXPMultiplier.Rank_" + tier.toNumerical() + " should be less than or equal to Skills.Smelting.VanillaXPMultiplier.Rank_" + nextTier.toNumerical() + "!");
}
}
}
/* SWORDS */
if (getMaxChance(SecondaryAbility.BLEED) < 1) {
reason.add("Skills.Swords.Bleed.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SecondaryAbility.BLEED) < 1) {
reason.add("Skills.Swords.Bleed.MaxBonusLevel should be at least 1!");
}
if (getBleedMaxTicks() < 1) {
reason.add("Skills.Swords.Bleed.MaxTicks should be at least 1!");
}
if (getBleedMaxTicks() < getBleedBaseTicks()) {
reason.add("Skills.Swords.Bleed.MaxTicks should be at least Skills.Swords.Bleed.BaseTicks!");
}
if (getBleedBaseTicks() < 1) {
reason.add("Skills.Swords.Bleed.BaseTicks should be at least 1!");
}
if (getMaxChance(SecondaryAbility.COUNTER) < 1) {
reason.add("Skills.Swords.Counter.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SecondaryAbility.COUNTER) < 1) {
reason.add("Skills.Swords.Counter.MaxBonusLevel should be at least 1!");
}
if (getCounterModifier() < 1) {
reason.add("Skills.Swords.Counter.DamageModifier should be at least 1!");
}
if (getSerratedStrikesModifier() < 1) {
reason.add("Skills.Swords.SerratedStrikes.DamageModifier should be at least 1!");
}
if (getSerratedStrikesTicks() < 1) {
reason.add("Skills.Swords.SerratedStrikes.BleedTicks should be at least 1!");
}
/* TAMING */
if (getMaxChance(SecondaryAbility.GORE) < 1) {
reason.add("Skills.Taming.Gore.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SecondaryAbility.GORE) < 1) {
reason.add("Skills.Taming.Gore.MaxBonusLevel should be at least 1!");
}
if (getGoreBleedTicks() < 1) {
reason.add("Skills.Taming.Gore.BleedTicks should be at least 1!");
}
if (getGoreModifier() < 1) {
reason.add("Skills.Taming.Gore.Modifier should be at least 1!");
}
if (getFastFoodUnlock() < 1) {
reason.add("Skills.Taming.FastFood.UnlockLevel should be at least 1!");
}
if (getFastFoodChance() < 1) {
reason.add("Skills.Taming.FastFood.Chance should be at least 1!");
}
if (getEnviromentallyAwareUnlock() < 1) {
reason.add("Skills.Taming.EnvironmentallyAware.UnlockLevel should be at least 1!");
}
if (getThickFurUnlock() < 1) {
reason.add("Skills.Taming.ThickFur.UnlockLevel should be at least 1!");
}
if (getThickFurModifier() < 1) {
reason.add("Skills.Taming.ThickFur.Modifier should be at least 1!");
}
if (getHolyHoundUnlock() < 1) {
reason.add("Skills.Taming.HolyHound.UnlockLevel should be at least 1!");
}
if (getShockProofUnlock() < 1) {
reason.add("Skills.Taming.ShockProof.UnlockLevel should be at least 1!");
}
if (getShockProofModifier() < 1) {
reason.add("Skills.Taming.ShockProof.Modifier should be at least 1!");
}
if (getSharpenedClawsUnlock() < 1) {
reason.add("Skills.Taming.SharpenedClaws.UnlockLevel should be at least 1!");
}
if (getSharpenedClawsBonus() < 1) {
reason.add("Skills.Taming.SharpenedClaws.Bonus should be at least 1!");
}
if (getMaxHorseJumpStrength() < 0 || getMaxHorseJumpStrength() > 2) {
reason.add("Skills.Taming.CallOfTheWild.MaxHorseJumpStrength should be between 0 and 2!");
}
/* UNARMED */
if (getMaxChance(SecondaryAbility.DISARM) < 1) {
reason.add("Skills.Unarmed.Disarm.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SecondaryAbility.DISARM) < 1) {
reason.add("Skills.Unarmed.Disarm.MaxBonusLevel should be at least 1!");
}
if (getMaxChance(SecondaryAbility.DEFLECT) < 1) {
reason.add("Skills.Unarmed.Deflect.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SecondaryAbility.DEFLECT) < 1) {
reason.add("Skills.Unarmed.Deflect.MaxBonusLevel should be at least 1!");
}
if (getMaxChance(SecondaryAbility.IRON_GRIP) < 1) {
reason.add("Skills.Unarmed.IronGrip.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SecondaryAbility.IRON_GRIP) < 1) {
reason.add("Skills.Unarmed.IronGrip.MaxBonusLevel should be at least 1!");
}
if (getIronArmMinBonus() < 0) {
reason.add("Skills.Unarmed.IronArm.BonusMin should be at least 0!");
}
if (getIronArmMaxBonus() < 0) {
reason.add("Skills.Unarmed.IronArm.BonusMax should be at least 0!");
}
if (getIronArmMaxBonus() < getIronArmMinBonus()) {
reason.add("Skills.Unarmed.IronArm.BonusMax should be greater than or equal to Skills.Unarmed.IronArm.BonusMin!");
}
if (getIronArmIncreaseLevel() < 1) {
reason.add("Skills.Unarmed.IronArm.IncreaseLevel should be at least 1!");
}
/* WOODCUTTING */
if (getLeafBlowUnlockLevel() < 1) {
reason.add("Skills.Woodcutting.LeafBlower.UnlockLevel should be at least 1!");
}
if (getMaxChance(SecondaryAbility.WOODCUTTING_DOUBLE_DROPS) < 1) {
reason.add("Skills.Woodcutting.DoubleDrops.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SecondaryAbility.WOODCUTTING_DOUBLE_DROPS) < 1) {
reason.add("Skills.Woodcutting.DoubleDrops.MaxBonusLevel should be at least 1!");
}
/* KRAKEN */
if (getKrakenTriesBeforeRelease() < 1) {
reason.add("Kraken.Tries_Before_Release should be at least 1!");
}
if (getKrakenHealth() < 1) {
reason.add("Kraken.Health should be at least 1!");
}
if (getKrakenAttackInterval() < 1) {
reason.add("Kraken.Attack_Interval_Seconds should be at least 1!");
}
if (getKrakenAttackDamage() < 1) {
reason.add("Kraken.Attack_Damage should be at least 1!");
}
return noErrorsInConfig(reason);
}
@Override
protected void loadKeys() {}
/* GENERAL */
public int getAbilityLength() { return config.getInt("Skills.General.Ability.IncreaseLevel", 50); }
public int getEnchantBuff() { return config.getInt("Skills.General.Ability.EnchantBuff", 5); }
public int getMaxBonusLevel(SecondaryAbility skillAbility) { return config.getInt("Skills." + StringUtils.getCapitalized(SkillType.bySecondaryAbility(skillAbility).toString()) + "." + StringUtils.getPrettySecondaryAbilityString(skillAbility).replace(" ", "") + ".MaxBonusLevel"); }
public double getMaxChance(SecondaryAbility skillAbility) { return config.getDouble("Skills." + StringUtils.getCapitalized(SkillType.bySecondaryAbility(skillAbility).toString()) + "." + StringUtils.getPrettySecondaryAbilityString(skillAbility).replace(" ", "") + ".ChanceMax", 100.0D); }
/* ACROBATICS */
public double getDodgeDamageModifier() { return config.getDouble("Skills.Acrobatics.Dodge.DamageModifier", 2.0D); }
public double getRollDamageThreshold() { return config.getDouble("Skills.Acrobatics.Roll.DamageThreshold", 7.0D); }
public double getGracefulRollDamageThreshold() { return config.getDouble("Skills.Acrobatics.GracefulRoll.DamageThreshold", 14.0D); }
/* 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 getSkillShotDamageMax() { return config.getDouble("Skills.Archery.SkillShot.MaxDamage", 9.0D); }
public double getDazeModifier() { return config.getDouble("Skills.Archery.Daze.BonusDamage", 4.0D); }
public double getForceMultiplier() { return config.getDouble("Skills.Archery.ForceMultiplier", 2.0D); }
/* AXES */
public double getAxeMasteryBonusMax() { return config.getDouble("Skills.Axes.AxeMastery.MaxBonus", 4.0D); }
public int getAxeMasteryMaxBonusLevel() { return config.getInt("Skills.Axes.AxeMastery.MaxBonusLevel", 200); }
public double getCriticalHitPVPModifier() { return config.getDouble("Skills.Axes.CriticalHit.PVP_Modifier", 1.5D); }
public double getCriticalHitPVEModifier() { return config.getDouble("Skills.Axes.CriticalHit.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.5D); }
public double getGreaterImpactBonusDamage() { return config.getDouble("Skills.Axes.GreaterImpact.BonusDamage", 2.0D); }
public int getArmorImpactIncreaseLevel() { return config.getInt("Skills.Axes.ArmorImpact.IncreaseLevel", 50); }
public double getImpactChance() { return config.getDouble("Skills.Axes.ArmorImpact.Chance", 25.0D); }
public double getArmorImpactMaxDurabilityDamage() { return config.getDouble("Skills.Axes.ArmorImpact.MaxPercentageDurabilityDamage", 20.0D); }
public double getSkullSplitterModifier() { return config.getDouble("Skills.Axes.SkullSplitter.DamagerModifier", 2.0D); }
/* EXCAVATION */ /* EXCAVATION */
//Nothing to configure, everything is already configurable in config.yml //Nothing to configure, everything is already configurable in config.yml
/* FISHING */ /* FISHING */
public int getFishingTierLevelsTier1() { return config.getInt("Skills.Fishing.Tier_Levels.Tier1", 0); } public int getFishingTierLevel(Fishing.Tier tier) { return config.getInt("Skills.Fishing.Rank_Levels.Rank_" + tier.toNumerical()); }
public int getFishingTierLevelsTier2() { return config.getInt("Skills.Fishing.Tier_Levels.Tier2", 200); } public double getShakeChance(Fishing.Tier tier) { return config.getDouble("Skills.Fishing.ShakeChance.Rank_" + tier.toNumerical()); }
public int getFishingTierLevelsTier3() { return config.getInt("Skills.Fishing.Tier_Levels.Tier3", 400); } public int getFishingVanillaXPModifier(Fishing.Tier tier) { return config.getInt("Skills.Fishing.VanillaXPMultiplier.Rank_" + tier.toNumerical()); }
public int getFishingTierLevelsTier4() { return config.getInt("Skills.Fishing.Tier_Levels.Tier4", 600); }
public int getFishingTierLevelsTier5() { return config.getInt("Skills.Fishing.Tier_Levels.Tier5", 800); }
public int getFishingMagicMultiplier() { return config.getInt("Skills.Fishing.MagicHunter_Multiplier", 5); } public int getFishermanDietRankChange() { return config.getInt("Skills.Fishing.FishermansDiet.RankChange", 200); }
public int getFishermanDietRankChange() { return config.getInt("Skills.Fishing.Fisherman_Diet_RankChange", 200); } public int getIceFishingUnlockLevel() { return config.getInt("Skills.Fishing.IceFishing.UnlockLevel", 50); }
public int getIceFishingUnlockLevel() { return config.getInt("Skills.Fishing.Ice_Fishing_UnlockLevel", 50); } public int getMasterAnglerUnlockLevel() {return config.getInt("Skills.Fishing.MasterAngler.UnlockLevel", 125); }
public double getMasterAnglerBoatModifier() {return config.getDouble("Skills.Fishing.MasterAngler.BoatModifier", 2.0); }
/* Shake */ public double getMasterAnglerBiomeModifier() {return config.getDouble("Skills.Fishing.MasterAngler.BiomeModifier", 2.0); }
public int getShakeUnlockLevel() { return config.getInt("Skills.Fishing.Shake_UnlockLevel", 150); }
public int getShakeChanceRank1() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_1", 25); }
public int getShakeChanceRank2() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_2", 40); }
public int getShakeChanceRank3() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_3", 55); }
public int getShakeChanceRank4() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_4", 60); }
public int getShakeChanceRank5() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_5", 75); }
/* Vanilla XP Boost */
public int getFishingVanillaXPModifierRank1() { return config.getInt("Skills.Fishing.VanillaXPBoost.Rank_1", 1); }
public int getFishingVanillaXPModifierRank2() { return config.getInt("Skills.Fishing.VanillaXPBoost.Rank_2", 2); }
public int getFishingVanillaXPModifierRank3() { return config.getInt("Skills.Fishing.VanillaXPBoost.Rank_3", 3); }
public int getFishingVanillaXPModifierRank4() { return config.getInt("Skills.Fishing.VanillaXPBoost.Rank_4", 4); }
public int getFishingVanillaXPModifierRank5() { return config.getInt("Skills.Fishing.VanillaXPBoost.Rank_5", 5); }
/* HERBALISM */ /* HERBALISM */
public int getFarmerDietRankChange() { return config.getInt("Skills.Herbalism.Farmer_Diet_RankChange", 200); } public int getFarmerDietRankChange() { return config.getInt("Skills.Herbalism.FarmersDiet.RankChange", 200); }
public int getGreenThumbStageChange() { return config.getInt("Skills.Herbalism.GreenThumb_StageChange", 200); } public int getGreenThumbStageChange() { return config.getInt("Skills.Herbalism.GreenThumb.StageChange", 200); }
public double getGreenThumbChanceMax() { return config.getDouble("Skills.Herbalism.GreenThumb_ChanceMax", 100.0D); }
public int getGreenThumbMaxLevel() { return config.getInt("Skills.Herbalism.GreenThumb_MaxBonusLevel", 1500); }
public double getHerbalismDoubleDropsChanceMax() { return config.getDouble("Skills.Herbalism.DoubleDrops_ChanceMax", 100.0D); }
public int getHerbalismDoubleDropsMaxLevel() { return config.getInt("Skills.Herbalism.DoubleDrops_MaxBonusLevel", 1000); }
public double getHylianLuckChanceMax() { return config.getDouble("Skills.Herbalism.HylianLuck_ChanceMax", 10.0D); }
public int getHylianLuckMaxLevel() { return config.getInt("Skills.Herbalism.HylianLuck_MaxBonusLevel", 1000); }
public double getShroomThumbChanceMax() { return config.getDouble("Skills.Herbalism.ShroomThumb_ChanceMax", 50.0D); }
public int getShroomThumbMaxLevel() { return config.getInt("Skills.Herbalism.ShroomThumb_MaxBonusLevel", 1500); }
/* MINING */ /* MINING */
public double getMiningDoubleDropChance() { return config.getDouble("Skills.Mining.DoubleDrops_ChanceMax", 100.0D); } public int getBlastMiningRankLevel(BlastMining.Tier tier) { return config.getInt("Skills.Mining.BlastMining.Rank_Levels.Rank_" + tier.toNumerical()); }
public int getMiningDoubleDropMaxLevel() { return config.getInt("Skills.Mining.DoubleDrops_MaxBonusLevel", 1000); } public double getBlastDamageDecrease(BlastMining.Tier tier) { return config.getDouble("Skills.Mining.BlastMining.BlastDamageDecrease.Rank_" + tier.toNumerical()); }
public double getOreBonus(BlastMining.Tier tier) { return config.getDouble("Skills.Mining.BlastMining.OreBonus.Rank_" + tier.toNumerical()); }
public int getBlastMiningRank1() { return config.getInt("Skills.Mining.BlastMining_Rank1", 125); } public double getDebrisReduction(BlastMining.Tier tier) { return config.getDouble("Skills.Mining.BlastMining.DebrisReduction.Rank_" + tier.toNumerical()); }
public int getBlastMiningRank2() { return config.getInt("Skills.Mining.BlastMining_Rank2", 250); } public int getDropMultiplier(BlastMining.Tier tier) { return config.getInt("Skills.Mining.BlastMining.DropMultiplier.Rank_" + tier.toNumerical()); }
public int getBlastMiningRank3() { return config.getInt("Skills.Mining.BlastMining_Rank3", 375); } public double getBlastRadiusModifier(BlastMining.Tier tier) { return config.getDouble("Skills.Mining.BlastMining.BlastRadiusModifier.Rank_" + tier.toNumerical()); }
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); }
public double getBlastDamageDecreaseRank1() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank1", 0.0D); }
public double getBlastDamageDecreaseRank2() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank2", 0.0D); }
public double getBlastDamageDecreaseRank3() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank3", 0.0D); }
public double getBlastDamageDecreaseRank4() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank4", 25.0D); }
public double getBlastDamageDecreaseRank5() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank5", 25.0D); }
public double getBlastDamageDecreaseRank6() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank6", 50.0D); }
public double getBlastDamageDecreaseRank7() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank7", 50.0D); }
public double getBlastDamageDecreaseRank8() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank8", 100.0D); }
public double getOreBonusRank1() { return config.getDouble("Skills.Mining.OreBonus_Rank1", 35.0D); }
public double getOreBonusRank2() { return config.getDouble("Skills.Mining.OreBonus_Rank2", 40.0D); }
public double getOreBonusRank3() { return config.getDouble("Skills.Mining.OreBonus_Rank3", 45.0D); }
public double getOreBonusRank4() { return config.getDouble("Skills.Mining.OreBonus_Rank4", 50.0D); }
public double getOreBonusRank5() { return config.getDouble("Skills.Mining.OreBonus_Rank5", 55.0D); }
public double getOreBonusRank6() { return config.getDouble("Skills.Mining.OreBonus_Rank6", 60.0D); }
public double getOreBonusRank7() { return config.getDouble("Skills.Mining.OreBonus_Rank7", 65.0D); }
public double getOreBonusRank8() { return config.getDouble("Skills.Mining.OreBonus_Rank8", 70.0D); }
public double getDebrisReductionRank1() { return config.getDouble("Skills.Mining.DebrisReduction_Rank1", 10.0D); }
public double getDebrisReductionRank2() { return config.getDouble("Skills.Mining.DebrisReduction_Rank2", 20.0D); }
public double getDebrisReductionRank3() { return config.getDouble("Skills.Mining.DebrisReduction_Rank3", 30.0D); }
public double getDebrisReductionRank4() { return config.getDouble("Skills.Mining.DebrisReduction_Rank4", 30.0D); }
public double getDebrisReductionRank5() { return config.getDouble("Skills.Mining.DebrisReduction_Rank5", 30.0D); }
public double getDebrisReductionRank6() { return config.getDouble("Skills.Mining.DebrisReduction_Rank6", 30.0D); }
public double getDebrisReductionRank7() { return config.getDouble("Skills.Mining.DebrisReduction_Rank7", 30.0D); }
public double getDebrisReductionRank8() { return config.getDouble("Skills.Mining.DebrisReduction_Rank8", 30.0D); }
public int getDropMultiplierRank1() { return config.getInt("Skills.Mining.DropMultiplier_Rank1", 1); }
public int getDropMultiplierRank2() { return config.getInt("Skills.Mining.DropMultiplier_Rank2", 1); }
public int getDropMultiplierRank3() { return config.getInt("Skills.Mining.DropMultiplier_Rank3", 1); }
public int getDropMultiplierRank4() { return config.getInt("Skills.Mining.DropMultiplier_Rank4", 1); }
public int getDropMultiplierRank5() { return config.getInt("Skills.Mining.DropMultiplier_Rank5", 2); }
public int getDropMultiplierRank6() { return config.getInt("Skills.Mining.DropMultiplier_Rank6", 2); }
public int getDropMultiplierRank7() { return config.getInt("Skills.Mining.DropMultiplier_Rank7", 3); }
public int getDropMultiplierRank8() { return config.getInt("Skills.Mining.DropMultiplier_Rank8", 3); }
public double getBlastRadiusModifierRank1() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank1", 1.0); }
public double getBlastRadiusModifierRank2() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank2", 1.0); }
public double getBlastRadiusModifierRank3() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank3", 2.0); }
public double getBlastRadiusModifierRank4() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank4", 2.0); }
public double getBlastRadiusModifierRank5() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank5", 3.0); }
public double getBlastRadiusModifierRank6() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank6", 3.0); }
public double getBlastRadiusModifierRank7() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank7", 4.0); }
public double getBlastRadiusModifierRank8() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank8", 4.0); }
/* REPAIR */ /* REPAIR */
public double getRepairMasteryMaxBonus() { return config.getDouble("Skills.Repair.RepairMastery_MaxBonusPercentage", 200.0D); } public double getRepairMasteryMaxBonus() { return config.getDouble("Skills.Repair.RepairMastery.MaxBonusPercentage", 200.0D); }
public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery_MaxBonusLevel", 1000); } public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery.MaxBonusLevel", 1000); }
public double getSuperRepairChanceMax() { return config.getDouble("Skills.Repair.SuperRepair_ChanceMax", 100.0D); } public int getSalvageUnlockLevel() { return config.getInt("Skills.Repair.Salvage.UnlockLevel", 600); }
public int getSuperRepairMaxLevel() { return config.getInt("Skills.Repair.SuperRepair_MaxBonusLevel", 1000); }
public int getSalvageUnlockLevel() { return config.getInt("Skills.Repair.Salvage_UnlockLevel", 600); }
/* Arcane Forging */ /* Arcane Forging */
public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Skills.Repair.Arcane_Forging.Downgrades.Enabled", true); } public int getArcaneForgingRankLevel(ArcaneForging.Tier tier) { return config.getInt("Skills.Repair.ArcaneForging.Rank_Levels.Rank_" + tier.toNumerical()); }
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 boolean getArcaneForgingEnchantLossEnabled() { return config.getBoolean("Skills.Repair.ArcaneForging.May_Lose_Enchants", true); }
public int getArcaneForgingDowngradeChanceRank3() { return config.getInt("Skills.Repair.Arcane_Forging.Downgrades.Chance.Rank_3", 25); } public double getArcaneForgingKeepEnchantsChance(ArcaneForging.Tier tier) { return config.getDouble("Skills.Repair.ArcaneForging.Keep_Enchants_Chance.Rank_" + tier.toNumerical()); }
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 boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Skills.Repair.ArcaneForging.Downgrades_Enabled", true); }
public int getArcaneForgingKeepEnchantsChanceRank1() { return config.getInt("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_1", 10); } public double getArcaneForgingDowngradeChance(ArcaneForging.Tier tier) { return config.getDouble("Skills.Repair.ArcaneForging.Downgrades_Chance.Rank_" + tier.toNumerical()); }
public int getArcaneForgingKeepEnchantsChanceRank2() { return config.getInt("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_2", 20); }
public int getArcaneForgingKeepEnchantsChanceRank3() { return config.getInt("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_3", 30); }
public int getArcaneForgingKeepEnchantsChanceRank4() { return config.getInt("Skills.Repair.Arcane_Forging.Keep_Enchants.Chance.Rank_4", 40); }
public int getArcaneForgingRankLevels1() { return config.getInt("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_1", 100); }
public int getArcaneForgingRankLevels2() { return config.getInt("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_2", 250); }
public int getArcaneForgingRankLevels3() { return config.getInt("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_3", 500); }
public int getArcaneForgingRankLevels4() { return config.getInt("Skills.Repair.Arcane_Forging.Rank_Levels.Rank_4", 750); }
/* SMELTING */ /* SMELTING */
public int getBurnModifierMaxLevel() { return config.getInt("Skills.Smelting.FuelEfficiency_MaxBonusLevel", 1000); } public int getBurnModifierMaxLevel() { return config.getInt("Skills.Smelting.FuelEfficiency.MaxBonusLevel", 1000); }
public double getBurnTimeMultiplier() { return config.getDouble("Skills.Smelting.FuelEfficiency_Multiplier", 3.0D); } public double getBurnTimeMultiplier() { return config.getDouble("Skills.Smelting.FuelEfficiency.Multiplier", 3.0D); }
public int getSecondSmeltMaxLevel() { return config.getInt("Skills.Smelting.SecondSmelt_MaxBonusLevel", 1000); } public int getFluxMiningUnlockLevel() { return config.getInt("Skills.Smelting.FluxMining.UnlockLevel", 250); }
public double getSecondSmeltMaxChance() { return config.getDouble("Skills.Smelting.SecondSmelt_MaxBonusChance", 100.0D); } public double getFluxMiningChance() { return config.getDouble("Skills.Smelting.FluxMining.Chance", 33.0D); }
public int getFluxMiningUnlockLevel() { return config.getInt("Skills.Smelting.FluxMining_UnlockLevel", 250); } public int getSmeltingRankLevel(Smelting.Tier tier) { return config.getInt("Skills.Smelting.Rank_Levels.Rank_" + tier.toNumerical()); }
public double getFluxMiningChance() { return config.getDouble("Skills.Smelting.FluxMining_Chance", 33.0D); }
public int getSmeltingVanillaXPBoostRank1Level() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank1Level", 100); } public int getSmeltingVanillaXPBoostMultiplier(Smelting.Tier tier) { return config.getInt("Skills.Smelting.VanillaXPMultiplier.Rank_" + tier.toNumerical()); }
public int getSmeltingVanillaXPBoostRank2Level() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank2Level", 300); }
public int getSmeltingVanillaXPBoostRank3Level() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank3Level", 500); }
public int getSmeltingVanillaXPBoostRank4Level() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank4Level", 700); }
public int getSmeltingVanillaXPBoostRank5Level() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank5Level", 900); }
public int getSmeltingVanillaXPBoostRank1Multiplier() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank1Multiplier", 2); }
public int getSmeltingVanillaXPBoostRank2Multiplier() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank2Multiplier", 3); }
public int getSmeltingVanillaXPBoostRank3Multiplier() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank3Multiplier", 4); }
public int getSmeltingVanillaXPBoostRank4Multiplier() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank4Multiplier", 5); }
public int getSmeltingVanillaXPBoostRank5Multiplier() { return config.getInt("Skills.Smelting.VanillaXPBoost_Rank5Multiplier", 6); }
/* SWORDS */ /* SWORDS */
public double getBleedChanceMax() { return config.getDouble("Skills.Swords.Bleed_ChanceMax", 75.0D); } public int getBleedMaxTicks() { return config.getInt("Skills.Swords.Bleed.MaxTicks", 3); }
public int getBleedMaxBonusLevel() { return config.getInt("Skills.Swords.Bleed_MaxBonusLevel", 750); } public int getBleedBaseTicks() { return config.getInt("Skills.Swords.Bleed.BaseTicks", 2); }
public int getBleedMaxTicks() { return config.getInt("Skills.Swords.Bleed_MaxTicks", 3); }
public int getBleedBaseTicks() { return config.getInt("Skills.Swords.Bleed_BaseTicks", 2); }
public double getCounterChanceMax() { return config.getDouble("Skills.Swords.Counter_ChanceMax", 30.0D); } public boolean getCounterRequiresBlock() { return config.getBoolean("Skills.Swords.Counter.RequiresBlock"); }
public int getCounterMaxBonusLevel() { return config.getInt("Skills.Swords.Counter_MaxBonusLevel", 600); } public double getCounterModifier() { return config.getDouble("Skills.Swords.Counter.DamageModifier", 2.0D); }
public int getCounterModifier() { return config.getInt("Skills.Swords.Counter_DamageModifier", 2); }
public int getSerratedStrikesModifier() { return config.getInt("Skills.Swords.SerratedStrikes_DamageModifier", 4); } public double getSerratedStrikesModifier() { return config.getDouble("Skills.Swords.SerratedStrikes.DamageModifier", 4.0D); }
public int getSerratedStrikesTicks() { return config.getInt("Skills.Swords.SerratedStrikes_BleedTicks", 5); } public int getSerratedStrikesTicks() { return config.getInt("Skills.Swords.SerratedStrikes.BleedTicks", 5); }
/* TAMING */ /* TAMING */
public double getGoreChanceMax() { return config.getInt("Skills.Taming.Gore_ChanceMax", 100); } public int getGoreBleedTicks() { return config.getInt("Skills.Taming.Gore.BleedTicks", 2); }
public int getGoreMaxBonusLevel() { return config.getInt("Skills.Taming.Gore_MaxBonusLevel", 1000); } public double getGoreModifier() { return config.getDouble("Skills.Taming.Gore.Modifier", 2.0D); }
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 getFastFoodUnlock() { return config.getInt("Skills.Taming.FastFood.UnlockLevel", 50); }
public double getFastFoodChance() { return config.getInt("Skills.Taming.FastFood_Chance", 50); } public double getFastFoodChance() { return config.getDouble("Skills.Taming.FastFood.Chance", 50.0D); }
public int getEnviromentallyAwareUnlock() { return config.getInt("Skills.Taming.EnvironmentallyAware_UnlockLevel", 100); } public int getEnviromentallyAwareUnlock() { return config.getInt("Skills.Taming.EnvironmentallyAware.UnlockLevel", 100); }
public int getThickFurUnlock() { return config.getInt("Skills.Taming.ThickFur_UnlockLevel", 250); } public int getThickFurUnlock() { return config.getInt("Skills.Taming.ThickFur.UnlockLevel", 250); }
public int getThickFurModifier() { return config.getInt("Skills.Taming.ThickFur_Modifier", 2); } public double getThickFurModifier() { return config.getDouble("Skills.Taming.ThickFur.Modifier", 2.0D); }
public int getHolyHoundUnlock() {return config.getInt("Skills.Taming.HolyHound_UnlockLevel", 375); } public int getHolyHoundUnlock() {return config.getInt("Skills.Taming.HolyHound.UnlockLevel", 375); }
public int getShockProofUnlock() { return config.getInt("Skills.Taming.ShockProof_UnlockLevel", 500); } public int getShockProofUnlock() { return config.getInt("Skills.Taming.ShockProof.UnlockLevel", 500); }
public int getShockProofModifier() { return config.getInt("Skills.Taming.ShockProof_Modifier", 6); } public double getShockProofModifier() { return config.getDouble("Skills.Taming.ShockProof.Modifier", 6.0D); }
public int getSharpenedClawsUnlock() { return config.getInt("Skills.Taming.SharpenedClaws_UnlockLevel", 750); } public int getSharpenedClawsUnlock() { return config.getInt("Skills.Taming.SharpenedClaws.UnlockLevel", 750); }
public int getSharpenedClawsBonus() { return config.getInt("Skills.Taming.SharpenedClaws_Bonus", 2); } public double getSharpenedClawsBonus() { return config.getDouble("Skills.Taming.SharpenedClaws.Bonus", 2.0D); }
public double getMaxHorseJumpStrength() { return config.getDouble("Skills.Taming.CallOfTheWild.MaxHorseJumpStrength", 2.0D); }
/* UNARMED */ /* UNARMED */
public double getDisarmChanceMax() { return config.getDouble("Skills.Unarmed.Disarm_ChanceMax", 33.0D); } public double getIronArmMinBonus() { return config.getDouble("Skills.Unarmed.IronArm.BonusMin", 3.0D); }
public int getDisarmMaxBonusLevel() { return config.getInt("Skills.Unarmed.Disarm_MaxBonusLevel", 1000); } public double getIronArmMaxBonus() { return config.getDouble("Skills.Unarmed.IronArm.BonusMax", 8.0D); }
public int getIronArmIncreaseLevel() { return config.getInt("Skills.Unarmed.IronArm.IncreaseLevel", 50); }
public double getDeflectChanceMax() { return config.getDouble("Skills.Unarmed.Deflect_ChanceMax", 50.0D); } public boolean getDisarmProtected() { return config.getBoolean("Skills.Unarmed.Disarm.AntiTheft", false); }
public int getDeflectMaxBonusLevel() { return config.getInt("Skills.Unarmed.Deflect_MaxBonusLevel", 1000); }
public double getIronGripChanceMax() { return config.getDouble("Skills.Unarmed.IronGrip_ChanceMax", 100.0D); }
public int getIronGripMaxBonusLevel() { return config.getInt("Skills.Unarmed.IronGrip_MaxBonusLevel", 1000); }
public int getIronArmMaxBonus() { return config.getInt("Skills.Unarmed.IronArm_BonusMax", 8); }
public int getIronArmIncreaseLevel() { return config.getInt("Skills.Unarmed.IronArm_IncreaseLevel", 50); }
/* WOODCUTTING */ /* WOODCUTTING */
public int getLeafBlowUnlockLevel() { return config.getInt("Skills.Woodcutting.LeafBlower_UnlockLevel", 100); } public int getLeafBlowUnlockLevel() { return config.getInt("Skills.Woodcutting.LeafBlower.UnlockLevel", 100); }
public double getWoodcuttingDoubleDropChance() { return config.getDouble("Skills.Woodcutting.DoubleDrops_ChanceMax", 100.0D); }
public int getWoodcuttingDoubleDropMaxLevel() { return config.getInt("Skills.Woodcutting.DoubleDrops_MaxBonusLevel", 1000); }
/* KRAKEN STUFF */ /* KRAKEN STUFF */
public boolean getKrakenEnabled() { return config.getBoolean("Kraken.Enabled", true); } public boolean getKrakenEnabled() { return config.getBoolean("Kraken.Enabled", true); }
public boolean getKrakenGlobalSoundsEnabled() { return config.getBoolean("Kraken.Global_Sounds", true); }
public boolean getKrakenEscapeAllowed() { return config.getBoolean("Kraken.Allow_Escaping", false); }
public int getKrakenTriesBeforeRelease() { return config.getInt("Kraken.Tries_Before_Release", 50); } public int getKrakenTriesBeforeRelease() { return config.getInt("Kraken.Tries_Before_Release", 50); }
public int getKrakenHealth() { return config.getInt("Kraken.Health", 50); } public double getKrakenHealth() { return config.getDouble("Kraken.Health", 50.0D); }
public String getKrakenName() { return config.getString("Kraken.Name", "The Kraken"); } public String getKrakenName() { return config.getString("Kraken.Name", "The Kraken"); }
public String getServerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Server", "(PLAYER) has unleashed the kraken!"); }
public String getPlayerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Player", "THE KRAKEN HAS BEEN UNLEASHED!"); }
public String getPlayerDefeatMessage() { return config.getString("Kraken.Defeated_Message.Killed", "You have slain the kraken!"); }
public String getPlayerEscapeMessage() { return config.getString("Kraken.Defeated_Message.Escape", "You have escaped from the kraken!"); }
public int getKrakenAttackInterval() { return config.getInt("Kraken.Attack_Interval_Seconds", 1); } public int getKrakenAttackInterval() { return config.getInt("Kraken.Attack_Interval_Seconds", 1); }
public int getKrakenAttackDamage() { return config.getInt("Kraken.Attack_Damage", 1); } public double getKrakenAttackDamage() { return config.getDouble("Kraken.Attack_Damage", 1.0D); }
public boolean getKrakenGlobalEffectsEnabled() { return config.getBoolean("Kraken.Global_Effects", false); }
public boolean getKrakenEscapeAllowed() { return config.getBoolean("Kraken.Allow_Escaping", false); }
public String getServerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Server", ""); }
public String getPlayerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Player", ""); }
public String getPlayerDefeatMessage() { return config.getString("Kraken.Defeated_Message.Killed", ""); }
public String getPlayerEscapeMessage() { return config.getString("Kraken.Defeated_Message.Escape", ""); }
} }

View File

@@ -63,7 +63,7 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
output = output.replace(" ", " "); output = output.replace(" ", " ");
// Rip out Bukkit's attempt to save comments at the top of the file // Rip out Bukkit's attempt to save comments at the top of the file
while (output.indexOf('#') != -1) { while (output.replaceAll("[//s]", "").startsWith("#")) {
output = output.substring(output.indexOf('\n', output.indexOf('#')) + 1); output = output.substring(output.indexOf('\n', output.indexOf('#')) + 1);
} }
@@ -90,7 +90,7 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
// Dump to the new one // Dump to the new one
for (String key : comments.keySet()) { for (String key : comments.keySet()) {
if (output.indexOf(key) != -1) { if (output.contains(key)) {
output = output.substring(0, output.indexOf(key)) + comments.get(key) + output.substring(output.indexOf(key)); output = output.substring(0, output.indexOf(key)) + comments.get(key) + output.substring(output.indexOf(key));
} }
} }

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50.config; package com.gmail.nossr50.config;
import java.util.ArrayList;
import java.util.List;
import java.util.Set; import java.util.Set;
import org.bukkit.Material; import org.bukkit.Material;
@@ -16,6 +18,7 @@ public class Config extends AutoUpdateConfigLoader {
private Config() { private Config() {
super("config.yml"); super("config.yml");
validate();
} }
public static Config getInstance() { public static Config getInstance() {
@@ -26,6 +29,167 @@ public class Config extends AutoUpdateConfigLoader {
return instance; return instance;
} }
@Override
protected boolean validateKeys() {
// Validate all the settings!
List<String> reason = new ArrayList<String>();
/* General Settings */
if (getSaveInterval() <= 0) {
reason.add("General.Save_Interval should be greater than 0!");
}
/* Mob Healthbar */
if (getMobHealthbarTime() == 0) {
reason.add("Mob_Healthbar.Display_Time cannot be 0! Set to -1 to disable or set a valid value.");
}
/* Scoreboards */
if (getRankScoreboardTime() != -1 && getRankScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Rank.Display_Time should be greater than 0, or -1!");
}
if (getStatsScoreboardTime() != -1 && getStatsScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Stats.Display_Time should be greater than 0, or -1!");
}
if (getTopScoreboardTime() != -1 && getTopScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Top.Display_Time should be greater than 0, or -1!");
}
if (getInspectScoreboardTime() != -1 && getInspectScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Inspect.Display_Time should be greater than 0, or -1!");
}
if (getSkillScoreboardTime() != -1 && getSkillScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Skill.Display_Time should be greater than 0, or -1!");
}
if (getSkillLevelUpTime() != -1 && getSkillScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Skill.Display_Time should be greater than 0, or -1!");
}
if (!(getRankUseChat() || getRankUseBoard())) {
reason.add("Either Board or Print in Scoreboard.Types.Rank must be true!");
}
if (!(getTopUseChat() || getTopUseBoard())) {
reason.add("Either Board or Print in Scoreboard.Types.Top must be true!");
}
if (!(getStatsUseChat() || getStatsUseBoard())) {
reason.add("Either Board or Print in Scoreboard.Types.Stats must be true!");
}
if (!(getInspectUseChat() || getInspectUseBoard())) {
reason.add("Either Board or Print in Scoreboard.Types.Inspect must be true!");
}
/* Database Purging */
if (getPurgeInterval() < -1) {
reason.add("Database_Purging.Purge_Interval should be greater than, or equal to -1!");
}
if (getOldUsersCutoff() != -1 && getOldUsersCutoff() <= 0) {
reason.add("Database_Purging.Old_User_Cutoff should be greater than 0 or -1!");
}
/* Hardcore Mode */
if (getHardcoreDeathStatPenaltyPercentage() < 0.01 || getHardcoreDeathStatPenaltyPercentage() > 100) {
reason.add("Hardcore.Death_Stat_Loss.Penalty_Percentage only accepts values from 0.01 to 100!");
}
if (getHardcoreVampirismStatLeechPercentage() < 0.01 || getHardcoreVampirismStatLeechPercentage() > 100) {
reason.add("Hardcore.Vampirism.Leech_Percentage only accepts values from 0.01 to 100!");
}
/* Items */
if (getChimaeraUseCost() < 1 || getChimaeraUseCost() > 64) {
reason.add("Items.Chimaera_Wing.Use_Cost only accepts values from 1 to 64!");
}
if (getChimaeraRecipeCost() < 1 || getChimaeraRecipeCost() > 9) {
reason.add("Items.Chimaera_Wing.Recipe_Cost only accepts values from 1 to 64!");
}
if (getChimaeraItem() == null) {
reason.add("Items.Chimaera_Wing.Item_Name is invalid!");
}
/* Particles */
if (getLevelUpEffectsTier() < 1) {
reason.add("Particles.LevelUp_Tier should be at least 1!");
}
/* PARTY SETTINGS */
if (getAutoPartyKickInterval() < -1) {
reason.add("Party.AutoKick_Interval should be at least -1!");
}
if (getAutoPartyKickTime() < 0) {
reason.add("Party.Old_Party_Member_Cutoff should be at least 0!");
}
if (getPartyShareBonusBase() <= 0) {
reason.add("Party.Sharing.ExpShare_bonus_base should be greater than 0!");
}
if (getPartyShareBonusIncrease() < 0) {
reason.add("Party.Sharing.ExpShare_bonus_increase should be at least 0!");
}
if (getPartyShareBonusCap() <= 0) {
reason.add("Party.Sharing.ExpShare_bonus_cap should be greater than 0!");
}
if (getPartyShareRange() <= 0) {
reason.add("Party.Sharing.Range should be greater than 0!");
}
/* Inspect command distance */
if (getInspectDistance() <= 0) {
reason.add("Commands.inspect.Max_Distance should be greater than 0!");
}
if (getTreeFellerThreshold() <= 0) {
reason.add("Abilities.Limits.Tree_Feller_Threshold should be greater than 0!");
}
if (getDetonatorItem() == null) {
reason.add("Skills.Mining.Detonator_Item is invalid!");
}
if (getRepairAnvilMaterial() == null) {
reason.add("Skills.Repair.Anvil_Type is invalid!!");
}
if (getSalvageAnvilMaterial() == null) {
reason.add("Skills.Repair.Salvage_Anvil_Type is invalid!");
}
if (getRepairAnvilMaterial() == getSalvageAnvilMaterial()) {
reason.add("Cannot use the same item for Repair and Salvage anvils!");
}
if (getTamingCOTWWolfCost() < 1) {
reason.add("Skills.Taming.Call_Of_The_Wild.Bones_Required should be at least 1!");
}
if (getTamingCOTWOcelotCost() < 1) {
reason.add("Skills.Taming.Call_Of_The_Wild.Fish_Required should be at least 1!");
}
if (getTamingCOTWAmount(EntityType.OCELOT) <= 0) {
reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot_Amount should be greater than 0!");
}
if (getTamingCOTWAmount(EntityType.WOLF) <= 0) {
reason.add("Skills.Taming.Call_Of_The_Wild.Wolf_Amount should be greater than 0!");
}
return noErrorsInConfig(reason);
}
@Override @Override
protected void loadKeys() {} protected void loadKeys() {}
@@ -42,12 +206,19 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getUpdateCheckEnabled() { return config.getBoolean("General.Update_Check", true); } public boolean getUpdateCheckEnabled() { return config.getBoolean("General.Update_Check", true); }
public boolean getPreferBeta() { return config.getBoolean("General.Prefer_Beta", false); } public boolean getPreferBeta() { return config.getBoolean("General.Prefer_Beta", false); }
public boolean getEventCallbackEnabled() { return config.getBoolean("General.Event_Callback", true); } public boolean getEventCallbackEnabled() { return config.getBoolean("General.Event_Callback", true); }
public boolean getBackupsEnabled() { return config.getBoolean("General.Generate_Backups", true); }
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); } public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); } public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); }
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); } public String getPartyChatPrefix() { return config.getString("Commands.partychat.Chat_Prefix_Format", "[[GREEN]]([[WHITE]]{0}[[GREEN]])"); }
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); } public boolean getPartyChatColorLeaderName() { return config.getBoolean("Commands.partychat.Gold_Leader_Name", true); }
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.partychat.Use_Display_Names", true); }
public String getAdminChatPrefix() { return config.getString("Commands.adminchat.Chat_Prefix_Format", "[[AQUA]][[[WHITE]]{0}[[AQUA]]]"); }
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.adminchat.Use_Display_Names", true); }
public boolean getMatchOfflinePlayers() { return config.getBoolean("Commands.Generic.Match_OfflinePlayers", false); }
public boolean getLevelUpSoundsEnabled() { return config.getBoolean("General.LevelUp_Sounds", true); }
/* Mob Healthbar */ /* Mob Healthbar */
public MobHealthbarType getMobHealthbarDefault() { public MobHealthbarType getMobHealthbarDefault() {
@@ -62,84 +233,97 @@ public class Config extends AutoUpdateConfigLoader {
public int getMobHealthbarTime() { return config.getInt("Mob_Healthbar.Display_Time", 3); } public int getMobHealthbarTime() { return config.getInt("Mob_Healthbar.Display_Time", 3); }
/* Scoreboards */ /* Scoreboards */
public boolean getMcrankScoreboardEnabled() { return config.getBoolean("Scoreboards.Mcrank.Use", true); } public boolean getRankUseChat() { return config.getBoolean("Scoreboard.Types.Rank.Print", false); }
public int getMcrankScoreboardTime() { return config.getInt("Scoreboards.Mcrank.Display_Time", 10); } public boolean getRankUseBoard() { return config.getBoolean("Scoreboard.Types.Rank.Board", true); }
public int getRankScoreboardTime() { return config.getInt("Scoreboard.Types.Rank.Display_Time", 10); }
public boolean getMcstatsScoreboardsEnabled() { return config.getBoolean("Scoreboards.Mcstats.Use", true); } public boolean getTopUseChat() { return config.getBoolean("Scoreboard.Types.Top.Print", true); }
public int getMcstatsScoreboardTime() { return config.getInt("Scoreboards.Mcstats.Display_Time", 10); } public boolean getTopUseBoard() { return config.getBoolean("Scoreboard.Types.Top.Board", true); }
public int getTopScoreboardTime() { return config.getInt("Scoreboard.Types.Top.Display_Time", 15); }
public boolean getMctopScoreboardEnabled() { return config.getBoolean("Scoreboards.Mctop.Use", true); } public boolean getStatsUseChat() { return config.getBoolean("Scoreboard.Types.Stats.Print", true); }
public int getMctopScoreboardTime() { return config.getInt("Scoreboards.Mctop.Display_Time", 10); } public boolean getStatsUseBoard() { return config.getBoolean("Scoreboard.Types.Stats.Board", true); }
public int getStatsScoreboardTime() { return config.getInt("Scoreboard.Types.Stats.Display_Time", 10); }
public boolean getInspectScoreboardEnabled() { return config.getBoolean("Scoreboards.Inspect.Use", true); } public boolean getInspectUseChat() { return config.getBoolean("Scoreboard.Types.Inspect.Print", true); }
public int getInspectScoreboardTime() { return config.getInt("Scoreboards.Inspect.Display_Time", 10); } public boolean getInspectUseBoard() { return config.getBoolean("Scoreboard.Types.Inspect.Board", true); }
public int getInspectScoreboardTime() { return config.getInt("Scoreboard.Types.Inspect.Display_Time", 25); }
public boolean getSkillScoreboardEnabled() { return config.getBoolean("Scoreboards.Skillname.Use", true); } public boolean getCooldownUseChat() { return config.getBoolean("Scoreboard.Types.Cooldown.Print", false); }
public int getSkillScoreboardTime() { return config.getInt("Scoreboards.Skillname.Display_Time", 10); } public boolean getCooldownUseBoard() { return config.getBoolean("Scoreboard.Types.Cooldown.Board", true); }
public int getCooldownScoreboardTime() { return config.getInt("Scoreboard.Types.Cooldown.Display_Time", 41); }
public boolean getPowerLevelsEnabled() { return config.getBoolean("Scoreboards.Power_Level.Use", false); } public boolean getSkillUseBoard() { return config.getBoolean("Scoreboard.Types.Skill.Board", true); }
public int getSkillScoreboardTime() { return config.getInt("Scoreboard.Types.Skill.Display_Time", 30); }
public boolean getSkillLevelUpBoard() { return config.getBoolean("Scoreboard.Types.Skill.LevelUp_Board", true); }
public int getSkillLevelUpTime() { return config.getInt("Scoreboard.Types.Skill.LevelUp_Time", 5); }
public boolean getPowerLevelTagsEnabled() { return config.getBoolean("Scoreboard.Power_Level_Tags", false); }
public boolean getAllowKeepBoard() { return config.getBoolean("Scoreboard.Allow_Keep", true); }
public boolean getScoreboardRainbows() { return config.getBoolean("Scoreboard.Rainbows", false); }
/* Database Purging */ /* Database Purging */
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); } public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
public int getOldUsersCutoff() { return config.getInt("Database_Purging.Old_User_Cutoff", 6); } public int getOldUsersCutoff() { return config.getInt("Database_Purging.Old_User_Cutoff", 6); }
/* Backups */
public boolean getBackupsEnabled() { return config.getBoolean("Backups.Enabled", true); }
public boolean getKeepLast24Hours() { return config.getBoolean("Backups.Keep.Last_24_Hours", true); }
public boolean getKeepDailyLastWeek() { return config.getBoolean("Backups.Keep.Daily_Last_Week", true); }
public boolean getKeepWeeklyPastMonth() { return config.getBoolean("Backups.Keep.Weekly_Past_Months", true); }
/* mySQL */ /* mySQL */
public boolean getUseMySQL() { return config.getBoolean("MySQL.Enabled", false); } public boolean getUseMySQL() { return config.getBoolean("MySQL.Enabled", false); }
public String getMySQLTablePrefix() { return config.getString("MySQL.Database.TablePrefix", "mcmmo_"); } public String getMySQLTablePrefix() { return config.getString("MySQL.Database.TablePrefix", "mcmmo_"); }
public String getMySQLDatabaseName() { return getStringIncludingInts(config, "MySQL.Database.Name"); } public String getMySQLDatabaseName() { return getStringIncludingInts("MySQL.Database.Name"); }
public String getMySQLUserName() { return getStringIncludingInts(config, "MySQL.Database.User_Name"); } public String getMySQLUserName() { return getStringIncludingInts("MySQL.Database.User_Name"); }
public int getMySQLServerPort() { return config.getInt("MySQL.Server.Port", 3306); } public int getMySQLServerPort() { return config.getInt("MySQL.Server.Port", 3306); }
public String getMySQLServerName() { return config.getString("MySQL.Server.Address", "localhost"); } public String getMySQLServerName() { return config.getString("MySQL.Server.Address", "localhost"); }
public String getMySQLUserPassword() { return getStringIncludingInts("MySQL.Database.User_Password"); }
public String getMySQLUserPassword() { private String getStringIncludingInts(String key) {
if (getStringIncludingInts(config, "MySQL.Database.User_Password") != null) { String str = config.getString(key);
return getStringIncludingInts(config, "MySQL.Database.User_Password");
}
return "";
}
private static String getStringIncludingInts(ConfigurationSection cfg, String key) {
String str = cfg.getString(key);
if (str == null) { if (str == null) {
str = String.valueOf(cfg.getInt(key)); str = String.valueOf(config.getInt(key));
} }
if (str == "0") { if (str.equals("0")) {
str = "No value set for '" + key + "'"; str = "No value set for '" + key + "'";
} }
return str; return str;
} }
/* Hardcore Mode */ /* Hardcore Mode */
public boolean getHardcoreEnabled() { return config.getBoolean("Hardcore.Enabled", false); } public boolean getHardcoreStatLossEnabled(SkillType skillType) { return config.getBoolean("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(skillType.toString()), false); }
public void setHardcoreEnabled(boolean enabled) { config.set("Hardcore.Enabled", enabled); } public void setHardcoreStatLossEnabled(SkillType skillType, boolean enabled) { config.set("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(skillType.toString()), enabled); }
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss_Penalty_Percentage", 75.0); } public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss.Penalty_Percentage", 75.0D); }
public void setHardcoreDeathStatPenaltyPercentage(double value) { config.set("Hardcore.Death_Stat_Loss_Penalty_Percentage", value); } public void setHardcoreDeathStatPenaltyPercentage(double value) { config.set("Hardcore.Death_Stat_Loss.Penalty_Percentage", value); }
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism_Stat_Leech_Percentage", 5.0); } public boolean getHardcoreVampirismEnabled(SkillType skillType) { return config.getBoolean("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(skillType.toString()), false); }
public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism_Stat_Leech_Percentage", value); } public void setHardcoreVampirismEnabled(SkillType skillType, boolean enabled) { config.set("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(skillType.toString()), enabled); }
public boolean getHardcoreVampirismEnabled() { return config.getBoolean("Hardcore.Vampirism", false); } public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism.Leech_Percentage", 5.0D); }
public void setHardcoreVampirismEnabled(boolean enabled) { config.set("Hardcore.Vampirism", enabled); } public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism.Leech_Percentage", value); }
/* SMP Mods */ /* SMP Mods */
public boolean getToolModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); } public boolean getToolModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
public boolean getArmorModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); } public boolean getArmorModsEnabled() { return config.getBoolean("Mods.Armor_Mods_Enabled", false); }
public boolean getBlockModsEnabled() { return config.getBoolean("Mods.Block_Mods_Enabled", false); } public boolean getBlockModsEnabled() { return config.getBoolean("Mods.Block_Mods_Enabled", false); }
public boolean getEntityModsEnabled() { return config.getBoolean("Mods.Entity_Mods_Enabled", false); } public boolean getEntityModsEnabled() { return config.getBoolean("Mods.Entity_Mods_Enabled", false); }
/* Items */ /* Items */
public int getChimaeraUseCost() { return config.getInt("Items.Chimaera_Wing.Use_Cost", 1); } public int getChimaeraUseCost() { return config.getInt("Items.Chimaera_Wing.Use_Cost", 1); }
public int getChimaeraRecipeCost() { return config.getInt("Items.Chimaera_Wing.Recipe_Cost", 5); } public int getChimaeraRecipeCost() { return config.getInt("Items.Chimaera_Wing.Recipe_Cost", 5); }
public int getChimaeraItemId() { return config.getInt("Items.Chimaera_Wing.Item_ID", 288); } public Material getChimaeraItem() { return Material.matchMaterial(config.getString("Items.Chimaera_Wing.Item_Name", "Feather")); }
public boolean getChimaeraEnabled() { return config.getBoolean("Items.Chimaera_Wing.Enabled", true); } public boolean getChimaeraEnabled() { return config.getBoolean("Items.Chimaera_Wing.Enabled", true); }
public boolean getChimaeraPreventUseUnderground() { return config.getBoolean("Items.Chimaera_Wing.Prevent_Use_Underground", true); } public boolean getChimaeraPreventUseUnderground() { return config.getBoolean("Items.Chimaera_Wing.Prevent_Use_Underground", true); }
public int getChimaeraCooldown() { return config.getInt("Items.Chimaera_Wing.Cooldown", 240); } public int getChimaeraCooldown() { return config.getInt("Items.Chimaera_Wing.Cooldown", 240); }
public int getChimaeraWarmup() { return config.getInt("Items.Chimaera_Wing.Warmup", 5); } public int getChimaeraWarmup() { return config.getInt("Items.Chimaera_Wing.Warmup", 5); }
public int getChimaeraRecentlyHurtCooldown() { return config.getInt("Items.Chimaera_Wing.RecentlyHurt_Cooldown", 60); } public int getChimaeraRecentlyHurtCooldown() { return config.getInt("Items.Chimaera_Wing.RecentlyHurt_Cooldown", 60); }
public boolean getChimaeraSoundEnabled() { return config.getBoolean("Items.Chimaera_Wing.Sound_Enabled", true); }
/* Particles */ /* Particles */
public boolean getAbilityActivationEffectEnabled() { return config.getBoolean("Particles.Ability_Activation", true); } public boolean getAbilityActivationEffectEnabled() { return config.getBoolean("Particles.Ability_Activation", true); }
@@ -155,11 +339,11 @@ public class Config extends AutoUpdateConfigLoader {
public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); } public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); }
public int getAutoPartyKickTime() { return config.getInt("Party.Old_Party_Member_Cutoff", 7); } public int getAutoPartyKickTime() { return config.getInt("Party.Old_Party_Member_Cutoff", 7); }
public boolean getExpShareEnabled() { return config.getBoolean("Party.Sharing.ExpShare_enabled", true); } public boolean getExpShareEnabled() { return config.getBoolean("Party.Sharing.ExpShare_enabled", true); }
public double getPartyShareBonusBase() { return config.getDouble("Party.Sharing.ExpShare_bonus_base", 1.1); } public double getPartyShareBonusBase() { return config.getDouble("Party.Sharing.ExpShare_bonus_base", 1.1D); }
public double getPartyShareBonusIncrease() { return config.getDouble("Party.Sharing.ExpShare_bonus_increase", 0.05); } public double getPartyShareBonusIncrease() { return config.getDouble("Party.Sharing.ExpShare_bonus_increase", 0.05D); }
public double getPartyShareBonusCap() { return config.getDouble("Party.Sharing.ExpShare_bonus_cap", 1.5); } public double getPartyShareBonusCap() { return config.getDouble("Party.Sharing.ExpShare_bonus_cap", 1.5D); }
public boolean getItemShareEnabled() { return config.getBoolean("Party.Sharing.ItemShare_enabled", true); } public boolean getItemShareEnabled() { return config.getBoolean("Party.Sharing.ItemShare_enabled", true); }
public double getPartyShareRange() { return config.getDouble("Party.Sharing.Range", 75.0); } public double getPartyShareRange() { return config.getDouble("Party.Sharing.Range", 75.0D); }
/* Party Teleport Settings */ /* Party Teleport Settings */
public int getPTPCommandCooldown() { return config.getInt("Commands.ptp.Cooldown", 120); } public int getPTPCommandCooldown() { return config.getInt("Commands.ptp.Cooldown", 120); }
@@ -170,7 +354,7 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); } public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); }
/* Inspect command distance */ /* Inspect command distance */
public double getInspectDistance() { return config.getDouble("Commands.inspect.Max_Distance", 30); } public double getInspectDistance() { return config.getDouble("Commands.inspect.Max_Distance", 30.0D); }
/* /*
* ABILITY SETTINGS * ABILITY SETTINGS
@@ -182,11 +366,10 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getAbilitiesOnlyActivateWhenSneaking() { return config.getBoolean("Abilities.Activation.Only_Activate_When_Sneaking", false); } public boolean getAbilitiesOnlyActivateWhenSneaking() { return config.getBoolean("Abilities.Activation.Only_Activate_When_Sneaking", false); }
public int getCooldown(AbilityType ability) { return config.getInt("Abilities.Cooldowns." + ability.toString()); } public int getCooldown(AbilityType ability) { return config.getInt("Abilities.Cooldowns." + ability.toString()); }
public int getMaxTicks(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); } public int getMaxLength(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); }
/* Durability Settings */ /* Durability Settings */
public boolean getAbilitiesDamageTools() { return config.getBoolean("Abilities.Tools.Durability_Loss_Enabled", true); } public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 1); }
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 2); }
/* Thresholds */ /* Thresholds */
public int getTreeFellerThreshold() { return config.getInt("Abilities.Limits.Tree_Feller_Threshold", 500); } public int getTreeFellerThreshold() { return config.getInt("Abilities.Limits.Tree_Feller_Threshold", 500); }
@@ -194,8 +377,6 @@ public class Config extends AutoUpdateConfigLoader {
/* /*
* SKILL SETTINGS * SKILL SETTINGS
*/ */
public int getXp(SkillType skill, Material material) { return config.getInt("Experience." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
public boolean getDoubleDropsEnabled(SkillType skill, Material material) { return config.getBoolean("Double_Drops." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); } public boolean getDoubleDropsEnabled(SkillType skill, Material material) { return config.getBoolean("Double_Drops." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
public boolean getDoubleDropsDisabled(SkillType skill) { public boolean getDoubleDropsDisabled(SkillType skill) {
@@ -216,18 +397,20 @@ public class Config extends AutoUpdateConfigLoader {
/* Acrobatics */ /* Acrobatics */
public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); } public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
public boolean getPreventXPAfterTeleport() { return config.getBoolean("Skills.Acrobatics.Prevent_XP_After_Teleport", true); }
/* Fishing */ /* Fishing */
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); } public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
/* Mining */ /* Mining */
public int getDetonatorItemID() { return config.getInt("Skills.Mining.Detonator_ID", 259); } public Material getDetonatorItem() { return Material.matchMaterial(config.getString("Skills.Mining.Detonator_Name", "FLINT_AND_STEEL")); }
/* Repair */ /* Repair */
public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); } public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); }
public int getRepairAnvilId() { return config.getInt("Skills.Repair.Anvil_ID", 42); } public boolean getRepairAnvilPlaceSoundsEnabled() { return config.getBoolean("Skills.Repair.Anvil_Placed_Sounds", true); }
public int getSalvageAnvilId() { return config.getInt("Skills.Repair.Salvage_Anvil_ID", 41); } public boolean getRepairAnvilUseSoundsEnabled() { return config.getBoolean("Skills.Repair.Anvil_Use_Sounds", true); }
public Material getRepairAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Repair.Anvil_Material", "IRON_BLOCK")); }
public Material getSalvageAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Repair.Salvage_Anvil_Material", "GOLD_BLOCK")); }
public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); } public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); } public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); }
public boolean getRepairConfirmRequired() { return config.getBoolean("Skills.Repair.Confirm_Required", true); } public boolean getRepairConfirmRequired() { return config.getBoolean("Skills.Repair.Confirm_Required", true); }
@@ -236,27 +419,23 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); } public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); }
/* Taming */ /* Taming */
public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); } public int getTamingCOTWHorseCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Apples_Required", 10); }
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
public int getTamingCOTWWolfCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Bones_Required", 10); } public int getTamingCOTWWolfCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Bones_Required", 10); }
public int getTamingCOTWOcelotCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Fish_Required", 10); } public int getTamingCOTWOcelotCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Fish_Required", 10); }
public double getTamingCOTWRange() { return config.getDouble("Skills.Taming.Call_Of_The_Wild.Range", 40.0D); }
public int getTamingCOTWAmount(EntityType type) { return config.getInt("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type)+ "_Amount"); }
/* Woodcutting */ /* Woodcutting */
public int getWoodcuttingXPOak() { return config.getInt("Experience.Woodcutting.Oak", 70); }
public int getWoodcuttingXPBirch() { return config.getInt("Experience.Woodcutting.Birch", 90); }
public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); }
public int getWoodcuttingXPJungle() { return config.getInt("Experience.Woodcutting.Jungle", 100); }
public int getWoodcuttingXPHugeBrownMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Brown", 70); }
public int getWoodcuttingXPHugeRedMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Red", 70); }
public boolean getOakDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Oak", true); } public boolean getOakDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Oak", true); }
public boolean getBirchDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Birch", true); } public boolean getBirchDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Birch", true); }
public boolean getSpruceDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Spruce", true); } public boolean getSpruceDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Spruce", true); }
public boolean getJungleDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Jungle", true); } public boolean getJungleDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Jungle", true); }
public boolean getTreeFellerSoundsEnabled() { return config.getBoolean("Skills.Woodcutting.Tree_Feller_Sounds", true); }
/* AFK Leveling */ /* AFK Leveling */
public boolean getAcrobaticsAFKDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); } public boolean getAcrobaticsPreventAFK() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
public boolean getHerbalismAFKDisabled() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); } public int getAcrobaticsAFKMaxTries() { return config.getInt("Skills.Acrobatics.Max_Tries_At_Same_Location", 3); }
public boolean getHerbalismPreventAFK() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
/* Level Caps */ /* Level Caps */
public int getPowerLevelCap() { public int getPowerLevelCap() {
@@ -272,27 +451,4 @@ public class Config extends AutoUpdateConfigLoader {
/* PVP & PVE Settings */ /* PVP & PVE Settings */
public boolean getPVPEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVP", true); } public boolean getPVPEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVP", true); }
public boolean getPVEEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVE", true); } public boolean getPVEEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVE", true); }
/*
* XP SETTINGS
*/
/* General Settings */
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience.Gains.Multiplier.Global", 1.0); }
public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience.Gains.Multiplier.Global", value); }
/* Combat XP Multipliers */
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience.Gains.Multiplier.PVP", 1.0); }
public double getCombatXP(EntityType entity) { return config.getDouble("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); }
public double getWitherSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Wither_Skeleton", 4.0); }
public double getSpawnedMobXpMultiplier() { return config.getDouble("Experience.Gains.Mobspawners.Multiplier", 0.0); }
/* XP Formula Multiplier */
public int getFormulaMultiplierCurve() { return config.getInt("Experience.Formula.Curve_Modifier", 20); }
public double getFormulaSkillModifier(SkillType skill) { return config.getDouble("Experience.Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }
} }

View File

@@ -1,11 +1,7 @@
package com.gmail.nossr50.config; package com.gmail.nossr50.config;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.util.List;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@@ -15,7 +11,7 @@ import com.gmail.nossr50.mcMMO;
public abstract class ConfigLoader { public abstract class ConfigLoader {
protected static final mcMMO plugin = mcMMO.p; protected static final mcMMO plugin = mcMMO.p;
protected String fileName; protected String fileName;
protected File configFile; private File configFile;
protected FileConfiguration config; protected FileConfiguration config;
public ConfigLoader(String relativePath, String fileName) { public ConfigLoader(String relativePath, String fileName) {
@@ -33,7 +29,13 @@ public abstract class ConfigLoader {
protected void loadFile() { protected void loadFile() {
if (!configFile.exists()) { if (!configFile.exists()) {
plugin.debug("Creating mcMMO " + fileName + " File..."); plugin.debug("Creating mcMMO " + fileName + " File...");
createFile();
try {
plugin.saveResource(fileName, false); // Normal files
}
catch (IllegalArgumentException ex) {
plugin.saveResource(configFile.getParentFile().getName() + File.separator + fileName, false); // Mod files
}
} }
else { else {
plugin.debug("Loading mcMMO " + fileName + " File..."); plugin.debug("Loading mcMMO " + fileName + " File...");
@@ -44,50 +46,45 @@ public abstract class ConfigLoader {
protected abstract void loadKeys(); protected abstract void loadKeys();
protected void createFile() { protected boolean validateKeys() {
configFile.getParentFile().mkdirs(); return true;
InputStream inputStream = plugin.getResource(fileName);
if (inputStream == null) {
plugin.getLogger().severe("Missing resource file: '" + fileName + "' please notify the plugin authors");
return;
} }
OutputStream outputStream = null; protected boolean noErrorsInConfig(List<String> issues) {
for (String issue : issues) {
plugin.getLogger().warning(issue);
}
try { return issues.isEmpty();
outputStream = new FileOutputStream(configFile); }
int read; protected void validate() {
byte[] bytes = new byte[1024]; if (validateKeys()) {
plugin.debug("No errors found in " + fileName + "!");
while ((read = inputStream.read(bytes)) != -1) {
outputStream.write(bytes, 0, read);
} }
} else {
catch (FileNotFoundException e) { plugin.getLogger().warning("Errors were found in " + fileName + "! mcMMO was disabled!");
e.printStackTrace(); plugin.getServer().getPluginManager().disablePlugin(plugin);
} plugin.noErrorsInConfigFiles = false;
catch (IOException e) {
e.printStackTrace();
}
finally {
if (outputStream != null) {
try {
outputStream.close();
}
catch (IOException e) {
e.printStackTrace();
} }
} }
try { public File getFile() {
inputStream.close(); return configFile;
}
catch (IOException e) {
e.printStackTrace();
}
} }
public void backup() {
plugin.getLogger().warning("You are using an old version of the " + fileName + " file.");
plugin.getLogger().warning("Your old file has been renamed to " + fileName + ".old and has been replaced by an updated version.");
configFile.renameTo(new File(configFile.getPath() + ".old"));
if (plugin.getResource(fileName) != null) {
plugin.saveResource(fileName, true);
}
plugin.getLogger().warning("Reloading " + fileName + " with new values...");
loadFile();
loadKeys();
} }
} }

View File

@@ -0,0 +1,222 @@
package com.gmail.nossr50.config.experience;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
import com.gmail.nossr50.util.StringUtils;
public class ExperienceConfig extends AutoUpdateConfigLoader {
private static ExperienceConfig instance;
private ExperienceConfig() {
super("experience.yml");
validate();
}
public static ExperienceConfig getInstance() {
if (instance == null) {
instance = new ExperienceConfig();
}
return instance;
}
@Override
protected void loadKeys() {}
@Override
protected boolean validateKeys() {
List<String> reason = new ArrayList<String>();
/*
* FORMULA SETTINGS
*/
/* Curve values */
if (getMultiplier(FormulaType.EXPONENTIAL) <= 0) {
reason.add("Experience_Formula.Exponential_Values.multiplier should be greater than 0!");
}
if (getMultiplier(FormulaType.LINEAR) <= 0) {
reason.add("Experience_Formula.Linear_Values.multiplier should be greater than 0!");
}
if (getExponent(FormulaType.EXPONENTIAL) <= 0) {
reason.add("Experience_Formula.Exponential_Values.exponent should be greater than 0!");
}
/* Global modifier */
if (getExperienceGainsGlobalMultiplier() <= 0) {
reason.add("Experience_Formula.Multiplier.Global should be greater than 0!");
}
/* PVP modifier */
if (getPlayerVersusPlayerXP() < 0) {
reason.add("Experience_Formula.Multiplier.PVP should be at least 0!");
}
/* Spawned Mob modifier */
if (getSpawnedMobXpMultiplier() < 0) {
reason.add("Experience_Formula.Mobspawners.Multiplier should be at least 0!");
}
/* Conversion */
if (getExpModifier() <= 0) {
reason.add("Conversion.Exp_Modifier should be greater than 0!");
}
/*
* XP SETTINGS
*/
/* Combat XP Multipliers */
if (getAnimalsXP() < 0) {
reason.add("Experience.Combat.Multiplier.Animals should be at least 0!");
}
if (getWitherSkeletonXP() < 0) {
reason.add("Experience.Combat.Multiplier.Wither_Skeleton should be at least 0!");
}
if (getDodgeXPModifier() < 0) {
reason.add("Skills.Acrobatics.Dodge_XP_Modifier should be at least 0!");
}
if (getRollXPModifier() < 0) {
reason.add("Skills.Acrobatics.Roll_XP_Modifier should be at least 0!");
}
if (getFallXPModifier() < 0) {
reason.add("Skills.Acrobatics.Fall_XP_Modifier should be at least 0!");
}
/* Fishing */
if (getFishingBaseXP() <= 0) {
reason.add("Experience.Fishing.Base should be greater than 0!");
}
if (getFishingShakeXP() <= 0) {
reason.add("Experience.Fishing.Shake should be greater than 0!");
}
/* Repair */
if (getRepairXPBase() <= 0) {
reason.add("Experience.Repair.Base should be greater than 0!");
}
/* Taming */
if (getTamingXPWolf() <= 0) {
reason.add("Experience.Taming.Animal_Taming.Wolf should be greater than 0!");
}
if (getTamingXPOcelot() <= 0) {
reason.add("Experience.Taming.Animal_Taming.Ocelot should be greater than 0!");
}
/* Woodcutting */
if (getWoodcuttingXPOak() <= 0) {
reason.add("Experience.Woodcutting.Oak should be greater than 0!");
}
if (getWoodcuttingXPBirch() <= 0) {
reason.add("Experience.Woodcutting.Birch should be greater than 0!");
}
if (getWoodcuttingXPSpruce() <= 0) {
reason.add("Experience.Woodcutting.Spruce should be greater than 0!");
}
if (getWoodcuttingXPJungle() <= 0) {
reason.add("Experience.Woodcutting.Jungle should be greater than 0!");
}
if (getWoodcuttingXPHugeBrownMushroom() <= 0) {
reason.add("Experience.Woodcutting.Huge_Mushroom_Brown should be greater than 0!");
}
if (getWoodcuttingXPHugeRedMushroom() <= 0) {
reason.add("Experience.Woodcutting.Huge_Mushroom_Red should be greater than 0!");
}
return noErrorsInConfig(reason);
}
/*
* FORMULA SETTINGS
*/
/* Curve settings */
public FormulaType getFormulaType() { return FormulaType.getFormulaType(config.getString("Experience_Formula.Curve")); }
public boolean getCumulativeCurveEnabled() { return config.getBoolean("Experience_Formula.Cumulative_Curve", false); }
/* Curve values */
public double getMultiplier(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.multiplier"); }
public int getBase(FormulaType type) { return config.getInt("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.base"); }
public double getExponent(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) +"_Values.exponent"); }
/* Global modifier */
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience_Formula.Multiplier.Global", 1.0); }
public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience_Formula.Multiplier.Global", value); }
/* PVP modifier */
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience_Formula.Multiplier.PVP", 1.0); }
/* Spawned Mob modifier */
public double getSpawnedMobXpMultiplier() { return config.getDouble("Experience_Formula.Mobspawners.Multiplier", 0.0); }
/* Skill modifiers */
public double getFormulaSkillModifier(SkillType skill) { return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }
/* Conversion */
public double getExpModifier() { return config.getDouble("Conversion.Exp_Modifier", 1); }
/*
* XP SETTINGS
*/
/* General Settings */
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
/* Combat XP Multipliers */
public double getCombatXP(EntityType entity) { return config.getDouble("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); }
public double getWitherSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Wither_Skeleton", 4.0); }
/* Materials */
public int getXp(SkillType skill, Material material) { return config.getInt("Experience." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
/* Acrobatics */
public int getDodgeXPModifier() { return config.getInt("Experience.Acrobatics.Dodge", 120); }
public int getRollXPModifier() { return config.getInt("Experience.Acrobatics.Roll", 80); }
public int getFallXPModifier() { return config.getInt("Experience.Acrobatics.Fall", 120); }
public double getFeatherFallXPModifier() { return config.getDouble("Experience.Acrobatics.FeatherFall_Multiplier", 2.0); }
/* Fishing */
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
public int getFishingShakeXP() { return config.getInt("Experience.Fishing.Shake", 50); }
/* Repair */
public double getRepairXPBase() { return config.getDouble("Experience.Repair.Base", 1000.0); }
public double getRepairXP(RepairMaterialType repairMaterialType) { return config.getDouble("Experience.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); }
/* Taming */
public int getTamingXPHorse() { return config.getInt("Experience.Taming.Animal_Taming.Horse", 1000); }
public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); }
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
/* Woodcutting */
public int getWoodcuttingXPOak() { return config.getInt("Experience.Woodcutting.Oak", 70); }
public int getWoodcuttingXPBirch() { return config.getInt("Experience.Woodcutting.Birch", 90); }
public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); }
public int getWoodcuttingXPJungle() { return config.getInt("Experience.Woodcutting.Jungle", 100); }
public int getWoodcuttingXPHugeBrownMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Brown", 70); }
public int getWoodcuttingXPHugeRedMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Red", 70); }
}

View File

@@ -1,33 +1,34 @@
package com.gmail.nossr50.config.mods; package com.gmail.nossr50.config.mods;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.ConfigLoader; import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.mods.CustomItem; import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.Repairable; import com.gmail.nossr50.skills.repair.repairables.RepairItemType;
import com.gmail.nossr50.skills.repair.RepairableFactory; import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
public class CustomArmorConfig extends ConfigLoader { public class CustomArmorConfig extends ConfigLoader {
private static CustomArmorConfig instance; private static CustomArmorConfig instance;
private boolean needsUpdate = false;
private List<Repairable> repairables; private List<Repairable> repairables;
public List<Integer> customBootIDs = new ArrayList<Integer>(); private List<Material> customBoots = new ArrayList<Material>();
public List<Integer> customChestplateIDs = new ArrayList<Integer>(); private List<Material> customChestplates = new ArrayList<Material>();
public List<Integer> customHelmetIDs = new ArrayList<Integer>(); private List<Material> customHelmets = new ArrayList<Material>();
public List<Integer> customLeggingIDs = new ArrayList<Integer>(); private List<Material> customLeggings = new ArrayList<Material>();
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() { public CustomArmorConfig() {
super("ModConfigs", "armor.yml"); super("mods", "armor.yml");
loadKeys(); loadKeys();
} }
@@ -51,13 +52,22 @@ public class CustomArmorConfig extends ConfigLoader {
protected void loadKeys() { protected void loadKeys() {
repairables = new ArrayList<Repairable>(); repairables = new ArrayList<Repairable>();
loadArmor("Boots", customBootIDs); loadArmor("Boots", customBoots);
loadArmor("Chestplates", customChestplateIDs); loadArmor("Chestplates", customChestplates);
loadArmor("Helmets", customHelmetIDs); loadArmor("Helmets", customHelmets);
loadArmor("Leggings", customLeggingIDs); loadArmor("Leggings", customLeggings);
if (needsUpdate) {
needsUpdate = false;
backup();
}
}
private void loadArmor(String armorType, List<Material> materialList) {
if (needsUpdate) {
return;
} }
private void loadArmor(String armorType, List<Integer> idList) {
ConfigurationSection armorSection = config.getConfigurationSection(armorType); ConfigurationSection armorSection = config.getConfigurationSection(armorType);
if (armorSection == null) { if (armorSection == null) {
@@ -67,35 +77,60 @@ public class CustomArmorConfig extends ConfigLoader {
Set<String> armorConfigSet = armorSection.getKeys(false); Set<String> armorConfigSet = armorSection.getKeys(false);
for (String armorName : armorConfigSet) { for (String armorName : armorConfigSet) {
int id = config.getInt(armorType + "." + armorName + ".ID", 0); if (config.contains(armorType + "." + armorName + "." + ".ID")) {
boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable"); needsUpdate = true;
int repairID = config.getInt(armorType + "." + armorName + ".Repair_Material_ID", 0); return;
byte repairData = (byte) config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Value", 0); }
int repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Quantity", 0);
short durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 0);
if (id == 0) { Material armorMaterial = Material.matchMaterial(armorName);
plugin.getLogger().warning("Missing ID. This item will be skipped.");
if (armorMaterial == null) {
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + armorName);
continue; continue;
} }
if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) { boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable");
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable."); Material repairMaterial = Material.matchMaterial(config.getString(armorType + "." + armorName + ".Repair_Material", ""));
if (repairMaterial == null) {
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable. - " + armorName);
repairable = false; repairable = false;
} }
CustomItem armor;
if (repairable) { if (repairable) {
repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability)); byte repairData = (byte) config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Value", -1);
int repairQuantity = Repair.getRepairAndSalvageQuantities(new ItemStack(armorMaterial), repairMaterial, repairData);
if (repairQuantity == 0) {
repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Quantity", 2);
} }
armor = new CustomItem(id, durability); short durability = armorMaterial.getMaxDurability();
idList.add(id); if (durability == 0) {
customIDs.add(id); durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 70);
customArmorList.add(armor); }
customArmor.put(id, armor);
repairables.add(RepairableFactory.getRepairable(armorMaterial, repairMaterial, repairData, 0, repairQuantity, durability, RepairItemType.ARMOR, RepairMaterialType.OTHER, 1.0));
}
materialList.add(armorMaterial);
} }
} }
public boolean isCustomBoots(Material material) {
return customBoots.contains(material);
}
public boolean isCustomChestplate(Material material) {
return customChestplates.contains(material);
}
public boolean isCustomHelmet(Material material) {
return customHelmets.contains(material);
}
public boolean isCustomLeggings(Material material) {
return customLeggings.contains(material);
}
} }

View File

@@ -1,11 +1,12 @@
package com.gmail.nossr50.config.mods; package com.gmail.nossr50.config.mods;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData; import org.bukkit.material.MaterialData;
import com.gmail.nossr50.config.ConfigLoader; import com.gmail.nossr50.config.ConfigLoader;
@@ -14,20 +15,21 @@ import com.gmail.nossr50.datatypes.mods.CustomBlock;
public class CustomBlockConfig extends ConfigLoader { public class CustomBlockConfig extends ConfigLoader {
private static CustomBlockConfig instance; private static CustomBlockConfig instance;
public List<ItemStack> customExcavationBlocks = new ArrayList<ItemStack>(); private boolean needsUpdate = false;
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>(); private List<MaterialData> customExcavationBlocks = new ArrayList<MaterialData>();
private List<MaterialData> customHerbalismBlocks = new ArrayList<MaterialData>();
private List<MaterialData> customMiningBlocks = new ArrayList<MaterialData>();
private List<MaterialData> customWoodcuttingBlocks = new ArrayList<MaterialData>();
private List<MaterialData> customOres = new ArrayList<MaterialData>();
private List<MaterialData> customLogs = new ArrayList<MaterialData>();
private List<MaterialData> customLeaves = new ArrayList<MaterialData>();
private List<MaterialData> customAbilityBlocks = new ArrayList<MaterialData>();
private HashMap<MaterialData, CustomBlock> customBlockMap = new HashMap<MaterialData, CustomBlock>();
public CustomBlockConfig() { public CustomBlockConfig() {
super("ModConfigs", "blocks.yml"); super("mods", "blocks.yml");
loadKeys(); loadKeys();
} }
@@ -46,9 +48,18 @@ public class CustomBlockConfig extends ConfigLoader {
loadBlocks("Mining", customMiningBlocks); loadBlocks("Mining", customMiningBlocks);
loadBlocks("Woodcutting", customWoodcuttingBlocks); loadBlocks("Woodcutting", customWoodcuttingBlocks);
loadBlocks("Ability_Blocks", customAbilityBlocks); loadBlocks("Ability_Blocks", customAbilityBlocks);
if (needsUpdate) {
needsUpdate = false;
backup();
}
}
private void loadBlocks(String skillType, List<MaterialData> blockList) {
if (needsUpdate) {
return;
} }
private void loadBlocks(String skillType, List<ItemStack> blockList) {
ConfigurationSection skillSection = config.getConfigurationSection(skillType); ConfigurationSection skillSection = config.getConfigurationSection(skillType);
if (skillSection == null) { if (skillSection == null) {
@@ -58,63 +69,82 @@ public class CustomBlockConfig extends ConfigLoader {
Set<String> skillConfigSet = skillSection.getKeys(false); Set<String> skillConfigSet = skillSection.getKeys(false);
for (String blockName : skillConfigSet) { for (String blockName : skillConfigSet) {
int id = config.getInt(skillType + "." + blockName + ".ID", 0); if (config.contains(skillType + "." + blockName + "." + ".Drop_Item")) {
byte data = (byte) config.getInt(skillType + "." + blockName + ".Data_Value", 0); needsUpdate = true;
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain", 0); return;
int tier = config.getInt(skillType + "." + blockName + ".Tier", 1); }
boolean dropItem = config.getBoolean(skillType + "." + blockName + ".Drop_Item", false);
int dropID = config.getInt(skillType + "." + blockName + ".Drop_Item_ID", 0);
byte dropData = (byte) config.getInt(skillType + "." + blockName + ".Drop_Item_Data_Value", 0);
int minimumDropAmount = config.getInt(skillType + "." + blockName + ".Min_Drop_Item_Amount", 1);
int maxiumDropAmount = config.getInt(skillType + "." + blockName + ".Max_Drop_Item_Amount", 1);
CustomBlock block; String[] blockInfo = blockName.split("[|]");
ItemStack itemDrop;
ItemStack blockItem;
if (id == 0) { Material blockMaterial = Material.matchMaterial(blockInfo[0]);
plugin.getLogger().warning("Missing ID. This block will be skipped.");
if (blockMaterial == null) {
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + blockInfo[0]);
continue; continue;
} }
byte blockData = (blockInfo.length == 2) ? Byte.valueOf(blockInfo[1]) : 0;
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
blockList.add(blockMaterialData);
if (skillType.equals("Ability_Blocks")) { if (skillType.equals("Ability_Blocks")) {
blockItem = (new MaterialData(id, data)).toItemStack(1);
blockList.add(blockItem);
continue; continue;
} }
if (dropItem && dropID == 0) { int xp = config.getInt(skillType + "." + blockName + ".XP_Gain");
plugin.getLogger().warning("Incomplete item drop information. This block will drop itself."); int smeltingXp = 0;
dropItem = false;
}
if (dropItem) {
itemDrop = (new MaterialData(dropID, dropData)).toItemStack(1);
}
else {
itemDrop = (new MaterialData(id, data)).toItemStack(1);
}
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")) { if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
customOres.add(blockItem); customOres.add(blockMaterialData);
smeltingXp = config.getInt(skillType + "." + blockName + ".Smelting_XP_Gain", xp / 10);
} }
else if (skillType.equals("Woodcutting")) { else if (skillType.equals("Woodcutting")) {
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) { if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
customLogs.add(blockItem); customLogs.add(blockMaterialData);
} }
else { else {
customLeaves.add(blockItem); customLeaves.add(blockMaterialData);
block.setXpGain(0); // Leaves don't grant XP xp = 0; // Leaves don't grant XP
} }
} }
blockList.add(blockItem); customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
customItems.add(blockItem);
customBlocks.add(block);
} }
} }
public CustomBlock getCustomBlock(MaterialData data) {
return customBlockMap.get(data);
}
public boolean isCustomOre(MaterialData data) {
return customOres.contains(data);
}
public boolean isCustomLog(MaterialData data) {
return customLogs.contains(data);
}
public boolean isCustomLeaf(MaterialData data) {
return customLeaves.contains(data);
}
public boolean isCustomAbilityBlock(MaterialData data) {
return customAbilityBlocks.contains(data);
}
public boolean isCustomExcavationBlock(MaterialData data) {
return customExcavationBlocks.contains(data);
}
public boolean isCustomHerbalismBlock(MaterialData data) {
return customHerbalismBlocks.contains(data);
}
public boolean isCustomMiningBlock(MaterialData data) {
return customMiningBlocks.contains(data);
}
public boolean isCustomWoodcuttingBlock(MaterialData data) {
return customWoodcuttingBlocks.contains(data);
}
} }

View File

@@ -1,29 +1,24 @@
package com.gmail.nossr50.config.mods; package com.gmail.nossr50.config.mods;
import java.util.ArrayList; import java.util.HashMap;
import java.util.List;
import java.util.Set;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.Material;
import org.bukkit.entity.EntityType; import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack; import org.bukkit.material.MaterialData;
import com.gmail.nossr50.config.ConfigLoader; import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.mods.CustomEntity; import com.gmail.nossr50.datatypes.mods.CustomEntity;
import org.apache.commons.lang.ClassUtils;
public class CustomEntityConfig extends ConfigLoader { public class CustomEntityConfig extends ConfigLoader {
private static CustomEntityConfig instance; private static CustomEntityConfig instance;
public List<Integer> customEntityIds = new ArrayList<Integer>(); private HashMap<String, CustomEntity> customEntityClassMap = new HashMap<String, CustomEntity>();
public List<Integer> customHostileEntityIds = new ArrayList<Integer>(); private HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<String, CustomEntity>();
public List<Integer> customNeutralEntityIds = new ArrayList<Integer>();
public List<Integer> customPassiveEntityIds = new ArrayList<Integer>();
public List<EntityType> customEntityTypes = new ArrayList<EntityType>();
public List<CustomEntity> customEntities = new ArrayList<CustomEntity>();
public CustomEntityConfig() { public CustomEntityConfig() {
super("ModConfigs", "entities.yml"); super("mods", "entities.yml");
loadKeys(); loadKeys();
} }
@@ -37,48 +32,86 @@ public class CustomEntityConfig extends ConfigLoader {
@Override @Override
protected void loadKeys() { protected void loadKeys() {
loadMobs("Hostile", customHostileEntityIds); if (config.getConfigurationSection("Hostile") != null) {
loadMobs("Neutral", customNeutralEntityIds); backup();
loadMobs("Passive", customPassiveEntityIds);
}
private void loadMobs(String entityType, List<Integer> entityIdList) {
ConfigurationSection entitySection = config.getConfigurationSection(entityType);
if (entitySection == null) {
return; return;
} }
Set<String> entityConfigSet = entitySection.getKeys(false); for (String entityName : config.getKeys(false)) {
Class<?> clazz = null;
String className = config.getString(entityName + ".Class", "");
for (String entityName : entityConfigSet) { try {
int id = config.getInt(entityType + "." + entityName + ".ID", 0); clazz = ClassUtils.getClass(className);
EntityType type = EntityType.fromId(id); }
double xpMultiplier = config.getDouble(entityType + "." + entityName + ".XP_Multiplier", 1.0D); catch (ClassNotFoundException e) {
boolean canBeTamed = config.getBoolean(entityType + "." + entityName + ".Tameable", false); plugin.getLogger().warning("Invalid class (" + className + ") detected for " + entityName + ".");
int tamingXp = config.getInt(entityType + "." + entityName + "Taming_XP", 0); plugin.getLogger().warning("This custom entity may not function properly.");
boolean canBeSummoned = config.getBoolean(entityType + "." + entityName + "CanBeSummoned", false);
int callOfTheWildId = config.getInt(entityType + "." + entityName + "COTW_Material_ID", 0);
int callOfTheWildData = config.getInt(entityType + "." + entityName + "COTW_Material_Data", 0);
int callOfTheWildAmount = config.getInt(entityType + "." + entityName + "COTW_Material_Amount", 0);
CustomEntity entity;
if (id == 0) {
plugin.getLogger().warning("Missing ID. This block will be skipped.");
continue;
} }
if (canBeSummoned && (callOfTheWildId == 0 || callOfTheWildAmount == 0)) { String entityTypeName = entityName.replace("_", ".");
plugin.getLogger().warning("Incomplete Call of the Wild information. This enitity will not be able to be summoned by Call of the Wild."); double xpMultiplier = config.getDouble(entityName + ".XP_Multiplier", 1.0D);
boolean canBeTamed = config.getBoolean(entityName + ".Tameable");
int tamingXp = config.getInt(entityName + ".Taming_XP");
boolean canBeSummoned = config.getBoolean(entityName + ".CanBeSummoned");
Material callOfTheWildMaterial = Material.matchMaterial(config.getString(entityName + ".COTW_Material", ""));
byte callOfTheWildData = (byte) config.getInt(entityName + ".COTW_Material_Data");
int callOfTheWildAmount = config.getInt(entityName + ".COTW_Material_Amount");
if (canBeSummoned && (callOfTheWildMaterial == null || callOfTheWildAmount == 0)) {
plugin.getLogger().warning("Incomplete Call of the Wild information. This entity will not be able to be summoned by Call of the Wild.");
canBeSummoned = false; canBeSummoned = false;
} }
entity = new CustomEntity(id, type, xpMultiplier, canBeTamed, tamingXp, canBeSummoned, new ItemStack(callOfTheWildId, callOfTheWildData), callOfTheWildAmount); CustomEntity entity = new CustomEntity(xpMultiplier, canBeTamed, tamingXp, canBeSummoned, (canBeSummoned ? new MaterialData(callOfTheWildMaterial, callOfTheWildData).toItemStack(1) : null), callOfTheWildAmount);
entityIdList.add(id); customEntityTypeMap.put(entityTypeName, entity);
customEntityTypes.add(type); customEntityClassMap.put(clazz == null ? null : clazz.getName(), entity);
customEntities.add(entity); }
}
public boolean isCustomEntity(Entity entity) {
if (customEntityTypeMap.containsKey(entity.getType().toString())) {
return true;
}
try {
return customEntityClassMap.containsKey(((Class<?>) entity.getClass().getDeclaredField("entityClass").get(entity)).getName());
}
catch (Exception e) {
if (e instanceof NoSuchFieldException || e instanceof IllegalArgumentException || e instanceof IllegalAccessException) {
return customEntityClassMap.containsKey(entity.getClass().getName());
}
e.printStackTrace();
return false;
}
}
public CustomEntity getCustomEntity(Entity entity) {
CustomEntity customEntity = customEntityTypeMap.get(entity.getType().toString());
if (customEntity == null) {
try {
customEntity = customEntityClassMap.get(((Class<?>) entity.getClass().getDeclaredField("entityClass").get(entity)).getName());
}
catch (Exception e) {
if (e instanceof NoSuchFieldException || e instanceof IllegalArgumentException || e instanceof IllegalAccessException) {
customEntity = customEntityClassMap.get(entity.getClass().getName());
}
else {
e.printStackTrace();
} }
} }
} }
return customEntity;
}
public void addEntity(CustomEntity customEntity, String className, String entityName) {
customEntityTypeMap.put(entityName, customEntity);
customEntityClassMap.put(className, customEntity);
}
}

View File

@@ -5,28 +5,36 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.ConfigLoader; import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.mods.CustomTool; import com.gmail.nossr50.datatypes.mods.CustomTool;
import com.gmail.nossr50.skills.repair.Repairable; import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.RepairableFactory; import com.gmail.nossr50.skills.repair.repairables.RepairItemType;
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
public class CustomToolConfig extends ConfigLoader { public class CustomToolConfig extends ConfigLoader {
private static CustomToolConfig instance; private static CustomToolConfig instance;
private boolean needsUpdate = false;
private List<Repairable> repairables; private List<Repairable> repairables;
public List<Integer> customAxeIDs = new ArrayList<Integer>();
public List<Integer> customBowIDs = new ArrayList<Integer>(); private List<Material> customAxes = new ArrayList<Material>();
public List<Integer> customHoeIDs = new ArrayList<Integer>(); private List<Material> customBows = new ArrayList<Material>();
public List<Integer> customPickaxeIDs = new ArrayList<Integer>(); private List<Material> customHoes = new ArrayList<Material>();
public List<Integer> customShovelIDs = new ArrayList<Integer>(); private List<Material> customPickaxes = new ArrayList<Material>();
public List<Integer> customSwordIDs = new ArrayList<Integer>(); private List<Material> customShovels = new ArrayList<Material>();
public List<Integer> customIDs = new ArrayList<Integer>(); private List<Material> customSwords = new ArrayList<Material>();
public List<CustomTool> customToolList = new ArrayList<CustomTool>();
public HashMap<Integer, CustomTool> customTools = new HashMap<Integer, CustomTool>(); private HashMap<Material, CustomTool> customToolMap = new HashMap<Material, CustomTool>();
private CustomToolConfig() { private CustomToolConfig() {
super("ModConfigs", "tools.yml"); super("mods", "tools.yml");
loadKeys(); loadKeys();
} }
@@ -50,15 +58,24 @@ public class CustomToolConfig extends ConfigLoader {
protected void loadKeys() { protected void loadKeys() {
repairables = new ArrayList<Repairable>(); repairables = new ArrayList<Repairable>();
loadTool("Axes", customAxeIDs); loadTool("Axes", customAxes);
loadTool("Bows", customBowIDs); loadTool("Bows", customBows);
loadTool("Hoes", customHoeIDs); loadTool("Hoes", customHoes);
loadTool("Pickaxes", customPickaxeIDs); loadTool("Pickaxes", customPickaxes);
loadTool("Shovels", customShovelIDs); loadTool("Shovels", customShovels);
loadTool("Swords", customSwordIDs); loadTool("Swords", customSwords);
if (needsUpdate) {
needsUpdate = false;
backup();
}
}
private void loadTool(String toolType, List<Material> materialList) {
if (needsUpdate) {
return;
} }
private void loadTool(String toolType, List<Integer> idList) {
ConfigurationSection toolSection = config.getConfigurationSection(toolType); ConfigurationSection toolSection = config.getConfigurationSection(toolType);
if (toolSection == null) { if (toolSection == null) {
@@ -68,38 +85,83 @@ public class CustomToolConfig extends ConfigLoader {
Set<String> toolConfigSet = toolSection.getKeys(false); Set<String> toolConfigSet = toolSection.getKeys(false);
for (String toolName : toolConfigSet) { for (String toolName : toolConfigSet) {
int id = config.getInt(toolType + "." + toolName + ".ID", 0); if (config.contains(toolType + "." + toolName + "." + ".ID")) {
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0); needsUpdate = true;
boolean abilityEnabled = config.getBoolean(toolType + "." + toolName + ".Ability_Enabled", true); return;
int tier = config.getInt(toolType + "." + toolName + ".Tier", 1); }
boolean repairable = config.getBoolean(toolType + "." + toolName + ".Repairable");
int repairID = config.getInt(toolType + "." + toolName + ".Repair_Material_ID", 0);
byte repairData = (byte) config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Value", 0);
int repairQuantity = config.getInt(toolType + "." + toolName + ".Repair_Material_Quantity", 0);
short durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 0);
if (id == 0) { Material toolMaterial = Material.matchMaterial(toolName);
plugin.getLogger().warning("Missing ID. This item will be skipped.");
if (toolMaterial == null) {
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + toolName);
continue; continue;
} }
if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) { boolean repairable = config.getBoolean(toolType + "." + toolName + ".Repairable");
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable."); Material repairMaterial = Material.matchMaterial(config.getString(toolType + "." + toolName + ".Repair_Material", ""));
if (repairMaterial == null) {
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable. - " + toolName);
repairable = false; repairable = false;
} }
CustomTool tool;
if (repairable) { if (repairable) {
repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability)); byte repairData = (byte) config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Value", -1);
int repairQuantity = Repair.getRepairAndSalvageQuantities(new ItemStack(toolMaterial), repairMaterial, repairData);
if (repairQuantity == 0) {
repairQuantity = config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Quantity", 2);
} }
tool = new CustomTool(tier, abilityEnabled, multiplier, durability, id); short durability = toolMaterial.getMaxDurability();
idList.add(id); if (durability == 0) {
customIDs.add(id); durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 60);
customToolList.add(tool); }
customTools.put(id, tool);
repairables.add(RepairableFactory.getRepairable(toolMaterial, repairMaterial, repairData, 0, repairQuantity, durability, RepairItemType.TOOL, RepairMaterialType.OTHER, 1.0));
}
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);
boolean abilityEnabled = config.getBoolean(toolType + "." + toolName + ".Ability_Enabled", true);
int tier = config.getInt(toolType + "." + toolName + ".Tier", 1);
CustomTool tool = new CustomTool(tier, abilityEnabled, multiplier);
materialList.add(toolMaterial);
customToolMap.put(toolMaterial, tool);
} }
} }
public boolean isCustomAxe(Material material) {
return customAxes.contains(material);
}
public boolean isCustomBow(Material material) {
return customBows.contains(material);
}
public boolean isCustomHoe(Material material) {
return customHoes.contains(material);
}
public boolean isCustomPickaxe(Material material) {
return customPickaxes.contains(material);
}
public boolean isCustomShovel(Material material) {
return customShovels.contains(material);
}
public boolean isCustomSword(Material material) {
return customSwords.contains(material);
}
public boolean isCustomTool(Material material) {
return customToolMap.containsKey(material);
}
public CustomTool getCustomTool(Material material) {
return customToolMap.get(material);
}
} }

View File

@@ -1,75 +0,0 @@
package com.gmail.nossr50.config.spout;
import org.getspout.spoutapi.keyboard.Keyboard;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
public class SpoutConfig extends ConfigLoader {
private static SpoutConfig instance;
private SpoutConfig() {
super("spout.yml");
}
public static SpoutConfig getInstance() {
if (instance == null) {
instance = new SpoutConfig();
}
return instance;
}
@Override
protected void loadKeys() {
// Setup default HUD
}
public HudType getDefaultHudType() {
try {
return HudType.valueOf(config.getString("Spout.HUD.Default", "STANDARD").toUpperCase().trim());
}
catch (IllegalArgumentException ex) {
return HudType.STANDARD;
}
}
public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); }
public Keyboard getMenuKey() {
try {
return Keyboard.valueOf(config.getString("Menu.Key", "KEY_M").toUpperCase().trim());
}
catch (IllegalArgumentException ex) {
return Keyboard.KEY_M;
}
}
/* XP Bar */
public boolean getXPBarEnabled() { return config.getBoolean("XP.Bar.Enabled", true); }
public void setXPBarEnabled(boolean enabled) { config.set("XP.Bar.Enabled", enabled); }
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 getRetroHUDRed(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
public double getRetroHUDGreen(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
public double getRetroHUDBlue(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
/* Notification Tiers */
public int getNotificationTier1() { return config.getInt("Notifications.Tier1", 200); }
public int getNotificationTier2() { return config.getInt("Notifications.Tier2", 400); }
public int getNotificationTier3() { return config.getInt("Notifications.Tier3", 600); }
public int getNotificationTier4() { return config.getInt("Notifications.Tier4", 800); }
}

View File

@@ -3,24 +3,26 @@ package com.gmail.nossr50.config.treasure;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.bukkit.DyeColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.Dye;
import org.bukkit.potion.Potion; import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionType; import org.bukkit.potion.PotionType;
import com.gmail.nossr50.config.ConfigLoader; import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.treasure.EnchantmentTreasure;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.datatypes.treasure.FishingTreasure; import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
import com.gmail.nossr50.datatypes.treasure.HylianTreasure; import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
import com.gmail.nossr50.datatypes.treasure.Rarity;
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure; import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
import com.gmail.nossr50.datatypes.treasure.Treasure; import com.gmail.nossr50.util.EnchantmentUtils;
public class TreasureConfig extends ConfigLoader { public class TreasureConfig extends ConfigLoader {
private static TreasureConfig instance; private static TreasureConfig instance;
@@ -32,6 +34,7 @@ public class TreasureConfig extends ConfigLoader {
public List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>(); public List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>(); public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>(); public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromSnow = new ArrayList<ExcavationTreasure>();
public List<HylianTreasure> hylianFromBushes = new ArrayList<HylianTreasure>(); public List<HylianTreasure> hylianFromBushes = new ArrayList<HylianTreasure>();
public List<HylianTreasure> hylianFromFlowers = new ArrayList<HylianTreasure>(); public List<HylianTreasure> hylianFromFlowers = new ArrayList<HylianTreasure>();
@@ -45,6 +48,7 @@ public class TreasureConfig extends ConfigLoader {
public List<ShakeTreasure> shakeFromCreeper = new ArrayList<ShakeTreasure>(); public List<ShakeTreasure> shakeFromCreeper = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromEnderman = new ArrayList<ShakeTreasure>(); public List<ShakeTreasure> shakeFromEnderman = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromGhast = new ArrayList<ShakeTreasure>(); public List<ShakeTreasure> shakeFromGhast = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromHorse = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromIronGolem = new ArrayList<ShakeTreasure>(); public List<ShakeTreasure> shakeFromIronGolem = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromMagmaCube = new ArrayList<ShakeTreasure>(); public List<ShakeTreasure> shakeFromMagmaCube = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromMushroomCow = new ArrayList<ShakeTreasure>(); public List<ShakeTreasure> shakeFromMushroomCow = new ArrayList<ShakeTreasure>();
@@ -58,11 +62,13 @@ public class TreasureConfig extends ConfigLoader {
public List<ShakeTreasure> shakeFromWitch = new ArrayList<ShakeTreasure>(); public List<ShakeTreasure> shakeFromWitch = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromZombie = new ArrayList<ShakeTreasure>(); public List<ShakeTreasure> shakeFromZombie = new ArrayList<ShakeTreasure>();
public List<FishingTreasure> fishingRewards = new ArrayList<FishingTreasure>(); public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<Rarity, List<FishingTreasure>>();
public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<Rarity, List<EnchantmentTreasure>>();
private TreasureConfig() { private TreasureConfig() {
super("treasures.yml"); super("treasures.yml");
loadKeys(); loadKeys();
validate();
} }
public static TreasureConfig getInstance() { public static TreasureConfig getInstance() {
@@ -73,379 +79,349 @@ public class TreasureConfig extends ConfigLoader {
return instance; return instance;
} }
@Override
protected boolean validateKeys() {
// Validate all the settings!
List<String> reason = new ArrayList<String>();
for (String tier : config.getConfigurationSection("Enchantment_Drop_Rates").getKeys(false)) {
double totalEnchantDropRate = 0;
double totalItemDropRate = 0;
for (Rarity rarity : Rarity.values()) {
double enchantDropRate = config.getDouble("Enchantment_Drop_Rates." + tier + "." + rarity.toString());
double itemDropRate = config.getDouble("Item_Drop_Rates." + tier + "." + rarity.toString());
if ((enchantDropRate < 0.0 || enchantDropRate > 100.0) && rarity != Rarity.TRAP && rarity != Rarity.RECORD) {
reason.add("The enchant drop rate for " + tier + " items that are " + rarity.toString() + "should be between 0.0 and 100.0!");
}
if (itemDropRate < 0.0 || itemDropRate > 100.0) {
reason.add("The item drop rate for " + tier + " items that are " + rarity.toString() + "should be between 0.0 and 100.0!");
}
totalEnchantDropRate += enchantDropRate;
totalItemDropRate += itemDropRate;
}
if (totalEnchantDropRate < 0 || totalEnchantDropRate > 100.0) {
reason.add("The total enchant drop rate for " + tier + " should be between 0.0 and 100.0!");
}
if (totalItemDropRate < 0 || totalItemDropRate > 100.0) {
reason.add("The total item drop rate for " + tier + " should be between 0.0 and 100.0!");
}
}
return noErrorsInConfig(reason);
}
@Override @Override
protected void loadKeys() { protected void loadKeys() {
Map<String, Treasure> treasures = new HashMap<String, Treasure>(); if (config.getConfigurationSection("Treasures") != null) {
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures"); backup();
return;
}
loadTreaures("Fishing");
loadTreaures("Excavation");
loadTreaures("Hylian_Luck");
loadEnchantments();
for (EntityType entity : EntityType.values()) {
if (entity.isAlive()) {
loadTreaures("Shake." + entity.toString());
}
}
}
private void loadTreaures(String type) {
boolean isFishing = type.equals("Fishing");
boolean isShake = type.contains("Shake");
boolean isExcavation = type.equals("Excavation");
boolean isHylian = type.equals("Hylian_Luck");
ConfigurationSection treasureSection = config.getConfigurationSection(type);
if (treasureSection == null) { if (treasureSection == null) {
return; return;
} }
Set<String> treasureConfigSet = treasureSection.getKeys(false); // Initialize fishing HashMap
for (Rarity rarity : Rarity.values()) {
for (String treasureName : treasureConfigSet) { if (!fishingRewards.containsKey(rarity)) {
fishingRewards.put(rarity, (new ArrayList<FishingTreasure>()));
}
}
for (String treasureName : treasureSection.getKeys(false)) {
// Validate all the things! // Validate all the things!
List<String> reason = new ArrayList<String>(); List<String> reason = new ArrayList<String>();
/* /*
* ID, Amount, and Data * Material, Amount, and Data
*/ */
Material material;
if (!config.contains("Treasures." + treasureName + ".ID")) { if (treasureName.contains("POTION")) {
reason.add("Missing ID"); material = Material.POTION;
}
else if (treasureName.contains("INK_SACK")) {
material = Material.INK_SACK;
}
else {
material = Material.matchMaterial(treasureName);
} }
if (!config.contains("Treasures." + treasureName + ".Amount")) { int amount = config.getInt(type + "." + treasureName + ".Amount");
reason.add("Missing Amount"); int data = config.getInt(type + "." + treasureName + ".Data");
if (material == null) {
reason.add("Invalid material: " + treasureName);
} }
if (!config.contains("Treasures." + treasureName + ".Data")) { if (amount <= 0) {
reason.add("Missing Data"); reason.add("Amount of " + treasureName + " must be greater than 0! " + amount);
} }
int id = config.getInt("Treasures." + treasureName + ".ID"); if (material != null && material.isBlock() && (data > 127 || data < -128)) {
int amount = config.getInt("Treasures." + treasureName + ".Amount"); reason.add("Data of " + treasureName + " is invalid! " + data);
int data = config.getInt("Treasures." + treasureName + ".Data");
if (Material.getMaterial(id) == null) {
reason.add("Invalid id: " + id);
}
if (amount < 1) {
reason.add("Invalid amount: " + amount);
}
if (id < 256 && (data > 127 || data < -128)) {
reason.add("Invalid data: " + data);
} }
/* /*
* XP, Drop Chance, and Drop Level * XP, Drop Chance, and Drop Level
*/ */
if (!config.contains("Treasures." + treasureName + ".XP")) { int xp = config.getInt(type + "." + treasureName + ".XP");
reason.add("Missing XP"); double dropChance = config.getDouble(type + "." + treasureName + ".Drop_Chance");
} int dropLevel = config.getInt(type + "." + treasureName + ".Drop_Level");
if (!config.contains("Treasures." + treasureName + ".Drop_Chance")) {
reason.add("Missing Drop_Chance");
}
if (!config.contains("Treasures." + treasureName + ".Drop_Level")) {
reason.add("Missing Drop_Level");
}
int xp = config.getInt("Treasures." + treasureName + ".XP");
Double dropChance = config.getDouble("Treasures." + treasureName + ".Drop_Chance");
int dropLevel = config.getInt("Treasures." + treasureName + ".Drop_Level");
if (xp < 0) { if (xp < 0) {
reason.add("Invalid xp: " + xp); reason.add(treasureName + " has an invalid XP value: " + xp);
} }
if (dropChance < 0) { if (dropChance < 0.0D) {
reason.add("Invalid Drop_Chance: " + dropChance); reason.add(treasureName + " has an invalid Drop_Chance: " + dropChance);
} }
if (dropLevel < 0) { if (dropLevel < 0) {
reason.add("Invalid Drop_Level: " + dropLevel); reason.add(treasureName + " has an invalid Drop_Level: " + dropLevel);
} }
/* /*
* Potions * Specific Types
*/ */
Rarity rarity = null;
if (isFishing) {
rarity = Rarity.getRarity(config.getString(type + "." + treasureName + ".Rarity"));
if (rarity == null) {
reason.add("Invalid Rarity for item: " + treasureName);
}
}
/*
* Itemstack
*/
ItemStack item = null; ItemStack item = null;
if (config.contains("Treasures." + treasureName + ".Potion_Type")) { if (treasureName.contains("POTION")) {
String potionType = config.getString("Treasures." + treasureName + ".Potion_Type"); String potionType = treasureName.substring(7);
try { try {
item = new Potion(PotionType.valueOf(potionType.toUpperCase())).toItemStack(amount); item = new Potion(PotionType.valueOf(potionType.toUpperCase().trim())).toItemStack(amount);
} }
catch (IllegalArgumentException ex) { catch (IllegalArgumentException ex) {
reason.add("Invalid Potion_Type: " + potionType); reason.add("Invalid Potion_Type: " + potionType);
} }
} }
else { else if (treasureName.contains("INK_SACK")) {
item = (new MaterialData(id, (byte) data)).toItemStack(amount); String color = treasureName.substring(9);
}
/*
* Drops From & Max Level
*/
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) {
reason.add("This can only be a fishing drop.");
}
if (!config.contains("Treasures." + treasureName + ".Max_Level")) {
reason.add("Missing Max_Level");
}
int maxLevel = config.getInt("Treasures." + treasureName + ".Max_Level");
if (noErrorsInTreasure(reason)) {
FishingTreasure fTreasure = new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel);
treasures.put(treasureName, fTreasure);
}
}
else if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Shake", false)) {
if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) {
reason.add("This can only be a shake drop.");
}
if (!config.contains("Treasures." + treasureName + ".Mob")) {
reason.add("Missing Mob");
}
String mobType = config.getString("Treasures." + treasureName + ".Mob");
EntityType mob = null;
try { try {
mob = EntityType.valueOf(mobType.toUpperCase().trim()); Dye dye = new Dye();
dye.setColor(DyeColor.valueOf(color.toUpperCase().trim()));
item = dye.toItemStack(amount);
} }
catch (IllegalArgumentException ex) { catch (IllegalArgumentException ex) {
reason.add("Invalid Mob: " + mobType); reason.add("Invalid Dye_Color: " + color);
}
}
else if (material != null) {
item = new ItemStack(material, amount, (short) data);
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(config.getString(type + "." + treasureName + "Custom_Name"));
item.setItemMeta(itemMeta);
} }
if (noErrorsInTreasure(reason)) { if (config.contains(type + "." + treasureName + ".Lore")) {
ShakeTreasure sTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel, mob); ItemMeta itemMeta = item.getItemMeta();
treasures.put(treasureName, sTreasure); itemMeta.setLore(config.getStringList(type + "." + treasureName + "Custom_Name"));
item.setItemMeta(itemMeta);
} }
} }
else {
ExcavationTreasure eTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
HylianTreasure hTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Dirt", false)) {
eTreasure.setDropsFromDirt();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Grass", false)) { if (noErrorsInConfig(reason)) {
eTreasure.setDropsFromGrass(); if (isFishing) {
fishingRewards.get(rarity).add(new FishingTreasure(item, xp));
}
else if (isShake) {
ShakeTreasure shakeTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel);
if (type.equals("Shake.BLAZE")) {
shakeFromBlaze.add(shakeTreasure);
}
else if (type.equals("Shake.CAVE_SPIDER")) {
shakeFromCaveSpider.add(shakeTreasure);
}
else if (type.equals("Shake.CHICKEN")) {
shakeFromChicken.add(shakeTreasure);
}
else if (type.equals("Shake.COW")) {
shakeFromCow.add(shakeTreasure);
}
else if (type.equals("Shake.CREEPER")) {
shakeFromCreeper.add(shakeTreasure);
}
else if (type.equals("Shake.ENDERMAN")) {
shakeFromEnderman.add(shakeTreasure);
}
else if (type.equals("Shake.GHAST")) {
shakeFromGhast.add(shakeTreasure);
}
else if (type.equals("Shake.HORSE")) {
shakeFromHorse.add(shakeTreasure);
}
else if (type.equals("Shake.IRON_GOLEM")) {
shakeFromIronGolem.add(shakeTreasure);
}
else if (type.equals("Shake.MAGMA_CUBE")) {
shakeFromMagmaCube.add(shakeTreasure);
}
else if (type.equals("Shake.MUSHROOM_COW")) {
shakeFromMushroomCow.add(shakeTreasure);
}
else if (type.equals("Shake.PIG")) {
shakeFromPig.add(shakeTreasure);
}
else if (type.equals("Shake.PIG_ZOMBIE")) {
shakeFromPigZombie.add(shakeTreasure);
}
else if (type.equals("Shake.SHEEP")) {
shakeFromSheep.add(shakeTreasure);
}
else if (type.equals("Shake.SKELETON")) {
shakeFromSkeleton.add(shakeTreasure);
}
else if (type.equals("Shake.SLIME")) {
shakeFromSlime.add(shakeTreasure);
}
else if (type.equals("Shake.SPIDER")) {
shakeFromSpider.add(shakeTreasure);
}
else if (type.equals("Shake.SNOWMAN")) {
shakeFromSnowman.add(shakeTreasure);
}
else if (type.equals("Shake.SQUID")) {
shakeFromSquid.add(shakeTreasure);
}
else if (type.equals("Shake.WITCH")) {
shakeFromWitch.add(shakeTreasure);
}
else if (type.equals("Shake.ZOMBIE")) {
shakeFromZombie.add(shakeTreasure);
}
}
else if (isExcavation) {
ExcavationTreasure excavationTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
if (dropList.contains("Dirt")) {
excavationFromDirt.add(excavationTreasure);
} }
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Sand", false)) { if (dropList.contains("Grass")) {
eTreasure.setDropsFromSand(); excavationFromGrass.add(excavationTreasure);
} }
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Gravel", false)) { if (dropList.contains("Sand")) {
eTreasure.setDropsFromGravel(); excavationFromSand.add(excavationTreasure);
} }
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Clay", false)) { if (dropList.contains("Gravel")) {
eTreasure.setDropsFromClay(); excavationFromGravel.add(excavationTreasure);
} }
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Mycelium", false)) { if (dropList.contains("Clay")) {
eTreasure.setDropsFromMycel(); excavationFromClay.add(excavationTreasure);
} }
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Soul_Sand", false)) { if (dropList.contains("Mycelium")) {
eTreasure.setDropsFromSoulSand(); excavationFromMycel.add(excavationTreasure);
} }
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Bushes", false)) { if (dropList.contains("Soul_Sand")) {
hTreasure.setDropsFromBushes(); excavationFromSoulSand.add(excavationTreasure);
} }
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Flowers", false)) { if (dropList.contains("Snow")) {
hTreasure.setDropsFromFlowers(); excavationFromSnow.add(excavationTreasure);
}
}
else if (isHylian) {
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
if (dropList.contains("Bushes")) {
hylianFromBushes.add(hylianTreasure);
} }
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Pots", false)) { if (dropList.contains("Flowers")) {
hTreasure.setDropsFromPots(); hylianFromFlowers.add(hylianTreasure);
} }
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) { if (dropList.contains("Pots")) {
reason.add("This cannot also be a fishing drop."); hylianFromPots.add(hylianTreasure);
} }
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Shake", false)) {
reason.add("This cannot also be a shake drop.");
} }
if (noErrorsInTreasure(reason) && hTreasure.getDropsFrom() == (byte) 0x0) {
treasures.put(treasureName, eTreasure);
}
else if (noErrorsInTreasure(reason) && eTreasure.getDropsFrom() == (byte) 0x0) {
treasures.put(treasureName, hTreasure);
} }
} }
} }
List<String> excavationTreasures = config.getStringList("Excavation.Treasure"); private void loadEnchantments() {
List<String> fishingTreasures = config.getStringList("Fishing.Treasure"); for (Rarity rarity : Rarity.values()) {
List<String> hylianTreasures = config.getStringList("Hylian_Luck.Treasure"); if (rarity == Rarity.TRAP || rarity == Rarity.RECORD) {
List<String> shakeTreasures = config.getStringList("Shake.Treasure");
for (Entry<String, Treasure> nextEntry : treasures.entrySet()) {
String treasureKey = nextEntry.getKey();
Treasure treasure = nextEntry.getValue();
if (treasure instanceof FishingTreasure) {
if (fishingTreasures == null || !fishingTreasures.contains(treasureKey)) {
continue; continue;
} }
fishingRewards.add((FishingTreasure) treasure); if (!fishingEnchantments.containsKey(rarity)) {
fishingEnchantments.put(rarity, (new ArrayList<EnchantmentTreasure>()));
} }
else if (treasure instanceof ShakeTreasure) {
if (shakeTreasures == null || !shakeTreasures.contains(treasureKey)) { ConfigurationSection enchantmentSection = config.getConfigurationSection("Enchantments_Rarity." + rarity.toString());
if (enchantmentSection == null) {
return;
}
for (String enchantmentName : enchantmentSection.getKeys(false)) {
int level = config.getInt("Enchantments_Rarity." + rarity.toString() + "." + enchantmentName);
Enchantment enchantment = EnchantmentUtils.getByName(enchantmentName);
if (enchantment == null) {
plugin.getLogger().warning("Skipping invalid enchantment in treasures.yml: " + enchantmentName);
continue; continue;
} }
ShakeTreasure e = (ShakeTreasure) treasure; fishingEnchantments.get(rarity).add(new EnchantmentTreasure(enchantment, level));
switch (e.getMob()) {
case BLAZE:
shakeFromBlaze.add(e);
break;
case CAVE_SPIDER:
shakeFromCaveSpider.add(e);
break;
case CHICKEN:
shakeFromChicken.add(e);
break;
case COW:
shakeFromCow.add(e);
break;
case CREEPER:
shakeFromCreeper.add(e);
break;
case ENDERMAN:
shakeFromEnderman.add(e);
break;
case GHAST:
shakeFromGhast.add(e);
break;
case IRON_GOLEM:
shakeFromIronGolem.add(e);
break;
case MAGMA_CUBE:
shakeFromMagmaCube.add(e);
break;
case MUSHROOM_COW:
shakeFromMushroomCow.add(e);
break;
case PIG:
shakeFromPig.add(e);
break;
case PIG_ZOMBIE:
shakeFromPigZombie.add(e);
break;
case SHEEP:
shakeFromSheep.add(e);
break;
case SKELETON:
shakeFromSkeleton.add(e);
break;
case SLIME:
shakeFromSlime.add(e);
break;
case SPIDER:
shakeFromSpider.add(e);
break;
case SNOWMAN:
shakeFromSnowman.add(e);
break;
case SQUID:
shakeFromSquid.add(e);
break;
case WITCH:
shakeFromWitch.add(e);
break;
case ZOMBIE:
shakeFromZombie.add(e);
break;
default:
break;
}
}
else if (treasure instanceof HylianTreasure) {
if (hylianTreasures == null || !hylianTreasures.contains(treasureKey)) {
continue;
}
HylianTreasure hTreasure = (HylianTreasure) treasure;
if (hTreasure.getDropsFromBushes()) {
hylianFromBushes.add(hTreasure);
}
if (hTreasure.getDropsFromFlowers()) {
hylianFromFlowers.add(hTreasure);
}
if (hTreasure.getDropsFromPots()) {
hylianFromPots.add(hTreasure);
}
}
else if (treasure instanceof ExcavationTreasure) {
if (excavationTreasures == null || !excavationTreasures.contains(treasureKey)) {
continue;
}
ExcavationTreasure eTreasure = (ExcavationTreasure) treasure;
if (eTreasure.getDropsFromDirt()) {
excavationFromDirt.add(eTreasure);
}
if (eTreasure.getDropsFromGrass()) {
excavationFromGrass.add(eTreasure);
}
if (eTreasure.getDropsFromSand()) {
excavationFromSand.add(eTreasure);
}
if (eTreasure.getDropsFromGravel()) {
excavationFromGravel.add(eTreasure);
}
if (eTreasure.getDropsFromClay()) {
excavationFromClay.add(eTreasure);
}
if (eTreasure.getDropsFromMycel()) {
excavationFromMycel.add(eTreasure);
}
if (eTreasure.getDropsFromSoulSand()) {
excavationFromSoulSand.add(eTreasure);
}
} }
} }
} }
private boolean noErrorsInTreasure(List<String> issues) { public double getItemDropRate(int tier, Rarity rarity) { return config.getDouble("Item_Drop_Rates.Tier_" + tier + "." + rarity.toString()); }
for (String issue : issues) { public double getEnchantmentDropRate(int tier, Rarity rarity) { return config.getDouble("Enchantment_Drop_Rates.Tier_" + tier + "." + rarity.toString()); }
plugin.getLogger().warning(issue);
}
return issues.isEmpty();
}
} }

View File

@@ -4,12 +4,16 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.database.PlayerStat; import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType;
public interface DatabaseManager { public interface DatabaseManager {
// One month in milliseconds // One month in milliseconds
public final long PURGE_TIME = 2630000000L * Config.getInstance().getOldUsersCutoff(); public final long PURGE_TIME = 2630000000L * Config.getInstance().getOldUsersCutoff();
// During convertUsers, how often to output a status
public final int progressInterval = 200;
/** /**
* Purge users with 0 power level from the database. * Purge users with 0 power level from the database.
@@ -17,7 +21,8 @@ public interface DatabaseManager {
public void purgePowerlessUsers(); public void purgePowerlessUsers();
/** /**
* Purge users who haven't logged on in over a certain time frame from the database. * Purge users who haven't logged on in over a certain time frame from the
* database.
*/ */
public void purgeOldUsers(); public void purgeOldUsers();
@@ -33,8 +38,9 @@ public interface DatabaseManager {
* Save a user to the database. * Save a user to the database.
* *
* @param profile The profile of the player to save * @param profile The profile of the player to save
* @return true if successful, false on failure
*/ */
public void saveUser(PlayerProfile profile); public boolean saveUser(PlayerProfile profile);
/** /**
* Retrieve leaderboard info. * Retrieve leaderboard info.
@@ -44,15 +50,18 @@ public interface DatabaseManager {
* @param statsPerPage The number of stats per page * @param statsPerPage The number of stats per page
* @return the requested leaderboard information * @return the requested leaderboard information
*/ */
public List<PlayerStat> readLeaderboard(String skillName, int pageNumber, int statsPerPage); public List<PlayerStat> readLeaderboard(SkillType skill, int pageNumber, int statsPerPage);
/** /**
* Retrieve rank info. * Retrieve rank info into a HashMap from SkillType to the rank.
* <p>
* The special value <code>null</code> is used to represent the Power
* Level rank (the combination of all skill levels).
* *
* @param playerName The name of the user to retrieve the rankings for * @param playerName The name of the user to retrieve the rankings for
* @return the requested rank information * @return the requested rank information
*/ */
public Map<String, Integer> readRank(String playerName); public Map<SkillType, Integer> readRank(String playerName);
/** /**
* Add a new user to the database. * Add a new user to the database.
@@ -83,7 +92,22 @@ public interface DatabaseManager {
* Convert all users from this database to the provided database using * Convert all users from this database to the provided database using
* {@link #saveUser(PlayerProfile)}. * {@link #saveUser(PlayerProfile)}.
* *
* @param the DatabaseManager to save to * @param destination The DatabaseManager to save to
*/ */
public void convertUsers(DatabaseManager destination); public void convertUsers(DatabaseManager destination);
/**
* Retrieve the type of database in use. Custom databases should return
* CUSTOM.
*
* @return The type of database
*/
public DatabaseType getDatabaseType();
/**
* Used for database conversion. If this is set to true, profiles may not
* be loaded from the database. This method will be called before and
* after database imports.
*/
public void setLoadingDisabled(boolean state);
} }

View File

@@ -2,6 +2,7 @@ package com.gmail.nossr50.database;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.database.DatabaseType;
public class DatabaseManagerFactory { public class DatabaseManagerFactory {
private static Class<? extends DatabaseManager> customManager = null; private static Class<? extends DatabaseManager> customManager = null;
@@ -9,31 +10,35 @@ public class DatabaseManagerFactory {
public static DatabaseManager getDatabaseManager() { public static DatabaseManager getDatabaseManager() {
if (customManager != null) { if (customManager != null) {
try { try {
return createCustomDatabaseManager(customManager); return createDefaultCustomDatabaseManager();
} catch (Exception e) { }
catch (Exception e) {
mcMMO.p.debug("Could not create custom database manager"); mcMMO.p.debug("Could not create custom database manager");
e.printStackTrace(); e.printStackTrace();
} catch (Throwable e) { }
catch (Throwable e) {
mcMMO.p.debug("Failed to create custom database manager"); mcMMO.p.debug("Failed to create custom database manager");
e.printStackTrace(); e.printStackTrace();
} }
mcMMO.p.debug("Falling back on " + (Config.getInstance().getUseMySQL() ? "SQL" : "Flatfile") + " database"); mcMMO.p.debug("Falling back on " + (Config.getInstance().getUseMySQL() ? "SQL" : "Flatfile") + " database");
} }
return Config.getInstance().getUseMySQL() ? new SQLDatabaseManager() : new FlatfileDatabaseManager(); return Config.getInstance().getUseMySQL() ? new SQLDatabaseManager() : new FlatfileDatabaseManager();
} }
/** /**
* Sets the custom DatabaseManager class for McMMO to use. This should be * Sets the custom DatabaseManager class for mcMMO to use. This should be
* called prior to mcMMO enabling. * called prior to mcMMO enabling.
* <p> * <p/>
* The provided class must have an empty constructor, which is the one * The provided class must have an empty constructor, which is the one
* that will be used. * that will be used.
* <p> * <p/>
* This method is intended for API use, but it should not be considered * This method is intended for API use, but it should not be considered
* stable. This method is subject to change and/or removal in future * stable. This method is subject to change and/or removal in future
* versions. * versions.
* *
* @param man the DatabaseManager class to use * @param clazz the DatabaseManager class to use
*
* @throws IllegalArgumentException if the provided class does not have * @throws IllegalArgumentException if the provided class does not have
* an empty constructor * an empty constructor
*/ */
@@ -41,7 +46,8 @@ public class DatabaseManagerFactory {
try { try {
clazz.getConstructor((Class<?>) null); clazz.getConstructor((Class<?>) null);
customManager = clazz; customManager = clazz;
} catch (Throwable e) { }
catch (Throwable e) {
throw new IllegalArgumentException("Provided database manager class must have an empty constructor", e); throw new IllegalArgumentException("Provided database manager class must have an empty constructor", e);
} }
} }
@@ -50,17 +56,32 @@ public class DatabaseManagerFactory {
return customManager; return customManager;
} }
// For data conversion purposes public static DatabaseManager createDatabaseManager(DatabaseType type) {
switch (type) {
public static FlatfileDatabaseManager createFlatfileDatabaseManager() { case FLATFILE:
return new FlatfileDatabaseManager(); return new FlatfileDatabaseManager();
case SQL:
return new SQLDatabaseManager();
case CUSTOM:
try {
return createDefaultCustomDatabaseManager();
}
catch (Throwable e) {
e.printStackTrace();
} }
public static SQLDatabaseManager createSQLDatabaseManager() { default:
return new SQLDatabaseManager(); return null;
}
}
public static DatabaseManager createDefaultCustomDatabaseManager() throws Throwable {
return customManager.getConstructor((Class<?>) null).newInstance((Object[]) null);
} }
public static DatabaseManager createCustomDatabaseManager(Class<? extends DatabaseManager> clazz) throws Throwable { public static DatabaseManager createCustomDatabaseManager(Class<? extends DatabaseManager> clazz) throws Throwable {
return customManager.getConstructor((Class<?>) null).newInstance((Object[]) null); return clazz.getConstructor((Class<?>) null).newInstance((Object[]) null);
} }
} }

View File

@@ -11,20 +11,20 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.MobHealthbarType; import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.database.PlayerStat; import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.AbilityType; import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
public final class FlatfileDatabaseManager implements DatabaseManager { public final class FlatfileDatabaseManager implements DatabaseManager {
@@ -35,6 +35,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
private final long UPDATE_WAIT_TIME = 600000L; // 10 minutes private final long UPDATE_WAIT_TIME = 600000L; // 10 minutes
private final File usersFile; private final File usersFile;
private static final Object fileWritingLock = new Object(); private static final Object fileWritingLock = new Object();
private volatile boolean converting = false;
protected FlatfileDatabaseManager() { protected FlatfileDatabaseManager() {
usersFile = new File(mcMMO.getUsersFilePath()); usersFile = new File(mcMMO.getUsersFilePath());
@@ -42,6 +43,10 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
updateLeaderboards(); updateLeaderboards();
} }
public void setLoadingDisabled(boolean state) {
converting = state;
}
public void purgePowerlessUsers() { public void purgePowerlessUsers() {
int purgedUsers = 0; int purgedUsers = 0;
@@ -102,7 +107,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
mcMMO.p.getLogger().info("Purging old users..."); mcMMO.p.getLogger().info("Purging old users...");
BufferedReader in = null; BufferedReader in = null;
FileWriter out = null; FileWriter out = null;
String usersFilePath = mcMMO.getUsersFilePath(); String usersFilePath = mcMMO.getUsersFilePath();
@@ -117,19 +121,34 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
String[] character = line.split(":"); String[] character = line.split(":");
String name = character[0]; String name = character[0];
OfflinePlayer player = Bukkit.getOfflinePlayer(name); long lastPlayed = 0;
boolean old = true; boolean rewrite = false;
if (player != null) { try {
old = (currentTime - player.getLastPlayed()) > PURGE_TIME; lastPlayed = Long.parseLong(character[37]) * Misc.TIME_CONVERSION_FACTOR;
}
catch (NumberFormatException e) {
}
if (lastPlayed == 0) {
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(name);
lastPlayed = player.getLastPlayed();
rewrite = true;
} }
if (!old) { if (currentTime - lastPlayed > PURGE_TIME) {
writer.append(line).append("\r\n");
}
else {
removedPlayers++; removedPlayers++;
Misc.profileCleanup(name); Misc.profileCleanup(name);
} }
else {
if (rewrite) {
// Rewrite their data with a valid time
character[37] = Long.toString(lastPlayed);
String newLine = org.apache.commons.lang.StringUtils.join(character, ":");
writer.append(newLine).append("\r\n");
}
else {
writer.append(line).append("\r\n");
}
}
} }
// Write the new file // Write the new file
@@ -189,7 +208,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
return worked; return worked;
} }
public void saveUser(PlayerProfile profile) { public boolean saveUser(PlayerProfile profile) {
String playerName = profile.getPlayerName(); String playerName = profile.getPlayerName();
BufferedReader in = null; BufferedReader in = null;
@@ -237,18 +256,17 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
writer.append(":"); writer.append(":");
writer.append(profile.getSkillLevel(SkillType.TAMING)).append(":"); writer.append(profile.getSkillLevel(SkillType.TAMING)).append(":");
writer.append(profile.getSkillXpLevel(SkillType.TAMING)).append(":"); writer.append(profile.getSkillXpLevel(SkillType.TAMING)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.BERSERK)).append(":"); writer.append((int) profile.getAbilityDATS(AbilityType.BERSERK)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.GIGA_DRILL_BREAKER)).append(":"); writer.append((int) profile.getAbilityDATS(AbilityType.GIGA_DRILL_BREAKER)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.TREE_FELLER)).append(":"); writer.append((int) profile.getAbilityDATS(AbilityType.TREE_FELLER)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.GREEN_TERRA)).append(":"); writer.append((int) profile.getAbilityDATS(AbilityType.GREEN_TERRA)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.SERRATED_STRIKES)).append(":"); writer.append((int) profile.getAbilityDATS(AbilityType.SERRATED_STRIKES)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.SKULL_SPLITTER)).append(":"); writer.append((int) profile.getAbilityDATS(AbilityType.SKULL_SPLITTER)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.SUPER_BREAKER)).append(":"); writer.append((int) profile.getAbilityDATS(AbilityType.SUPER_BREAKER)).append(":");
HudType hudType = profile.getHudType(); writer.append(":");
writer.append(hudType == null ? "STANDARD" : hudType.toString()).append(":");
writer.append(profile.getSkillLevel(SkillType.FISHING)).append(":"); writer.append(profile.getSkillLevel(SkillType.FISHING)).append(":");
writer.append(profile.getSkillXpLevel(SkillType.FISHING)).append(":"); writer.append(profile.getSkillXpLevel(SkillType.FISHING)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.BLAST_MINING)).append(":"); writer.append((int) profile.getAbilityDATS(AbilityType.BLAST_MINING)).append(":");
writer.append(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR).append(":"); writer.append(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR).append(":");
MobHealthbarType mobHealthbarType = profile.getMobHealthbarType(); MobHealthbarType mobHealthbarType = profile.getMobHealthbarType();
writer.append(mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()).append(":"); writer.append(mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()).append(":");
@@ -259,9 +277,11 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
// Write the new file // Write the new file
out = new FileWriter(usersFilePath); out = new FileWriter(usersFilePath);
out.write(writer.toString()); out.write(writer.toString());
return true;
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return false;
} }
finally { finally {
tryClose(in); tryClose(in);
@@ -270,24 +290,24 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
} }
} }
public List<PlayerStat> readLeaderboard(String skillName, int pageNumber, int statsPerPage) { public List<PlayerStat> readLeaderboard(SkillType skill, int pageNumber, int statsPerPage) {
updateLeaderboards(); updateLeaderboards();
List<PlayerStat> statsList = skillName.equalsIgnoreCase("all") ? powerLevels : playerStatHash.get(SkillType.getSkill(skillName)); List<PlayerStat> statsList = skill == null ? powerLevels : playerStatHash.get(skill);
int fromIndex = (Math.max(pageNumber, 1) - 1) * statsPerPage; int fromIndex = (Math.max(pageNumber, 1) - 1) * statsPerPage;
return statsList.subList(Math.min(fromIndex, statsList.size()), Math.min(fromIndex + statsPerPage, statsList.size())); return statsList.subList(Math.min(fromIndex, statsList.size()), Math.min(fromIndex + statsPerPage, statsList.size()));
} }
public Map<String, Integer> readRank(String playerName) { public Map<SkillType, Integer> readRank(String playerName) {
updateLeaderboards(); updateLeaderboards();
Map<String, Integer> skills = new HashMap<String, Integer>(); Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>();
for (SkillType skill : SkillType.nonChildSkills()) { for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
skills.put(skill.name(), getPlayerRank(playerName, playerStatHash.get(skill))); skills.put(skill, getPlayerRank(playerName, playerStatHash.get(skill)));
} }
skills.put("ALL", getPlayerRank(playerName, powerLevels)); skills.put(null, getPlayerRank(playerName, powerLevels));
return skills; return skills;
} }
@@ -333,7 +353,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
out.append("0:"); // DATS out.append("0:"); // DATS
out.append("0:"); // DATS out.append("0:"); // DATS
out.append("0:"); // DATS out.append("0:"); // DATS
out.append("STANDARD").append(":"); // HUD out.append(":");
out.append("0:"); // Fishing out.append("0:"); // Fishing
out.append("0:"); // FishingXp out.append("0:"); // FishingXp
out.append("0:"); // Blast Mining out.append("0:"); // Blast Mining
@@ -354,6 +374,10 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
} }
public PlayerProfile loadPlayerProfile(String playerName, boolean create) { public PlayerProfile loadPlayerProfile(String playerName, boolean create) {
if (converting) {
return new PlayerProfile(playerName, false);
}
BufferedReader in = null; BufferedReader in = null;
String usersFilePath = mcMMO.getUsersFilePath(); String usersFilePath = mcMMO.getUsersFilePath();
@@ -372,28 +396,41 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
} }
PlayerProfile p = loadFromLine(character); PlayerProfile p = loadFromLine(character);
in.close();
return p; return p;
} }
// Didn't find the player, create a new one
if (create) {
newUser(playerName);
return new PlayerProfile(playerName, true);
}
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
finally { finally {
tryClose(in); // I have no idea why it's necessary to inline tryClose() here, but it removes
// a resource leak warning, and I'm trusting the compiler on this one.
if (in != null) {
try {
in.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
} }
} }
if (create) { // Return unloaded profile
newUser(playerName);
return new PlayerProfile(playerName, true);
}
return new PlayerProfile(playerName); return new PlayerProfile(playerName);
} }
public void convertUsers(DatabaseManager destination) { public void convertUsers(DatabaseManager destination) {
BufferedReader in = null; BufferedReader in = null;
String usersFilePath = mcMMO.getUsersFilePath(); String usersFilePath = mcMMO.getUsersFilePath();
int convertedUsers = 0;
long startMillis = System.currentTimeMillis();
synchronized (fileWritingLock) { synchronized (fileWritingLock) {
try { try {
@@ -410,6 +447,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
convertedUsers++;
Misc.printProgress(convertedUsers, progressInterval, startMillis);
} }
} }
catch (Exception e) { catch (Exception e) {
@@ -421,11 +460,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
} }
} }
public boolean checkConnected() {
// Not implemented
return true;
}
public List<String> getStoredUsers() { public List<String> getStoredUsers() {
ArrayList<String> users = new ArrayList<String>(); ArrayList<String> users = new ArrayList<String>();
BufferedReader in = null; BufferedReader in = null;
@@ -480,25 +514,18 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
List<PlayerStat> fishing = new ArrayList<PlayerStat>(); List<PlayerStat> fishing = new ArrayList<PlayerStat>();
BufferedReader in = null; BufferedReader in = null;
String playerName = null;
// Read from the FlatFile database and fill our arrays with information // Read from the FlatFile database and fill our arrays with information
synchronized (fileWritingLock) { synchronized (fileWritingLock) {
try { try {
in = new BufferedReader(new FileReader(usersFilePath)); in = new BufferedReader(new FileReader(usersFilePath));
String line = ""; String line = "";
ArrayList<String> players = new ArrayList<String>();
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
String[] data = line.split(":"); String[] data = line.split(":");
String playerName = data[0]; playerName = data[0];
int powerLevel = 0; int powerLevel = 0;
// Prevent the same player from being added multiple times (I'd like to note that this shouldn't happen...)
if (players.contains(playerName)) {
continue;
}
players.add(playerName);
Map<SkillType, Integer> skills = getSkillMapFromLine(data); Map<SkillType, Integer> skills = getSkillMapFromLine(data);
powerLevel += putStat(acrobatics, playerName, skills.get(SkillType.ACROBATICS)); powerLevel += putStat(acrobatics, playerName, skills.get(SkillType.ACROBATICS));
@@ -518,7 +545,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
} }
} }
catch (Exception e) { catch (Exception e) {
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString()); mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " during user " + playerName + " (Are you sure you formatted it correctly?) " + e.toString());
} }
finally { finally {
tryClose(in); tryClose(in);
@@ -569,16 +596,100 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
in = new BufferedReader(new FileReader(usersFilePath)); in = new BufferedReader(new FileReader(usersFilePath));
StringBuilder writer = new StringBuilder(); StringBuilder writer = new StringBuilder();
String line = ""; String line = "";
HashSet<String> players = new HashSet<String>();
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
// Remove empty lines from the file
if (line.isEmpty()) {
continue;
}
// Length checks depend on last character being ':'
if (line.charAt(line.length() - 1) != ':') {
line = line + ":";
}
String[] character = line.split(":"); String[] character = line.split(":");
// If they're valid, rewrite them to the file. // Prevent the same player from being present multiple times
if (character.length >= 37) { if (!players.add(character[0])) {
writer.append(line).append("\r\n"); continue;
} else {
// Placeholder, repair row if needed (I.E. when new skills are added and such)
} }
if (character.length < 33) {
// Before Version 1.0 - Drop
mcMMO.p.getLogger().warning("Dropping malformed or before version 1.0 line from database - " + line);
continue;
}
String oldVersion = null;
if (!character[33].isEmpty()) {
// Removal of Spout Support
// Version 1.4.07-dev2
// commit 7bac0e2ca5143bce84dc160617fed97f0b1cb968
line = line.replace(character[33], "");
oldVersion = "1.4.07";
}
// If they're valid, rewrite them to the file.
if (character.length > 38) {
writer.append(line).append("\r\n");
continue;
}
StringBuilder newLine = new StringBuilder(line);
if (character.length <= 33) {
// Introduction of HUDType
// Version 1.1.06
// commit 78f79213cdd7190cd11ae54526f3b4ea42078e8a
newLine.append(":");
oldVersion = "1.1.06";
}
if (character.length <= 35) {
// Introduction of Fishing
// Version 1.2.00
// commit a814b57311bc7734661109f0e77fc8bab3a0bd29
newLine.append(0).append(":");
newLine.append(0).append(":");
if (oldVersion == null) {
oldVersion = "1.2.00";
}
}
if (character.length <= 36) {
// Introduction of Blast Mining cooldowns
// Version 1.3.00-dev
// commit fadbaf429d6b4764b8f1ad0efaa524a090e82ef5
newLine.append(0).append(":");
if (oldVersion == null) {
oldVersion = "1.3.00";
}
}
if (character.length <= 37) {
// Making old-purge work with flatfile
// Version 1.4.00-dev
// commmit 3f6c07ba6aaf44e388cc3b882cac3d8f51d0ac28
// XXX Cannot create an OfflinePlayer at startup, use 0 and fix in purge
newLine.append("0").append(":");
if (oldVersion == null) {
oldVersion = "1.4.00";
}
}
if (character.length <= 38) {
// Addition of mob healthbars
// Version 1.4.06
// commit da29185b7dc7e0d992754bba555576d48fa08aa6
newLine.append(Config.getInstance().getMobHealthbarDefault().toString()).append(":");
if (oldVersion == null) {
oldVersion = "1.4.06";
}
}
if (oldVersion != null) {
mcMMO.p.debug("Updating database line for player " + character[0] + " from before version " + oldVersion);
}
writer.append(newLine).append("\r\n");
} }
// Write the new file // Write the new file
@@ -608,10 +719,13 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
} }
private void tryClose(Closeable c) { private void tryClose(Closeable c) {
if (c == null) return; if (c == null) {
return;
}
try { try {
c.close(); c.close();
} catch (IOException e) { }
catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@@ -650,7 +764,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
Map<SkillType, Integer> skills = getSkillMapFromLine(character); // Skill levels Map<SkillType, Integer> skills = getSkillMapFromLine(character); // Skill levels
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
HudType hudType;
MobHealthbarType mobHealthbarType; MobHealthbarType mobHealthbarType;
// TODO on updates, put new values in a try{} ? // TODO on updates, put new values in a try{} ?
@@ -681,13 +794,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
// Acrobatics - Unused // Acrobatics - Unused
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[36])); skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[36]));
try {
hudType = HudType.valueOf(character[33]);
}
catch (Exception e) {
hudType = HudType.STANDARD; // Shouldn't happen unless database is being tampered with
}
try { try {
mobHealthbarType = MobHealthbarType.valueOf(character[38]); mobHealthbarType = MobHealthbarType.valueOf(character[38]);
} }
@@ -695,7 +801,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
mobHealthbarType = Config.getInstance().getMobHealthbarDefault(); mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
} }
return new PlayerProfile(character[0], skills, skillsXp, skillsDATS, hudType, mobHealthbarType); return new PlayerProfile(character[0], skills, skillsXp, skillsDATS, mobHealthbarType);
} }
private Map<SkillType, Integer> getSkillMapFromLine(String[] character) { private Map<SkillType, Integer> getSkillMapFromLine(String[] character) {
@@ -716,4 +822,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
return skills; return skills;
} }
public DatabaseType getDatabaseType() {
return DatabaseType.FLATFILE;
}
} }

View File

@@ -12,17 +12,17 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.MobHealthbarType; import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.database.DatabaseUpdateType; import com.gmail.nossr50.datatypes.database.DatabaseUpdateType;
import com.gmail.nossr50.datatypes.database.PlayerStat; import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.AbilityType; import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.spout.huds.HudType; import com.gmail.nossr50.runnables.database.SQLDatabaseKeepaliveTask;
import com.gmail.nossr50.runnables.database.SQLReconnectTask; import com.gmail.nossr50.runnables.database.SQLReconnectTask;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
@@ -49,12 +49,24 @@ public final class SQLDatabaseManager implements DatabaseManager {
// How many connection attempts have failed // How many connection attempts have failed
private int reconnectAttempt = 0; private int reconnectAttempt = 0;
// If we're importing users, do not allow creation of profiles
private volatile boolean converting = false;
protected SQLDatabaseManager() { protected SQLDatabaseManager() {
checkConnected();
checkStructure(); checkStructure();
new SQLDatabaseKeepaliveTask(this).runTaskTimerAsynchronously(mcMMO.p, 10, 60L * 60 * Misc.TICK_CONVERSION_FACTOR);
}
public void setLoadingDisabled(boolean state) {
converting = state;
} }
public void purgePowerlessUsers() { public void purgePowerlessUsers() {
if (!checkConnected()) {
return;
}
mcMMO.p.getLogger().info("Purging powerless users..."); mcMMO.p.getLogger().info("Purging powerless users...");
Collection<ArrayList<String>> usernames = read("SELECT u.user FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u WHERE s.user_id = u.id AND (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0").values(); Collection<ArrayList<String>> usernames = read("SELECT u.user FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u WHERE s.user_id = u.id AND (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0").values();
@@ -71,6 +83,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
} }
public void purgeOldUsers() { public void purgeOldUsers() {
if (!checkConnected()) {
return;
}
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
mcMMO.p.getLogger().info("Purging old users..."); mcMMO.p.getLogger().info("Purging old users...");
@@ -85,10 +101,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
"WHERE ((" + currentTime + " - lastlogin * " + Misc.TIME_CONVERSION_FACTOR + ") > " + PURGE_TIME + ")"); "WHERE ((" + currentTime + " - lastlogin * " + Misc.TIME_CONVERSION_FACTOR + ") > " + PURGE_TIME + ")");
processPurge(usernames); processPurge(usernames);
mcMMO.p.getLogger().info("Purged " + usernames.size() + " users from the database.");; mcMMO.p.getLogger().info("Purged " + usernames.size() + " users from the database.");
} }
public boolean removeUser(String playerName) { public boolean removeUser(String playerName) {
if (!checkConnected()) {
return false;
}
boolean success = update("DELETE FROM u, e, h, s, c " + boolean success = update("DELETE FROM u, e, h, s, c " +
"USING " + tablePrefix + "users u " + "USING " + tablePrefix + "users u " +
"JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " + "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " +
@@ -102,37 +122,39 @@ public final class SQLDatabaseManager implements DatabaseManager {
return success; return success;
} }
public void saveUser(PlayerProfile profile) { public boolean saveUser(PlayerProfile profile) {
checkConnected(); if (!checkConnected()) {
return false;
}
int userId = readId(profile.getPlayerName()); int userId = readId(profile.getPlayerName());
if (userId == -1) { if (userId == -1) {
newUser(profile.getPlayerName()); newUser(profile.getPlayerName());
userId = readId(profile.getPlayerName()); userId = readId(profile.getPlayerName());
if (userId == -1) { if (userId == -1) {
mcMMO.p.getLogger().log(Level.WARNING, "Failed to save user " + profile.getPlayerName()); return false;
return;
} }
} }
boolean success = true;
MobHealthbarType mobHealthbarType = profile.getMobHealthbarType(); MobHealthbarType mobHealthbarType = profile.getMobHealthbarType();
HudType hudType = profile.getHudType();
saveLogin(userId, ((int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR))); success &= saveLogin(userId, ((int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
saveHuds(userId, (hudType == null ? "STANDARD" : hudType.toString()), (mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString())); success &= saveHuds(userId, (mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()));
saveLongs( success &= saveLongs(
"UPDATE " + tablePrefix + "cooldowns SET " "UPDATE " + tablePrefix + "cooldowns SET "
+ " mining = ?, woodcutting = ?, unarmed = ?" + " mining = ?, woodcutting = ?, unarmed = ?"
+ ", herbalism = ?, excavation = ?, swords = ?" + ", herbalism = ?, excavation = ?, swords = ?"
+ ", axes = ?, blast_mining = ? WHERE user_id = ?", + ", axes = ?, blast_mining = ? WHERE user_id = ?",
userId, userId,
profile.getSkillDATS(AbilityType.SUPER_BREAKER), profile.getAbilityDATS(AbilityType.SUPER_BREAKER),
profile.getSkillDATS(AbilityType.TREE_FELLER), profile.getAbilityDATS(AbilityType.TREE_FELLER),
profile.getSkillDATS(AbilityType.BERSERK), profile.getAbilityDATS(AbilityType.BERSERK),
profile.getSkillDATS(AbilityType.GREEN_TERRA), profile.getAbilityDATS(AbilityType.GREEN_TERRA),
profile.getSkillDATS(AbilityType.GIGA_DRILL_BREAKER), profile.getAbilityDATS(AbilityType.GIGA_DRILL_BREAKER),
profile.getSkillDATS(AbilityType.SERRATED_STRIKES), profile.getAbilityDATS(AbilityType.SERRATED_STRIKES),
profile.getSkillDATS(AbilityType.SKULL_SPLITTER), profile.getAbilityDATS(AbilityType.SKULL_SPLITTER),
profile.getSkillDATS(AbilityType.BLAST_MINING)); profile.getAbilityDATS(AbilityType.BLAST_MINING));
saveIntegers( success &= saveIntegers(
"UPDATE " + tablePrefix + "skills SET " "UPDATE " + tablePrefix + "skills SET "
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?" + " taming = ?, mining = ?, repair = ?, woodcutting = ?"
+ ", unarmed = ?, herbalism = ?, excavation = ?" + ", unarmed = ?, herbalism = ?, excavation = ?"
@@ -151,7 +173,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillLevel(SkillType.ACROBATICS),
profile.getSkillLevel(SkillType.FISHING), profile.getSkillLevel(SkillType.FISHING),
userId); userId);
saveIntegers( success &= saveIntegers(
"UPDATE " + tablePrefix + "experience SET " "UPDATE " + tablePrefix + "experience SET "
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?" + " taming = ?, mining = ?, repair = ?, woodcutting = ?"
+ ", unarmed = ?, herbalism = ?, excavation = ?" + ", unarmed = ?, herbalism = ?, excavation = ?"
@@ -170,13 +192,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS),
profile.getSkillXpLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING),
userId); userId);
return success;
} }
public List<PlayerStat> readLeaderboard(String skillName, int pageNumber, int statsPerPage) { public List<PlayerStat> readLeaderboard(SkillType skill, int pageNumber, int statsPerPage) {
List<PlayerStat> stats = new ArrayList<PlayerStat>(); List<PlayerStat> stats = new ArrayList<PlayerStat>();
if (checkConnected()) { if (checkConnected()) {
String query = skillName.equalsIgnoreCase("ALL") ? "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing" : skillName; String query = skill == null ? "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing" : skill.name().toLowerCase();
ResultSet resultSet = null; ResultSet resultSet = null;
PreparedStatement statement = null; PreparedStatement statement = null;
@@ -214,14 +237,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
return stats; return stats;
} }
public Map<String, Integer> readRank(String playerName) { public Map<SkillType, Integer> readRank(String playerName) {
Map<String, Integer> skills = new HashMap<String, Integer>(); Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>();
if (checkConnected()) { if (checkConnected()) {
ResultSet resultSet; ResultSet resultSet;
try { try {
for (SkillType skillType : SkillType.nonChildSkills()) { for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
String skillName = skillType.name().toLowerCase(); String skillName = skillType.name().toLowerCase();
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " + String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " + "AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
@@ -246,7 +269,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
while (resultSet.next()) { while (resultSet.next()) {
if (resultSet.getString("user").equalsIgnoreCase(playerName)) { if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
skills.put(skillType.name(), rank + resultSet.getRow()); skills.put(skillType, rank + resultSet.getRow());
break; break;
} }
} }
@@ -283,7 +306,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
while (resultSet.next()) { while (resultSet.next()) {
if (resultSet.getString("user").equalsIgnoreCase(playerName)) { if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
skills.put("ALL", rank + resultSet.getRow()); skills.put(null, rank + resultSet.getRow());
break; break;
} }
} }
@@ -299,6 +322,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
} }
public void newUser(String playerName) { public void newUser(String playerName) {
if (!checkConnected()) {
return;
}
PreparedStatement statement = null; PreparedStatement statement = null;
try { try {
@@ -326,6 +353,18 @@ public final class SQLDatabaseManager implements DatabaseManager {
} }
public PlayerProfile loadPlayerProfile(String playerName, boolean create) { public PlayerProfile loadPlayerProfile(String playerName, boolean create) {
if (converting) {
return new PlayerProfile(playerName, false); // return unloaded profile during database conversion
}
return loadPlayerProfile(playerName, create, true);
}
private PlayerProfile loadPlayerProfile(String playerName, boolean create, boolean retry) {
if (!checkConnected()) {
return new PlayerProfile(playerName, false); // return unloaded profile if not connected
}
PreparedStatement statement = null; PreparedStatement statement = null;
try { try {
@@ -334,7 +373,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, " + "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, "
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, " + "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, "
+ "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, " + "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, "
+ "h.hudtype, h.mobhealthbar " + "h.mobhealthbar "
+ "FROM " + tablePrefix + "users u " + "FROM " + tablePrefix + "users u "
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " + "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " + "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
@@ -351,7 +390,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
result.close(); result.close();
return ret; return ret;
} }
catch (SQLException e) {} catch (SQLException e) {
}
} }
result.close(); result.close();
} }
@@ -371,6 +411,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
// Problem, nothing was returned // Problem, nothing was returned
// Quit if this is second time around
if (!retry) {
return new PlayerProfile(playerName, false);
}
// First, read User Id - this is to check for orphans // First, read User Id - this is to check for orphans
int id = readId(playerName); int id = readId(playerName);
@@ -379,19 +424,23 @@ public final class SQLDatabaseManager implements DatabaseManager {
// There is no such user // There is no such user
if (create) { if (create) {
newUser(playerName); newUser(playerName);
return new PlayerProfile(playerName, true); return loadPlayerProfile(playerName, false, false);
} }
else {
// Return unloaded profile if can't create
return new PlayerProfile(playerName, false); return new PlayerProfile(playerName, false);
} }
}
// There is such a user // There is such a user
writeMissingRows(id); writeMissingRows(id);
// Retry, and abort on re-failure // Retry, and abort on re-failure
return loadPlayerProfile(playerName, false); return loadPlayerProfile(playerName, create, false);
} }
public void convertUsers(DatabaseManager destination) { public void convertUsers(DatabaseManager destination) {
if (!checkConnected()) {
return;
}
PreparedStatement statement = null; PreparedStatement statement = null;
try { try {
@@ -400,7 +449,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, " + "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, "
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, " + "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, "
+ "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, " + "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, "
+ "h.hudtype, h.mobhealthbar " + "h.mobhealthbar "
+ "FROM " + tablePrefix + "users u " + "FROM " + tablePrefix + "users u "
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " + "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " + "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
@@ -409,6 +458,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "WHERE u.user = ?"); + "WHERE u.user = ?");
List<String> usernames = getStoredUsers(); List<String> usernames = getStoredUsers();
ResultSet result = null; ResultSet result = null;
int convertedUsers = 0;
long startMillis = System.currentTimeMillis();
for (String playerName : usernames) { for (String playerName : usernames) {
statement.setString(1, playerName); statement.setString(1, playerName);
try { try {
@@ -420,6 +471,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
catch (SQLException e) { catch (SQLException e) {
// Ignore // Ignore
} }
convertedUsers++;
Misc.printProgress(convertedUsers, progressInterval, startMillis);
} }
} }
catch (SQLException e) { catch (SQLException e) {
@@ -429,13 +482,15 @@ public final class SQLDatabaseManager implements DatabaseManager {
if (statement != null) { if (statement != null) {
try { try {
statement.close(); statement.close();
} catch (SQLException e) { }
catch (SQLException e) {
// Ignore // Ignore
} }
} }
} }
} }
/** /**
* Check connection status and re-establish if dead or stale. * Check connection status and re-establish if dead or stale.
* *
@@ -528,6 +583,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
public List<String> getStoredUsers() { public List<String> getStoredUsers() {
ArrayList<String> users = new ArrayList<String>(); ArrayList<String> users = new ArrayList<String>();
if (checkConnected()) {
Statement stmt = null; Statement stmt = null;
try { try {
stmt = connection.createStatement(); stmt = connection.createStatement();
@@ -544,11 +601,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
if (stmt != null) { if (stmt != null) {
try { try {
stmt.close(); stmt.close();
} catch (SQLException e) { }
catch (SQLException e) {
// Ignore // Ignore
} }
} }
} }
}
return users; return users;
} }
@@ -576,14 +636,15 @@ public final class SQLDatabaseManager implements DatabaseManager {
connection = null; connection = null;
if (reconnectAttempt == 0 || reconnectAttempt >= 11) { if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
mcMMO.p.getLogger().info("Connection to MySQL failed!"); mcMMO.p.getLogger().severe("Connection to MySQL failed!");
printErrors(ex);
} }
} }
catch (ClassNotFoundException ex) { catch (ClassNotFoundException ex) {
connection = null; connection = null;
if (reconnectAttempt == 0 || reconnectAttempt >= 11) { if (reconnectAttempt == 0 || reconnectAttempt >= 11) {
mcMMO.p.getLogger().info("MySQL database driver not found!"); mcMMO.p.getLogger().severe("MySQL database driver not found!");
} }
} }
} }
@@ -592,6 +653,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
* Checks that the database structure is present and correct * Checks that the database structure is present and correct
*/ */
private void checkStructure() { private void checkStructure() {
if (!checkConnected()) {
return;
}
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "users` (" write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "users` ("
+ "`id` int(10) unsigned NOT NULL AUTO_INCREMENT," + "`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
+ "`user` varchar(40) NOT NULL," + "`user` varchar(40) NOT NULL,"
@@ -600,7 +665,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "UNIQUE KEY `user` (`user`)) DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;"); + "UNIQUE KEY `user` (`user`)) DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "huds` (" write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "huds` ("
+ "`user_id` int(10) unsigned NOT NULL," + "`user_id` int(10) unsigned NOT NULL,"
+ "`hudtype` varchar(50) NOT NULL DEFAULT 'STANDARD',"
+ "`mobhealthbar` varchar(50) NOT NULL DEFAULT '" + Config.getInstance().getMobHealthbarDefault() + "'," + "`mobhealthbar` varchar(50) NOT NULL DEFAULT '" + Config.getInstance().getMobHealthbarDefault() + "',"
+ "PRIMARY KEY (`user_id`)) " + "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=latin1;"); + "DEFAULT CHARSET=latin1;");
@@ -701,6 +765,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
write("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party` ;"); write("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party` ;");
return; return;
case DROPPED_SPOUT:
write("ALTER TABLE `" + tablePrefix + "huds` DROP COLUMN `hudtype` ;");
return;
case KILL_ORPHANS: case KILL_ORPHANS:
mcMMO.p.getLogger().info("Killing orphans"); mcMMO.p.getLogger().info("Killing orphans");
write( write(
@@ -807,7 +875,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
return true; return true;
} }
catch (SQLException ex) { catch (SQLException ex) {
if (!sql.equalsIgnoreCase("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party` ;")) { if (!sql.contains("DROP COLUMN")) {
printErrors(ex); printErrors(ex);
} }
return false; return false;
@@ -906,7 +974,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
/** /**
* Get the Integer. Only return first row / first field. * Get the Integer. Only return first row / first field.
* *
* @param sql SQL query to execute * @param statement SQL query to execute
* @return the value in the first row / first field * @return the value in the first row / first field
*/ */
private int readInt(PreparedStatement statement) { private int readInt(PreparedStatement statement) {
@@ -985,7 +1053,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
} }
} }
private void saveIntegers(String sql, int... args) { private boolean saveIntegers(String sql, int... args) {
PreparedStatement statement = null; PreparedStatement statement = null;
try { try {
@@ -997,9 +1065,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
} }
statement.execute(); statement.execute();
return true;
} }
catch (SQLException ex) { catch (SQLException ex) {
printErrors(ex); printErrors(ex);
return false;
} }
finally { finally {
if (statement != null) { if (statement != null) {
@@ -1013,7 +1083,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
} }
} }
private void saveLongs(String sql, int id, long... args) { private boolean saveLongs(String sql, int id, long... args) {
PreparedStatement statement = null; PreparedStatement statement = null;
try { try {
@@ -1026,9 +1096,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement.setInt(i++, id); statement.setInt(i++, id);
statement.execute(); statement.execute();
return true;
} }
catch (SQLException ex) { catch (SQLException ex) {
printErrors(ex); printErrors(ex);
return false;
} }
finally { finally {
if (statement != null) { if (statement != null) {
@@ -1063,7 +1135,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
return id; return id;
} }
private void saveLogin(int id, long login) { private boolean saveLogin(int id, long login) {
PreparedStatement statement = null; PreparedStatement statement = null;
try { try {
@@ -1071,9 +1143,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement.setLong(1, login); statement.setLong(1, login);
statement.setInt(2, id); statement.setInt(2, id);
statement.execute(); statement.execute();
return true;
} }
catch (SQLException ex) { catch (SQLException ex) {
printErrors(ex); printErrors(ex);
return false;
} }
finally { finally {
if (statement != null) { if (statement != null) {
@@ -1087,18 +1161,19 @@ public final class SQLDatabaseManager implements DatabaseManager {
} }
} }
private void saveHuds(int userId, String hudType, String mobHealthBar) { private boolean saveHuds(int userId, String mobHealthBar) {
PreparedStatement statement = null; PreparedStatement statement = null;
try { try {
statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET hudtype = ?, mobhealthbar = ? WHERE user_id = ?"); statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ? WHERE user_id = ?");
statement.setString(1, hudType); statement.setString(1, mobHealthBar);
statement.setString(2, mobHealthBar); statement.setInt(2, userId);
statement.setInt(3, userId);
statement.execute(); statement.execute();
return true;
} }
catch (SQLException ex) { catch (SQLException ex) {
printErrors(ex); printErrors(ex);
return false;
} }
finally { finally {
if (statement != null) { if (statement != null) {
@@ -1116,7 +1191,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skill & Level Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skill & Level
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
HudType hudType;
MobHealthbarType mobHealthbarType; MobHealthbarType mobHealthbarType;
final int OFFSET_SKILLS = 0; // TODO update these numbers when the query changes (a new skill is added) final int OFFSET_SKILLS = 0; // TODO update these numbers when the query changes (a new skill is added)
@@ -1163,13 +1237,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
// Acrobatics - Unused - result.getInt(OFFSET_DATS + 11) // Acrobatics - Unused - result.getInt(OFFSET_DATS + 11)
skillsDATS.put(AbilityType.BLAST_MINING, result.getInt(OFFSET_DATS + 12)); skillsDATS.put(AbilityType.BLAST_MINING, result.getInt(OFFSET_DATS + 12));
try {
hudType = HudType.valueOf(result.getString(OFFSET_OTHER + 1));
}
catch (Exception e) {
hudType = HudType.STANDARD; // Shouldn't happen unless database is being tampered with
}
try { try {
mobHealthbarType = MobHealthbarType.valueOf(result.getString(OFFSET_OTHER + 2)); mobHealthbarType = MobHealthbarType.valueOf(result.getString(OFFSET_OTHER + 2));
} }
@@ -1177,7 +1244,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
mobHealthbarType = Config.getInstance().getMobHealthbarDefault(); mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
} }
return new PlayerProfile(playerName, skills, skillsXp, skillsDATS, hudType, mobHealthbarType); return new PlayerProfile(playerName, skills, skillsXp, skillsDATS, mobHealthbarType);
} }
private void printErrors(SQLException ex) { private void printErrors(SQLException ex) {
@@ -1185,4 +1252,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
mcMMO.p.getLogger().severe("SQLState: " + ex.getSQLState()); mcMMO.p.getLogger().severe("SQLState: " + ex.getSQLState());
mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode()); mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode());
} }
public DatabaseType getDatabaseType() {
return DatabaseType.SQL;
}
} }

View File

@@ -0,0 +1,24 @@
package com.gmail.nossr50.datatypes.chat;
import com.gmail.nossr50.locale.LocaleLoader;
public enum ChatMode {
ADMIN(LocaleLoader.getString("Commands.AdminChat.On"), LocaleLoader.getString("Commands.AdminChat.Off")),
PARTY(LocaleLoader.getString("Commands.Party.Chat.On"), LocaleLoader.getString("Commands.Party.Chat.Off"));
private String enabledMessage;
private String disabledMessage;
private ChatMode(String enabledMessage, String disabledMessage) {
this.enabledMessage = enabledMessage;
this.disabledMessage = disabledMessage;
}
public String getEnabledMessage() {
return enabledMessage;
}
public String getDisabledMessage() {
return disabledMessage;
}
}

View File

@@ -0,0 +1,24 @@
package com.gmail.nossr50.datatypes.database;
public enum DatabaseType {
FLATFILE,
SQL,
CUSTOM;
public static DatabaseType getDatabaseType(String typeName) {
for (DatabaseType type : values()) {
if (type.name().equalsIgnoreCase(typeName)) {
return type;
}
}
if (typeName.equalsIgnoreCase("file")) {
return FLATFILE;
}
else if (typeName.equalsIgnoreCase("mysql")) {
return SQL;
}
return CUSTOM;
}
}

View File

@@ -7,5 +7,6 @@ public enum DatabaseUpdateType {
MOB_HEALTHBARS, MOB_HEALTHBARS,
PARTY_NAMES, PARTY_NAMES,
KILL_ORPHANS, KILL_ORPHANS,
DROPPED_SPOUT
; ;
} }

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